summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-01-03 00:12:07 +0200
committerunknown <bell@sanja.is.com.ua>2004-01-03 00:12:07 +0200
commitb21d8b0eff5b2da2f4b565ab630549ede52ed28a (patch)
tree5368d917dca8b3cf091c64b5b199e33ef115d291 /sql
parent3940368293134f3fcce418c8533143ab6f4581ec (diff)
downloadmariadb-git-b21d8b0eff5b2da2f4b565ab630549ede52ed28a.tar.gz
removed droping field->query_id for reinitialization tables for subquery.
(BUG#2089) mysql-test/r/subselect_innodb.result: correct results sql/mysql_priv.h: new parameter for setup_tables() sql/sql_base.cc: new parameter for setup_tables() added to avoid dropping query_id of fields during reinitialization subquery sql/sql_class.cc: layout fixed sql/sql_help.cc: new parameter for setup_tables() sql/sql_insert.cc: new parameter for setup_tables() sql/sql_lex.cc: removed incorrect code sql/sql_load.cc: new parameter for setup_tables() sql/sql_olap.cc: new parameter for setup_tables() sql/sql_prepare.cc: new parameter for setup_tables() sql/sql_select.cc: new parameter for setup_tables() sql/sql_update.cc: new parameter for setup_tables()
Diffstat (limited to 'sql')
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/sql_base.cc27
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_help.cc2
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_lex.cc5
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_olap.cc2
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_update.cc2
11 files changed, 31 insertions, 23 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 15a99385285..bba30964a31 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -664,7 +664,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
bool insert_fields(THD *thd,TABLE_LIST *tables,
const char *db_name, const char *table_name,
List_iterator<Item> *it);
-bool setup_tables(TABLE_LIST *tables);
+bool setup_tables(TABLE_LIST *tables, my_bool reinit);
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
List<Item> *sum_func_list, uint wild_num);
int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index d7984213fd6..3125c392751 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2039,15 +2039,28 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
/*
- Remap table numbers if INSERT ... SELECT
- Check also that the 'used keys' and 'ignored keys' exists and set up the
- table structure accordingly
+ prepare tables
- This has to be called for all tables that are used by items, as otherwise
- table->map is not set and all Item_field will be regarded as const items.
+ SYNOPSIS
+ setup_tables()
+ tables - tables list
+ reinit - true if called for table reinitialization before
+ subquery reexecuting
+
+ RETURN
+ 0 ok; In this case *map will includes the choosed index
+ 1 error
+
+ NOTE
+ Remap table numbers if INSERT ... SELECT
+ Check also that the 'used keys' and 'ignored keys' exists and set up the
+ table structure accordingly
+
+ This has to be called for all tables that are used by items, as otherwise
+ table->map is not set and all Item_field will be regarded as const items.
*/
-bool setup_tables(TABLE_LIST *tables)
+bool setup_tables(TABLE_LIST *tables, my_bool reinit)
{
DBUG_ENTER("setup_tables");
uint tablenr=0;
@@ -2074,7 +2087,7 @@ bool setup_tables(TABLE_LIST *tables)
table->keys_in_use_for_query.subtract(map);
}
table->used_keys.intersect(table->keys_in_use_for_query);
- if (table_list->shared || table->clear_query_id)
+ if ((table_list->shared || table->clear_query_id) && !reinit)
{
table->clear_query_id= 0;
/* Clear query_id that may have been set by previous select */
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 60220ffc889..2c75c3c5a22 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1037,7 +1037,7 @@ bool select_singlerow_subselect::send_data(List<Item> &items)
Item_singlerow_subselect *it= (Item_singlerow_subselect *)item;
if (it->assigned())
{
- my_message(ER_SUBQUERY_NO_1_ROW, ER(ER_SUBQUERY_NO_1_ROW), MYF(0));
+ my_message(ER_SUBQUERY_NO_1_ROW, ER(ER_SUBQUERY_NO_1_ROW), MYF(0));
DBUG_RETURN(1);
}
if (unit->offset_limit_cnt)
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index c40133c04a8..a5b7c691ae1 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -686,7 +686,7 @@ int mysqld_help(THD *thd, const char *mask)
goto end;
}
/* Init tables and fields to be usable from items */
- setup_tables(tables);
+ setup_tables(tables, 0);
memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields));
if (init_fields(thd, tables, used_fields, array_elements(used_fields)))
{
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e23e62fb714..c2f3e737daf 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -84,7 +84,7 @@ check_insert_fields(THD *thd,TABLE *table,List<Item> &fields,
table_list.grant=table->grant;
thd->dupp_field=0;
- if (setup_tables(&table_list) ||
+ if (setup_tables(&table_list, 0) ||
setup_fields(thd, 0, &table_list,fields,1,0,0))
return -1;
if (thd->dupp_field)
@@ -204,7 +204,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
}
if (check_insert_fields(thd,table,fields,*values,1) ||
- setup_tables(insert_table_list) ||
+ setup_tables(insert_table_list, 0) ||
setup_fields(thd, 0, insert_table_list, *values, 0, 0, 0) ||
(duplic == DUP_UPDATE &&
(setup_fields(thd, 0, insert_table_list, update_fields, 0, 0, 0) ||
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index de0d6ade618..efb0ce92ad0 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1222,11 +1222,6 @@ void st_select_lex::mark_as_dependent(SELECT_LEX *last)
s->uncacheable|= UNCACHEABLE_DEPENDENT;
SELECT_LEX_UNIT *munit= s->master_unit();
munit->uncacheable|= UNCACHEABLE_DEPENDENT;
- //Tables will be reopened many times
- for (TABLE_LIST *tbl= s->get_table_list();
- tbl;
- tbl= tbl->next)
- tbl->shared= 1;
}
}
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 0c35e99ed08..175791ef31e 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -123,7 +123,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else
{ // Part field list
thd->dupp_field=0;
- if (setup_tables(table_list) ||
+ if (setup_tables(table_list, 0) ||
setup_fields(thd, 0, table_list, fields, 1, 0, 0))
DBUG_RETURN(-1);
if (thd->dupp_field)
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
index ef7bf013be8..1d16771c1a4 100644
--- a/sql/sql_olap.cc
+++ b/sql/sql_olap.cc
@@ -164,7 +164,7 @@ int handle_olaps(LEX *lex, SELECT_LEX *select_lex)
List<Item> all_fields(select_lex->item_list);
- if (setup_tables((TABLE_LIST *)select_lex->table_list.first) ||
+ if (setup_tables((TABLE_LIST *)select_lex->table_list.first, 0) ||
setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first,
select_lex->item_list, 1, &all_fields,1) ||
setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first,
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 5d6ab165641..0a565c00ba7 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -679,7 +679,7 @@ static bool mysql_test_upd_fields(Prepared_statement *stmt,
#endif
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(1);
- if (setup_tables(table_list) ||
+ if (setup_tables(table_list, 0) ||
setup_fields(thd, 0, table_list, fields, 1, 0, 0) ||
setup_conds(thd, table_list, &conds) || thd->net.report_error)
DBUG_RETURN(1);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a1f6abfd53a..fe5b8885810 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -301,7 +301,7 @@ JOIN::prepare(Item ***rref_pointer_array,
/* Check that all tables, fields, conds and order are ok */
- if (setup_tables(tables_list) ||
+ if (setup_tables(tables_list, 0) ||
setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) ||
select_lex->setup_ref_array(thd, og_num) ||
setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1,
@@ -1015,7 +1015,7 @@ JOIN::reinit()
if (unit->select_limit_cnt == HA_POS_ERROR)
select_lex->options&= ~OPTION_FOUND_ROWS;
- if (setup_tables(tables_list))
+ if (setup_tables(tables_list, 1))
DBUG_RETURN(1);
/* Reset of sum functions */
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index cdea32ad3f6..9fc8d482bfa 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -95,7 +95,7 @@ int mysql_update(THD *thd,
tables.table= table;
tables.alias= table_list->alias;
- if (setup_tables(update_table_list) ||
+ if (setup_tables(update_table_list, 0) ||
setup_conds(thd,update_table_list,&conds) ||
thd->lex->select_lex.setup_ref_array(thd, order_num) ||
setup_order(thd, thd->lex->select_lex.ref_pointer_array,