2946 Martin Hansson 2009-11-20 [merge]
merge of Bug#33204 (backport)
removed:
dbug/.cvsignore
dbug/doinstall.sh
dbug/install.sh
dbug/mklintlib.sh
dbug/qmake.cmd
dbug/vargs.h
libmysql/manager.c
mysql-test/r/locale.result
mysql-test/t/locale.test
added:
dbug/remove_function_from_trace.pl
dbug/tests-t.pl
dbug/tests.c
include/mysql/service_my_snprintf.h
include/mysql/service_thd_alloc.h
include/mysql/services.h
include/service_versions.h
libservices/
libservices/CMakeLists.txt
libservices/HOWTO
libservices/Makefile.am
libservices/my_snprintf_service.c
libservices/thd_alloc_service.c
mysql-test/include/bug38347.inc
mysql-test/include/have_case_insensitive_fs.inc
mysql-test/r/case_insensitive_fs.require
mysql-test/r/drop_debug.result
mysql-test/r/grant4.result
mysql-test/r/grant_lowercase_fs.result
mysql-test/r/innodb_bug47777.result
mysql-test/r/locale.result
mysql-test/r/log_state_bug33693.result
mysql-test/r/partition_column.result
mysql-test/r/partition_column_prune.result
mysql-test/r/partition_utf8.result
mysql-test/r/query_cache_disabled.result
mysql-test/r/sp-bugs.result
mysql-test/suite/binlog/r/binlog_delete_and_flush_index.result
mysql-test/suite/binlog/r/binlog_stm_do_db.result
mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test
mysql-test/suite/binlog/t/binlog_stm_do_db-master.opt
mysql-test/suite/binlog/t/binlog_stm_do_db.test
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock-slave.opt
mysql-test/t/drop_debug.test
mysql-test/t/grant4.test
mysql-test/t/grant_lowercase_fs.test
mysql-test/t/innodb_bug47777.test
mysql-test/t/locale.test
mysql-test/t/log_state_bug33693-master.opt
mysql-test/t/log_state_bug33693.test
mysql-test/t/partition_column.test
mysql-test/t/partition_column_prune.test
mysql-test/t/partition_utf8.test
mysql-test/t/query_cache_disabled-master.opt
mysql-test/t/query_cache_disabled.test
mysql-test/t/sp-bugs.test
sql/records.h
sql/sql_plugin_services.h
sql/sql_prepare.h
unittest/mysys/my_vsnprintf-t.c
renamed:
mysql-test/include/have_community_features.inc => mysql-test/include/have_profiling.inc
mysql-test/r/bug40113.result => mysql-test/r/innodb_lock_wait_timeout_1.result
mysql-test/r/have_community_features.require => mysql-test/r/have_profiling.require
mysql-test/t/bug40113-master.opt => mysql-test/t/innodb_lock_wait_timeout_1-master.opt
mysql-test/t/bug40113.test => mysql-test/t/innodb_lock_wait_timeout_1.test
modified:
.bzr-mysql/default.conf
.bzrignore
BUILD/build_mccge.sh
CMakeLists.txt
Makefile.am
client/mysql.cc
client/mysql_upgrade.c
client/mysqladmin.cc
client/mysqlbinlog.cc
client/mysqlcheck.c
client/mysqldump.c
client/mysqlimport.c
client/mysqlshow.c
client/mysqlslap.c
client/mysqltest.cc
configure.in
dbug/Makefile.am
dbug/dbug.c
dbug/dbug_add_tags.pl
dbug/user.r
extra/my_print_defaults.c
extra/yassl/taocrypt/src/random.cpp
include/Makefile.am
include/config-win.h
include/errmsg.h
include/hash.h
include/m_string.h
include/my_base.h
include/my_dbug.h
include/my_global.h
include/my_pthread.h
include/my_sys.h
include/myisam.h
include/mysql.h
include/mysql.h.pp
include/mysql/plugin.h
include/mysql/plugin.h.pp
include/mysql_com.h
libmysql/CMakeLists.txt
libmysql/Makefile.shared
libmysql/client_settings.h
libmysql/errmsg.c
libmysql/libmysql.c
libmysql/libmysql.def
libmysqld/lib_sql.cc
libmysqld/libmysqld.c
libmysqld/libmysqld.def
mysql-test/collections/default.experimental
mysql-test/extra/binlog_tests/drop_temp_table.test
mysql-test/extra/rpl_tests/rpl_loaddata.test
mysql-test/extra/rpl_tests/rpl_stm_000001.test
mysql-test/include/query_cache_sql_prepare.inc
mysql-test/lib/My/SafeProcess/safe_process_win.cc
mysql-test/r/alter_table.result
mysql-test/r/analyse.result
mysql-test/r/create.result
mysql-test/r/ctype_collate.result
mysql-test/r/ctype_ldml.result
mysql-test/r/delayed.result
mysql-test/r/drop.result
mysql-test/r/events_bugs.result
mysql-test/r/explain.result
mysql-test/r/func_math.result
mysql-test/r/func_str.result
mysql-test/r/gis-rtree.result
mysql-test/r/gis.result
mysql-test/r/grant.result
mysql-test/r/grant2.result
mysql-test/r/grant3.result
mysql-test/r/information_schema.result
mysql-test/r/information_schema_db.result
mysql-test/r/innodb-autoinc.result
mysql-test/r/innodb_bug46000.result
mysql-test/r/innodb_mysql.result
mysql-test/r/insert.result
mysql-test/r/join.result
mysql-test/r/loadxml.result
mysql-test/r/log_state.result
mysql-test/r/lowercase_fs_off.result
mysql-test/r/lowercase_table2.result
mysql-test/r/merge.result
mysql-test/r/myisam.result
mysql-test/r/myisam_crash_before_flush_keys.result
mysql-test/r/mysqlbinlog_row.result
mysql-test/r/mysqlbinlog_row_innodb.result
mysql-test/r/mysqlbinlog_row_myisam.result
mysql-test/r/mysqlbinlog_row_trans.result
mysql-test/r/mysqldump.result
mysql-test/r/olap.result
mysql-test/r/outfile.result
mysql-test/r/partition.result
mysql-test/r/partition_datatype.result
mysql-test/r/partition_error.result
mysql-test/r/partition_innodb.result
mysql-test/r/partition_list.result
mysql-test/r/partition_mgm_err.result
mysql-test/r/partition_pruning.result
mysql-test/r/partition_range.result
mysql-test/r/plugin.result
mysql-test/r/profiling.result
mysql-test/r/ps.result
mysql-test/r/ps_1general.result
mysql-test/r/ps_grant.result
mysql-test/r/query_cache.result
mysql-test/r/query_cache_ps_no_prot.result
mysql-test/r/query_cache_ps_ps_prot.result
mysql-test/r/range.result
mysql-test/r/select.result
mysql-test/r/show_check.result
mysql-test/r/sp-error.result
mysql-test/r/sp-vars.result
mysql-test/r/sp.result
mysql-test/r/sp_trans.result
mysql-test/r/sql_mode.result
mysql-test/r/strict.result
mysql-test/r/subselect.result
mysql-test/r/subselect3.result
mysql-test/r/system_mysql_db.result
mysql-test/r/trigger.result
mysql-test/r/type_decimal.result
mysql-test/r/type_newdecimal.result
mysql-test/r/type_varchar.result
mysql-test/r/update.result
mysql-test/r/view_grant.result
mysql-test/r/xa.result
mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result
mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result
mysql-test/suite/funcs_1/r/innodb_func_view.result
mysql-test/suite/funcs_1/r/innodb_storedproc_07.result
mysql-test/suite/funcs_1/r/innodb_trig_03.result
mysql-test/suite/funcs_1/r/innodb_trig_03e.result
mysql-test/suite/funcs_1/r/innodb_views.result
mysql-test/suite/funcs_1/r/is_columns_is.result
mysql-test/suite/funcs_1/r/is_columns_mysql.result
mysql-test/suite/funcs_1/r/is_routines.result
mysql-test/suite/funcs_1/r/is_statistics.result
mysql-test/suite/funcs_1/r/is_user_privileges.result
mysql-test/suite/funcs_1/r/memory_func_view.result
mysql-test/suite/funcs_1/r/memory_storedproc_07.result
mysql-test/suite/funcs_1/r/memory_trig_03.result
mysql-test/suite/funcs_1/r/memory_trig_03e.result
mysql-test/suite/funcs_1/r/memory_views.result
mysql-test/suite/funcs_1/r/myisam_func_view.result
mysql-test/suite/funcs_1/r/myisam_storedproc_07.result
mysql-test/suite/funcs_1/r/myisam_trig_03.result
mysql-test/suite/funcs_1/r/myisam_trig_03e.result
mysql-test/suite/funcs_1/r/myisam_views.result
mysql-test/suite/funcs_1/r/ndb_func_view.result
mysql-test/suite/funcs_1/r/ndb_storedproc_07.result
mysql-test/suite/funcs_1/r/ndb_trig_03.result
mysql-test/suite/funcs_1/r/ndb_trig_03e.result
mysql-test/suite/funcs_1/r/ndb_views.result
mysql-test/suite/funcs_1/r/storedproc.result
mysql-test/suite/innodb/r/innodb-zip.result
mysql-test/suite/innodb/t/disabled.def
mysql-test/suite/innodb/t/innodb-analyze.test
mysql-test/suite/innodb/t/innodb-zip.test
mysql-test/suite/innodb/t/innodb_bug36169.test
mysql-test/suite/innodb/t/innodb_bug36172.test
mysql-test/suite/innodb/t/innodb_information_schema.test
mysql-test/suite/ndb/r/ndb_dd_ddl.result
mysql-test/suite/ndb/t/ndb_dd_ddl.test
mysql-test/suite/parts/inc/partition_key_32col.inc
mysql-test/suite/parts/inc/partition_syntax.inc
mysql-test/suite/parts/r/partition_special_innodb.result
mysql-test/suite/parts/r/partition_special_myisam.result
mysql-test/suite/parts/r/partition_syntax_innodb.result
mysql-test/suite/parts/r/partition_syntax_myisam.result
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
mysql-test/suite/rpl/r/rpl_loaddata.result
mysql-test/suite/rpl/r/rpl_udf.result
mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test
mysql-test/suite/sys_vars/r/auto_commit_basic.result
mysql-test/suite/sys_vars/r/automatic_sp_privileges_basic.result
mysql-test/suite/sys_vars/r/big_tables_basic.result
mysql-test/suite/sys_vars/r/engine_condition_pushdown_basic.result
mysql-test/suite/sys_vars/r/flush_basic.result
mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result
mysql-test/suite/sys_vars/r/general_log_basic.result
mysql-test/suite/sys_vars/r/innodb_checksums_basic.result
mysql-test/suite/sys_vars/r/innodb_doublewrite_basic.result
mysql-test/suite/sys_vars/r/innodb_locks_unsafe_for_binlog_basic.result
mysql-test/suite/sys_vars/r/innodb_rollback_on_timeout_basic.result
mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result
mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result
mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result
mysql-test/suite/sys_vars/r/local_infile_basic.result
mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result
mysql-test/suite/sys_vars/r/log_queries_not_using_indexes_basic.result
mysql-test/suite/sys_vars/r/low_priority_updates_basic.result
mysql-test/suite/sys_vars/r/myisam_use_mmap_basic.result
mysql-test/suite/sys_vars/r/new_basic.result
mysql-test/suite/sys_vars/r/old_passwords_basic.result
mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result
mysql-test/suite/sys_vars/r/read_only_basic.result
mysql-test/suite/sys_vars/r/relay_log_purge_basic.result
mysql-test/suite/sys_vars/r/secure_auth_basic.result
mysql-test/suite/sys_vars/r/slave_allow_batching_basic.result
mysql-test/suite/sys_vars/r/slave_compressed_protocol_basic.result
mysql-test/suite/sys_vars/r/slow_query_log_basic.result
mysql-test/suite/sys_vars/r/sql_auto_is_null_basic.result
mysql-test/suite/sys_vars/r/sql_big_selects_basic.result
mysql-test/suite/sys_vars/r/sql_big_tables_basic.result
mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result
mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
mysql-test/suite/sys_vars/r/sql_log_off_basic.result
mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result
mysql-test/suite/sys_vars/r/sql_notes_basic.result
mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result
mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result
mysql-test/suite/sys_vars/r/sql_warnings_basic.result
mysql-test/suite/sys_vars/r/sync_frm_basic.result
mysql-test/suite/sys_vars/r/timed_mutexes_basic.result
mysql-test/suite/sys_vars/r/unique_checks_basic.result
mysql-test/suite/sys_vars/t/auto_commit_basic.test
mysql-test/suite/sys_vars/t/automatic_sp_privileges_basic.test
mysql-test/suite/sys_vars/t/big_tables_basic.test
mysql-test/suite/sys_vars/t/engine_condition_pushdown_basic.test
mysql-test/suite/sys_vars/t/flush_basic.test
mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test
mysql-test/suite/sys_vars/t/general_log_basic.test
mysql-test/suite/sys_vars/t/innodb_checksums_basic.test
mysql-test/suite/sys_vars/t/innodb_doublewrite_basic.test
mysql-test/suite/sys_vars/t/innodb_locks_unsafe_for_binlog_basic.test
mysql-test/suite/sys_vars/t/innodb_rollback_on_timeout_basic.test
mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test
mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test
mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test
mysql-test/suite/sys_vars/t/local_infile_basic.test
mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test
mysql-test/suite/sys_vars/t/log_queries_not_using_indexes_basic.test
mysql-test/suite/sys_vars/t/low_priority_updates_basic.test
mysql-test/suite/sys_vars/t/myisam_use_mmap_basic.test
mysql-test/suite/sys_vars/t/new_basic.test
mysql-test/suite/sys_vars/t/old_passwords_basic.test
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test
mysql-test/suite/sys_vars/t/read_only_basic.test
mysql-test/suite/sys_vars/t/relay_log_purge_basic.test
mysql-test/suite/sys_vars/t/secure_auth_basic.test
mysql-test/suite/sys_vars/t/slave_allow_batching_basic.test
mysql-test/suite/sys_vars/t/slave_compressed_protocol_basic.test
mysql-test/suite/sys_vars/t/slow_query_log_basic.test
mysql-test/suite/sys_vars/t/sql_auto_is_null_basic.test
mysql-test/suite/sys_vars/t/sql_big_selects_basic.test
mysql-test/suite/sys_vars/t/sql_big_tables_basic.test
mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test
mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
mysql-test/suite/sys_vars/t/sql_log_off_basic.test
mysql-test/suite/sys_vars/t/sql_low_priority_updates_basic.test
mysql-test/suite/sys_vars/t/sql_notes_basic.test
mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test
mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test
mysql-test/suite/sys_vars/t/sql_warnings_basic.test
mysql-test/suite/sys_vars/t/sync_frm_basic.test
mysql-test/suite/sys_vars/t/timed_mutexes_basic.test
mysql-test/suite/sys_vars/t/unique_checks_basic.test
mysql-test/t/alter_table.test
mysql-test/t/analyse.test
mysql-test/t/create.test
mysql-test/t/ctype_collate.test
mysql-test/t/ctype_ldml.test
mysql-test/t/ctype_utf8.test
mysql-test/t/delayed.test
mysql-test/t/disabled.def
mysql-test/t/drop.test
mysql-test/t/explain.test
mysql-test/t/flush_read_lock_kill.test
mysql-test/t/gis-rtree.test
mysql-test/t/gis.test
mysql-test/t/grant.test
mysql-test/t/grant3.test
mysql-test/t/information_schema_db.test
mysql-test/t/innodb-autoinc.test
mysql-test/t/innodb.test
mysql-test/t/innodb_bug39438.test
mysql-test/t/innodb_bug44369.test
mysql-test/t/innodb_bug46000.test
mysql-test/t/innodb_mysql.test
mysql-test/t/insert.test
mysql-test/t/join.test
mysql-test/t/kill.test
mysql-test/t/loadxml.test
mysql-test/t/log_state.test
mysql-test/t/lowercase_fs_off.test
mysql-test/t/lowercase_table2.test
mysql-test/t/merge.test
mysql-test/t/myisam.test
mysql-test/t/myisam_crash_before_flush_keys.test
mysql-test/t/olap.test
mysql-test/t/outfile.test
mysql-test/t/partition.test
mysql-test/t/partition_datatype.test
mysql-test/t/partition_error.test
mysql-test/t/partition_innodb.test
mysql-test/t/partition_list.test
mysql-test/t/partition_mgm_err.test
mysql-test/t/partition_pruning.test
mysql-test/t/partition_range.test
mysql-test/t/plugin.test
mysql-test/t/profiling.test
mysql-test/t/ps.test
mysql-test/t/query_cache.test
mysql-test/t/range.test
mysql-test/t/select.test
mysql-test/t/sp-error.test
mysql-test/t/sp-vars.test
mysql-test/t/sp.test
mysql-test/t/sp_trans.test
mysql-test/t/sql_mode.test
mysql-test/t/subselect.test
mysql-test/t/subselect3.test
mysql-test/t/trigger.test
mysql-test/t/type_decimal.test
mysql-test/t/type_newdecimal.test
mysql-test/t/type_varchar.test
mysql-test/t/update.test
mysql-test/t/variables+c.test
mysql-test/t/view_grant.test
mysql-test/t/xa.test
mysys/default.c
mysys/mf_keycaches.c
mysys/my_error.c
mysys/my_getopt.c
mysys/my_largepage.c
mysys/my_thr_init.c
mysys/typelib.c
plugin/daemon_example/Makefile.am
scripts/mysql_system_tables.sql
scripts/mysql_system_tables_data.sql
scripts/mysql_system_tables_fix.sql
scripts/mysqld_safe.sh
sql-common/client.c
sql/CMakeLists.txt
sql/Makefile.am
sql/debug_sync.cc
sql/event_data_objects.cc
sql/event_scheduler.cc
sql/events.cc
sql/field.cc
sql/field.h
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_partition.cc
sql/ha_partition.h
sql/handler.cc
sql/handler.h
sql/hash_filo.h
sql/hostname.cc
sql/item.cc
sql/item.h
sql/item_cmpfunc.cc
sql/item_cmpfunc.h
sql/item_create.cc
sql/item_func.cc
sql/item_func.h
sql/item_geofunc.cc
sql/item_subselect.cc
sql/item_sum.cc
sql/item_sum.h
sql/item_timefunc.cc
sql/item_timefunc.h
sql/lock.cc
sql/log.cc
sql/log_event.cc
sql/log_event_old.cc
sql/my_decimal.h
sql/mysql_priv.h
sql/mysqld.cc
sql/net_serv.cc
sql/opt_range.cc
sql/partition_element.h
sql/partition_info.cc
sql/partition_info.h
sql/procedure.h
sql/protocol.cc
sql/protocol.h
sql/records.cc
sql/repl_failsafe.cc
sql/replication.h
sql/rpl_filter.cc
sql/rpl_handler.cc
sql/rpl_injector.h
sql/rpl_tblmap.cc
sql/rpl_tblmap.h
sql/set_var.cc
sql/set_var.h
sql/share/errmsg-utf8.txt
sql/share/errmsg.txt
sql/slave.cc
sql/sp.cc
sql/sp_cache.cc
sql/sp_head.cc
sql/sql_acl.cc
sql/sql_acl.h
sql/sql_base.cc
sql/sql_cache.cc
sql/sql_cache.h
sql/sql_class.cc
sql/sql_class.h
sql/sql_connect.cc
sql/sql_cursor.cc
sql/sql_db.cc
sql/sql_delete.cc
sql/sql_error.cc
sql/sql_handler.cc
sql/sql_help.cc
sql/sql_insert.cc
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_list.cc
sql/sql_list.h
sql/sql_load.cc
sql/sql_locale.cc
sql/sql_parse.cc
sql/sql_partition.cc
sql/sql_partition.h
sql/sql_plugin.cc
sql/sql_plugin.h
sql/sql_prepare.cc
sql/sql_profile.cc
sql/sql_profile.h
sql/sql_rename.cc
sql/sql_repl.cc
sql/sql_select.cc
sql/sql_select.h
sql/sql_servers.cc
sql/sql_show.cc
sql/sql_string.h
sql/sql_table.cc
sql/sql_tablespace.cc
sql/sql_test.cc
sql/sql_trigger.cc
sql/sql_udf.cc
sql/sql_update.cc
sql/sql_view.cc
sql/sql_yacc.yy
sql/structs.h
sql/table.cc
sql/table.h
sql/time.cc
sql/tztime.cc
storage/archive/archive_reader.c
storage/archive/ha_archive.cc
storage/blackhole/ha_blackhole.cc
storage/csv/ha_tina.cc
storage/csv/ha_tina.h
storage/example/Makefile.am
storage/example/ha_example.cc
storage/federated/ha_federated.cc
storage/innobase/ChangeLog
storage/innobase/buf/buf0buf.c
storage/innobase/buf/buf0flu.c
storage/innobase/buf/buf0lru.c
storage/innobase/fil/fil0fil.c
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/ha_innodb.h
storage/innobase/handler/handler0alter.cc
storage/innobase/include/buf0buf.h
storage/innobase/include/buf0buf.ic
storage/innobase/include/handler0alter.h
storage/innobase/include/page0page.ic
storage/innobase/include/row0merge.h
storage/innobase/include/row0mysql.h
storage/innobase/include/row0types.h
storage/innobase/include/univ.i
storage/innobase/os/os0file.c
storage/innobase/os/os0proc.c
storage/innobase/row/row0ins.c
storage/innobase/row/row0merge.c
storage/innobase/row/row0mysql.c
storage/innobase/srv/srv0start.c
storage/myisam/ha_myisam.cc
storage/myisam/mi_check.c
storage/myisam/mi_dynrec.c
storage/myisam/myisamchk.c
storage/myisam/myisampack.c
storage/myisam/sort.c
storage/mysql_storage_engine.cmake
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
strings/ctype-uca.c
strings/my_vsnprintf.c
tests/mysql_client_test.c
tests/thread_test.c
unittest/mysys/Makefile.am
vio/viosslfactories.c
mysql-test/include/have_profiling.inc
mysql-test/r/innodb_lock_wait_timeout_1.result
mysql-test/r/have_profiling.require
mysql-test/t/innodb_lock_wait_timeout_1.test
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result 2009-11-06 16:15:09 +0000
+++ b/mysql-test/r/subselect.result 2009-11-20 12:29:43 +0000
@@ -3562,9 +3562,7 @@ SELECT sql_no_cache * FROM t1 WHERE NOT
(SELECT i FROM t1) UNION
(SELECT i FROM t1)
);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
-(SELECT i FROM t1)
-)' at line 3
+i
SELECT * FROM t1
WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT i FROM t1)))' at line 2
@@ -3574,7 +3572,11 @@ ERROR 42000: You have an error in your S
from t1' at line 1
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select t12.i from t1 t12))' at line 2
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
insert into t1 (a) values (FLOOR(rand() * 100));
@@ -4279,8 +4281,15 @@ Note 1003 select 2 AS `2` from `test`.`t
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
-(SELECT 1 FROM t2 WHERE t1.a = t2.a))' at line 2
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
+Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
+Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 AS `1` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 AS `1` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))
DROP TABLE t1,t2;
create table t1(f11 int, f12 int);
create table t2(f21 int unsigned not null, f22 int, f23 varchar(10));
@@ -4563,6 +4572,270 @@ id g v s
51 50 NULL l
61 60 NULL l
drop table t1, t2;
+#
+# Bug#33204: INTO is allowed in subselect, causing inconsistent results
+#
+CREATE TABLE t1( a INT );
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2( a INT, b INT );
+SELECT *
+FROM (SELECT a INTO @var FROM t1 WHERE a = 2) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var FROM t1 WHERE a = 2) t1a' at line 2
+SELECT *
+FROM (SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a' at line 2
+SELECT *
+FROM (SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a' at line 2
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a INTO @var FROM t1 WHERE a = 2
+) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @var FROM t1 WHERE a = 2
+) t1a' at line 4
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a' at line 4
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a' at line 4
+SELECT * FROM (SELECT a FROM t1 WHERE a = 2) t1a;
+a
+2
+SELECT * FROM (
+SELECT a FROM t1 WHERE a = 2
+UNION
+SELECT a FROM t1 WHERE a = 2
+) t1a;
+a
+2
+SELECT * FROM (
+SELECT 1 a
+UNION
+SELECT a FROM t1 WHERE a = 2
+UNION
+SELECT a FROM t1 WHERE a = 2
+) t1a;
+a
+1
+2
+SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
+a
+1
+SELECT * FROM (SELECT 1 UNION SELECT 1) t1a;
+1
+1
+SELECT * FROM ((SELECT 1 a INTO @a)) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)) t1a' at line 1
+SELECT * FROM ((SELECT 1 a INTO OUTFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )) t1a' at line 1
+SELECT * FROM ((SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO @a)) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO OUTFILE 'file' )) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO @a))) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a))) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO DUMPFILE 'file' ))) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' ))) t1a' at line 1
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO OUTFILE 'file' ))) t1a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' ))) t1a' at line 1
+SELECT * FROM (SELECT 1 a ORDER BY a) t1a;
+a
+1
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a) t1a;
+a
+1
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a LIMIT 1) t1a;
+a
+1
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a LIMIT 1) t1a;
+a
+1
+SELECT * FROM t1 JOIN (SELECT 1 UNION SELECT 1) alias ON 1;
+a 1
+1 1
+2 1
+SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ON 1' at line 1
+SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON 1' at line 1
+SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ON 1' at line 1
+SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a ON 1' at line 1
+SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a ON 1' at line 1
+SELECT * FROM t1 JOIN (t1 t1a) ON 1;
+a a
+1 1
+2 1
+1 2
+2 2
+SELECT * FROM t1 JOIN ((t1 t1a)) ON 1;
+a a
+1 1
+2 1
+1 2
+2 2
+SELECT * FROM (t1 t1a);
+a
+1
+2
+SELECT * FROM ((t1 t1a));
+a
+1
+2
+SELECT * FROM t1 JOIN (SELECT 1 t1a) alias ON 1;
+a t1a
+1 1
+2 1
+SELECT * FROM t1 JOIN ((SELECT 1 t1a)) alias ON 1;
+a t1a
+1 1
+2 1
+SELECT * FROM t1 JOIN (SELECT 1 a) a ON 1;
+a a
+1 1
+2 1
+SELECT * FROM t1 JOIN ((SELECT 1 a)) a ON 1;
+a a
+1 1
+2 1
+SELECT * FROM (t1 JOIN (SELECT 1) t1a1 ON 1) t1a2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1a2' at line 1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 3 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO @a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)' at line 1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO @a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO @a);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @a)' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT ( SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT ( SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT ( SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO OUTFILE 'file' )' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO DUMPFILE 'file' )' at line 1
+SELECT ( SELECT a FROM t1 WHERE a = 1 ), a FROM t1;
+( SELECT a FROM t1 WHERE a = 1 ) a
+1 1
+1 2
+SELECT ( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ), a FROM t1;
+( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ) a
+1 1
+1 2
+SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
+a b
+SELECT 1 UNION ( SELECT 1 UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 )' at line 1
+( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) UNION SELECT 1' at line 1
+SELECT ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1' at line 1
+SELECT ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+( SELECT 1 UNION SELECT 1 UNION SELECT 1 )
+1
+SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
+((SELECT 1 UNION SELECT 1 UNION SELECT 1))
+1
+SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
+SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
+1
+1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
+SELECT * FROM t1 WHERE a = ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a = ALL ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a = ANY ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 ) UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a IN ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION SELECT 1 )' at line 1
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+a
+1
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 UNION SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT EXISTS(SELECT 1+1);
+EXISTS(SELECT 1+1)
+1
+SELECT EXISTS(SELECT 1+1 INTO @test);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @test)' at line 1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
+DROP TABLE t1, t2;
CREATE TABLE t1 (a ENUM('rainbow'));
INSERT INTO t1 VALUES (),(),(),(),();
SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID()));
=== modified file 'mysql-test/r/union.result'
--- a/mysql-test/r/union.result 2009-05-15 07:11:07 +0000
+++ b/mysql-test/r/union.result 2009-11-10 12:52:46 +0000
@@ -153,48 +153,6 @@ ERROR 42S22: Unknown column 'a' in 'fiel
1 3
1 3
2 1
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (1);
-SELECT a INTO @v FROM (
-SELECT a FROM t1
-UNION
-SELECT a FROM t1
-) alias;
-SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
-SELECT a FROM t1
-UNION
-SELECT a FROM t1 WHERE 0
-) alias;
-SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
-SELECT a FROM t1
-UNION
-SELECT a FROM t1 WHERE 0
-) alias;
-SELECT a FROM (
-SELECT a FROM t1
-UNION
-SELECT a INTO @v FROM t1
-) alias;
-SELECT a FROM (
-SELECT a FROM t1
-UNION
-SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
-) alias;
-SELECT a FROM (
-SELECT a FROM t1
-UNION
-SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
-) alias;
-SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
-SELECT a FROM t1 UNION SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
-SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
-SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
-ERROR HY000: Incorrect usage of UNION and INTO
-SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
-ERROR HY000: Incorrect usage of UNION and INTO
-SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
-ERROR HY000: Incorrect usage of UNION and INTO
-DROP TABLE t1;
CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '',
@@ -1588,3 +1546,39 @@ Warnings:
Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a`
DROP TABLE t1;
End of 5.0 tests
+#
+# Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
+# subselects into account
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+# Tests fix in parser rule select_derived_union.
+SELECT a INTO @v FROM (
+SELECT a FROM t1
+UNION
+SELECT a FROM t1
+) alias;
+SELECT a INTO OUTFILE 'union.out.file' FROM (
+SELECT a FROM t1
+UNION
+SELECT a FROM t1 WHERE 0
+) alias;
+SELECT a INTO DUMPFILE 'union.out.file2' FROM (
+SELECT a FROM t1
+UNION
+SELECT a FROM t1 WHERE 0
+) alias;
+SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
+SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
+ERROR HY000: Incorrect usage of UNION and INTO
+SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+ERROR HY000: Incorrect usage of UNION and INTO
+SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+ERROR HY000: Incorrect usage of UNION and INTO
+# Tests fix in parser rule query_expression_body.
+SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
+DROP TABLE t1;
=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test 2009-11-06 16:15:09 +0000
+++ b/mysql-test/t/subselect.test 2009-11-20 12:29:43 +0000
@@ -2513,8 +2513,6 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (i INT);
(SELECT i FROM t1) UNION (SELECT i FROM t1);
-#TODO:not supported
---error ER_PARSE_ERROR
SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
(
(SELECT i FROM t1) UNION
@@ -2531,8 +2529,6 @@ WHERE NOT EXISTS (((SELECT i FROM t1) UN
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1;
-#TODO:not supported
---error ER_PARSE_ERROR
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
@@ -3203,8 +3199,6 @@ EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
-#TODO:not supported
---error ER_PARSE_ERROR
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
@@ -3544,6 +3538,232 @@ where v in(select v
where t1.g=t2.g) is unknown;
drop table t1, t2;
+-- echo #
+-- echo # Bug#33204: INTO is allowed in subselect, causing inconsistent results
+-- echo #
+CREATE TABLE t1( a INT );
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2( a INT, b INT );
+
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO @var FROM t1 WHERE a = 2) t1a;
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a;
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO @var FROM t1 WHERE a = 2
+) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+
+SELECT * FROM (SELECT a FROM t1 WHERE a = 2) t1a;
+
+SELECT * FROM (
+ SELECT a FROM t1 WHERE a = 2
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+) t1a;
+
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+) t1a;
+
+# This was not allowed previously. Possibly, it should be allowed on the future.
+# For now, the intent is to keep the fix as non-intrusive as possible.
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
+SELECT * FROM (SELECT 1 UNION SELECT 1) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO @a)) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO OUTFILE 'file' )) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO @a)) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO OUTFILE 'file' )) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO @a))) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO DUMPFILE 'file' ))) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO OUTFILE 'file' ))) t1a;
+
+SELECT * FROM (SELECT 1 a ORDER BY a) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a LIMIT 1) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a LIMIT 1) t1a;
+
+# Test of rule
+# table_factor: '(' get_select_lex query_expression_body ')' opt_table_alias
+# UNION should not be allowed inside the parentheses, nor should
+# aliases after.
+#
+SELECT * FROM t1 JOIN (SELECT 1 UNION SELECT 1) alias ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
+
+SELECT * FROM t1 JOIN (t1 t1a) ON 1;
+SELECT * FROM t1 JOIN ((t1 t1a)) ON 1;
+
+SELECT * FROM (t1 t1a);
+SELECT * FROM ((t1 t1a));
+
+SELECT * FROM t1 JOIN (SELECT 1 t1a) alias ON 1;
+SELECT * FROM t1 JOIN ((SELECT 1 t1a)) alias ON 1;
+
+SELECT * FROM t1 JOIN (SELECT 1 a) a ON 1;
+SELECT * FROM t1 JOIN ((SELECT 1 a)) a ON 1;
+
+# For the join, TABLE_LIST::select_lex == NULL
+# Check that we handle this.
+--error ER_PARSE_ERROR
+SELECT * FROM (t1 JOIN (SELECT 1) t1a1 ON 1) t1a2;
+
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 );
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ANY ( SELECT 3 UNION SELECT 1 );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+SELECT * FROM t1 WHERE a = ( SELECT 1 );
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+# Make sure context is popped when we leave the nested select
+SELECT ( SELECT a FROM t1 WHERE a = 1 ), a FROM t1;
+SELECT ( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ), a FROM t1;
+
+# Make sure we have feature F561 (see .yy file)
+SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
+
+# Make sure the parser does not allow nested UNIONs anywhere
+
+--error ER_PARSE_ERROR
+SELECT 1 UNION ( SELECT 1 UNION SELECT 1 );
+--error ER_PARSE_ERROR
+( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+SELECT ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
+
+--error ER_PARSE_ERROR
+SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ALL ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 UNION SELECT 1 INTO @v );
+SELECT EXISTS(SELECT 1+1);
+--error ER_PARSE_ERROR
+SELECT EXISTS(SELECT 1+1 INTO @test);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 INTO @v );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
+
+DROP TABLE t1, t2;
#
# Bug #31157: Crash when select+order by the avg of some field within the
# group by
=== modified file 'mysql-test/t/union.test'
--- a/mysql-test/t/union.test 2009-05-15 07:11:07 +0000
+++ b/mysql-test/t/union.test 2009-11-10 12:52:46 +0000
@@ -91,88 +91,6 @@ SELECT @a:=1 UNION SELECT @a:=@a+1;
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
-
-#
-# Bug#32858: Erro: "Incorrect usage of UNION and INTO" does not take subselects
-# into account
-#
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (1);
-
-SELECT a INTO @v FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1
-) alias;
-
---let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file
---error 0,1
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a INTO OUTFILE '$outfile' FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1 WHERE 0
-) alias;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a INTO DUMPFILE '$outfile' FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1 WHERE 0
-) alias;
---remove_file $outfile
-
-#
-# INTO will not be allowed in subqueries in version 5.1 and above.
-#
-SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO @v FROM t1
-) alias;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO OUTFILE '$outfile' FROM t1
-) alias;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO DUMPFILE '$outfile' FROM t1
-) alias;
---remove_file $outfile
-
-SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1;
---remove_file $outfile
-
---error ER_WRONG_USAGE
-SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_WRONG_USAGE
-eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_WRONG_USAGE
-eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
-
-DROP TABLE t1;
-
#
# Test bug reported by joc@stripped
#
@@ -1102,3 +1020,45 @@ DROP TABLE t1;
--echo End of 5.0 tests
+-- echo #
+-- echo # Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
+-- echo # subselects into account
+-- echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+
+-- echo # Tests fix in parser rule select_derived_union.
+SELECT a INTO @v FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1
+) alias;
+
+SELECT a INTO OUTFILE 'union.out.file' FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1 WHERE 0
+) alias;
+
+SELECT a INTO DUMPFILE 'union.out.file2' FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1 WHERE 0
+) alias;
+
+SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+
+-- echo # Tests fix in parser rule query_expression_body.
+SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
+
+DROP TABLE t1;
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2009-11-10 07:31:33 +0000
+++ b/sql/sql_class.cc 2009-11-20 12:29:43 +0000
@@ -1609,7 +1609,6 @@ void THD::rollback_item_tree_changes()
select_result::select_result()
{
thd=current_thd;
- nest_level= -1;
}
void select_result::send_error(uint errcode,const char *err)
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2009-11-10 07:31:33 +0000
+++ b/sql/sql_class.h 2009-11-20 12:29:43 +0000
@@ -2400,7 +2400,6 @@ class select_result :public Sql_alloc {
protected:
THD *thd;
SELECT_LEX_UNIT *unit;
- uint nest_level;
public:
select_result();
virtual ~select_result() {};
@@ -2437,12 +2436,6 @@ public:
*/
virtual void cleanup();
void set_thd(THD *thd_arg) { thd= thd_arg; }
- /**
- The nest level, if supported.
- @return
- -1 if nest level is undefined, otherwise a positive integer.
- */
- int get_nest_level() { return nest_level; }
#ifdef EMBEDDED_LIBRARY
virtual void begin_dataset() {}
#else
@@ -2537,14 +2530,6 @@ class select_export :public select_to_fi
CHARSET_INFO *write_cs; // output charset
public:
select_export(sql_exchange *ex) :select_to_file(ex) {}
- /**
- Creates a select_export to represent INTO OUTFILE <filename> with a
- defined level of subquery nesting.
- */
- select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex)
- {
- nest_level= nest_level_arg;
- }
~select_export();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
@@ -2554,15 +2539,6 @@ public:
class select_dump :public select_to_file {
public:
select_dump(sql_exchange *ex) :select_to_file(ex) {}
- /**
- Creates a select_export to represent INTO DUMPFILE <filename> with a
- defined level of subquery nesting.
- */
- select_dump(sql_exchange *ex, uint nest_level_arg) :
- select_to_file(ex)
- {
- nest_level= nest_level_arg;
- }
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
};
@@ -3033,16 +3009,6 @@ class select_dumpvar :public select_resu
public:
List<my_var> var_list;
select_dumpvar() { var_list.empty(); row_count= 0;}
- /**
- Creates a select_dumpvar to represent INTO <variable> with a defined
- level of subquery nesting.
- */
- select_dumpvar(uint nest_level_arg)
- {
- var_list.empty();
- row_count= 0;
- nest_level= nest_level_arg;
- }
~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2009-11-12 12:13:43 +0000
+++ b/sql/sql_yacc.yy 2009-11-20 12:29:43 +0000
@@ -466,6 +466,90 @@ Item* handle_sql2003_note184_exception(T
DBUG_RETURN(result);
}
+/**
+ @brief Creates a new SELECT_LEX for a UNION branch.
+
+ Sets up and initializes a SELECT_LEX structure for a query once the parser
+ discovers a UNION token. The current SELECT_LEX is pushed on the stack and
+ the new SELECT_LEX becomes the current one.
+
+ @param lex The parser state.
+
+ @param is_union_distinct True if the union preceding the new select statement
+ uses UNION DISTINCT.
+
+ @param is_top_level This should be @c TRUE if the newly created SELECT_LEX
+ is a non-nested statement.
+
+ @return <code>false</code> if successful, <code>true</code> if an error was
+ reported. In the latter case parsing should stop.
+ */
+bool add_select_to_union_list(LEX *lex, bool is_union_distinct,
+ bool is_top_level)
+{
+ /*
+ Only the last SELECT can have INTO. Since the grammar won't allow INTO in
+ a nested SELECT, we make this check only when creating a top-level SELECT.
+ */
+ if (is_top_level && lex->result)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
+ return TRUE;
+ }
+ if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ return TRUE;
+ }
+ /* This counter shouldn't be incremented for UNION parts */
+ lex->nest_level--;
+ if (mysql_new_select(lex, 0))
+ return TRUE;
+ mysql_init_select(lex);
+ lex->current_select->linkage=UNION_TYPE;
+ if (is_union_distinct) /* UNION DISTINCT - remember position */
+ lex->current_select->master_unit()->union_distinct=
+ lex->current_select;
+ return FALSE;
+}
+
+/**
+ @brief Initializes a SELECT_LEX for a query within parentheses (aka
+ braces).
+
+ @return false if successful, true if an error was reported. In the latter
+ case parsing should stop.
+ */
+bool setup_select_in_parentheses(LEX *lex)
+{
+ SELECT_LEX * sel= lex->current_select;
+ if (sel->set_braces(1))
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ return TRUE;
+ }
+ if (sel->linkage == UNION_TYPE &&
+ !sel->master_unit()->first_select()->braces &&
+ sel->master_unit()->first_select()->linkage ==
+ UNION_TYPE)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ return TRUE;
+ }
+ if (sel->linkage == UNION_TYPE &&
+ sel->olap != UNSPECIFIED_OLAP_TYPE &&
+ sel->master_unit()->fake_select_lex)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
+ return TRUE;
+ }
+ /* select in braces, can't contain global parameters */
+ if (sel->master_unit()->fake_select_lex)
+ sel->master_unit()->global_parameters=
+ sel->master_unit()->fake_select_lex;
+ return FALSE;
+}
+
%}
%union {
int num;
@@ -519,10 +603,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
%pure_parser /* We have threads */
/*
- Currently there are 168 shift/reduce conflicts.
+ Currently there are 174 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 168
+%expect 174
/*
Comments for TOKENS.
@@ -1235,6 +1319,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
join_table_list join_table
table_factor table_ref esc_table_ref
select_derived derived_table_list
+ select_derived_union
%type <date_time_type> date_time_type;
%type <interval> interval
@@ -1270,8 +1355,9 @@ bool my_yyoverflow(short **a, YYSTYPE **
%type <variable> internal_variable_name
-%type <select_lex> subselect take_first_select
- get_select_lex
+%type <select_lex> subselect
+ get_select_lex query_specification
+ query_expression_body
%type <boolfunc2creator> comp_op
@@ -6807,37 +6893,22 @@ select_init:
select_paren:
SELECT_SYM select_part2
{
- LEX *lex= Lex;
- SELECT_LEX * sel= lex->current_select;
- if (sel->set_braces(1))
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
- MYSQL_YYABORT;
- }
- if (sel->linkage == UNION_TYPE &&
- !sel->master_unit()->first_select()->braces &&
- sel->master_unit()->first_select()->linkage ==
- UNION_TYPE)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
+ if (setup_select_in_parentheses(Lex))
MYSQL_YYABORT;
- }
- if (sel->linkage == UNION_TYPE &&
- sel->olap != UNSPECIFIED_OLAP_TYPE &&
- sel->master_unit()->fake_select_lex)
- {
- my_error(ER_WRONG_USAGE, MYF(0),
- "CUBE/ROLLUP", "ORDER BY");
- MYSQL_YYABORT;
- }
- /* select in braces, can't contain global parameters */
- if (sel->master_unit()->fake_select_lex)
- sel->master_unit()->global_parameters=
- sel->master_unit()->fake_select_lex;
}
| '(' select_paren ')'
;
+/* The equivalent of select_paren for nested queries. */
+select_paren_derived:
+ SELECT_SYM select_part2_derived
+ {
+ if (setup_select_in_parentheses(Lex))
+ MYSQL_YYABORT;
+ }
+ | '(' select_paren_derived ')'
+ ;
+
select_init2:
select_part2
{
@@ -8676,6 +8747,7 @@ when_list:
}
;
+/* Equivalent to <table reference> in the SQL:2003 standard. */
/* Warning - may return NULL in case of incomplete SELECT */
table_ref:
table_factor { $$=$1; }
@@ -8703,6 +8775,7 @@ esc_table_ref:
| '{' ident table_ref '}' { $$=$3; }
;
+/* Equivalent to <table reference list> in the SQL:2003 standard. */
/* Warning - may return NULL in case of incomplete SELECT */
derived_table_list:
esc_table_ref { $$=$1; }
@@ -8856,6 +8929,13 @@ normal_join:
| CROSS JOIN_SYM {}
;
+/*
+ This is a flattening of the rules <table factor> and <table primary>
+ in the SQL:2003 standard, since we don't have <sample clause>
+
+ I.e.
+ <table factor> ::= <table primary> [ <sample clause> ]
+*/
/* Warning - may return NULL in case of incomplete SELECT */
table_factor:
{
@@ -8893,12 +8973,29 @@ table_factor:
/* incomplete derived tables return NULL, we must be
nested in select_derived rule to be here. */
}
- | '(' get_select_lex select_derived union_opt ')' opt_table_alias
+ /*
+ Represents a flattening of the following rules from the SQL:2003
+ standard. This sub-rule corresponds to the sub-rule
+ <table primary> ::= ... | <derived table> [ AS ] <correlation name>
+
+ The following rules have been flattened into query_expression_body
+ (since we have no <with clause>).
+
+ <derived table> ::= <table subquery>
+ <table subquery> ::= <subquery>
+ <subquery> ::= <left paren> <query expression> <right paren>
+ <query expression> ::= [ <with clause> ] <query expression body>
+
+ For the time being we use the non-standard rule
+ select_derived_union which is a compromise between the standard
+ and our parser. Possibly this rule could be replaced by our
+ query_expression_body.
+ */
+ | '(' get_select_lex select_derived_union ')' opt_table_alias
{
/* Use $2 instead of Lex->current_select as derived table will
alter value of Lex->current_select. */
-
- if (!($3 || $6) && $2->embedding &&
+ if (!($3 || $5) && $2->embedding &&
!$2->embedding->nested_join->join_list.elements)
{
/* we have a derived table ($3 == NULL) but no alias,
@@ -8920,7 +9017,7 @@ table_factor:
if (ti == NULL)
MYSQL_YYABORT;
if (!($$= sel->add_table_to_list(lex->thd,
- ti, $6, 0,
+ new Table_ident(unit), $5, 0,
TL_READ)))
MYSQL_YYABORT;
@@ -8928,7 +9025,8 @@ table_factor:
lex->pop_context();
lex->nest_level--;
}
- else if ($4 || $6)
+ else if ($3->select_lex &&
+ $3->select_lex->master_unit()->is_union() || $5)
{
/* simple nested joins cannot have aliases or unions */
my_parse_error(ER(ER_SYNTAX_ERROR));
@@ -8943,6 +9041,62 @@ table_factor:
}
;
+select_derived_union:
+ select_derived opt_order_clause opt_limit_clause
+ | select_derived_union
+ UNION_SYM
+ union_option
+ {
+ if (add_select_to_union_list(Lex, (bool)$3, FALSE))
+ MYSQL_YYABORT;
+ }
+ query_specification
+ {
+ /*
+ Remove from the name resolution context stack the context of the
+ last select in the union.
+ */
+ Lex->pop_context();
+ }
+ opt_order_clause opt_limit_clause
+ ;
+
+/* The equivalent of select_init2 for nested queries. */
+select_init2_derived:
+ select_part2_derived
+ {
+ LEX *lex= Lex;
+ SELECT_LEX * sel= lex->current_select;
+ if (lex->current_select->set_braces(0))
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ MYSQL_YYABORT;
+ }
+ if (sel->linkage == UNION_TYPE &&
+ sel->master_unit()->first_select()->braces)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ MYSQL_YYABORT;
+ }
+ }
+ ;
+
+/* The equivalent of select_part2 for nested queries. */
+select_part2_derived:
+ {
+ LEX *lex= Lex;
+ SELECT_LEX *sel= lex->current_select;
+ if (sel->linkage != UNION_TYPE)
+ mysql_init_select(lex);
+ lex->current_select->parsing_place= SELECT_LIST;
+ }
+ select_options select_item_list
+ {
+ Select->parsing_place= NO_MATTER;
+ }
+ opt_select_from select_lock_type
+ ;
+
/* handle contents of parentheses in join expression */
select_derived:
get_select_lex
@@ -9557,8 +9711,7 @@ procedure_item:
select_var_list_init:
{
LEX *lex=Lex;
- if (!lex->describe &&
- (!(lex->result= new select_dumpvar(lex->nest_level))))
+ if (!lex->describe && (!(lex->result= new select_dumpvar())))
MYSQL_YYABORT;
}
select_var_list
@@ -9639,7 +9792,7 @@ into_destination:
LEX *lex= Lex;
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($2.str, 0)) ||
- !(lex->result= new select_export(lex->exchange, lex->nest_level)))
+ !(lex->result= new select_export(lex->exchange)))
MYSQL_YYABORT;
}
opt_load_data_charset
@@ -9653,7 +9806,7 @@ into_destination:
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($2.str,1)))
MYSQL_YYABORT;
- if (!(lex->result= new select_dump(lex->exchange, lex->nest_level)))
+ if (!(lex->result= new select_dump(lex->exchange)))
MYSQL_YYABORT;
}
}
@@ -13272,33 +13425,8 @@ union_clause:
union_list:
UNION_SYM union_option
{
- LEX *lex=Lex;
- if (lex->result &&
- (lex->result->get_nest_level() == -1 ||
- lex->result->get_nest_level() == lex->nest_level))
- {
- /*
- Only the last SELECT can have INTO unless the INTO and UNION
- are at different nest levels. In version 5.1 and above, INTO
- will onle be allowed at top level.
- */
- my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
- MYSQL_YYABORT;
- }
- if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
+ if (add_select_to_union_list(Lex, (bool)$2, TRUE))
MYSQL_YYABORT;
- }
- /* This counter shouldn't be incremented for UNION parts */
- Lex->nest_level--;
- if (mysql_new_select(lex, 0))
- MYSQL_YYABORT;
- mysql_init_select(lex);
- lex->current_select->linkage=UNION_TYPE;
- if ($2) /* UNION DISTINCT - remember position */
- lex->current_select->master_unit()->union_distinct=
- lex->current_select;
}
select_init
{
@@ -13351,22 +13479,39 @@ union_option:
| ALL { $$=0; }
;
-take_first_select: /* empty */
- {
- $$= Lex->current_select->master_unit()->first_select();
- };
+query_specification:
+ SELECT_SYM select_init2_derived
+ {
+ $$= Lex->current_select->master_unit()->first_select();
+ }
+ | '(' select_paren_derived ')'
+ {
+ $$= Lex->current_select->master_unit()->first_select();
+ }
+ ;
+
+query_expression_body:
+ query_specification
+ | query_expression_body
+ UNION_SYM union_option
+ {
+ if (add_select_to_union_list(Lex, (bool)$3, FALSE))
+ MYSQL_YYABORT;
+ }
+ query_specification
+ {
+ Lex->pop_context();
+ $$= $1;
+ }
+ ;
+/* Corresponds to <query expression> in the SQL:2003 standard. */
subselect:
- SELECT_SYM subselect_start select_init2 take_first_select
- subselect_end
- {
- $$= $4;
- }
- | '(' subselect_start select_paren take_first_select
- subselect_end ')'
- {
- $$= $4;
- };
+ subselect_start query_expression_body subselect_end
+ {
+ $$= $2;
+ }
+ ;
subselect_start:
{
Attachment: [text/bzr-bundle] bzr/martin.hansson@sun.com-20091120122943-otifi96r4sqkabfb.bundle
Thread |
---|
• bzr push into mysql-5.6-next-mr-bugfixing branch (martin.hansson:2946)Bug#33204 | Martin Hansson | 20 Nov |