summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorigor@igor-inspiron.creware.com <>2005-07-12 10:44:31 -0700
committerigor@igor-inspiron.creware.com <>2005-07-12 10:44:31 -0700
commit7725eb31419ad9ac00245a2fdb9a8dfb1568e8d3 (patch)
tree574383253d728670eed62a19a7f70093a0eda004 /sql
parenta0f594a8efcacc4d3a0443700810feab9e4f9e88 (diff)
parent83b84bc393c5c4877d50b8e45223db533d9ffbb6 (diff)
downloadmariadb-git-7725eb31419ad9ac00245a2fdb9a8dfb1568e8d3.tar.gz
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0
into igor-inspiron.creware.com:/home/igor/mysql-5.0
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc8
-rw-r--r--sql/sql_base.cc22
2 files changed, 22 insertions, 8 deletions
diff --git a/sql/item.cc b/sql/item.cc
index e53c1ebf734..4679b62643e 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5421,9 +5421,13 @@ void Item_type_holder::get_full_info(Item *item)
if (fld_type == MYSQL_TYPE_ENUM ||
fld_type == MYSQL_TYPE_SET)
{
+ if (item->type() == Item::SUM_FUNC_ITEM &&
+ (((Item_sum*)item)->sum_func() == Item_sum::MAX_FUNC ||
+ ((Item_sum*)item)->sum_func() == Item_sum::MIN_FUNC))
+ item = ((Item_sum*)item)->args[0];
/*
- We can have enum/set type after merging only if we have one enum/set
- field and number of NULL fields
+ We can have enum/set type after merging only if we have one enum|set
+ field (or MIN|MAX(enum|set field)) and number of NULL fields
*/
DBUG_ASSERT((enum_set_typelib &&
get_real_type(item) == MYSQL_TYPE_NULL) ||
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 57f46b59c13..c9d50bef82a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2400,9 +2400,11 @@ Field *view_ref_found= (Field*) 0x2;
name name of field
item_name name of item if it will be created (VIEW)
length length of name
- ref expression substituted in VIEW should be
+ ref [in/out] expression substituted in VIEW should be
passed using this reference (return
view_ref_found)
+ (*ref != NULL) only if *ref contains
+ the item that we need to replace.
check_grants_table do check columns grants for table?
check_grants_view do check columns grants for view?
allow_rowid do allow finding of "_rowid" field?
@@ -2440,11 +2442,6 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
{
if (!my_strcasecmp(system_charset_info, field_it.name(), name))
{
- Item *item= field_it.create_item(thd);
- if (!item)
- {
- DBUG_RETURN(0);
- }
if (table_list->schema_table_reformed)
{
/*
@@ -2463,6 +2460,19 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
name, length))
DBUG_RETURN(WRONG_GRANT);
#endif
+ Item *item= field_it.create_item(thd);
+ if (!item)
+ {
+ DBUG_RETURN(0);
+ }
+ /*
+ *ref != NULL means that *ref contains the item that we need to
+ replace. If the item was aliased by the user, set the alias to
+ the replacing item.
+ */
+ if (*ref && !(*ref)->is_autogenerated_name)
+ item->set_name((*ref)->name, (*ref)->name_length,
+ system_charset_info);
if (register_tree_change)
thd->change_item_tree(ref, item);
else