Skip to content

Commit c788e69

Browse files
author
Sreeharsha Ramanavarapu
committed
Bug #20730155: BACKPORT BUG#19699237 TO 5.1
Backport from mysql-5.5 to mysql-5.1 Bug# 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT LEADS TO INCORRECT BEHAVIOR ISSUE: ------ When the following conditions are satisfied in a query, a server crash occurs: a) Two rows are compared using a NULL-safe equal-to operator. b) Each of these rows belong to different charsets. SOLUTION: --------- When one charset is converted to another for comparision, the constructor of "Item_func_conv_charset" is called. This will attempt to use the Item_cache if the string is a constant. This check succeeds because the "used_table_map" of the Item_cache class is never set to the correct value. Since it is mistakenly assumed to be a constant, it tries to fetch the relevant null value related fields which are yet to be initialized. This results in valgrind issues and wrong results. The fix is to update the "used_table_map" of "Item_cache". This will allow "Item_func_conv_charset" to realise that this is not a constant.
1 parent 3c02e6e commit c788e69

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sql/item.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -3024,7 +3024,11 @@ class Item_cache: public Item_basic_constant
30243024
collation.set(item->collation);
30253025
unsigned_flag= item->unsigned_flag;
30263026
if (item->type() == FIELD_ITEM)
3027+
{
30273028
cached_field= ((Item_field *)item)->field;
3029+
if (cached_field->table)
3030+
used_table_map= cached_field->table->map;
3031+
}
30283032
return 0;
30293033
};
30303034
enum Type type() const { return CACHE_ITEM; }

0 commit comments

Comments
 (0)