1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Better handling of ensuring that setup_tables() are not called twice

This fixed a bug in prepared statements when used with outher joins
Fixed a bug in SUM(DISTINCT) when used with prepared statements.
Some safety fixes in test scripts to ensure that previous test failures shouldn't affect other tests


mysql-test/r/mysqldump.result:
  Safety fix if a previous test would fail
mysql-test/r/show_check.result:
  Safety fix if a previous test would fail
mysql-test/r/sp.result:
  Fix for --ps-protocol
mysql-test/r/synchronization.result:
  Safety fix if a previous test would fail
mysql-test/r/system_mysql_db.result:
  Safety fix if a previous test would fail
mysql-test/t/mysqldump.test:
  Safety fix if a previous test would fail
mysql-test/t/select.test:
  Safety fix if a previous test would fail
mysql-test/t/show_check.test:
  Safety fix if a previous test would fail
mysql-test/t/sp.test:
  fix for --ps-protocol
mysql-test/t/strict.test:
  Fix for --ps-protocol
mysql-test/t/synchronization.test:
  Safety fix if a previous test would fail
mysql-test/t/system_mysql_db.test:
  Safety fix if a previous test would fail
sql/item_sum.cc:
  Fix bug in SUM(DISTINCT...) when using with prepared statements
sql/item_sum.h:
  Fix bug in SUM(DISTINCT...) when using with prepared statements
sql/mysql_priv.h:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_base.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_insert.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_parse.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_prepare.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_select.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_union.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/sql_update.cc:
  Better handling of ensuring that setup_tables() are not called twice
sql/table.h:
  Better handling of ensuring that setup_tables() are not called twice
This commit is contained in:
unknown
2005-01-03 21:04:33 +02:00
parent 79e05c8317
commit 2bcaed348d
23 changed files with 87 additions and 60 deletions

View File

@@ -1106,7 +1106,11 @@ static int mysql_test_select(Prepared_statement *stmt,
thd->used_tables= 0; // Updated by setup_fields
// JOIN::prepare calls
/*
JOIN::prepare calls
It is not SELECT COMMAND for sure, so setup_tables will be called as
usual, and we pass 0 as setup_tables_done_option
*/
if (unit->prepare(thd, 0, 0))
{
goto err_prep;
@@ -1239,7 +1243,8 @@ error:
*/
static bool select_like_statement_test(Prepared_statement *stmt,
TABLE_LIST *tables,
bool (*specific_prepare)(THD *thd))
bool (*specific_prepare)(THD *thd),
ulong setup_tables_done_option)
{
DBUG_ENTER("select_like_statement_test");
THD *thd= stmt->thd;
@@ -1258,7 +1263,7 @@ static bool select_like_statement_test(Prepared_statement *stmt,
thd->used_tables= 0; // Updated by setup_fields
// JOIN::prepare calls
if (lex->unit.prepare(thd, 0, 0))
if (lex->unit.prepare(thd, 0, setup_tables_done_option))
{
res= TRUE;
}
@@ -1298,7 +1303,7 @@ static int mysql_test_create_table(Prepared_statement *stmt)
select_lex->item_list.elements)
{
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
res= select_like_statement_test(stmt, tables, 0);
res= select_like_statement_test(stmt, tables, 0, 0);
select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE;
}
@@ -1333,7 +1338,8 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
here we do not pass tables for opening, tables will be opened and locked
by mysql_multi_update_prepare
*/
return select_like_statement_test(stmt, 0, &mysql_multi_update_prepare);
return select_like_statement_test(stmt, 0, &mysql_multi_update_prepare,
OPTION_SETUP_TABLES_DONE);
}
@@ -1362,7 +1368,8 @@ static int mysql_test_multidelete(Prepared_statement *stmt,
if ((res= multi_delete_precheck(stmt->thd, tables, &fake_counter)))
return res;
if ((res= select_like_statement_test(stmt, tables,
&mysql_multi_delete_prepare)))
&mysql_multi_delete_prepare,
OPTION_SETUP_TABLES_DONE)))
return res;
if (!tables->table)
{
@@ -1415,7 +1422,8 @@ static int mysql_test_insert_select(Prepared_statement *stmt,
and item_list belong to SELECT
*/
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
res= select_like_statement_test(stmt, tables, &mysql_insert_select_prepare);
res= select_like_statement_test(stmt, tables, &mysql_insert_select_prepare,
OPTION_SETUP_TABLES_DONE);
/* revert changes*/
lex->select_lex.table_list.first= (byte*) first_local_table;
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
@@ -1770,11 +1778,6 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
for (order= (ORDER *)sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr;
}
{
TABLE_LIST *tables= (TABLE_LIST *)sl->table_list.first;
if (tables)
tables->setup_is_done= 0;
}
{
SELECT_LEX_UNIT *unit= sl->master_unit();
unit->unclean();