"sanja" == sanja <sanja@askmonty.org> writes:
sanja> At file:///home/bell/maria/bzr/work-maria-5.3-lb615378/ sanja> ------------------------------------------------------------ sanja> revno: 2819 sanja> revision-id: sanja@askmonty.org-20101004100050-q1e95qec7288qkdo sanja> parent: sanja@askmonty.org-20100914134341-voquimk50t20zuiy sanja> committer: sanja@askmonty.org sanja> branch nick: work-maria-5.3-lb615378 sanja> timestamp: Mon 2010-10-04 13:00:50 +0300 sanja> message: sanja> Fixed LP BUG#615378 Incorrect processing of NULL result in Item_cache fixed. <cut>
=== modified file 'sql/item.cc' --- a/sql/item.cc 2010-09-06 12:34:24 +0000 +++ b/sql/item.cc 2010-10-04 10:00:50 +0000 @@ -7750,8 +7750,11 @@ void Item_cache_int::store_longlong(Item String *Item_cache_int::val_str(String *str) { DBUG_ASSERT(fixed == 1); - if (!value_cached && !cache_value()) + if ((!value_cached && !cache_value()) || null_value) + { + null_value= TRUE; return NULL; + } str->set(value, default_charset()); return str; }
<cut> (All other fixes are the same). Ok to push. Just a note about the item_cache code. If you would inherit Item_cache from Item_func_numhybrid, you could get away with having just 4 val methods, not 16 as you have now. For example: class Item_cache_int : public Item_func_numhybrid { longlong int_op() { if ((!value_cached && !cache_value()) || null_value) return 0; return value; } longlong val_int() { return int_op(); } /* Optimize default case */ } And that's about it. (Except that item_cache would need to provide dummy functions that just aborts for all xxx_op() functions). As a separate note, you can remove the following code from class Item_cache as 'Item_basic_constant' already provides it: table_map used_table_map; ... void set_used_tables(table_map map) { used_table_map= map; } ... table_map used_tables() const { return used_table_map; } Regards, Monty