summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-01-03 21:04:33 +0200
committerunknown <monty@mysql.com>2005-01-03 21:04:33 +0200
commit2bcaed348d59fb00b82bddf9284e7d70e87b5622 (patch)
treeca151e2a0c44dc6a1c8ca642907f92d7be53c489 /sql/sql_union.cc
parent79e05c83174783adb6cf89b2a2f3e9794637a2bb (diff)
downloadmariadb-git-2bcaed348d59fb00b82bddf9284e7d70e87b5622.tar.gz
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
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index d0a33163a38..012a26a6f4d 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -25,11 +25,12 @@
#include "sql_select.h"
bool mysql_union(THD *thd, LEX *lex, select_result *result,
- SELECT_LEX_UNIT *unit)
+ SELECT_LEX_UNIT *unit, ulong setup_tables_done_option)
{
DBUG_ENTER("mysql_union");
bool res;
- if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK)))
+ if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK |
+ setup_tables_done_option)))
res= unit->exec();
if (!res && thd->cursor && thd->cursor->is_open())
{
@@ -210,6 +211,13 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
JOIN *join= new JOIN(thd_arg, sl->item_list,
sl->options | thd_arg->options | additional_options,
tmp_result);
+ /*
+ setup_tables_done_option should be set only for very first SELECT,
+ because it protect from secont setup_tables call for select-like non
+ select commands (DELETE/INSERT/...) and they use only very first
+ SELECT (for union it can be only INSERT ... SELECT).
+ */
+ additional_options&= ~OPTION_SETUP_TABLES_DONE;
if (!join)
goto err;