Commit 9156c654 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  mishka.local:/home/my/mysql-5.0


sql/sql_base.cc:
  Auto merged
parents f02c1c2b 9fbd86a2
...@@ -2945,9 +2945,15 @@ find_field_in_tables(THD *thd, Item_ident *item, ...@@ -2945,9 +2945,15 @@ find_field_in_tables(THD *thd, Item_ident *item,
char name_buff[NAME_LEN+1]; char name_buff[NAME_LEN+1];
TABLE_LIST *cur_table= first_table; TABLE_LIST *cur_table= first_table;
TABLE_LIST *actual_table; TABLE_LIST *actual_table;
bool is_qualified= table_name && table_name[0]; bool allow_rowid;
bool allow_rowid= is_qualified ?
TRUE : (cur_table && !cur_table->next_local); if (!table_name || !table_name[0])
{
table_name= 0; // For easier test
db= 0;
}
allow_rowid= table_name || (cur_table && !cur_table->next_local);
if (item->cached_table) if (item->cached_table)
{ {
...@@ -3022,8 +3028,7 @@ find_field_in_tables(THD *thd, Item_ident *item, ...@@ -3022,8 +3028,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
cur_table= cur_table->next_name_resolution_table) cur_table= cur_table->next_name_resolution_table)
{ {
Field *cur_field= find_field_in_table_ref(thd, cur_table, name, item->name, Field *cur_field= find_field_in_table_ref(thd, cur_table, name, item->name,
is_qualified ? table_name : NULL, table_name, db,
is_qualified ? db : NULL,
length, ref, length, ref,
(cur_table->table && (cur_table->table &&
test(cur_table->table->grant. test(cur_table->table->grant.
...@@ -3053,7 +3058,7 @@ find_field_in_tables(THD *thd, Item_ident *item, ...@@ -3053,7 +3058,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
If we found a fully qualified field we return it directly as it can't If we found a fully qualified field we return it directly as it can't
have duplicates. have duplicates.
*/ */
if (is_qualified && db) if (db)
return cur_field; return cur_field;
if (found) if (found)
...@@ -3061,7 +3066,7 @@ find_field_in_tables(THD *thd, Item_ident *item, ...@@ -3061,7 +3066,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
if (report_error == REPORT_ALL_ERRORS || if (report_error == REPORT_ALL_ERRORS ||
report_error == IGNORE_EXCEPT_NON_UNIQUE) report_error == IGNORE_EXCEPT_NON_UNIQUE)
my_error(ER_NON_UNIQ_ERROR, MYF(0), my_error(ER_NON_UNIQ_ERROR, MYF(0),
is_qualified ? item->full_name() : name, thd->where); table_name ? item->full_name() : name, thd->where);
return (Field*) 0; return (Field*) 0;
} }
found= cur_field; found= cur_field;
...@@ -3078,7 +3083,7 @@ find_field_in_tables(THD *thd, Item_ident *item, ...@@ -3078,7 +3083,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
and cur_table wouldn't be updated by the loop increment part, so it and cur_table wouldn't be updated by the loop increment part, so it
will be equal to the first table. will be equal to the first table.
*/ */
if (is_qualified && (cur_table == first_table) && if (table_name && (cur_table == first_table) &&
(report_error == REPORT_ALL_ERRORS || (report_error == REPORT_ALL_ERRORS ||
report_error == REPORT_EXCEPT_NON_UNIQUE)) report_error == REPORT_EXCEPT_NON_UNIQUE))
{ {
...@@ -3091,13 +3096,13 @@ find_field_in_tables(THD *thd, Item_ident *item, ...@@ -3091,13 +3096,13 @@ find_field_in_tables(THD *thd, Item_ident *item,
my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where); my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where);
} }
else else
{
if (report_error == REPORT_ALL_ERRORS || if (report_error == REPORT_ALL_ERRORS ||
report_error == REPORT_EXCEPT_NON_UNIQUE) report_error == REPORT_EXCEPT_NON_UNIQUE)
my_error(ER_BAD_FIELD_ERROR, MYF(0), item->full_name(), thd->where); my_error(ER_BAD_FIELD_ERROR, MYF(0), item->full_name(), thd->where);
else else
found= not_found_field; found= not_found_field;
}
DBUG_ASSERT(!found || found == not_found_field);
return found; return found;
} }
......
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