Commit 28221328 authored by unknown's avatar unknown

insert_update.result, insert_update.test, sql_base.cc:

  Fix for bugfix #9728 merge


sql/sql_base.cc:
  Fix for bugfix #9728 merge
mysql-test/t/insert_update.test:
  Fix for bugfix #9728 merge
mysql-test/r/insert_update.result:
  Fix for bugfix #9728 merge
parent dbb7b330
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
INSERT t1 VALUES (1,2,10), (3,4,20); INSERT t1 VALUES (1,2,10), (3,4,20);
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100; INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
......
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1, t2;
--enable_warnings --enable_warnings
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B)); CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
......
...@@ -2626,7 +2626,6 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, ...@@ -2626,7 +2626,6 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
uint length=(uint) strlen(name); uint length=(uint) strlen(name);
char name_buff[NAME_LEN+1]; char name_buff[NAME_LEN+1];
if (item->cached_table) if (item->cached_table)
{ {
/* /*
...@@ -2693,10 +2692,13 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, ...@@ -2693,10 +2692,13 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
db= name_buff; db= name_buff;
} }
bool search_global= item->item_flags & MY_ITEM_PREFER_1ST_TABLE;
if (table_name && table_name[0]) if (table_name && table_name[0])
{ /* Qualified field */ { /* Qualified field */
bool found_table=0; bool found_table=0;
for (; tables; tables= tables->next_local) uint table_idx= 0;
for (; tables; tables= search_global?tables->next_global:tables->next_local,
table_idx++)
{ {
/* TODO; Ensure that db and tables->db always points to something ! */ /* TODO; Ensure that db and tables->db always points to something ! */
if (!my_strcasecmp(table_alias_charset, tables->alias, table_name) && if (!my_strcasecmp(table_alias_charset, tables->alias, table_name) &&
...@@ -2732,6 +2734,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, ...@@ -2732,6 +2734,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
return (Field*) 0; return (Field*) 0;
} }
found=find; found=find;
if (table_idx == 0 && item->item_flags & MY_ITEM_PREFER_1ST_TABLE)
break;
} }
} }
} }
...@@ -2758,7 +2762,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, ...@@ -2758,7 +2762,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
} }
bool allow_rowid= tables && !tables->next_local; // Only one table bool allow_rowid= tables && !tables->next_local; // Only one table
uint table_idx= 0; uint table_idx= 0;
for (; tables ; tables= tables->next_local, table_idx++) for (; tables ; tables= search_global?tables->next_global:tables->next_local,
table_idx++)
{ {
if (!tables->table && !tables->ancestor) if (!tables->table && !tables->ancestor)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment