diff options
author | unknown <kaa@kaamos.(none)> | 2008-02-17 14:37:39 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-02-17 14:37:39 +0300 |
commit | 4a834b4b12689f9f4f3aa62b10db88ce37431bf0 (patch) | |
tree | 747b6a0bfb58b3186474bac0295db2485f739ddd /sql/item.cc | |
parent | 99933c18d2134d7e382c894e829082922067809c (diff) | |
parent | c4fc5b096e582f23bac8bc14cb93f6ade63f476f (diff) | |
download | mariadb-git-4a834b4b12689f9f4f3aa62b10db88ce37431bf0.tar.gz |
Merge kaamos.(none):/data/src/mysql-5.0
into kaamos.(none):/data/src/opt/mysql-5.0-opt
mysql-test/r/variables.result:
Auto merged
mysql-test/t/variables.test:
Auto merged
sql/item.cc:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/sp.result:
Manual merge.
mysql-test/t/sp.test:
Manual merge.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/sql/item.cc b/sql/item.cc index ffb18054750..a3ed420b2ce 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3907,6 +3907,18 @@ bool Item_field::fix_fields(THD *thd, Item **reference) else if (!from_field) goto error; + if (!outer_fixed && cached_table && cached_table->select_lex && + context->select_lex && + cached_table->select_lex != context->select_lex) + { + int ret; + if ((ret= fix_outer_field(thd, &from_field, reference)) < 0) + goto error; + else if (!ret) + return FALSE; + outer_fixed= 1; + } + /* if it is not expression from merged VIEW we will set this field. @@ -3922,18 +3934,6 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if (from_field == view_ref_found) return FALSE; - if (!outer_fixed && cached_table && cached_table->select_lex && - context->select_lex && - cached_table->select_lex != context->select_lex) - { - int ret; - if ((ret= fix_outer_field(thd, &from_field, reference)) < 0) - goto error; - else if (!ret) - return FALSE; - outer_fixed= 1; - } - set_field(from_field); if (thd->lex->in_sum_func && thd->lex->in_sum_func->nest_level == @@ -4306,6 +4306,49 @@ String *Item::check_well_formed_result(String *str, bool send_error) return str; } +/* + Compare two items using a given collation + + SYNOPSIS + eq_by_collation() + item item to compare with + binary_cmp TRUE <-> compare as binaries + cs collation to use when comparing strings + + DESCRIPTION + This method works exactly as Item::eq if the collation cs coincides with + the collation of the compared objects. Otherwise, first the collations that + differ from cs are replaced for cs and then the items are compared by + Item::eq. After the comparison the original collations of items are + restored. + + RETURN + 1 compared items has been detected as equal + 0 otherwise +*/ + +bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs) +{ + CHARSET_INFO *save_cs= 0; + CHARSET_INFO *save_item_cs= 0; + if (collation.collation != cs) + { + save_cs= collation.collation; + collation.collation= cs; + } + if (item->collation.collation != cs) + { + save_item_cs= item->collation.collation; + item->collation.collation= cs; + } + bool res= eq(item, binary_cmp); + if (save_cs) + collation.collation= save_cs; + if (save_item_cs) + item->collation.collation= save_item_cs; + return res; +} + /* Create a field to hold a string value from an item |