summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 3c81723b61f..e7d63e1e5e4 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -34,8 +34,8 @@ HASH open_cache; /* Used by mysql_test */
static int open_unireg_entry(THD *thd,TABLE *entry,const char *db,
const char *name, const char *alias, bool locked);
-static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
- List_iterator<Item> *it);
+static bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
+ const char *table_name, List_iterator<Item> *it);
static void free_cache_entry(TABLE *entry);
static void mysql_rm_tmp_tables(void);
static key_map get_key_map_from_key_list(TABLE *table,
@@ -1754,7 +1754,8 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field_name[0] == '*')
{
- if (insert_fields(thd,tables,((Item_field*) item)->table_name,&it))
+ if (insert_fields(thd,tables,((Item_field*) item)->db_name,
+ ((Item_field*) item)->table_name,&it))
DBUG_RETURN(-1); /* purecov: inspected */
}
else
@@ -1838,8 +1839,8 @@ static key_map get_key_map_from_key_list(TABLE *table,
****************************************************************************/
static bool
-insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
- List_iterator<Item> *it)
+insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
+ const char *table_name, List_iterator<Item> *it)
{
uint found;
DBUG_ENTER("insert_fields");
@@ -1851,7 +1852,9 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *table_name,
if (grant_option && !thd->master_access &&
check_grant_all_columns(thd,SELECT_ACL,table) )
DBUG_RETURN(-1);
- if (!table_name || !strcmp(table_name,tables->name))
+ if (!table_name || (!strcmp(table_name,tables->name) &&
+ (!db_name || !tables->db ||
+ !strcmp(tables->db,db_name))))
{
Field **ptr=table->field,*field;
thd->used_tables|=table->map;