diff options
author | unknown <sanja@askmonty.org> | 2011-11-28 12:42:14 +0200 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2011-11-28 12:42:14 +0200 |
commit | 5412e82c01aa126448af8c64279e2cb9a7ffdd38 (patch) | |
tree | 36baa453eedce2045fc7efcbf57c43f1a6c69fa0 /sql/item.cc | |
parent | 17b4e4a194ea513f776bab5010d88d24a51b9d9e (diff) | |
download | mariadb-git-5412e82c01aa126448af8c64279e2cb9a7ffdd38.tar.gz |
Fixed LP BUG#747278
The problem was that when we have single row subquery with no rows
Item_cache(es) which represent result row was not null and being
requested via element_index() returned random value.
The fix is setting all Item_cache(es) in NULL before executing the
query (reset() method) which guaranty NULL value of whole query
or its elements requested in any way if no rows was found.
set_null() method was added to Item_cache to guaranty correct NULL
value in case of reseting the cache.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc index d321b74c1fc..9ba93780334 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8201,6 +8201,20 @@ void Item_cache::print(String *str, enum_query_type query_type) str->append(')'); } +/** + Assign to this cache NULL value if it is possible +*/ + +void Item_cache::set_null() +{ + if (maybe_null) + { + null_value= TRUE; + value_cached= TRUE; + } +} + + bool Item_cache_int::cache_value() { if (!example) @@ -8671,6 +8685,20 @@ void Item_cache_row::bring_value() } +/** + Assign to this cache NULL value if it is possible +*/ + +void Item_cache_row::set_null() +{ + Item_cache::set_null(); + if (!values) + return; + for (uint i= 0; i < item_count; i++) + values[i]->set_null(); +}; + + Item_type_holder::Item_type_holder(THD *thd, Item *item) :Item(thd, item), enum_set_typelib(0), fld_type(get_real_type(item)) { |