diff options
author | bell@sanja.is.com.ua <> | 2004-09-14 19:28:29 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2004-09-14 19:28:29 +0300 |
commit | f797298fc564c70accf5b227fcfe72f12869762b (patch) | |
tree | 44ca229eb83d0543674b391c46f4d3a77539bfb7 /sql/item.cc | |
parent | 31379fbebe149392550d3d3e2387785d55a230d5 (diff) | |
download | mariadb-git-f797298fc564c70accf5b227fcfe72f12869762b.tar.gz |
fixed merged view fields names (BUG#5147)
support of merged VIEW over several tables added (WL#1809)
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/sql/item.cc b/sql/item.cc index cbb760156b3..1e8b4d8630d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -45,12 +45,11 @@ void item_init(void) } Item::Item(): - name_length(0), fixed(0) + name(0), orig_name(0), name_length(0), fixed(0) { marker= 0; maybe_null=null_value=with_sum_func=unsigned_flag=0; collation.set(default_charset(), DERIVATION_COERCIBLE); - name= 0; decimals= 0; max_length= 0; /* Put item in free list so that we can free all items at end */ @@ -80,6 +79,7 @@ Item::Item(): Item::Item(THD *thd, Item *item): str_value(item->str_value), name(item->name), + orig_name(item->orig_name), max_length(item->max_length), marker(item->marker), decimals(item->decimals), @@ -110,12 +110,35 @@ void Item::print_item_w_name(String *str) void Item::cleanup() { DBUG_ENTER("Item::cleanup"); - DBUG_PRINT("info", ("Item: 0x%lx", this)); - DBUG_PRINT("info", ("Type: %d", (int)type())); + DBUG_PRINT("info", ("Item: 0x%lx, Type: %d, name %s, original name %s", + this, (int)type(), name, orig_name)); fixed=0; + if (orig_name) + name= orig_name; DBUG_VOID_RETURN; } + +/* + rename item (used for views, cleanup() return original name) + + SYNOPSIS + Item::rename() + new_name new name of item; +*/ + +void Item::rename(char *new_name) +{ + /* + we can compare pointers to names here, bacause if name was not changed, + pointer will be same + */ + if (!orig_name && new_name != name) + orig_name= name; + name= new_name; +} + + Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, const char *field_name_par) :orig_db_name(db_name_par), orig_table_name(table_name_par), @@ -2279,6 +2302,9 @@ void Item_ref::cleanup() DBUG_ENTER("Item_ref::cleanup"); Item_ident::cleanup(); result_field= 0; + DBUG_PRINT("info", ("hook: 0x%lx(0x%lx) original item: 0x%lx", + (ulong)hook_ptr, (ulong)(hook_ptr?*hook_ptr:0), + (ulong)orig_item)); if (hook_ptr) *hook_ptr= orig_item; DBUG_VOID_RETURN; |