mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
added NULLs check to the QUOTE() function
This commit is contained in:
parent
ea984d0229
commit
f86ed73a48
1 changed files with 8 additions and 4 deletions
|
@ -2085,16 +2085,16 @@ String *Item_func_quote::val_str(String *str)
|
||||||
char *from, *to, *end;
|
char *from, *to, *end;
|
||||||
uint delta= 2; /* for beginning and ending ' signs */
|
uint delta= 2; /* for beginning and ending ' signs */
|
||||||
|
|
||||||
|
if (!arg)
|
||||||
|
goto null;
|
||||||
|
|
||||||
for (from= (char*) arg->ptr(), end= from + arg->length(); from < end; from++)
|
for (from= (char*) arg->ptr(), end= from + arg->length(); from < end; from++)
|
||||||
{
|
{
|
||||||
if (*(escmask + (*from >> 3)) and (1 << (*from & 7)))
|
if (*(escmask + (*from >> 3)) and (1 << (*from & 7)))
|
||||||
delta++;
|
delta++;
|
||||||
}
|
}
|
||||||
if (str->alloc(arg->length() + delta))
|
if (str->alloc(arg->length() + delta))
|
||||||
{
|
goto null;
|
||||||
null_value= 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
to= (char*) str->ptr() + arg->length() + delta - 1;
|
to= (char*) str->ptr() + arg->length() + delta - 1;
|
||||||
*to--= '\'';
|
*to--= '\'';
|
||||||
for (end= (char*) arg->ptr(), from= end + arg->length() - 1; from >= end;
|
for (end= (char*) arg->ptr(), from= end + arg->length() - 1; from >= end;
|
||||||
|
@ -2107,4 +2107,8 @@ String *Item_func_quote::val_str(String *str)
|
||||||
*to= '\'';
|
*to= '\'';
|
||||||
str->length(arg->length() + delta);
|
str->length(arg->length() + delta);
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
|
null:
|
||||||
|
null_value= 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue