mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
Fix handling of NULL fields in FIELD(). (Bug #10944)
This commit is contained in:
parent
e877e71b17
commit
7ac7bfc3c8
3 changed files with 20 additions and 4 deletions
|
@ -783,3 +783,9 @@ id aes_decrypt(str, 'bar')
|
|||
1 foo
|
||||
2 NULL
|
||||
DROP TABLE t1, t2;
|
||||
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
|
||||
field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
|
||||
3 3 3
|
||||
select field(NULL,1,2,NULL), field(NULL,1,2,0);
|
||||
field(NULL,1,2,NULL) field(NULL,1,2,0)
|
||||
0 0
|
||||
|
|
|
@ -521,3 +521,9 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
|
|||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
|
||||
#
|
||||
# Bug #10944: Mishandling of NULL arguments in FIELD()
|
||||
#
|
||||
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
|
||||
select field(NULL,1,2,NULL), field(NULL,1,2,0);
|
||||
|
|
|
@ -1488,6 +1488,10 @@ void Item_func_locate::print(String *str)
|
|||
longlong Item_func_field::val_int()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
|
||||
if (args[0]->null_value)
|
||||
return 0;
|
||||
|
||||
if (cmp_type == STRING_RESULT)
|
||||
{
|
||||
String *field;
|
||||
|
@ -1505,8 +1509,8 @@ longlong Item_func_field::val_int()
|
|||
longlong val= args[0]->val_int();
|
||||
for (uint i=1; i < arg_count ; i++)
|
||||
{
|
||||
if (val == args[i]->val_int())
|
||||
return (longlong) (i);
|
||||
if (!args[i]->null_value && val == args[i]->val_int())
|
||||
return (longlong) (i);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1514,8 +1518,8 @@ longlong Item_func_field::val_int()
|
|||
double val= args[0]->val();
|
||||
for (uint i=1; i < arg_count ; i++)
|
||||
{
|
||||
if (val == args[i]->val())
|
||||
return (longlong) (i);
|
||||
if (!args[i]->null_value && val == args[i]->val())
|
||||
return (longlong) (i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue