Commit 66eb6db7 authored by unknown's avatar unknown

Merge rkalimullin@work.mysql.com:/home/bk/mysql-4.0

into ram.(none):/home/ram/work/mysql-4.0


sql/item_strfunc.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
parents 5dc118f4 8c1d8eb4
...@@ -73,3 +73,4 @@ worm@altair.is.lan ...@@ -73,3 +73,4 @@ worm@altair.is.lan
zak@balfor.local zak@balfor.local
zak@linux.local zak@linux.local
zgreant@mysql.com zgreant@mysql.com
ram@ram.(none)
...@@ -440,3 +440,7 @@ Item *create_func_is_free_lock(Item* a) ...@@ -440,3 +440,7 @@ Item *create_func_is_free_lock(Item* a)
return new Item_func_is_free_lock(a); return new Item_func_is_free_lock(a);
} }
Item *create_func_quote(Item* a)
{
return new Item_func_quote(a);
}
...@@ -93,3 +93,4 @@ Item *create_func_weekday(Item* a); ...@@ -93,3 +93,4 @@ Item *create_func_weekday(Item* a);
Item *create_load_file(Item* a); Item *create_load_file(Item* a);
Item *create_wait_for_master_pos(Item* a, Item* b); Item *create_wait_for_master_pos(Item* a, Item* b);
Item *create_func_is_free_lock(Item* a); Item *create_func_is_free_lock(Item* a);
Item *create_func_quote(Item* a);
...@@ -2070,3 +2070,41 @@ String* Item_func_inet_ntoa::val_str(String* str) ...@@ -2070,3 +2070,41 @@ String* Item_func_inet_ntoa::val_str(String* str)
str->length(str->length()-1); // Remove last '.'; str->length(str->length()-1); // Remove last '.';
return str; return str;
} }
/*
QUOTE() function returns argument string in single quotes,
also adds a \ before \, ' CHAR(0) and CHAR(24)
*/
String *Item_func_quote::val_str(String *str)
{
static char escmask[64] = {0x01, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
String *arg= args[0]->val_str(str);
char *from, *to, *end;
uint delta= 2; /* for beginning and ending ' signs */
for (from= (char*) arg->ptr(), end= from + arg->length(); from < end; from++)
{
if (*(escmask + (*from >> 3)) and (1 << (*from & 7)))
delta++;
}
if (str->alloc(arg->length() + delta))
{
null_value= 1;
return 0;
}
to= (char*) str->ptr() + arg->length() + delta - 1;
*to--= '\'';
for (end= (char*) arg->ptr(), from= end + arg->length() - 1; from >= end;
from--, to--)
{
*to= *from;
if (*(escmask + (*from >> 3)) and (1 << (*from & 7)))
*--to= '\\';
}
*to= '\'';
str->length(arg->length() + delta);
return str;
}
...@@ -526,3 +526,12 @@ public: ...@@ -526,3 +526,12 @@ public:
const char *func_name() const { return "inet_ntoa"; } const char *func_name() const { return "inet_ntoa"; }
void fix_length_and_dec() { decimals = 0; max_length=3*8+7; } void fix_length_and_dec() { decimals = 0; max_length=3*8+7; }
}; };
class Item_func_quote :public Item_str_func
{
public:
Item_func_quote(Item *a) :Item_str_func(a) {}
const char *func_name() const { return "quote"; }
String *val_str(String *);
void fix_length_and_dec() { max_length= args[0]->max_length * 2 + 2; }
};
...@@ -475,6 +475,7 @@ static SYMBOL sql_functions[] = { ...@@ -475,6 +475,7 @@ static SYMBOL sql_functions[] = {
{ "POW", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_pow)}, { "POW", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_pow)},
{ "POWER", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_pow)}, { "POWER", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_pow)},
{ "QUARTER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_quarter)}, { "QUARTER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_quarter)},
{ "QUOTE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_quote)},
{ "RADIANS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_radians)}, { "RADIANS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_radians)},
{ "RAND", SYM(RAND),0,0}, { "RAND", SYM(RAND),0,0},
{ "RELEASE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_release_lock)}, { "RELEASE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_release_lock)},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment