diff options
author | unknown <sanja@montyprogram.com> | 2012-09-05 23:23:58 +0300 |
---|---|---|
committer | unknown <sanja@montyprogram.com> | 2012-09-05 23:23:58 +0300 |
commit | 54bb28d4a151d0eb5c3b74edb40ddf6e118c124b (patch) | |
tree | 51f71f55c54b4fbf5bc0229527b40fc475d63211 /sql/item.h | |
parent | 589c62fefec759a467b6dec1badb2cd283564845 (diff) | |
download | mariadb-git-54bb28d4a151d0eb5c3b74edb40ddf6e118c124b.tar.gz |
MDEV-486 LP BUG#1010116 fix.
Link view/derived table fields to a real table to check turning the table record to null row.
Item_direct_view_ref wrapper now checks if table is turned to null row.
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 103 |
1 files changed, 95 insertions, 8 deletions
diff --git a/sql/item.h b/sql/item.h index 055225a79d7..5dde9cf9a3f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2925,20 +2925,29 @@ class Item_direct_view_ref :public Item_direct_ref { Item_equal *item_equal; TABLE_LIST *view; + TABLE *null_ref_table; + + bool check_null_ref() + { + if (null_ref_table == NULL) + { + null_ref_table= view->get_real_join_table(); + } + if (null_ref_table->null_row) + { + null_value= 1; + return TRUE; + } + return FALSE; + } public: Item_direct_view_ref(Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, TABLE_LIST *view_arg) :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg), - item_equal(0), view(view_arg) {} - /* Constructor need to process subselect with temporary tables (see Item) */ - Item_direct_view_ref(THD *thd, Item_direct_ref *item) - :Item_direct_ref(thd, item), item_equal(0) {} - Item_direct_view_ref(TABLE_LIST *view_arg, Item **item, - const char *field_name_arg) - :Item_direct_ref(view_arg, item, field_name_arg), item_equal(0) - {} + item_equal(0), view(view_arg), + null_ref_table(NULL) {} bool fix_fields(THD *, Item **); bool eq(const Item *item, bool binary_cmp) const; @@ -2969,6 +2978,84 @@ public: view_arg->view_used_tables|= (*ref)->used_tables(); return 0; } + void save_val(Field *to) + { + if (check_null_ref()) + to->set_null(); + else + Item_direct_ref::save_val(to); + } + double val_real() + { + if (check_null_ref()) + return 0; + else + return Item_direct_ref::val_real(); + } + longlong val_int() + { + if (check_null_ref()) + return 0; + else + return Item_direct_ref::val_int(); + } + String *val_str(String* tmp) + { + if (check_null_ref()) + return NULL; + else + return Item_direct_ref::val_str(tmp); + } + my_decimal *val_decimal(my_decimal *tmp) + { + if (check_null_ref()) + return NULL; + else + return Item_direct_ref::val_decimal(tmp); + } + bool val_bool() + { + if (check_null_ref()) + return 0; + else + return Item_direct_ref::val_bool(); + } + bool is_null() + { + if (check_null_ref()) + return 1; + else + return Item_direct_ref::is_null(); + } + bool get_date(MYSQL_TIME *ltime, uint fuzzydate) + { + if (check_null_ref()) + { + bzero((char*) ltime,sizeof(*ltime)); + return 1; + } + return Item_direct_ref::get_date(ltime, fuzzydate); + } + bool send(Protocol *protocol, String *buffer) + { + if (check_null_ref()) + return protocol->store_null(); + return Item_direct_ref::send(protocol, buffer); + } + void save_org_in_field(Field *field) + { + if (check_null_ref()) + field->set_null(); + else + Item_direct_ref::save_val(field); + } + void save_in_result_field(bool no_conversions) + { + if (check_null_ref()) + result_field->set_null(); + else + Item_direct_ref::save_in_result_field(no_conversions); + } }; |