summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-08-02 10:11:41 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2021-08-02 10:11:41 +0200
commit6efb5e9f5e3cd3ec811ae832a67e1878c14f0dea (patch)
treeb7c1a18b8bbc638ee12951d1d04db6d21bebcaed /sql/sql_base.cc
parent07674e6a741a82d2e30f9798f699209a6c34dfef (diff)
parentec8882b9ddbba2f9fc3571a1ac2ade0dabf412d9 (diff)
downloadmariadb-git-6efb5e9f5e3cd3ec811ae832a67e1878c14f0dea.tar.gz
Merge branch '10.5' into 10.6
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index e46a8587503..55c2b6db7e7 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -6268,7 +6268,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
TABLE *table= field_to_set->table;
DBUG_ASSERT(table);
if (thd->column_usage == MARK_COLUMNS_READ)
- bitmap_set_bit(table->read_set, field_to_set->field_index);
+ field_to_set->register_field_in_read_map();
else
bitmap_set_bit(table->write_set, field_to_set->field_index);
}
@@ -7558,7 +7558,7 @@ static bool setup_natural_join_row_types(THD *thd,
****************************************************************************/
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
- List<Item> *sum_func_list, SELECT_LEX *select_lex)
+ List<Item> *sum_func_list, SELECT_LEX *select_lex, bool returning_field)
{
Item *item;
List_iterator<Item> it(fields);
@@ -7598,7 +7598,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
else if (insert_fields(thd, ((Item_field*) item)->context,
((Item_field*) item)->db_name.str,
((Item_field*) item)->table_name.str, &it,
- any_privileges, &select_lex->hidden_bit_fields))
+ any_privileges, &select_lex->hidden_bit_fields, returning_field))
{
if (arena)
thd->restore_active_arena(arena, &backup);
@@ -7744,7 +7744,7 @@ int setup_returning_fields(THD* thd, TABLE_LIST* table_list)
if (!thd->lex->has_returning())
return 0;
return setup_wild(thd, table_list, thd->lex->returning()->item_list, NULL,
- thd->lex->returning())
+ thd->lex->returning(), true)
|| setup_fields(thd, Ref_ptr_array(), thd->lex->returning()->item_list,
MARK_COLUMNS_READ, NULL, NULL, false);
}
@@ -8071,7 +8071,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
bool
insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
const char *table_name, List_iterator<Item> *it,
- bool any_privileges, uint *hidden_bit_fields)
+ bool any_privileges, uint *hidden_bit_fields, bool returning_field)
{
Field_iterator_table_ref field_iterator;
bool found;
@@ -8098,12 +8098,14 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
else treat natural joins as leaves and do not iterate over their underlying
tables.
*/
- for (TABLE_LIST *tables= (table_name ? context->table_list :
- context->first_name_resolution_table);
- tables;
- tables= (table_name ? tables->next_local :
- tables->next_name_resolution_table)
- )
+ TABLE_LIST *first= context->first_name_resolution_table;
+ TABLE_LIST *TABLE_LIST::* next= &TABLE_LIST::next_name_resolution_table;
+ if (table_name && !returning_field)
+ {
+ first= context->table_list;
+ next= &TABLE_LIST::next_local;
+ }
+ for (TABLE_LIST *tables= first; tables; tables= tables->*next)
{
Field *field;
TABLE *table= tables->table;