mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
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
This commit is contained in:
commit
66eb6db755
6 changed files with 54 additions and 0 deletions
|
@ -73,3 +73,4 @@ worm@altair.is.lan
|
|||
zak@balfor.local
|
||||
zak@linux.local
|
||||
zgreant@mysql.com
|
||||
ram@ram.(none)
|
||||
|
|
|
@ -440,3 +440,7 @@ Item *create_func_is_free_lock(Item* 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);
|
|||
Item *create_load_file(Item* a);
|
||||
Item *create_wait_for_master_pos(Item* a, Item* b);
|
||||
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)
|
|||
str->length(str->length()-1); // Remove last '.';
|
||||
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:
|
|||
const char *func_name() const { return "inet_ntoa"; }
|
||||
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[] = {
|
|||
{ "POW", 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)},
|
||||
{ "QUOTE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_quote)},
|
||||
{ "RADIANS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_radians)},
|
||||
{ "RAND", SYM(RAND),0,0},
|
||||
{ "RELEASE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_release_lock)},
|
||||
|
|
Loading…
Add table
Reference in a new issue