summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2011-06-20 00:21:41 +0500
committerAlexey Botchkov <holyfoot@askmonty.org>2011-06-20 00:21:41 +0500
commitb826c888417e258dc0da6b6c0d011960db38f4b9 (patch)
tree4ab265b3c9f0db0fbc7cde2ebdd8073a10278f5f
parent9d51588e9560e963fa6087513098c940b70b2e3d (diff)
parent4058115cf74d00fcf0e432b23981c6393d5abbc5 (diff)
downloadmariadb-git-b826c888417e258dc0da6b6c0d011960db38f4b9.tar.gz
gis-related tests fixes.
merging.
-rw-r--r--.bzr-mysql/default.conf8
-rw-r--r--.bzrignore26
-rwxr-xr-xCMakeLists.txt12
-rwxr-xr-xclient/CMakeLists.txt19
-rw-r--r--client/Makefile.am5
-rw-r--r--client/client_priv.h1
-rw-r--r--client/my_readline.h4
-rw-r--r--client/mysql.cc16
-rw-r--r--client/mysqladmin.cc3
-rw-r--r--client/mysqlbinlog.cc54
-rw-r--r--client/mysqldump.c23
-rw-r--r--client/mysqlslap.c30
-rw-r--r--client/mysqltest.cc105
-rw-r--r--client/readline.cc43
-rw-r--r--client/sql_string.cc6
-rw-r--r--client/sql_string.h2
-rw-r--r--cmd-line-utils/libedit/vi.c17
-rw-r--r--configure.in9
-rwxr-xr-xextra/CMakeLists.txt16
-rw-r--r--extra/comp_err.c85
-rw-r--r--extra/perror.c31
-rw-r--r--extra/yassl/src/yassl_int.cpp2
-rw-r--r--include/Makefile.am7
-rw-r--r--include/config-win.h12
-rw-r--r--include/decimal.h12
-rw-r--r--include/ft_global.h2
-rw-r--r--include/heap.h2
-rw-r--r--include/m_ctype.h3
-rw-r--r--include/ma_dyncol.h147
-rw-r--r--include/maria.h1
-rw-r--r--include/my_base.h3
-rw-r--r--include/my_bit.h25
-rw-r--r--include/my_bitmap.h10
-rw-r--r--include/my_compare.h121
-rw-r--r--include/my_decimal_limits.h31
-rw-r--r--include/my_global.h6
-rw-r--r--include/my_handler.h107
-rw-r--r--include/my_pthread.h41
-rw-r--r--include/my_sys.h22
-rw-r--r--include/my_time.h76
-rw-r--r--include/myisam.h1
-rw-r--r--include/mysql.h.pp3
-rw-r--r--include/mysql_com.h3
-rwxr-xr-xlibmysql/CMakeLists.txt14
-rw-r--r--libmysql/Makefile.shared6
-rw-r--r--libmysql/libmysql.c9
-rw-r--r--libmysqld/CMakeLists.txt3
-rw-r--r--libmysqld/Makefile.am2
-rw-r--r--libmysqld/lib_sql.cc2
-rw-r--r--libmysqld/libmysqld.def1
-rw-r--r--mysql-test/Makefile.am11
-rw-r--r--mysql-test/collections/README.experimental6
-rw-r--r--mysql-test/collections/default.experimental7
-rwxr-xr-xmysql-test/collections/default.weekly1
-rw-r--r--mysql-test/collections/mysql-5.1-bugteam.daily5
-rw-r--r--mysql-test/collections/mysql-5.1-bugteam.push4
-rw-r--r--mysql-test/collections/mysql-next-mr-wl2540.push6
-rw-r--r--mysql-test/collections/mysql-trunk.daily7
-rw-r--r--mysql-test/collections/mysql-trunk.weekly2
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test12
-rw-r--r--mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_conflicts.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_extra_col_master.test10
-rw-r--r--mysql-test/extra/rpl_tests/rpl_extra_col_slave.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_flsh_tbls.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_duplicate.test64
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_ignore.test80
-rw-r--r--mysql-test/extra/rpl_tests/rpl_loaddata.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_record_compare.test20
-rw-r--r--mysql-test/extra/rpl_tests/rpl_reset_slave.test3
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_basic.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_tabledefs.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test1
-rw-r--r--mysql-test/include/binlog_start_pos.inc10
-rw-r--r--mysql-test/include/check_shared_row_lock.inc3
-rw-r--r--mysql-test/include/commit.inc8
-rw-r--r--mysql-test/include/gis_keys.inc16
-rw-r--r--mysql-test/include/have_binlog_checksum_off.inc4
-rw-r--r--mysql-test/include/have_dbi_dbd-mysql.inc78
-rw-r--r--mysql-test/include/mix1.inc4
-rw-r--r--mysql-test/include/mtr_warnings.sql43
-rw-r--r--mysql-test/include/mysqlhotcopy.inc18
-rw-r--r--mysql-test/include/not_crashrep.inc24
-rw-r--r--mysql-test/include/ps_conv.inc49
-rw-r--r--mysql-test/include/restart_slave_sql.inc43
-rw-r--r--mysql-test/include/rpl_connection_master.inc2
-rw-r--r--mysql-test/include/rpl_connection_slave.inc2
-rw-r--r--mysql-test/include/rpl_connection_slave1.inc2
-rw-r--r--mysql-test/include/rpl_sync.inc2
-rw-r--r--mysql-test/include/show_binlog_events2.inc2
-rw-r--r--mysql-test/include/subselect_mat_cost.inc152
-rw-r--r--mysql-test/include/type_hrtime.inc128
-rw-r--r--mysql-test/lib/My/ConfigFactory.pm16
-rw-r--r--mysql-test/lib/My/CoreDump.pm2
-rw-r--r--mysql-test/lib/My/File/Path.pm15
-rw-r--r--mysql-test/lib/My/Find.pm6
-rw-r--r--mysql-test/lib/My/Options.pm2
-rw-r--r--mysql-test/lib/My/Platform.pm2
-rw-r--r--mysql-test/lib/My/SafeProcess.pm36
-rw-r--r--mysql-test/lib/My/SafeProcess/Base.pm2
-rw-r--r--mysql-test/lib/My/SafeProcess/CMakeLists.txt1
-rw-r--r--mysql-test/lib/My/SafeProcess/Makefile.am2
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_kill_win.cc2
-rw-r--r--mysql-test/lib/My/SafeProcess/safe_process.cc2
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_process_win.cc2
-rw-r--r--mysql-test/lib/My/SysInfo.pm2
-rw-r--r--mysql-test/lib/My/Test.pm14
-rw-r--r--mysql-test/lib/mtr_gcov.pl2
-rw-r--r--mysql-test/lib/mtr_gprof.pl2
-rw-r--r--mysql-test/lib/mtr_io.pl2
-rw-r--r--mysql-test/lib/mtr_match.pm2
-rw-r--r--mysql-test/lib/mtr_misc.pl20
-rw-r--r--mysql-test/lib/mtr_report.pm12
-rw-r--r--mysql-test/lib/mtr_stress.pl2
-rw-r--r--mysql-test/lib/mtr_unique.pm2
-rwxr-xr-xmysql-test/lib/v1/mysql-test-run.pl2
-rwxr-xr-xmysql-test/mysql-stress-test.pl1
-rwxr-xr-xmysql-test/mysql-test-run.pl99
-rw-r--r--mysql-test/r/analyse.result26
-rw-r--r--mysql-test/r/archive_gis.result20
-rw-r--r--mysql-test/r/bigint.result4
-rw-r--r--mysql-test/r/cast.result295
-rw-r--r--mysql-test/r/client_xml.result6
-rw-r--r--mysql-test/r/commit_1innodb.result8
-rw-r--r--mysql-test/r/create.result19
-rw-r--r--mysql-test/r/csv_not_null.result3
-rw-r--r--mysql-test/r/ctype_cp1250_ch.result3
-rw-r--r--mysql-test/r/ctype_cp1251.result2
-rw-r--r--mysql-test/r/ctype_cp932_binlog_stm.result3
-rw-r--r--mysql-test/r/ctype_eucjpms.result2
-rw-r--r--mysql-test/r/ctype_many.result15
-rw-r--r--mysql-test/r/ctype_sjis.result6
-rw-r--r--mysql-test/r/ctype_ucs.result15
-rw-r--r--mysql-test/r/date_formats.result22
-rw-r--r--mysql-test/r/ddl_i18n_koi8r.result48
-rw-r--r--mysql-test/r/ddl_i18n_utf8.result48
-rw-r--r--mysql-test/r/derived.result63
-rw-r--r--mysql-test/r/derived_view.result591
-rw-r--r--mysql-test/r/distinct.result50
-rw-r--r--mysql-test/r/dyncol.result1337
-rw-r--r--mysql-test/r/errors.result2
-rw-r--r--mysql-test/r/events_1.result2
-rw-r--r--mysql-test/r/events_bugs.result9
-rw-r--r--mysql-test/r/explain.result52
-rw-r--r--mysql-test/r/func_compress.result2
-rw-r--r--mysql-test/r/func_default.result2
-rw-r--r--mysql-test/r/func_encrypt_ucs2.result19
-rw-r--r--mysql-test/r/func_gconcat.result10
-rw-r--r--mysql-test/r/func_group.result89
-rw-r--r--mysql-test/r/func_if.result13
-rw-r--r--mysql-test/r/func_in.result14
-rw-r--r--mysql-test/r/func_like.result5
-rw-r--r--mysql-test/r/func_math.result59
-rw-r--r--mysql-test/r/func_sapdb.result24
-rw-r--r--mysql-test/r/func_str.result276
-rw-r--r--mysql-test/r/func_test.result2
-rw-r--r--mysql-test/r/func_time.result384
-rw-r--r--mysql-test/r/func_time_hires.result208
-rw-r--r--mysql-test/r/func_timestamp.result4
-rw-r--r--mysql-test/r/gis-rtree.result3
-rw-r--r--mysql-test/r/gis.result61
-rw-r--r--mysql-test/r/grant.result197
-rw-r--r--mysql-test/r/grant_cache_no_prot.result4
-rw-r--r--mysql-test/r/grant_cache_ps_prot.result4
-rw-r--r--mysql-test/r/group_by.result39
-rw-r--r--mysql-test/r/group_min_max.result156
-rw-r--r--mysql-test/r/having.result26
-rw-r--r--mysql-test/r/index_intersect.result2
-rw-r--r--mysql-test/r/index_intersect_innodb.result2
-rw-r--r--mysql-test/r/index_merge_innodb.result6
-rw-r--r--mysql-test/r/index_merge_myisam.result5
-rw-r--r--mysql-test/r/information_schema.result11
-rw-r--r--mysql-test/r/innodb_mrr.result6
-rw-r--r--mysql-test/r/join.result2
-rw-r--r--mysql-test/r/join_cache.result2
-rw-r--r--mysql-test/r/join_nested.result8
-rw-r--r--mysql-test/r/join_nested_jcl6.result18
-rw-r--r--mysql-test/r/join_outer.result2
-rw-r--r--mysql-test/r/join_outer_jcl6.result2
-rw-r--r--mysql-test/r/key.result2
-rw-r--r--mysql-test/r/loaddata.result22
-rw-r--r--mysql-test/r/lock.result10
-rw-r--r--mysql-test/r/lock_multi_bug38499.result4
-rw-r--r--mysql-test/r/lock_sync.result27
-rw-r--r--mysql-test/r/log_slow.result6
-rw-r--r--mysql-test/r/log_state.result2
-rw-r--r--mysql-test/r/log_tables.result60
-rw-r--r--mysql-test/r/lowercase_table2.result30
-rw-r--r--mysql-test/r/maria_mrr.result1
-rw-r--r--mysql-test/r/metadata.result10
-rw-r--r--mysql-test/r/multi_update.result7
-rw-r--r--mysql-test/r/myisam_mrr.result6
-rw-r--r--mysql-test/r/mysqladmin.result8
-rw-r--r--mysql-test/r/mysqlbinlog.result12
-rw-r--r--mysql-test/r/mysqlbinlog_row_big.result8
-rw-r--r--mysql-test/r/mysqldump-max.result8
-rw-r--r--mysql-test/r/mysqldump.result74
-rw-r--r--mysql-test/r/mysqlslap.result20
-rw-r--r--mysql-test/r/mysqltest.result50
-rw-r--r--mysql-test/r/not_embedded_server.result4
-rw-r--r--mysql-test/r/optimizer_switch.result36
-rw-r--r--mysql-test/r/order_by.result48
-rw-r--r--mysql-test/r/packet.result1
-rw-r--r--mysql-test/r/parser.result4
-rw-r--r--mysql-test/r/parser_precedence.result1
-rw-r--r--mysql-test/r/partition.result56
-rw-r--r--mysql-test/r/partition_error.result25
-rw-r--r--mysql-test/r/plugin.result6
-rw-r--r--mysql-test/r/ps.result18
-rw-r--r--mysql-test/r/ps_11bugs.result6
-rw-r--r--mysql-test/r/ps_2myisam.result412
-rw-r--r--mysql-test/r/ps_3innodb.result412
-rw-r--r--mysql-test/r/ps_4heap.result412
-rw-r--r--mysql-test/r/ps_5merge.result824
-rw-r--r--mysql-test/r/ps_ddl.result12
-rw-r--r--mysql-test/r/query_cache.result40
-rw-r--r--mysql-test/r/range.result126
-rw-r--r--mysql-test/r/select.result97
-rw-r--r--mysql-test/r/select_jcl6.result97
-rw-r--r--mysql-test/r/select_pkeycache.result97
-rw-r--r--mysql-test/r/shm.result2
-rw-r--r--mysql-test/r/show_check.result1
-rw-r--r--mysql-test/r/sp-destruct.result1
-rw-r--r--mysql-test/r/sp-vars.result4
-rw-r--r--mysql-test/r/sp.result7
-rw-r--r--mysql-test/r/ssl_cipher.result9
-rw-r--r--mysql-test/r/strict.result87
-rw-r--r--mysql-test/r/subselect.result173
-rw-r--r--mysql-test/r/subselect3.result151
-rw-r--r--mysql-test/r/subselect3_jcl6.result153
-rw-r--r--mysql-test/r/subselect4.result659
-rw-r--r--mysql-test/r/subselect_cache.result18
-rw-r--r--mysql-test/r/subselect_mat.result315
-rw-r--r--mysql-test/r/subselect_mat_cost.result3771
-rw-r--r--mysql-test/r/subselect_mat_cost_bugs.result297
-rw-r--r--mysql-test/r/subselect_no_mat.result161
-rw-r--r--mysql-test/r/subselect_no_opts.result153
-rw-r--r--mysql-test/r/subselect_no_semijoin.result201
-rw-r--r--mysql-test/r/subselect_partial_match.result5
-rw-r--r--mysql-test/r/subselect_sj.result148
-rw-r--r--mysql-test/r/subselect_sj2.result78
-rw-r--r--mysql-test/r/subselect_sj2_jcl6.result84
-rw-r--r--mysql-test/r/subselect_sj2_mat.result761
-rw-r--r--mysql-test/r/subselect_sj_jcl6.result148
-rw-r--r--mysql-test/r/subselect_sj_mat.result1360
-rw-r--r--mysql-test/r/subselect_sj_nonmerged.result118
-rw-r--r--mysql-test/r/sysdate_is_now.result2
-rw-r--r--mysql-test/r/system_mysql_db.result8
-rw-r--r--mysql-test/r/table_elim.result36
-rw-r--r--mysql-test/r/table_options.result46
-rw-r--r--mysql-test/r/timezone.result7
-rw-r--r--mysql-test/r/timezone4.result2
-rw-r--r--mysql-test/r/type_bit.result2
-rw-r--r--mysql-test/r/type_bit_innodb.result2
-rw-r--r--mysql-test/r/type_blob.result58
-rw-r--r--mysql-test/r/type_date.result27
-rw-r--r--mysql-test/r/type_datetime.result88
-rw-r--r--mysql-test/r/type_datetime_hires.result340
-rw-r--r--mysql-test/r/type_decimal.result2
-rw-r--r--mysql-test/r/type_float.result2
-rw-r--r--mysql-test/r/type_newdecimal.result30
-rw-r--r--mysql-test/r/type_time.result35
-rw-r--r--mysql-test/r/type_time_hires.result340
-rw-r--r--mysql-test/r/type_timestamp.result91
-rw-r--r--mysql-test/r/type_timestamp_hires.result280
-rw-r--r--mysql-test/r/type_year.result3
-rw-r--r--mysql-test/r/union.result28
-rw-r--r--mysql-test/r/upgrade.result6
-rw-r--r--mysql-test/r/varbinary.result2
-rw-r--r--mysql-test/r/variables-notembedded.result24
-rw-r--r--mysql-test/r/variables.result52
-rw-r--r--mysql-test/r/view.result63
-rw-r--r--mysql-test/r/warnings.result2
-rw-r--r--mysql-test/r/windows.result2
-rw-r--r--mysql-test/r/xml.result19
-rw-r--r--mysql-test/std_data/checkDBI_DBD-mysql.pl97
-rw-r--r--mysql-test/suite/binlog/r/binlog_base64_flag.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_bug23533.result15
-rw-r--r--mysql-test/suite/binlog/r/binlog_bug36391.result10
-rw-r--r--mysql-test/suite/binlog/r/binlog_checksum.result23
-rw-r--r--mysql-test/suite/binlog/r/binlog_killed.result16
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_binlog.result613
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_binlog.result513
-rw-r--r--mysql-test/suite/binlog/t/binlog_base64_flag.test2
-rw-r--r--mysql-test/suite/binlog/t/binlog_bug23533.test (renamed from mysql-test/suite/bugs/t/rpl_bug23533.test)30
-rw-r--r--mysql-test/suite/binlog/t/binlog_bug36391-master.opt (renamed from mysql-test/suite/bugs/t/rpl_bug36391-master.opt)0
-rw-r--r--mysql-test/suite/binlog/t/binlog_bug36391.test (renamed from mysql-test/suite/bugs/t/rpl_bug36391.test)23
-rw-r--r--mysql-test/suite/binlog/t/binlog_checksum.test37
-rw-r--r--mysql-test/suite/binlog/t/binlog_index.test2
-rw-r--r--mysql-test/suite/binlog/t/binlog_killed.test46
-rw-r--r--mysql-test/suite/bugs/combinations8
-rw-r--r--mysql-test/suite/bugs/data/rpl_bug12691.dat3
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug12691.result33
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug23533.result23
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug31582.result16
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug31583.result16
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug33029.result15
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug36391.result18
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug37426.result17
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug38205.result56
-rw-r--r--mysql-test/suite/bugs/t/rpl_bug12691.test49
-rw-r--r--mysql-test/suite/bugs/t/rpl_bug31582.test25
-rw-r--r--mysql-test/suite/bugs/t/rpl_bug31583.test25
-rw-r--r--mysql-test/suite/bugs/t/rpl_bug33029.test26
-rw-r--r--mysql-test/suite/bugs/t/rpl_bug38205.test166
-rw-r--r--mysql-test/suite/engines/funcs/r/ps_string_not_null.resultbin11681 -> 11681 bytes
-rw-r--r--mysql-test/suite/engines/funcs/t/ps_string_not_null.test2
-rw-r--r--mysql-test/suite/engines/iuds/r/insert_year.result4
-rw-r--r--mysql-test/suite/funcs_1/datadict/datadict_priv.inc6
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_func_view.result228
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_storedproc_06.result2
-rw-r--r--mysql-test/suite/funcs_1/r/is_cml_innodb.result22
-rw-r--r--mysql-test/suite/funcs_1/r/is_cml_memory.result14
-rw-r--r--mysql-test/suite/funcs_1/r/is_cml_myisam.result22
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns.result42
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_innodb.result654
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is.result974
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is_embedded.result748
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_memory.result624
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_myisam.result704
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result704
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_mysql.result440
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result430
-rw-r--r--mysql-test/suite/funcs_1/r/memory_func_view.result228
-rw-r--r--mysql-test/suite/funcs_1/r/memory_storedproc_06.result2
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_func_view.result228
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_storedproc_06.result2
-rw-r--r--mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result4
-rw-r--r--mysql-test/suite/funcs_1/r/storedproc.result10
-rw-r--r--mysql-test/suite/funcs_1/storedproc/storedproc_06.inc4
-rw-r--r--mysql-test/suite/funcs_1/views/views_master.inc1
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug30423.result95
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug54044.result1
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug60049.result9
-rw-r--r--mysql-test/suite/innodb/r/innodb_gis.result32
-rw-r--r--mysql-test/suite/innodb/r/innodb_lock_wait_timeout_1.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb_mysql.result17
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug30423.test211
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug53756.test3
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug54044.test7
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug56143.test5
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug60049-master.opt1
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug60049.test44
-rw-r--r--mysql-test/suite/innodb_plugin/r/binlog_consistent.result60
-rw-r--r--mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos.result2
-rw-r--r--mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos_no_optimize_thread.result2
-rw-r--r--mysql-test/suite/innodb_plugin/r/group_commit_no_optimize_thread.result2
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb.result6
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_bug30423.result95
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_bug54044.result1
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_bug59307.result28
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_bug60049.result9
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_gis.result32
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_lock_wait_timeout_1.result4
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb_mysql.result15
-rw-r--r--mysql-test/suite/innodb_plugin/t/group_commit_no_optimize_thread.test2
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb.test6
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug30423.test211
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug53756.test3
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug54044.test7
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug56143.test5
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug59307.test32
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug60049-master.opt1
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_bug60049.test43
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb_information_schema.test28
-rw-r--r--mysql-test/suite/maria/r/compat_aliases.result58
-rw-r--r--mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result209
-rw-r--r--mysql-test/suite/maria/r/maria-gis-rtree-trans.result209
-rw-r--r--mysql-test/suite/maria/r/maria-gis-rtree.result209
-rw-r--r--mysql-test/suite/maria/r/maria-recover.result2
-rw-r--r--mysql-test/suite/maria/r/maria3.result2
-rw-r--r--mysql-test/suite/maria/r/ps_maria.result412
-rw-r--r--mysql-test/suite/maria/t/compat_aliases-master.opt1
-rw-r--r--mysql-test/suite/maria/t/compat_aliases.test59
-rw-r--r--mysql-test/suite/maria/t/maria-recover.test4
-rw-r--r--mysql-test/suite/maria/t/maria3.test2
-rw-r--r--mysql-test/suite/ndb/r/ndb_basic.result2
-rw-r--r--mysql-test/suite/ndb/t/ndb_basic.test7
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1-innodb.result4
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1.result4
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/r/bug43618.result6
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1-innodb.test4
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1.test5
-rw-r--r--mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test2
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc4
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc5
-rw-r--r--mysql-test/suite/parts/inc/partition_check_drop.inc2
-rw-r--r--mysql-test/suite/parts/inc/partition_layout_check1.inc13
-rw-r--r--mysql-test/suite/parts/inc/partition_layout_check2.inc7
-rw-r--r--mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc4
-rw-r--r--mysql-test/suite/parts/r/part_supported_sql_func_innodb.result1055
-rw-r--r--mysql-test/suite/parts/r/part_supported_sql_func_myisam.result1055
-rw-r--r--mysql-test/suite/parts/r/partition_bit_innodb.result2
-rw-r--r--mysql-test/suite/parts/r/partition_bit_myisam.result2
-rw-r--r--mysql-test/suite/parts/r/partition_repair_myisam.result3
-rw-r--r--mysql-test/suite/parts/r/rpl_partition.result6
-rw-r--r--mysql-test/suite/parts/t/part_supported_sql_func_innodb.test4
-rw-r--r--mysql-test/suite/parts/t/partition_repair_myisam.test3
-rw-r--r--mysql-test/suite/parts/t/rpl_partition.test6
-rw-r--r--mysql-test/suite/pbxt/r/cast.result12
-rw-r--r--mysql-test/suite/pbxt/r/client_xml.result6
-rw-r--r--mysql-test/suite/pbxt/r/date_formats.result22
-rw-r--r--mysql-test/suite/pbxt/r/derived.result47
-rw-r--r--mysql-test/suite/pbxt/r/errors.result2
-rw-r--r--mysql-test/suite/pbxt/r/func_in.result6
-rw-r--r--mysql-test/suite/pbxt/r/func_sapdb.result20
-rw-r--r--mysql-test/suite/pbxt/r/func_str.result250
-rw-r--r--mysql-test/suite/pbxt/r/func_timestamp.result4
-rw-r--r--mysql-test/suite/pbxt/r/grant_cache.result4
-rw-r--r--mysql-test/suite/pbxt/r/group_min_max.result10
-rw-r--r--mysql-test/suite/pbxt/r/join.result6
-rw-r--r--mysql-test/suite/pbxt/r/join_nested.result4
-rw-r--r--mysql-test/suite/pbxt/r/metadata.result2
-rw-r--r--mysql-test/suite/pbxt/r/ps_11bugs.result6
-rw-r--r--mysql-test/suite/pbxt/r/range.result16
-rw-r--r--mysql-test/suite/pbxt/r/select.result8
-rw-r--r--mysql-test/suite/pbxt/r/subselect.result86
-rw-r--r--mysql-test/suite/pbxt/r/type_bit.result2
-rw-r--r--mysql-test/suite/pbxt/r/type_datetime.result32
-rw-r--r--mysql-test/suite/pbxt/r/type_decimal.result2
-rw-r--r--mysql-test/suite/pbxt/r/type_float.result2
-rw-r--r--mysql-test/suite/pbxt/r/type_newdecimal.result22
-rw-r--r--mysql-test/suite/pbxt/r/type_time.result12
-rw-r--r--mysql-test/suite/pbxt/r/type_timestamp.result28
-rw-r--r--mysql-test/suite/pbxt/r/union.result24
-rw-r--r--mysql-test/suite/pbxt/r/view_grant.result6
-rw-r--r--mysql-test/suite/pbxt/t/grant_cache.test13
-rw-r--r--mysql-test/suite/pbxt/t/join.test2
-rw-r--r--mysql-test/suite/pbxt/t/mysqlshow.test1
-rw-r--r--mysql-test/suite/pbxt/t/range.test3
-rw-r--r--mysql-test/suite/pbxt/t/subselect.test8
-rw-r--r--mysql-test/suite/pbxt/t/type_timestamp.test13
-rw-r--r--mysql-test/suite/pbxt/t/union.test9
-rw-r--r--mysql-test/suite/percona/disabled.def1
-rw-r--r--mysql-test/suite/percona/innodb_fix_misc_bug51325.result13
-rw-r--r--mysql-test/suite/percona/innodb_fix_misc_bug51325.test13
-rw-r--r--mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.result12
-rw-r--r--mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.test3
-rw-r--r--mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_innodb_stats.result10
-rw-r--r--mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.result13
-rw-r--r--mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.test3
-rw-r--r--mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.result17
-rw-r--r--mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.test3
-rw-r--r--mysql-test/suite/percona/userstat_bug602047.result16
-rw-r--r--mysql-test/suite/percona/userstat_bug602047.test13
-rw-r--r--mysql-test/suite/rpl/extension/README.checksum23
-rw-r--r--mysql-test/suite/rpl/extension/checksum.pl164
-rw-r--r--mysql-test/suite/rpl/include/hrtime.inc27
-rw-r--r--mysql-test/suite/rpl/r/rpl_binlog_corruption.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_bug33931.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_bug37426.result12
-rw-r--r--mysql-test/suite/rpl/r/rpl_change_master.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_checksum.result135
-rw-r--r--mysql-test/suite/rpl/r/rpl_checksum_cache.result119
-rw-r--r--mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result5
-rw-r--r--mysql-test/suite/rpl/r/rpl_corruption.result51
-rw-r--r--mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_filter_tables_not_exist.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_hrtime.result67
-rw-r--r--mysql-test/suite/rpl/r/rpl_hrtime_row.result28
-rw-r--r--mysql-test/suite/rpl/r/rpl_idempotency.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_ignore_table.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_incident.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_init_slave_errors.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_innodb_bug28430.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_insert_duplicate.result29
-rw-r--r--mysql-test/suite/rpl/r/rpl_insert_ignore.result62
-rw-r--r--mysql-test/suite/rpl/r/rpl_known_bugs_detection.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_loaddata.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_loaddata_concurrent.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_loaddata_fatal.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_packet.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_rewrt_db.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_rotate_logs.result5
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_colSize.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_conflicts.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result20
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_skip_error.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_grp_exec.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_EE_err2.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_conflicts.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stop_slave.result44
-rw-r--r--mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_temporary_errors.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_variables_stm.result4
-rw-r--r--mysql-test/suite/rpl/t/disabled.def3
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_corruption.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug33931.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug37426.test (renamed from mysql-test/suite/bugs/t/rpl_bug37426.test)11
-rw-r--r--mysql-test/suite/rpl/t/rpl_change_master.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_checksum-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_checksum.test264
-rw-r--r--mysql-test/suite/rpl/t/rpl_checksum_cache.test255
-rw-r--r--mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test5
-rw-r--r--mysql-test/suite/rpl/t/rpl_corruption-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_corruption-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_corruption.test165
-rw-r--r--mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_hrtime.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_hrtime_row.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_idempotency.test5
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_table.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_incident.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_init_slave_errors.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_innodb_bug28430.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_duplicate.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_ignore.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_known_bugs_detection.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_fatal.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_packet.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_colSize.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_error.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_grp_exec.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_stop_slave.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_stop_slave.test67
-rw-r--r--mysql-test/suite/rpl/t/rpl_temporary_errors.test3
-rw-r--r--mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test2
-rw-r--r--mysql-test/suite/sys_vars/r/binlog_checksum_basic.result14
-rw-r--r--mysql-test/suite/sys_vars/r/general_log_file_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_max_dirty_pages_pct_func.result8
-rw-r--r--mysql-test/suite/sys_vars/r/log_output_func.result2
-rw-r--r--mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result11
-rw-r--r--mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result11
-rw-r--r--mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/t/binlog_checksum_basic.test25
-rw-r--r--mysql-test/suite/sys_vars/t/div_precision_increment_func.test2
-rw-r--r--mysql-test/suite/sys_vars/t/general_log_file_basic.test1
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test9
-rw-r--r--mysql-test/suite/sys_vars/t/log_output_func.test1
-rw-r--r--mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test19
-rw-r--r--mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test18
-rw-r--r--mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test1
-rw-r--r--mysql-test/suite/vcol/inc/vcol_keys.inc4
-rw-r--r--mysql-test/suite/vcol/inc/vcol_view.inc4
-rw-r--r--mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result2
-rw-r--r--mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result2
-rw-r--r--mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result20
-rw-r--r--mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result20
-rw-r--r--mysql-test/suite/vcol/r/vcol_keys_innodb.result8
-rw-r--r--mysql-test/suite/vcol/r/vcol_keys_myisam.result12
-rw-r--r--mysql-test/suite/vcol/r/vcol_misc.result94
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_innodb.result3
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_myisam.result7
-rw-r--r--mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result12
-rw-r--r--mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result12
-rw-r--r--mysql-test/suite/vcol/r/vcol_view_innodb.result12
-rw-r--r--mysql-test/suite/vcol/r/vcol_view_myisam.result12
-rw-r--r--mysql-test/suite/vcol/t/vcol_misc.test46
-rw-r--r--mysql-test/t/analyse.test24
-rw-r--r--mysql-test/t/cast.test127
-rw-r--r--mysql-test/t/crash_commit_before.test2
-rw-r--r--mysql-test/t/create.test25
-rw-r--r--mysql-test/t/csv_not_null.test6
-rw-r--r--mysql-test/t/ctype_cp1250_ch.test10
-rw-r--r--mysql-test/t/ctype_cp1251.test10
-rw-r--r--mysql-test/t/ctype_cp932_binlog_stm.test10
-rw-r--r--mysql-test/t/ctype_eucjpms.test8
-rw-r--r--mysql-test/t/ctype_many.test16
-rw-r--r--mysql-test/t/ctype_sjis.test8
-rw-r--r--mysql-test/t/ctype_ucs.test6
-rw-r--r--mysql-test/t/date_formats.test6
-rw-r--r--mysql-test/t/derived.test16
-rw-r--r--mysql-test/t/derived_view.test237
-rw-r--r--mysql-test/t/disabled.def7
-rw-r--r--mysql-test/t/distinct.test38
-rw-r--r--mysql-test/t/dyncol.test548
-rw-r--r--mysql-test/t/events_bugs.test15
-rw-r--r--mysql-test/t/explain.test21
-rw-r--r--mysql-test/t/func_encrypt_ucs2.test12
-rw-r--r--mysql-test/t/func_group.test34
-rw-r--r--mysql-test/t/func_if.test3
-rw-r--r--mysql-test/t/func_in.test6
-rw-r--r--mysql-test/t/func_like.test5
-rw-r--r--mysql-test/t/func_math.test25
-rw-r--r--mysql-test/t/func_sapdb.test4
-rw-r--r--mysql-test/t/func_str.test11
-rw-r--r--mysql-test/t/func_time.test214
-rw-r--r--mysql-test/t/func_time_hires.test108
-rw-r--r--mysql-test/t/gis.test24
-rw-r--r--mysql-test/t/grant.test177
-rw-r--r--mysql-test/t/group_by.test37
-rw-r--r--mysql-test/t/group_min_max.test50
-rw-r--r--mysql-test/t/having.test26
-rw-r--r--mysql-test/t/index_intersect.test3
-rw-r--r--mysql-test/t/innodb_mrr.test6
-rw-r--r--mysql-test/t/loaddata.test28
-rw-r--r--mysql-test/t/lock.test25
-rw-r--r--mysql-test/t/lock_multi_bug38499.test12
-rw-r--r--mysql-test/t/lock_sync.test54
-rw-r--r--mysql-test/t/log_tables.test20
-rw-r--r--mysql-test/t/lowercase_table2.test37
-rw-r--r--mysql-test/t/maria_mrr.test1
-rw-r--r--mysql-test/t/metadata.test8
-rw-r--r--mysql-test/t/multi_update.test3
-rw-r--r--mysql-test/t/myisam_crash_before_flush_keys.test3
-rw-r--r--mysql-test/t/mysql.test6
-rw-r--r--mysql-test/t/mysqladmin.test12
-rw-r--r--mysql-test/t/mysqlbinlog.test20
-rw-r--r--mysql-test/t/mysqlbinlog_row_big.test4
-rw-r--r--mysql-test/t/mysqldump.test36
-rw-r--r--mysql-test/t/mysqlslap.test15
-rw-r--r--mysql-test/t/mysqltest.test6
-rw-r--r--mysql-test/t/not_embedded_server.test10
-rw-r--r--mysql-test/t/order_by.test34
-rw-r--r--mysql-test/t/parser_precedence.test2
-rw-r--r--mysql-test/t/partition.test62
-rw-r--r--mysql-test/t/partition_error.test16
-rw-r--r--mysql-test/t/ps.test12
-rw-r--r--mysql-test/t/query_cache.test21
-rw-r--r--mysql-test/t/range.test76
-rw-r--r--mysql-test/t/select.test29
-rw-r--r--mysql-test/t/show_check.test1
-rw-r--r--mysql-test/t/sp-destruct.test1
-rw-r--r--mysql-test/t/sp.test16
-rw-r--r--mysql-test/t/ssl_cipher-master.opt1
-rw-r--r--mysql-test/t/ssl_cipher.test23
-rw-r--r--mysql-test/t/strict.test2
-rw-r--r--mysql-test/t/subselect.test79
-rw-r--r--mysql-test/t/subselect3.test3
-rw-r--r--mysql-test/t/subselect4.test478
-rw-r--r--mysql-test/t/subselect_mat.test952
-rw-r--r--mysql-test/t/subselect_mat_cost.test204
-rw-r--r--mysql-test/t/subselect_mat_cost_bugs.test328
-rw-r--r--mysql-test/t/subselect_no_opts.test4
-rw-r--r--mysql-test/t/subselect_sj.test98
-rw-r--r--mysql-test/t/subselect_sj2.test37
-rw-r--r--mysql-test/t/subselect_sj2_mat.test9
-rw-r--r--mysql-test/t/subselect_sj_mat.test974
-rw-r--r--mysql-test/t/subselect_sj_nonmerged.test114
-rw-r--r--mysql-test/t/system_mysql_db_fix40123.test4
-rw-r--r--mysql-test/t/system_mysql_db_fix50030.test6
-rw-r--r--mysql-test/t/system_mysql_db_fix50117.test6
-rw-r--r--mysql-test/t/timezone.test2
-rw-r--r--mysql-test/t/type_blob.test12
-rw-r--r--mysql-test/t/type_date.test8
-rw-r--r--mysql-test/t/type_datetime.test25
-rw-r--r--mysql-test/t/type_datetime_hires.test71
-rw-r--r--mysql-test/t/type_time.test23
-rw-r--r--mysql-test/t/type_time_hires.test12
-rw-r--r--mysql-test/t/type_timestamp.test60
-rw-r--r--mysql-test/t/type_timestamp_hires.test16
-rw-r--r--mysql-test/t/type_year.test1
-rw-r--r--mysql-test/t/union.test8
-rw-r--r--mysql-test/t/upgrade.test4
-rw-r--r--mysql-test/t/variables-notembedded.test27
-rw-r--r--mysql-test/t/variables.test43
-rw-r--r--mysql-test/t/view.test61
-rw-r--r--mysql-test/t/xml.test10
-rw-r--r--mysql-test/valgrind.supp75
-rw-r--r--mysys/CMakeLists.txt6
-rw-r--r--mysys/Makefile.am9
-rw-r--r--mysys/charset.c3
-rw-r--r--mysys/ma_dyncol.c2112
-rw-r--r--mysys/mf_getdate.c2
-rw-r--r--mysys/my_bitmap.c458
-rw-r--r--mysys/my_compare.c (renamed from mysys/my_handler.c)35
-rw-r--r--mysys/my_gethostbyname.c113
-rw-r--r--mysys/my_getsystime.c228
-rw-r--r--mysys/my_handler_errors.h4
-rw-r--r--mysys/my_init.c50
-rw-r--r--mysys/my_net.c92
-rw-r--r--mysys/my_port.c4
-rw-r--r--mysys/my_static.c5
-rw-r--r--mysys/my_static.h2
-rw-r--r--mysys/my_uuid.c12
-rw-r--r--mysys/my_wincond.c37
-rw-r--r--mysys/string.c12
-rw-r--r--mysys/thr_lock.c112
-rw-r--r--mysys/waiting_threads.c34
-rw-r--r--plugin/fulltext/plugin_example.c8
-rw-r--r--plugin/handler_socket/AUTHORS3
-rw-r--r--plugin/handler_socket/client/Makefile.am16
-rw-r--r--plugin/handler_socket/client/hslongrun.cpp1041
-rw-r--r--plugin/handler_socket/client/hstest.cpp96
-rw-r--r--plugin/handler_socket/configure.ac14
-rw-r--r--plugin/handler_socket/docs-en/configuration-options.en.txt14
-rw-r--r--plugin/handler_socket/docs-en/protocol.en.txt70
-rw-r--r--plugin/handler_socket/handlersocket/database.cpp219
-rw-r--r--plugin/handler_socket/handlersocket/database.hpp24
-rw-r--r--plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp86
-rw-r--r--plugin/handler_socket/handlersocket/mysql_incl.hpp1
-rw-r--r--plugin/handler_socket/libhsclient/Makefile.am1
-rw-r--r--plugin/handler_socket/libhsclient/allocator.hpp27
-rw-r--r--plugin/handler_socket/libhsclient/auto_addrinfo.hpp3
-rw-r--r--plugin/handler_socket/libhsclient/escape.cpp14
-rw-r--r--plugin/handler_socket/libhsclient/escape.hpp1
-rw-r--r--plugin/handler_socket/libhsclient/hstcpcli.cpp94
-rw-r--r--plugin/handler_socket/libhsclient/hstcpcli.hpp5
-rw-r--r--plugin/handler_socket/libhsclient/string_buffer.hpp2
-rw-r--r--plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs89
-rw-r--r--plugin/handler_socket/perl-Net-HandlerSocket/MANIFEST2
-rw-r--r--plugin/handler_socket/regtest/common/hstest.pm4
-rwxr-xr-xplugin/handler_socket/regtest/test_01_lib/run.sh2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test13.expected40
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test13.pl8
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test14.expected144
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test14.pl80
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test15.expected764
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test15.pl114
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test16.expected66
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test16.pl88
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test17.expectedbin0 -> 4105 bytes
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test17.pl125
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test18.expected22
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test18.pl63
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test19.expected14894
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test19.pl190
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test20.expected2
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test20.pl33
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test21.expected11
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test21.pl58
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test22.expected9
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test22.pl61
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test23.expected101
-rw-r--r--plugin/handler_socket/regtest/test_01_lib/test23.pl53
-rw-r--r--regex/my_regex.h4
-rw-r--r--regex/regcomp.c15
-rw-r--r--regex/reginit.c6
-rw-r--r--scripts/mysql_system_tables.sql10
-rw-r--r--scripts/mysql_system_tables_fix.sql10
-rw-r--r--scripts/mysqlhotcopy.sh2
-rw-r--r--sql-bench/server-cfg.sh11
-rwxr-xr-xsql-bench/test-table-elimination.sh1
-rw-r--r--sql-common/my_time.c251
-rw-r--r--sql/create_options.cc3
-rw-r--r--sql/create_options.h2
-rw-r--r--sql/derror.cc86
-rw-r--r--sql/event_data_objects.cc10
-rw-r--r--sql/event_db_repository.cc21
-rw-r--r--sql/event_parse_data.cc14
-rw-r--r--sql/event_queue.cc21
-rw-r--r--sql/event_queue.h2
-rw-r--r--sql/event_scheduler.cc9
-rw-r--r--sql/field.cc2719
-rw-r--r--sql/field.h689
-rw-r--r--sql/field_conv.cc72
-rw-r--r--sql/filesort.cc84
-rw-r--r--sql/ha_partition.cc447
-rw-r--r--sql/ha_partition.h46
-rw-r--r--sql/handler.cc40
-rw-r--r--sql/handler.h47
-rw-r--r--sql/hostname.cc5
-rw-r--r--sql/item.cc749
-rw-r--r--sql/item.h287
-rw-r--r--sql/item_cmpfunc.cc1360
-rw-r--r--sql/item_cmpfunc.h85
-rw-r--r--sql/item_create.cc262
-rw-r--r--sql/item_create.h10
-rw-r--r--sql/item_func.cc408
-rw-r--r--sql/item_func.h62
-rw-r--r--sql/item_row.h1
-rw-r--r--sql/item_strfunc.cc893
-rw-r--r--sql/item_strfunc.h91
-rw-r--r--sql/item_subselect.cc1678
-rw-r--r--sql/item_subselect.h306
-rw-r--r--sql/item_sum.cc62
-rw-r--r--sql/item_sum.h1
-rw-r--r--sql/item_timefunc.cc1180
-rw-r--r--sql/item_timefunc.h518
-rw-r--r--sql/key.cc1
-rw-r--r--sql/lex.h6
-rw-r--r--sql/log.cc397
-rw-r--r--sql/log.h56
-rw-r--r--sql/log_event.cc706
-rw-r--r--sql/log_event.h143
-rw-r--r--sql/log_event_old.cc8
-rw-r--r--sql/multi_range_read.cc13
-rw-r--r--sql/my_decimal.cc123
-rw-r--r--sql/my_decimal.h66
-rw-r--r--sql/mysql_priv.h311
-rw-r--r--sql/mysql_upgrade_service.cc11
-rw-r--r--sql/mysqld.cc227
-rw-r--r--sql/opt_range.cc131
-rw-r--r--sql/opt_subselect.cc1472
-rw-r--r--sql/opt_subselect.h10
-rw-r--r--sql/opt_sum.cc62
-rw-r--r--sql/protocol.cc59
-rw-r--r--sql/protocol.h12
-rw-r--r--sql/records.cc3
-rw-r--r--sql/repl_failsafe.cc6
-rw-r--r--sql/rpl_mi.cc3
-rw-r--r--sql/rpl_mi.h6
-rw-r--r--sql/rpl_record.cc4
-rw-r--r--sql/rpl_rli.cc15
-rw-r--r--sql/rpl_utility.cc63
-rw-r--r--sql/set_var.cc183
-rw-r--r--sql/set_var.h19
-rw-r--r--sql/share/errmsg.txt54
-rw-r--r--sql/slave.cc336
-rw-r--r--sql/sp_head.cc17
-rw-r--r--sql/sp_rcontext.cc6
-rw-r--r--sql/sp_rcontext.h2
-rw-r--r--sql/sql_acl.cc144
-rw-r--r--sql/sql_analyse.cc6
-rw-r--r--sql/sql_base.cc298
-rw-r--r--sql/sql_binlog.cc3
-rw-r--r--sql/sql_bitmap.h15
-rw-r--r--sql/sql_cache.cc561
-rw-r--r--sql/sql_cache.h31
-rw-r--r--sql/sql_class.cc46
-rw-r--r--sql/sql_class.h166
-rw-r--r--sql/sql_connect.cc33
-rw-r--r--sql/sql_cursor.cc24
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_delete.cc72
-rw-r--r--sql/sql_derived.cc998
-rw-r--r--sql/sql_expression_cache.cc3
-rw-r--r--sql/sql_help.cc4
-rw-r--r--sql/sql_insert.cc108
-rw-r--r--sql/sql_join_cache.cc219
-rw-r--r--sql/sql_join_cache.h13
-rw-r--r--sql/sql_lex.cc640
-rw-r--r--sql/sql_lex.h71
-rw-r--r--sql/sql_list.h4
-rw-r--r--sql/sql_load.cc24
-rw-r--r--sql/sql_olap.cc3
-rw-r--r--sql/sql_parse.cc56
-rw-r--r--sql/sql_partition.cc25
-rw-r--r--sql/sql_plugin.cc7
-rw-r--r--sql/sql_prepare.cc124
-rw-r--r--sql/sql_profile.cc2
-rw-r--r--sql/sql_rename.cc16
-rw-r--r--sql/sql_repl.cc241
-rw-r--r--sql/sql_select.cc3726
-rw-r--r--sql/sql_select.h222
-rw-r--r--sql/sql_show.cc154
-rw-r--r--sql/sql_string.cc47
-rw-r--r--sql/sql_string.h32
-rw-r--r--sql/sql_table.cc124
-rw-r--r--sql/sql_test.cc89
-rw-r--r--sql/sql_union.cc163
-rw-r--r--sql/sql_update.cc100
-rw-r--r--sql/sql_view.cc74
-rw-r--r--sql/sql_yacc.yy297
-rw-r--r--sql/structs.h3
-rw-r--r--sql/table.cc609
-rw-r--r--sql/table.h183
-rw-r--r--sql/time.cc290
-rw-r--r--sql/tztime.cc96
-rw-r--r--sql/tztime.h6
-rw-r--r--sql/unireg.cc1
-rw-r--r--sql/unireg.h5
-rw-r--r--storage/archive/ha_archive.cc1
-rw-r--r--storage/example/ha_example.cc69
-rw-r--r--storage/heap/ha_heap.cc8
-rw-r--r--storage/heap/ha_heap.h2
-rw-r--r--storage/heap/hp_test2.c8
-rw-r--r--storage/innobase/btr/btr0cur.c156
-rw-r--r--storage/innobase/dict/dict0dict.c10
-rw-r--r--storage/innobase/handler/ha_innodb.cc211
-rw-r--r--storage/innobase/handler/ha_innodb.h4
-rw-r--r--storage/innobase/include/btr0cur.h5
-rw-r--r--storage/innobase/include/dict0mem.h6
-rw-r--r--storage/innobase/include/dict0types.h5
-rw-r--r--storage/innobase/include/rem0cmp.h4
-rw-r--r--storage/innobase/include/rem0cmp.ic2
-rw-r--r--storage/innobase/include/srv0srv.h18
-rw-r--r--storage/innobase/include/sync0arr.h11
-rw-r--r--storage/innobase/include/sync0rw.h3
-rw-r--r--storage/innobase/include/trx0rseg.h4
-rw-r--r--storage/innobase/include/trx0trx.h5
-rw-r--r--storage/innobase/rem/rem0cmp.c14
-rw-r--r--storage/innobase/row/row0vers.c10
-rw-r--r--storage/innobase/srv/srv0srv.c24
-rw-r--r--storage/innobase/sync/sync0arr.c40
-rw-r--r--storage/innobase/sync/sync0rw.c19
-rw-r--r--storage/innobase/trx/trx0trx.c26
-rw-r--r--storage/innodb_plugin/ChangeLog86
-rw-r--r--storage/innodb_plugin/btr/btr0btr.c573
-rw-r--r--storage/innodb_plugin/btr/btr0cur.c441
-rw-r--r--storage/innodb_plugin/btr/btr0sea.c6
-rw-r--r--storage/innodb_plugin/buf/buf0buddy.c2
-rw-r--r--storage/innodb_plugin/buf/buf0buf.c85
-rw-r--r--storage/innodb_plugin/buf/buf0lru.c131
-rw-r--r--storage/innodb_plugin/dict/dict0dict.c10
-rw-r--r--storage/innodb_plugin/dict/dict0mem.c9
-rw-r--r--storage/innodb_plugin/fsp/fsp0fsp.c8
-rw-r--r--storage/innodb_plugin/handler/ha_innodb.cc218
-rw-r--r--storage/innodb_plugin/handler/handler0alter.cc12
-rw-r--r--storage/innodb_plugin/handler/i_s.cc2
-rw-r--r--storage/innodb_plugin/ibuf/ibuf0ibuf.c8
-rw-r--r--storage/innodb_plugin/include/btr0btr.h85
-rw-r--r--storage/innodb_plugin/include/btr0cur.h47
-rw-r--r--storage/innodb_plugin/include/btr0types.h125
-rw-r--r--storage/innodb_plugin/include/buf0buf.h18
-rw-r--r--storage/innodb_plugin/include/buf0buf.ic8
-rw-r--r--storage/innodb_plugin/include/buf0lru.h14
-rw-r--r--storage/innodb_plugin/include/dict0mem.h13
-rw-r--r--storage/innodb_plugin/include/dict0types.h5
-rw-r--r--storage/innodb_plugin/include/page0zip.h2
-rw-r--r--storage/innodb_plugin/include/rem0cmp.h4
-rw-r--r--storage/innodb_plugin/include/rem0cmp.ic2
-rw-r--r--storage/innodb_plugin/include/row0upd.h26
-rw-r--r--storage/innodb_plugin/include/srv0srv.h18
-rw-r--r--storage/innodb_plugin/include/sync0arr.h7
-rw-r--r--storage/innodb_plugin/include/sync0rw.h3
-rw-r--r--storage/innodb_plugin/include/trx0rseg.h4
-rw-r--r--storage/innodb_plugin/include/trx0trx.h4
-rw-r--r--storage/innodb_plugin/include/univ.i13
-rw-r--r--storage/innodb_plugin/mem/mem0mem.c2
-rw-r--r--storage/innodb_plugin/mtr/mtr0log.c2
-rw-r--r--storage/innodb_plugin/page/page0cur.c10
-rw-r--r--storage/innodb_plugin/page/page0page.c11
-rw-r--r--storage/innodb_plugin/page/page0zip.c24
-rw-r--r--storage/innodb_plugin/rem/rem0cmp.c14
-rw-r--r--storage/innodb_plugin/row/row0ins.c2
-rw-r--r--storage/innodb_plugin/row/row0purge.c68
-rw-r--r--storage/innodb_plugin/row/row0umod.c35
-rw-r--r--storage/innodb_plugin/row/row0upd.c82
-rw-r--r--storage/innodb_plugin/row/row0vers.c10
-rw-r--r--storage/innodb_plugin/srv/srv0srv.c16
-rw-r--r--storage/innodb_plugin/srv/srv0start.c6
-rw-r--r--storage/innodb_plugin/sync/sync0arr.c36
-rw-r--r--storage/innodb_plugin/sync/sync0rw.c22
-rw-r--r--storage/innodb_plugin/trx/trx0i_s.c2
-rw-r--r--storage/innodb_plugin/trx/trx0roll.c4
-rw-r--r--storage/innodb_plugin/trx/trx0trx.c25
-rw-r--r--storage/maria/CMakeLists.txt2
-rw-r--r--storage/maria/Makefile.am4
-rw-r--r--storage/maria/compat_aliases.cc245
-rw-r--r--storage/maria/compat_aliases.h27
-rw-r--r--storage/maria/ha_maria.cc15
-rw-r--r--storage/maria/ha_maria.h2
-rw-r--r--storage/maria/lockman.c6
-rw-r--r--storage/maria/ma_check.c36
-rw-r--r--storage/maria/ma_create.c3
-rw-r--r--storage/maria/ma_init.c1
-rw-r--r--storage/maria/ma_loghandler.c29
-rw-r--r--storage/maria/ma_loghandler.h3
-rw-r--r--storage/maria/ma_recovery.c14
-rw-r--r--storage/maria/maria_chk.c17
-rw-r--r--storage/maria/tablockman.c2
-rw-r--r--storage/maria/unittest/ma_control_file-t.c26
-rw-r--r--storage/maria/unittest/ma_loghandler_examples.c3
-rw-r--r--storage/maria/unittest/ma_maria_log_cleanup.c24
-rw-r--r--storage/maria/unittest/ma_pagecache_consist.c30
-rw-r--r--storage/maria/unittest/ma_pagecache_rwconsist.c29
-rw-r--r--storage/maria/unittest/ma_pagecache_rwconsist2.c29
-rw-r--r--storage/maria/unittest/ma_pagecache_single.c32
-rwxr-xr-xstorage/maria/unittest/ma_test_all-t47
-rw-r--r--storage/maria/unittest/ma_test_loghandler-t.c16
-rw-r--r--storage/maria/unittest/ma_test_loghandler_first_lsn-t.c23
-rw-r--r--storage/maria/unittest/ma_test_loghandler_max_lsn-t.c13
-rw-r--r--storage/maria/unittest/ma_test_loghandler_multigroup-t.c23
-rw-r--r--storage/maria/unittest/ma_test_loghandler_multithread-t.c21
-rw-r--r--storage/maria/unittest/ma_test_loghandler_noflush-t.c16
-rw-r--r--storage/maria/unittest/ma_test_loghandler_nologs-t.c14
-rw-r--r--storage/maria/unittest/ma_test_loghandler_pagecache-t.c28
-rw-r--r--storage/maria/unittest/ma_test_loghandler_purge-t.c12
-rw-r--r--storage/maria/unittest/trnman-t.c12
-rw-r--r--storage/myisam/ft_stopwords.c2
-rw-r--r--storage/myisam/ha_myisam.cc14
-rw-r--r--storage/myisam/ha_myisam.h3
-rw-r--r--storage/myisam/mi_create.c2
-rw-r--r--storage/myisam/mi_test1.c1
-rw-r--r--storage/myisam/mi_write.c1
-rw-r--r--storage/myisam/myisamdef.h4
-rw-r--r--storage/myisam/sp_test.c1
-rw-r--r--storage/myisammrg/ha_myisammrg.cc9
-rw-r--r--storage/myisammrg/ha_myisammrg.h2
-rw-r--r--storage/mysql_storage_engine.cmake1
-rw-r--r--storage/pbxt/src/cache_xt.cc5
-rw-r--r--storage/pbxt/src/filesys_xt.cc3
-rw-r--r--storage/pbxt/src/heap_xt.cc1
-rw-r--r--storage/pbxt/src/lock_xt.cc6
-rw-r--r--storage/pbxt/src/lock_xt.h1
-rwxr-xr-xstorage/pbxt/src/pthread_xt.cc45
-rw-r--r--storage/pbxt/src/thread_xt.cc16
-rw-r--r--storage/pbxt/src/xaction_xt.cc1
-rw-r--r--storage/xtradb/CMakeLists.txt7
-rw-r--r--storage/xtradb/ChangeLog58
-rw-r--r--storage/xtradb/btr/btr0btr.c2
-rw-r--r--storage/xtradb/btr/btr0cur.c596
-rw-r--r--storage/xtradb/btr/btr0sea.c165
-rw-r--r--storage/xtradb/buf/buf0buddy.c5
-rw-r--r--storage/xtradb/buf/buf0buf.c51
-rw-r--r--storage/xtradb/buf/buf0flu.c9
-rw-r--r--storage/xtradb/buf/buf0lru.c75
-rw-r--r--storage/xtradb/dict/dict0boot.c6
-rw-r--r--storage/xtradb/dict/dict0crea.c7
-rw-r--r--storage/xtradb/dict/dict0dict.c138
-rw-r--r--storage/xtradb/fil/fil0fil.c107
-rw-r--r--storage/xtradb/fsp/fsp0fsp.c25
-rw-r--r--storage/xtradb/handler/ha_innodb.cc165
-rw-r--r--storage/xtradb/handler/i_s.cc23
-rw-r--r--storage/xtradb/ibuf/ibuf0ibuf.c8
-rw-r--r--storage/xtradb/include/btr0cur.h47
-rw-r--r--storage/xtradb/include/buf0buf.h15
-rw-r--r--storage/xtradb/include/buf0buf.ic9
-rw-r--r--storage/xtradb/include/buf0lru.h21
-rw-r--r--storage/xtradb/include/buf0types.h2
-rw-r--r--storage/xtradb/include/dict0boot.h1
-rw-r--r--storage/xtradb/include/dict0dict.h7
-rw-r--r--storage/xtradb/include/dict0mem.h6
-rw-r--r--storage/xtradb/include/dict0types.h5
-rw-r--r--storage/xtradb/include/fil0fil.h12
-rw-r--r--storage/xtradb/include/os0file.h7
-rw-r--r--storage/xtradb/include/page0cur.h16
-rw-r--r--storage/xtradb/include/rem0cmp.h7
-rw-r--r--storage/xtradb/include/rem0cmp.ic2
-rw-r--r--storage/xtradb/include/row0mysql.h8
-rw-r--r--storage/xtradb/include/row0upd.h26
-rw-r--r--storage/xtradb/include/srv0srv.h24
-rw-r--r--storage/xtradb/include/sync0rw.h15
-rw-r--r--storage/xtradb/include/sync0sync.h13
-rw-r--r--storage/xtradb/include/trx0rseg.h4
-rw-r--r--storage/xtradb/include/trx0trx.h4
-rw-r--r--storage/xtradb/include/univ.i11
-rw-r--r--storage/xtradb/mem/mem0mem.c2
-rw-r--r--storage/xtradb/mtr/mtr0log.c2
-rw-r--r--storage/xtradb/os/os0file.c19
-rw-r--r--storage/xtradb/page/page0cur.c68
-rw-r--r--storage/xtradb/page/page0zip.c2
-rw-r--r--storage/xtradb/rem/rem0cmp.c17
-rw-r--r--storage/xtradb/row/row0ins.c4
-rw-r--r--storage/xtradb/row/row0mysql.c27
-rw-r--r--storage/xtradb/row/row0purge.c68
-rw-r--r--storage/xtradb/row/row0row.c16
-rw-r--r--storage/xtradb/row/row0umod.c35
-rw-r--r--storage/xtradb/row/row0upd.c65
-rw-r--r--storage/xtradb/row/row0vers.c10
-rw-r--r--storage/xtradb/srv/srv0srv.c16
-rw-r--r--storage/xtradb/sync/sync0arr.c4
-rw-r--r--storage/xtradb/sync/sync0rw.c34
-rw-r--r--storage/xtradb/sync/sync0sync.c10
-rw-r--r--storage/xtradb/trx/trx0rec.c17
-rw-r--r--storage/xtradb/trx/trx0roll.c4
-rw-r--r--storage/xtradb/trx/trx0trx.c25
-rw-r--r--strings/bchange.c35
-rw-r--r--strings/bcopy-duff.c44
-rw-r--r--strings/bfill.c44
-rw-r--r--strings/bmove.c44
-rw-r--r--strings/bmove512.c35
-rw-r--r--strings/bmove_upp.c41
-rw-r--r--strings/conf_to_src.c7
-rw-r--r--strings/ctype-big5.c3
-rw-r--r--strings/ctype-bin.c4
-rw-r--r--strings/ctype-cp932.c3
-rw-r--r--strings/ctype-czech.c3
-rw-r--r--strings/ctype-euc_kr.c3
-rw-r--r--strings/ctype-eucjpms.c6
-rw-r--r--strings/ctype-extra.c1
-rw-r--r--strings/ctype-gb2312.c3
-rw-r--r--strings/ctype-gbk.c3
-rw-r--r--strings/ctype-latin1.c3
-rw-r--r--strings/ctype-mb.c3
-rw-r--r--strings/ctype-simple.c7
-rw-r--r--strings/ctype-sjis.c3
-rw-r--r--strings/ctype-tis620.c5
-rw-r--r--strings/ctype-uca.c3
-rw-r--r--strings/ctype-ucs2.c3
-rw-r--r--strings/ctype-ujis.c4
-rw-r--r--strings/ctype-utf8.c3
-rw-r--r--strings/ctype-win1250ch.c4
-rw-r--r--strings/ctype.c3
-rw-r--r--strings/decimal.c19
-rw-r--r--strings/do_ctype.c3
-rw-r--r--strings/dump_map.c3
-rw-r--r--strings/int2str.c41
-rw-r--r--strings/is_prefix.c35
-rw-r--r--strings/llstr.c41
-rw-r--r--strings/longlong2str.c41
-rw-r--r--strings/longlong2str_asm.c41
-rw-r--r--strings/memcmp.c41
-rw-r--r--strings/memcpy.c35
-rw-r--r--strings/memset.c36
-rw-r--r--strings/my_strchr.c3
-rw-r--r--strings/my_strtoll10.c35
-rw-r--r--strings/my_vsnprintf.c4
-rw-r--r--strings/r_strinstr.c36
-rw-r--r--strings/str2int.c41
-rw-r--r--strings/str_alloc.c3
-rw-r--r--strings/str_test.c3
-rw-r--r--strings/strappend.c50
-rw-r--r--strings/strcat.c52
-rw-r--r--strings/strcend.c48
-rw-r--r--strings/strchr.c36
-rw-r--r--strings/strcmp.c36
-rw-r--r--strings/strcont.c41
-rw-r--r--strings/strend.c44
-rw-r--r--strings/strfill.c35
-rw-r--r--strings/strinstr.c42
-rw-r--r--strings/strlen.c36
-rw-r--r--strings/strmake.c3
-rw-r--r--strings/strmov.c35
-rw-r--r--strings/strnlen.c42
-rw-r--r--strings/strnmov.c35
-rw-r--r--strings/strrchr.c42
-rw-r--r--strings/strstr.c43
-rw-r--r--strings/strto.c41
-rw-r--r--strings/strtod.c16
-rw-r--r--strings/strtol.c35
-rw-r--r--strings/strtoll.c35
-rw-r--r--strings/strtoul.c35
-rw-r--r--strings/strtoull.c35
-rw-r--r--strings/strxmov.c44
-rw-r--r--strings/strxnmov.c44
-rw-r--r--strings/uca-dump.c3
-rw-r--r--strings/uctypedump.c2
-rw-r--r--strings/udiv.c41
-rw-r--r--strings/utr11-dump.c3
-rw-r--r--strings/xml.c33
-rw-r--r--support-files/compiler_warnings.supp15
-rw-r--r--support-files/mysql.spec.sh63
-rwxr-xr-xtests/CMakeLists.txt4
-rw-r--r--tests/mysql_client_test.c147
-rw-r--r--unittest/mysys/Makefile.am2
-rw-r--r--unittest/mysys/bitmap-t.c184
-rw-r--r--unittest/mysys/ma_dyncol-t.c795
-rw-r--r--unittest/mysys/thr_template.c10
-rw-r--r--unittest/mysys/waiting_threads-t.c9
-rw-r--r--unittest/mytap/tap.c87
-rw-r--r--unittest/unit.pl3
-rw-r--r--vio/viosocket.c7
-rw-r--r--win/Makefile.am3
-rw-r--r--win/cmake/create_initial_db.cmake.in2
-rw-r--r--win/cmake/mysql_version.cmake16
-rw-r--r--win/cmake/package_name.cmake2
-rw-r--r--win/packaging/CMakeLists.txt34
-rw-r--r--win/packaging/create_msi.cmake.in41
-rw-r--r--win/packaging/extra.wxs.in35
-rw-r--r--win/packaging/heidisql.cmake23
-rw-r--r--win/packaging/heidisql.wxi.in46
-rw-r--r--win/packaging/heidisql_feature.wxi.in10
1144 files changed, 76854 insertions, 23691 deletions
diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf
index 4eb39d5426c..20aadc5d7fc 100644
--- a/.bzr-mysql/default.conf
+++ b/.bzr-mysql/default.conf
@@ -1,6 +1,6 @@
[MYSQL]
-tree_location = lp:maria/5.2
+tree_location = lp:maria/5.3
post_commit_to = commits@mariadb.org
-post_commit_url = lp:maria/5.2
-tree_name = maria/5.2
-project_name = "Mariadb 5.2, with Maria 2.0"
+post_commit_url = lp:maria/5.3
+tree_name = maria/5.3
+project_name = "Mariadb 5.3, with Aria 2.0"
diff --git a/.bzrignore b/.bzrignore
index 37e2c84c618..685bcfff6b4 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -10,6 +10,7 @@
*.core
*.d
*.da
+*.dir
*.dll
*.exe
*.exp
@@ -31,6 +32,7 @@
*.pdb
*.reject
*.res
+*.rule
*.sbr
*.so
*.so.*
@@ -41,15 +43,21 @@
*.dsp
*.Po
*.Plo
-*.dir/
+*.vcxproj
+*.vcxproj.filters
+*/*.dir/*
+*.dir
+Debug
+MySql.sdf
+Win32
*/*_pure_*warnings
*/.deps
*/.libs/*
*/.pure
-debug/
-MinSizeRel/
-Release/
-RelWithDebInfo/
+*/debug/*
+*/minsizerel/*
+*/release/*
+RelWithDebInfo
*~
.*.swp
./CMakeCache.txt
@@ -336,6 +344,7 @@ client/rpl_record_old.h
client/rpl_tblmap.h
client/rpl_tblmap.cc
client/rpl_utility.h
+client/rpl_utility.cc
client/select_test
client/sql_string.cpp
client/ssl_test
@@ -429,6 +438,7 @@ include/mysql_h.ic
include/mysql_version.h
include/mysqld_ername.h
include/mysqld_error.h
+include/mysqld_error.h.rule
include/openssl
include/readline
include/readline/*.h
@@ -672,6 +682,8 @@ libmysqld/unireg.cc
libmysqld/discover_xt.cc
libmysqld/ha_pbxt.cc
libmysqld/myxt_xt.cc
+libmysqld/rpl_reporting.cc
+libmysqld/rpl_utility.cc
libmysqltest/*.ds?
libmysqltest/*.vcproj
libmysqltest/mytest.c
@@ -1154,7 +1166,9 @@ scripts/mysql_find_rows
scripts/mysql_fix_extensions
scripts/mysql_fix_privilege_tables
scripts/mysql_fix_privilege_tables.sql
+scripts/mysql_fix_privilege_tables.sql.rule
scripts/mysql_fix_privilege_tables_sql.c
+scripts/mysql_fix_privilege_tables_sql.c.rule
scripts/mysql_install_db
scripts/mysql_secure_installation
scripts/mysql_setpermission
@@ -1239,6 +1253,7 @@ sql/handlerton.cc
sql/html
sql/latex
sql/lex_hash.h
+sql/lex_hash.h.rule
sql/link_sources
sql/max/*
sql/message.h
@@ -1290,6 +1305,7 @@ sql/sql_builtin.cc
sql/sql_select.cc.orig
sql/sql_yacc.cc
sql/sql_yacc.h
+sql/sql_yacc.h.rule
sql/sql_yacc.output
sql/sql_yacc.yy.orig
sql/test_time
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f5546e9715..3c6a65505fe 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,7 @@ ADD_DEFINITIONS(-D__NT__)
IF(CYBOZU)
ADD_DEFINITIONS(-DCYBOZU)
+ ADD_DEFINITIONS(-DHAVE_UTF8_GENERAL_CS)
ENDIF(CYBOZU)
IF(EXTRA_DEBUG)
@@ -170,15 +171,7 @@ IF(MSVC)
IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 4)
-
- # Disable automatic manifest generation.
- STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
- ${CMAKE_EXE_LINKER_FLAGS})
- # Explicitly disable it since it is the default for newer versions of VS
- STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS})
- IF(NOT tmp_manifest)
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
- ENDIF(NOT tmp_manifest)
+ SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL:NO")
ENDIF(MSVC)
IF(WIN32)
@@ -363,7 +356,6 @@ ADD_SUBDIRECTORY(extra/libevent)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(sql)
ADD_SUBDIRECTORY(client)
-ADD_SUBDIRECTORY(server-tools/instance-manager)
ADD_SUBDIRECTORY(libmysql)
ADD_SUBDIRECTORY(libservices)
ADD_SUBDIRECTORY(tests)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 4105922fa90..886c6c8b65d 100755
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -14,7 +14,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
-# We use the "mysqlclient_notls" library here just as safety, in case
+# We use the "mysqlclient" library here just as safety, in case
# any of the clients here would go beyond the client API and access the
# Thread Local Storage directly.
@@ -29,27 +29,27 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR})
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysql mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc DESTINATION bin)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug)
MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysqldump mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysqlimport mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient wsock32)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysqlshow mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
../mysys/mf_tempdir.c
@@ -58,11 +58,12 @@ MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
../mysys/my_bitmap.c
../mysys/my_vle.c
../mysys/base64.c
+ ../mysys/checksum.c
DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc DESTINATION bin)
-TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysqladmin mysqlclient wsock32)
MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c DESTINATION bin)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
diff --git a/client/Makefile.am b/client/Makefile.am
index f3f964ace7b..b71b180d98d 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -24,6 +24,7 @@ endif
INCLUDES = -I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_srcdir)/regex \
+ @ZLIB_INCLUDES@ \
$(openssl_includes)
LIBS = @CLIENT_LIBS@
@@ -63,7 +64,8 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc \
$(top_srcdir)/mysys/my_bit.c \
$(top_srcdir)/mysys/my_bitmap.c \
$(top_srcdir)/mysys/my_vle.c \
- $(top_srcdir)/mysys/base64.c
+ $(top_srcdir)/mysys/base64.c \
+ $(top_srcdir)/mysys/checksum.c
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
mysqldump_SOURCES= mysqldump.c \
@@ -106,6 +108,7 @@ sql_src=log_event.h mysql_priv.h rpl_constants.h \
log_event.cc my_decimal.h my_decimal.cc \
log_event_old.h log_event_old.cc \
rpl_record_old.h rpl_record_old.cc \
+ rpl_utility.h rpl_utility.cc \
sql_list.h rpl_filter.h sql_list.cc rpl_filter.cc
strings_src=decimal.c strings_def.h
diff --git a/client/client_priv.h b/client/client_priv.h
index 0b617c564df..ec67ed3ae2d 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -85,6 +85,7 @@ enum options_client
OPT_SLAP_POST_SYSTEM,
OPT_SLAP_COMMIT,
OPT_SLAP_DETACH,
+ OPT_SLAP_NO_DROP,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
diff --git a/client/my_readline.h b/client/my_readline.h
index 62ad19bece9..3376fc81761 100644
--- a/client/my_readline.h
+++ b/client/my_readline.h
@@ -25,9 +25,11 @@ typedef struct st_line_buffer
uint eof;
ulong max_size;
ulong read_length; /* Length of last read string */
+ int error;
+ bool truncated;
} LINE_BUFFER;
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
-extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
+extern char *batch_readline(LINE_BUFFER *buffer);
extern void batch_readline_end(LINE_BUFFER *buffer);
diff --git a/client/mysql.cc b/client/mysql.cc
index 983953cfbea..03c1e669f60 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1137,6 +1137,8 @@ int main(int argc,char *argv[])
if (status.batch && !status.line_buff &&
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
{
+ put_info("Can't initialize batch_readline - may be the input source is "
+ "a directory or a block device.", INFO_ERROR, 0);
free_defaults(defaults_argv);
my_end(0);
exit(1);
@@ -1898,14 +1900,13 @@ static int read_and_execute(bool interactive)
ulong line_number=0;
bool ml_comment= 0;
COMMANDS *com;
- bool truncated= 0;
status.exit_status=1;
while (!aborted)
{
if (!interactive)
{
- line=batch_readline(status.line_buff, &truncated);
+ line=batch_readline(status.line_buff);
/*
Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
Editors like "notepad" put this marker in
@@ -1979,9 +1980,13 @@ static int read_and_execute(bool interactive)
if (opt_outfile && line)
fprintf(OUTFILE, "%s\n", line);
}
- if (!line) // End of file
+ // End of file or system error
+ if (!line)
{
- status.exit_status=0;
+ if (status.line_buff && status.line_buff->error)
+ status.exit_status= 1;
+ else
+ status.exit_status= 0;
break;
}
@@ -2002,7 +2007,8 @@ static int read_and_execute(bool interactive)
#endif
continue;
}
- if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
+ if (add_line(glob_buffer, line, &in_string, &ml_comment,
+ status.line_buff ? status.line_buff->truncated : 0))
break;
}
/* if in batch mode, send last query even if it doesn't end with \g or go */
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 5f3175f3ed6..3cc315ce1bc 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -423,6 +423,9 @@ int main(int argc,char *argv[])
if (interval) /* --sleep=interval given */
{
+ if (opt_count_iterations && --nr_iterations == 0)
+ break;
+
/*
If connection was dropped (unintentionally, or due to SHUTDOWN),
re-establish it if --wait ("retry-connect") was given and user
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 6e0b5cf5234..b7ebdbc9f58 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -84,6 +84,7 @@ static const char* database= 0;
static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
static my_bool debug_info_flag, debug_check_flag;
static my_bool force_if_open_opt= 1;
+static my_bool opt_verify_binlog_checksum= 1;
static ulonglong offset = 0;
static const char* host = 0;
static int port= 0;
@@ -164,7 +165,8 @@ Log_event* read_remote_annotate_event(uchar* net_buf, ulong event_len,
event_buf[event_len]= 0;
if (!(event= Log_event::read_log_event((const char*) event_buf, event_len,
- error_msg, glob_description_event)))
+ error_msg, glob_description_event,
+ opt_verify_binlog_checksum)))
{
my_free(event_buf, MYF(0));
return 0;
@@ -809,7 +811,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
read them to be able to process the wanted events.
*/
if (((rec_count >= offset) &&
- ((my_time_t)(ev->when) >= start_datetime)) ||
+ (ev->when >= start_datetime)) ||
(ev_type == FORMAT_DESCRIPTION_EVENT))
{
if (ev_type != FORMAT_DESCRIPTION_EVENT)
@@ -821,11 +823,19 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
*/
start_datetime= 0;
offset= 0; // print everything and protect against cycling rec_count
+ /*
+ Skip events according to the --server-id flag. However, don't
+ skip format_description or rotate events, because they they
+ are really "global" events that are relevant for the entire
+ binlog, even if they have a server_id. Also, we have to read
+ the format_description event so that we can parse subsequent
+ events.
+ */
+ if (ev_type != ROTATE_EVENT &&
+ server_id && (server_id != ev->server_id))
+ goto end;
}
- if (server_id && (server_id != ev->server_id))
- /* skip just this event, continue processing the log. */
- goto end;
- if (((my_time_t)(ev->when) >= stop_datetime)
+ if ((ev->when >= stop_datetime)
|| (pos >= stop_position_mot))
{
/* end the program */
@@ -1311,6 +1321,9 @@ that may lead to an endless loop.",
"Used to reserve file descriptors for use by this program.",
&open_files_limit, &open_files_limit, 0, GET_ULONG,
REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
+ {"verify-binlog-checksum", 'c', "Verify checksum binlog events.",
+ (uchar**) &opt_verify_binlog_checksum, (uchar**) &opt_verify_binlog_checksum,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"rewrite-db", OPT_REWRITE_DB,
"Updates to a database with a different name than the original. \
Example: rewrite-db='from->to'.",
@@ -1432,7 +1445,7 @@ static my_time_t convert_str_to_timestamp(const char* str)
int was_cut;
MYSQL_TIME l_time;
long dummy_my_timezone;
- my_bool dummy_in_dst_time_gap;
+ uint dummy_in_dst_time_gap;
/* We require a total specification (date AND time) */
if (str_to_datetime(str, (uint) strlen(str), &l_time, 0, &was_cut) !=
MYSQL_TIMESTAMP_DATETIME || was_cut)
@@ -1709,7 +1722,18 @@ static Exit_status check_master_version()
"Master reported NULL for the version.");
goto err;
}
-
+ /*
+ Make a notice to the server that this client
+ is checksum-aware. It does not need the first fake Rotate
+ necessary checksummed.
+ That preference is specified below.
+ */
+ if (mysql_query(mysql, "SET @master_binlog_checksum='NONE'"))
+ {
+ error("Could not notify master about checksum awareness."
+ "Master returned '%s'", mysql_error(mysql));
+ goto err;
+ }
delete glob_description_event;
switch (*version) {
case '3':
@@ -1838,7 +1862,8 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
{
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error_msg,
- glob_description_event)))
+ glob_description_event,
+ opt_verify_binlog_checksum)))
{
error("Could not construct log event object: %s", error_msg);
DBUG_RETURN(ERROR_STOP);
@@ -2066,7 +2091,8 @@ static Exit_status check_header(IO_CACHE* file,
Format_description_log_event *new_description_event;
my_b_seek(file, tmp_pos); /* seek back to event's start */
if (!(new_description_event= (Format_description_log_event*)
- Log_event::read_log_event(file, glob_description_event)))
+ Log_event::read_log_event(file, glob_description_event,
+ opt_verify_binlog_checksum)))
/* EOF can't be hit here normally, so it's a real error */
{
error("Could not read a Format_description_log_event event at "
@@ -2099,7 +2125,8 @@ static Exit_status check_header(IO_CACHE* file,
{
Log_event *ev;
my_b_seek(file, tmp_pos); /* seek back to event's start */
- if (!(ev= Log_event::read_log_event(file, glob_description_event)))
+ if (!(ev= Log_event::read_log_event(file, glob_description_event,
+ opt_verify_binlog_checksum)))
{
/* EOF can't be hit here normally, so it's a real error */
error("Could not read a Rotate_log_event event at offset %llu;"
@@ -2212,7 +2239,8 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
char llbuff[21];
my_off_t old_off = my_b_tell(file);
- Log_event* ev = Log_event::read_log_event(file, glob_description_event);
+ Log_event* ev = Log_event::read_log_event(file, glob_description_event,
+ opt_verify_binlog_checksum);
if (!ev)
{
/*
@@ -2391,4 +2419,4 @@ void *sql_alloc(size_t size)
#include "sql_string.cc"
#include "sql_list.cc"
#include "rpl_filter.cc"
-
+#include "rpl_utility.cc"
diff --git a/client/mysqldump.c b/client/mysqldump.c
index efda677b5aa..0eab2ae8e0b 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1176,6 +1176,9 @@ static int switch_db_collation(FILE *sql_file,
{
if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
{
+ char quoted_db_buf[NAME_LEN * 2 + 3];
+ char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
+
CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
if (!db_cl)
@@ -1183,7 +1186,7 @@ static int switch_db_collation(FILE *sql_file,
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
- (const char *) db_name,
+ (const char *) quoted_db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);
@@ -1204,6 +1207,9 @@ static int restore_db_collation(FILE *sql_file,
const char *delimiter,
const char *db_cl_name)
{
+ char quoted_db_buf[NAME_LEN * 2 + 3];
+ char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
+
CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
if (!db_cl)
@@ -1211,7 +1217,7 @@ static int restore_db_collation(FILE *sql_file,
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
- (const char *) db_name,
+ (const char *) quoted_db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);
@@ -2290,6 +2296,15 @@ static uint get_table_structure(char *table, char *db, char *table_type,
const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
+ const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, "
+ "`COLUMN_TYPE` AS `Type`, "
+ "`IS_NULLABLE` AS `Null`, "
+ "`COLUMN_KEY` AS `Key`, "
+ "`COLUMN_DEFAULT` AS `Default`, "
+ "`EXTRA` AS `Extra`, "
+ "`COLUMN_COMMENT` AS `Comment` "
+ "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE "
+ "TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
FILE *sql_file= md_result_file;
int len;
MYSQL_RES *result;
@@ -2557,8 +2572,8 @@ static uint get_table_structure(char *table, char *db, char *table_type,
verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
my_progname, mysql_error(mysql));
- my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
- result_table);
+ my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
+
if (mysql_query_with_error_report(mysql, &result, query_buff))
DBUG_RETURN(0);
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 8a45b567e84..c38380c7306 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -131,7 +131,7 @@ const char *delimiter= "\n";
const char *create_schema_string= "mysqlslap";
-static my_bool opt_preserve= TRUE;
+static my_bool opt_preserve= TRUE, opt_no_drop= FALSE;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool opt_only_print= FALSE;
static my_bool opt_compress= FALSE, tty_password= FALSE,
@@ -617,6 +617,8 @@ static struct my_option my_long_options[] =
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"iterations", 'i', "Number of times to run the tests.", &iterations,
&iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
+ {"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.",
+ &opt_no_drop, &opt_no_drop, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"number-char-cols", 'x',
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.",
(char**) &num_char_cols_opt, (char**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
@@ -1167,8 +1169,11 @@ get_options(int *argc,char ***argv)
if (!user)
user= (char *)"root";
- /* If something is created we clean it up, otherwise we leave schemas alone */
- if (create_string || auto_generate_sql)
+ /*
+ If something is created and --no-drop is not specified, we drop the
+ schema.
+ */
+ if (!opt_no_drop && (create_string || auto_generate_sql))
opt_preserve= FALSE;
if (auto_generate_sql && (create_string || user_supplied_query))
@@ -1541,7 +1546,12 @@ generate_primary_key_list(MYSQL *mysql, option_string *engine_stmt)
exit(1);
}
- result= mysql_store_result(mysql);
+ if (!(result= mysql_store_result(mysql)))
+ {
+ fprintf(stderr, "%s: Error when storing result: %d %s\n",
+ my_progname, mysql_errno(mysql), mysql_error(mysql));
+ exit(1);
+ }
primary_keys_number_of= mysql_num_rows(result);
/* So why check this? Blackhole :) */
@@ -1915,17 +1925,15 @@ limit_not_met:
{
if (mysql_field_count(mysql))
{
- if ((result= mysql_store_result(mysql)))
+ if (!(result= mysql_store_result(mysql)))
+ fprintf(stderr, "%s: Error when storing result: %d %s\n",
+ my_progname, mysql_errno(mysql), mysql_error(mysql));
+ else
{
- while ((row = mysql_fetch_row(result)))
+ while ((row= mysql_fetch_row(result)))
counter++;
mysql_free_result(result);
}
- else
- {
- fprintf(stderr,"%s: Error in mysql_store_result(): %d %s\n",
- my_progname, mysql_errno(mysql), mysql_error(mysql));
- }
}
} while(mysql_next_result(mysql) == 0);
queries++;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 65ae93696ea..a3689a7b757 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011 Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/*
mysqltest
@@ -111,7 +112,7 @@ static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
display_metadata= FALSE, display_result_sorted= FALSE;
static my_bool disable_query_log= 0, disable_result_log= 0;
static my_bool disable_connect_log= 1;
-static my_bool disable_warnings= 0;
+static my_bool disable_warnings= 0, disable_column_names= 0;
static my_bool prepare_warnings_enabled= 0;
static my_bool disable_info= 1;
static my_bool abort_on_error= 1;
@@ -297,6 +298,7 @@ enum enum_commands {
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
Q_ENABLE_INFO, Q_DISABLE_INFO,
Q_ENABLE_METADATA, Q_DISABLE_METADATA,
+ Q_ENABLE_COLUMN_NAMES, Q_DISABLE_COLUMN_NAMES,
Q_EXEC, Q_DELIMITER,
Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR,
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
@@ -370,6 +372,8 @@ const char *command_names[]=
"disable_info",
"enable_metadata",
"disable_metadata",
+ "enable_column_names",
+ "disable_column_names",
"exec",
"delimiter",
"disable_abort_on_error",
@@ -490,7 +494,7 @@ VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
void var_free(void* v);
VAR* var_get(const char *var_name, const char** var_name_end,
my_bool raw, my_bool ignore_not_existing);
-void eval_expr(VAR* v, const char *p, const char** p_end, bool backtick= true);
+void eval_expr(VAR* v, const char *p, const char** p_end, bool do_eval= true);
my_bool match_delimiter(int c, const char *delim, uint length);
void dump_result_to_reject_file(char *buf, int size);
void dump_warning_messages();
@@ -600,6 +604,10 @@ public:
DBUG_VOID_RETURN;
DBUG_ASSERT(ds->str);
+#ifdef EXTRA_DEBUG
+ DBUG_PRINT("QQ", ("str: %*s", (int) ds->length, ds->str));
+#endif
+
if (fwrite(ds->str, 1, ds->length, m_file) != ds->length)
die("Failed to write %lu bytes to '%s', errno: %d",
(unsigned long)ds->length, m_file_name, errno);
@@ -1269,6 +1277,22 @@ static void cleanup_and_exit(int exit_code)
exit(exit_code);
}
+void print_file_stack()
+{
+ struct st_test_file* err_file= cur_file;
+ if (err_file == file_stack)
+ return;
+
+ for (;;)
+ {
+ err_file--;
+ fprintf(stderr, "included from %s at line %d:\n",
+ err_file->file_name, err_file->lineno);
+ if (err_file == file_stack)
+ break;
+ }
+}
+
void die(const char *fmt, ...)
{
static int dying= 0;
@@ -1276,11 +1300,15 @@ void die(const char *fmt, ...)
DBUG_ENTER("die");
DBUG_PRINT("enter", ("start_lineno: %d", start_lineno));
+ fflush(stdout);
/* Print the error message */
fprintf(stderr, "mysqltest: ");
if (cur_file && cur_file != file_stack)
- fprintf(stderr, "In included file \"%s\": ",
+ {
+ fprintf(stderr, "In included file \"%s\": \n",
cur_file->file_name);
+ print_file_stack();
+ }
if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno);
if (fmt)
@@ -1319,7 +1347,6 @@ void die(const char *fmt, ...)
void abort_not_supported_test(const char *fmt, ...)
{
va_list args;
- struct st_test_file* err_file= cur_file;
DBUG_ENTER("abort_not_supported_test");
/* Print include filestack */
@@ -1327,13 +1354,8 @@ void abort_not_supported_test(const char *fmt, ...)
fprintf(stderr, "The test '%s' is not supported by this installation\n",
file_stack->file_name);
fprintf(stderr, "Detected in file %s at line %d\n",
- err_file->file_name, err_file->lineno);
- while (err_file != file_stack)
- {
- err_file--;
- fprintf(stderr, "included from %s at line %d\n",
- err_file->file_name, err_file->lineno);
- }
+ cur_file->file_name, cur_file->lineno);
+ print_file_stack();
/* Print error message */
va_start(args, fmt);
@@ -1365,6 +1387,7 @@ void verbose_msg(const char *fmt, ...)
if (!verbose)
DBUG_VOID_RETURN;
+ fflush(stdout);
va_start(args, fmt);
fprintf(stderr, "mysqltest: ");
if (cur_file && cur_file != file_stack)
@@ -1375,6 +1398,7 @@ void verbose_msg(const char *fmt, ...)
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
+ fflush(stderr);
DBUG_VOID_RETURN;
}
@@ -1459,6 +1483,8 @@ static int run_command(char* cmd,
char buf[512]= {0};
FILE *res_file;
int error;
+ DBUG_ENTER("run_command");
+ DBUG_PRINT("enter", ("cmd: %s", cmd));
if (!(res_file= popen(cmd, "r")))
die("popen(\"%s\", \"r\") failed", cmd);
@@ -1479,7 +1505,7 @@ static int run_command(char* cmd,
}
error= pclose(res_file);
- return WEXITSTATUS(error);
+ DBUG_RETURN(WEXITSTATUS(error));
}
@@ -2418,7 +2444,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
break;
}
}
- eval_expr(var, value, 0);
+ eval_expr(var, value, 0, false);
}
dynstr_free(&ds_query);
mysql_free_result(res);
@@ -2448,12 +2474,16 @@ void var_copy(VAR *dest, VAR *src)
}
-void eval_expr(VAR *v, const char *p, const char **p_end, bool backtick)
+void eval_expr(VAR *v, const char *p, const char **p_end, bool do_eval)
{
DBUG_ENTER("eval_expr");
DBUG_PRINT("enter", ("p: '%s'", p));
+ /* Skip to treat as pure string if no evaluation */
+ if (! do_eval)
+ goto NO_EVAL;
+
if (*p == '$')
{
VAR *vp;
@@ -2473,7 +2503,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end, bool backtick)
DBUG_VOID_RETURN;
}
- if (*p == '`' && backtick)
+ if (*p == '`')
{
var_query_set(v, p, p_end);
DBUG_VOID_RETURN;
@@ -2496,6 +2526,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end, bool backtick)
}
}
+ NO_EVAL:
{
int new_val_len = (p_end && *p_end) ?
(int) (*p_end - p) : (int) strlen(p);
@@ -6673,6 +6704,7 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
my_bool *is_null;
ulong *length;
uint i;
+ int error;
/* Allocate array with bind structs, lengths and NULL flags */
my_bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND),
@@ -6700,7 +6732,7 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
die("mysql_stmt_bind_result failed: %d: %s",
mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
- while (mysql_stmt_fetch(stmt) == 0)
+ while ((error=mysql_stmt_fetch(stmt)) == 0)
{
for (i= 0; i < num_fields; i++)
append_field(ds, i, &fields[i], (char*)my_bind[i].buffer,
@@ -6709,8 +6741,11 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
dynstr_append_mem(ds, "\n", 1);
}
+ if (error != MYSQL_NO_DATA)
+ die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: error: %d",
+ error);
if (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
- die("fetch didn't end with MYSQL_NO_DATA from statement: %d %s",
+ die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: %d %s",
mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
for (i= 0; i < num_fields; i++)
@@ -6805,6 +6840,8 @@ void append_table_headings(DYNAMIC_STRING *ds,
uint num_fields)
{
uint col_idx;
+ if (disable_column_names)
+ return;
for (col_idx= 0; col_idx < num_fields; col_idx++)
{
if (col_idx)
@@ -7450,7 +7487,8 @@ int util_query(MYSQL* org_mysql, const char* query){
cur_con->util_mysql= mysql;
}
- return mysql_query(mysql, query);
+ int ret= mysql_query(mysql, query);
+ DBUG_RETURN(ret);
}
@@ -7531,6 +7569,15 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
dynstr_append_mem(ds, "\n", 1);
}
+ /*
+ Write the command to the result file before we execute the query
+ This is needed to be able to analyse the log if something goes
+ wrong
+ */
+ log_file.write(&ds_res);
+ log_file.flush();
+ dynstr_set(&ds_res, 0);
+
if (view_protocol_enabled &&
complete_query &&
match_re(&view_re, query))
@@ -8121,13 +8168,15 @@ int main(int argc, char **argv)
cur_file->lineno= 1;
}
init_re();
+
+ /* Cursor protcol implies ps protocol */
+ if (cursor_protocol)
+ ps_protocol= 1;
+
ps_protocol_enabled= ps_protocol;
sp_protocol_enabled= sp_protocol;
view_protocol_enabled= view_protocol;
cursor_protocol_enabled= cursor_protocol;
- /* Cursor protcol implies ps protocol */
- if (cursor_protocol_enabled)
- ps_protocol_enabled= 1;
st_connection *con= connections;
if (! (con->mysql= mysql_init(0)))
@@ -8306,6 +8355,14 @@ int main(int argc, char **argv)
display_metadata= 0;
var_set_int("$ENABLED_METADATA", 0);
break;
+ case Q_ENABLE_COLUMN_NAMES:
+ disable_column_names= 0;
+ var_set_int("$ENABLED_COLUMN_NAMES", 0);
+ break;
+ case Q_DISABLE_COLUMN_NAMES:
+ disable_column_names= 1;
+ var_set_int("$ENABLED_COLUMN_NAMES", 1);
+ break;
case Q_SOURCE: do_source(command); break;
case Q_SLEEP: do_sleep(command, 0); break;
case Q_REAL_SLEEP: do_sleep(command, 1); break;
@@ -8693,7 +8750,7 @@ void timer_output(void)
ulonglong timer_now(void)
{
- return my_micro_time() / 1000;
+ return my_interval_timer() / 1000000;
}
diff --git a/client/readline.cc b/client/readline.cc
index 2a66fc6144b..4edccebef39 100644
--- a/client/readline.cc
+++ b/client/readline.cc
@@ -18,18 +18,28 @@
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
+#include <my_dir.h>
#include "my_readline.h"
static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
ulong max_size);
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
static size_t fill_buffer(LINE_BUFFER *buffer);
-static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated);
+static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length);
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
{
LINE_BUFFER *line_buff;
+
+#ifndef __WIN__
+ MY_STAT input_file_stat;
+ if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) ||
+ MY_S_ISDIR(input_file_stat.st_mode) ||
+ MY_S_ISBLK(input_file_stat.st_mode))
+ return 0;
+#endif
+
if (!(line_buff=(LINE_BUFFER*)
my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
return 0;
@@ -42,14 +52,13 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
}
-char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
+char *batch_readline(LINE_BUFFER *line_buff)
{
char *pos;
ulong out_length;
- DBUG_ASSERT(truncated != NULL);
LINT_INIT(out_length);
- if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
+ if (!(pos=intern_read_line(line_buff, &out_length)))
return 0;
if (out_length && pos[out_length-1] == '\n')
if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */
@@ -163,7 +172,10 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
buffer->bufread+1,
MYF(MY_WME | MY_FAE))))
- return (uint) -1;
+ {
+ buffer->error= my_errno;
+ return (size_t) -1;
+ }
buffer->start_of_line=buffer->buffer+start_offset;
buffer->end=buffer->buffer+bufbytes;
}
@@ -178,7 +190,10 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
/* Read in new stuff. */
if ((read_count= my_read(buffer->file, (uchar*) buffer->end, read_count,
MYF(MY_WME))) == MY_FILE_ERROR)
+ {
+ buffer->error= my_errno;
return (size_t) -1;
+ }
DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
@@ -199,8 +214,7 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
}
-
-char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
+char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length)
{
char *pos;
size_t length;
@@ -215,22 +229,25 @@ char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
if (pos == buffer->end)
{
/*
- fill_buffer() can return 0 either on EOF in which case we abort
- or when the internal buffer has hit the size limit. In the latter case
- return what we have read so far and signal string truncation.
+ fill_buffer() can return NULL on EOF (in which case we abort),
+ on error, or when the internal buffer has hit the size limit.
+ In the latter case return what we have read so far and signal
+ string truncation.
*/
- if (!(length=fill_buffer(buffer)) || length == (uint) -1)
+ if (!(length= fill_buffer(buffer)))
{
if (buffer->eof)
DBUG_RETURN(0);
}
+ else if (length == (size_t) -1)
+ DBUG_RETURN(NULL);
else
continue;
pos--; /* break line here */
- *truncated= 1;
+ buffer->truncated= 1;
}
else
- *truncated= 0;
+ buffer->truncated= 0;
buffer->end_of_line=pos+1;
*out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line);
DBUG_RETURN(buffer->start_of_line);
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 9fa8fae2860..315c8d786db 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -539,11 +539,11 @@ uint32 String::numchars()
return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
}
-int String::charpos(int i,uint32 offset)
+int String::charpos(longlong i,uint32 offset)
{
if (i <= 0)
- return i;
- return str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
+ return (int)i;
+ return (int)str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,(size_t)i);
}
int String::strstr(const String &s,uint32 offset)
diff --git a/client/sql_string.h b/client/sql_string.h
index a0f1f5b3a6c..f15df68b8a3 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -272,7 +272,7 @@ public:
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
uint32 numchars();
- int charpos(int i,uint32 offset=0);
+ int charpos(longlong i,uint32 offset=0);
int reserve(uint32 space_needed)
{
diff --git a/cmd-line-utils/libedit/vi.c b/cmd-line-utils/libedit/vi.c
index d18a518a10d..beffc7b40b5 100644
--- a/cmd-line-utils/libedit/vi.c
+++ b/cmd-line-utils/libedit/vi.c
@@ -1012,13 +1012,10 @@ vi_histedit(EditLine *el, int c __attribute__((__unused__)))
if (fd < 0)
return CC_ERROR;
cp = el->el_line.buffer;
- if (write(fd, cp, el->el_line.lastchar - cp +0u) == -1 ||
- write(fd, "\n", 1) == -1)
- {
- close(fd);
- unlink(tempfile);
- return CC_ERROR;
- }
+ if (write(fd, cp, el->el_line.lastchar - cp +0u) == -1)
+ goto error;
+ if (write(fd, "\n", 1) == -1)
+ goto error;
pid = fork();
switch (pid) {
case -1:
@@ -1046,6 +1043,12 @@ vi_histedit(EditLine *el, int c __attribute__((__unused__)))
unlink(tempfile);
/* return CC_REFRESH; */
return ed_newline(el, 0);
+
+/* XXXMYSQL: Avoid compiler warnings. */
+error:
+ close(fd);
+ unlink(tempfile);
+ return CC_ERROR;
}
/* vi_history_word():
diff --git a/configure.in b/configure.in
index 1eca0e23567..06ab18fd5d2 100644
--- a/configure.in
+++ b/configure.in
@@ -1962,6 +1962,15 @@ dnl
MYSQL_CHECK_TIME_T
+dnl
+dnl check size of time_t
+dnl
+
+AC_CHECK_SIZEOF(time_t, 8)
+if test "$ac_cv_sizeof_time_t" -eq 0
+then
+ AC_MSG_ERROR("MySQL needs a time_t type.")
+fi
# do we need #pragma interface/#pragma implementation ?
# yes if it's gcc 2.x, and not icc pretending to be gcc, and not cygwin
diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt
index 15194556a6b..adb357cf790 100755
--- a/extra/CMakeLists.txt
+++ b/extra/CMakeLists.txt
@@ -32,26 +32,26 @@ ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp
--charset=${PROJECT_SOURCE_DIR}/sql/share/charsets
--out-dir=${CMAKE_BINARY_DIR}/sql/share/
--header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp
- --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h
- --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h
+ --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h.tmp
+ --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h.tmp
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp ${CMAKE_BINARY_DIR}/include/mysqld_error.h
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/mysqld_ername.h.tmp ${CMAKE_BINARY_DIR}/include/mysqld_ername.h
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/sql_state.h.tmp ${CMAKE_BINARY_DIR}/include/sql_state.h
DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
ADD_CUSTOM_TARGET(GenError
ALL
DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp)
-ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
+MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32)
-ADD_EXECUTABLE(perror perror.c)
+MYSQL_ADD_EXECUTABLE(perror perror.c)
TARGET_LINK_LIBRARIES(perror strings mysys debug dbug wsock32)
-ADD_EXECUTABLE(resolveip resolveip.c)
+MYSQL_ADD_EXECUTABLE(resolveip resolveip.c)
TARGET_LINK_LIBRARIES(resolveip strings mysys debug dbug wsock32)
-ADD_EXECUTABLE(replace replace.c)
+MYSQL_ADD_EXECUTABLE(replace replace.c COMPONENT Server)
TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32)
-
-MYSQL_INSTALL_TARGETS(comp_err my_print_defaults perror resolveip replace DESTINATION bin COMPONENT Server)
diff --git a/extra/comp_err.c b/extra/comp_err.c
index adce6a6f5bd..24ec8974d03 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -34,6 +34,7 @@
#define HEADER_LENGTH 32 /* Length of header in errmsg.sys */
#define DEFAULT_CHARSET_DIR "../sql/share/charsets"
#define ER_PREFIX "ER_"
+#define ER_PREFIX2 "MARIA_ER_"
#define WARN_PREFIX "WARN_"
static char *OUTFILE= (char*) "errmsg.sys";
static char *HEADERFILE= (char*) "mysqld_error.h";
@@ -57,7 +58,7 @@ const char *empty_string= ""; /* For empty states */
*/
const char *default_language= "eng";
-int er_offset= 1000;
+uint er_offset= 1000;
my_bool info_flag= 0;
/* Storage of one error message row (for one language) */
@@ -85,7 +86,7 @@ struct languages
struct errors
{
const char *er_name; /* Name of the error (ER_HASHCK) */
- int d_code; /* Error code number */
+ uint d_code; /* Error code number */
const char *sql_code1; /* sql state */
const char *sql_code2; /* ODBC state */
struct errors *next_error; /* Pointer to next error */
@@ -127,6 +128,7 @@ static struct my_option my_long_options[]=
};
+static struct errors *generate_empty_message(uint dcode);
static struct languages *parse_charset_string(char *str);
static struct errors *parse_error_string(char *ptr, int er_count);
static struct message *parse_message_string(struct message *new_message,
@@ -203,6 +205,7 @@ static int create_header_files(struct errors *error_head)
uint er_last;
FILE *er_definef, *sql_statef, *er_namef;
struct errors *tmp_error;
+ uint current_d_code;
DBUG_ENTER("create_header_files");
LINT_INIT(er_last);
@@ -228,13 +231,22 @@ static int create_header_files(struct errors *error_head)
fprintf(er_definef, "#define ER_ERROR_FIRST %d\n", error_head->d_code);
+ current_d_code= error_head->d_code -1;
for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
{
/*
generating mysqld_error.h
fprintf() will automatically add \r on windows
*/
- fprintf(er_definef, "#define %s %d\n", tmp_error->er_name,
+
+ if (!tmp_error->er_name)
+ continue; /* Placeholder for gap */
+
+ if (tmp_error->d_code > current_d_code + 1)
+ fprintf(er_definef, "\n/* New section */\n\n");
+ current_d_code= tmp_error->d_code;
+
+ fprintf(er_definef, "#define %s %u\n", tmp_error->er_name,
tmp_error->d_code);
er_last= tmp_error->d_code;
@@ -403,7 +415,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
char *str, buff[1000];
struct errors *current_error= 0, **tail_error= top_error;
struct message current_message;
- int rcount= 0;
+ uint rcount= 0;
+ my_bool er_offset_found= 0;
DBUG_ENTER("parse_input_file");
*top_error= 0;
@@ -424,11 +437,32 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
}
if (is_prefix(str, "start-error-number"))
{
- if (!(er_offset= parse_error_offset(str)))
+ uint tmp_er_offset;
+ if (!(tmp_er_offset= parse_error_offset(str)))
{
fprintf(stderr, "Failed to parse the error offset string!\n");
DBUG_RETURN(0);
}
+ if (!er_offset_found)
+ {
+ er_offset_found= 1;
+ er_offset= tmp_er_offset;
+ }
+ else
+ {
+ /* Create empty error messages between er_offset and tmp_err_offset */
+ if (tmp_er_offset < er_offset + rcount)
+ {
+ fprintf(stderr, "new start-error-number %u is smaller than current error message: %u\n", tmp_er_offset, er_offset + rcount);
+ DBUG_RETURN(0);
+ }
+ for ( ; er_offset + rcount < tmp_er_offset ; rcount++)
+ {
+ current_error= generate_empty_message(er_offset + rcount);
+ *tail_error= current_error;
+ tail_error= &current_error->next_error;
+ }
+ }
continue;
}
if (is_prefix(str, "default-language"))
@@ -475,7 +509,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
DBUG_RETURN(0);
continue;
}
- if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX))
+ if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX) ||
+ is_prefix(str, ER_PREFIX2))
{
if (!(current_error= parse_error_string(str, rcount)))
{
@@ -490,12 +525,12 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
continue;
}
if (*str == '#' || *str == '\n')
- continue; /* skip comment or empty lines */
+ continue; /* skip comment or empty lines */
fprintf(stderr, "Wrong input file format. Stop!\nLine: %s\n", str);
DBUG_RETURN(0);
}
- *tail_error= 0; /* Mark end of list */
+ *tail_error= 0; /* Mark end of list */
my_fclose(file, MYF(0));
DBUG_RETURN(rcount);
@@ -604,7 +639,6 @@ static struct message *find_message(struct errors *err, const char *lang,
DBUG_RETURN(tmp);
if (!strcmp(tmp->lang_short_name, default_language))
{
- DBUG_ASSERT(tmp->text[0] != 0);
return_val= tmp;
}
}
@@ -824,6 +858,33 @@ static struct message *parse_message_string(struct message *new_message,
}
+static struct errors *generate_empty_message(uint d_code)
+{
+ struct errors *new_error;
+ struct message message;
+
+ /* create a new element */
+ if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
+ MYF(MY_WME))))
+ return(0);
+ if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1))
+ return(0); /* OOM: Fatal error */
+
+ new_error->er_name= NULL;
+ new_error->d_code= d_code;
+ new_error->sql_code1= empty_string;
+ new_error->sql_code2= empty_string;
+
+ if (!(message.lang_short_name= my_strdup(default_language, MYF(MY_WME))) ||
+ !(message.text= my_strdup("", MYF(MY_WME))))
+ return(0);
+
+ /* Can't fail as msg is preallocated */
+ (void) insert_dynamic(&new_error->msg, (uchar*) &message);
+ return(new_error);
+}
+
+
/*
Parsing the string with error name and codes; returns the pointer to
the errors struct
@@ -836,7 +897,9 @@ static struct errors *parse_error_string(char *str, int er_count)
DBUG_PRINT("enter", ("str: %s", str));
/* create a new element */
- new_error= (struct errors *) my_malloc(sizeof(*new_error), MYF(MY_WME));
+ if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
+ MYF(MY_WME))))
+ DBUG_RETURN(0);
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0))
DBUG_RETURN(0); /* OOM: Fatal error */
@@ -966,7 +1029,7 @@ static struct languages *parse_charset_string(char *str)
static void print_version(void)
{
DBUG_ENTER("print_version");
- printf("%s (Compile errormessage) Ver %s\n", my_progname, "2.0");
+ printf("%s (Compile errormessage) Ver %s\n", my_progname, "3.0");
DBUG_VOID_RETURN;
}
diff --git a/extra/perror.c b/extra/perror.c
index c32ad2bc791..5162f5e03dc 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -32,7 +32,6 @@ static my_bool verbose, print_all_codes;
#include "../include/my_base.h"
#include "../mysys/my_handler_errors.h"
-#include "../include/my_handler.h"
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
static my_bool ndb_code;
@@ -185,6 +184,36 @@ static const char *get_ha_error_msg(int code)
}
+/*
+ Register handler error messages for usage with my_error()
+
+ NOTES
+ This is safe to call multiple times as my_error_register()
+ will ignore calls to register already registered error numbers.
+*/
+void my_handler_error_register(void)
+{
+ /*
+ If you got compilation error here about compile_time_assert array, check
+ that every HA_ERR_xxx constant has a corresponding error message in
+ handler_error_messages[] list (check mysys/ma_handler_errors.h and
+ include/my_base.h).
+ */
+ compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
+ HA_ERR_LAST + 1);
+ my_error_register(handler_error_messages, HA_ERR_FIRST,
+ HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
+}
+
+
+void my_handler_error_unregister(void)
+{
+ my_error_unregister(HA_ERR_FIRST,
+ HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
+}
+
+
+
#if defined(__WIN__)
static my_bool print_win_error_msg(DWORD error, my_bool verbose)
{
diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp
index 8e4a9aa95ec..5af2f180bb1 100644
--- a/extra/yassl/src/yassl_int.cpp
+++ b/extra/yassl/src/yassl_int.cpp
@@ -308,7 +308,7 @@ SSL::SSL(SSL_CTX* ctx)
SetError(YasslError(err));
return;
}
- else if (serverSide) {
+ else if (serverSide && !(ctx->GetCiphers().setSuites_)) {
// remove RSA or DSA suites depending on cert key type
ProtocolVersion pv = secure_.get_connection().version_;
diff --git a/include/Makefile.am b/include/Makefile.am
index 3fbe349b9a4..99a21d686a3 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -30,6 +30,7 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
my_getopt.h sslopt-longopts.h my_dir.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
m_ctype.h my_attribute.h my_compiler.h \
+ my_decimal_limits.h ma_dyncol.h \
$(HEADERS_GEN_CONFIGURE) \
$(HEADERS_GEN_MAKE)
@@ -40,9 +41,11 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
- my_handler.h my_time.h service_versions.h \
+ service_versions.h \
+ my_compare.h my_handler.h my_time.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
- atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
+ atomic/rwlock.h atomic/x86-gcc.h \
+ atomic/generic-msvc.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
wqueue.h waiting_threads.h
diff --git a/include/config-win.h b/include/config-win.h
index b4958243abc..97b0891bcfb 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -201,6 +201,11 @@ typedef SSIZE_T ssize_t;
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_OFF_T 8
+/*
+ The size of time_t depends on the compiler.
+ But it's 8 for all the supported VC versions.
+*/
+#define SIZEOF_TIME_T 8
#ifdef _WIN64
#define SIZEOF_CHARP 8
#else
@@ -325,10 +330,9 @@ inline ulonglong double2ulonglong(double d)
#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */
#endif
-#ifdef NOT_USED
-#define HAVE_SNPRINTF /* Gave link error */
-#define _snprintf snprintf
-#endif
+
+#define HAVE_SNPRINTF
+#define snprintf _snprintf
#ifdef _MSC_VER
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
diff --git a/include/decimal.h b/include/decimal.h
index 530ed9e1757..aad9db9a1b8 100644
--- a/include/decimal.h
+++ b/include/decimal.h
@@ -29,17 +29,17 @@ typedef struct st_decimal_t {
int internal_str2dec(const char *from, decimal_t *to, char **end,
my_bool fixed);
-int decimal2string(decimal_t *from, char *to, int *to_len,
+int decimal2string(const decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler);
-int decimal2ulonglong(decimal_t *from, ulonglong *to);
+int decimal2ulonglong(const decimal_t *from, ulonglong *to);
int ulonglong2decimal(ulonglong from, decimal_t *to);
-int decimal2longlong(decimal_t *from, longlong *to);
+int decimal2longlong(const decimal_t *from, longlong *to);
int longlong2decimal(longlong from, decimal_t *to);
-int decimal2double(decimal_t *from, double *to);
+int decimal2double(const decimal_t *from, double *to);
int double2decimal(double from, decimal_t *to);
int decimal_actual_fraction(decimal_t *from);
-int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
+int decimal2bin(const decimal_t *from, uchar *to, int precision, int scale);
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
int decimal_size(int precision, int scale);
@@ -55,7 +55,7 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to,
int scale_incr);
int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to);
-int decimal_round(decimal_t *from, decimal_t *to, int new_scale,
+int decimal_round(const decimal_t *from, decimal_t *to, int new_scale,
decimal_round_mode mode);
int decimal_is_zero(decimal_t *from);
void max_decimal(int precision, int frac, decimal_t *to);
diff --git a/include/ft_global.h b/include/ft_global.h
index 4a4cf84b119..e16b77422d1 100644
--- a/include/ft_global.h
+++ b/include/ft_global.h
@@ -25,6 +25,8 @@
extern "C" {
#endif
+#include <my_compare.h>
+
#define HA_FT_MAXBYTELEN 254
#define HA_FT_MAXCHARLEN (HA_FT_MAXBYTELEN/3)
diff --git a/include/heap.h b/include/heap.h
index 74bec8079f2..62436ccd2aa 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -30,7 +30,7 @@ extern "C" {
#include <thr_lock.h>
#endif
-#include "my_handler.h"
+#include "my_compare.h"
#include "my_tree.h"
/* defines used by heap-funktions */
diff --git a/include/m_ctype.h b/include/m_ctype.h
index fa7b1f6f00c..696a1a83c7f 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -148,7 +148,8 @@ enum my_lex_states
MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
MY_LEX_IDENT_OR_KEYWORD,
MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
- MY_LEX_STRING_OR_DELIMITER
+ MY_LEX_STRING_OR_DELIMITER, MY_LEX_MINUS_OR_COMMENT, MY_LEX_PLACEHOLDER,
+ MY_LEX_COMMA
};
struct charset_info_st;
diff --git a/include/ma_dyncol.h b/include/ma_dyncol.h
new file mode 100644
index 00000000000..687823a4e73
--- /dev/null
+++ b/include/ma_dyncol.h
@@ -0,0 +1,147 @@
+/* Copyright (c) 2011, Monty Program Ab
+ Copyright (c) 2011, Oleksandr Byelkin
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
+
+#ifndef ma_dyncol_h
+#define ma_dyncol_h
+
+#include <decimal.h>
+#include <my_decimal_limits.h>
+#include <mysql_time.h>
+
+/*
+ Max length for data in a dynamic colums. This comes from how the
+ how the offset are stored.
+*/
+#define MAX_DYNAMIC_COLUMN_LENGTH 0X1FFFFFFFL
+
+/* NO and OK is the same used just to show semantics */
+#define ER_DYNCOL_NO ER_DYNCOL_OK
+
+enum enum_dyncol_func_result
+{
+ ER_DYNCOL_OK= 0,
+ ER_DYNCOL_YES= 1, /* For functions returning 0/1 */
+ ER_DYNCOL_FORMAT= -1, /* Wrong format of the encoded string */
+ ER_DYNCOL_LIMIT= -2, /* Some limit reached */
+ ER_DYNCOL_RESOURCE= -3, /* Out of resourses */
+ ER_DYNCOL_DATA= -4, /* Incorrect input data */
+ ER_DYNCOL_UNKNOWN_CHARSET= -5 /* Unknown character set */
+};
+
+typedef DYNAMIC_STRING DYNAMIC_COLUMN;
+
+enum enum_dynamic_column_type
+{
+ DYN_COL_NULL= 0,
+ DYN_COL_INT,
+ DYN_COL_UINT,
+ DYN_COL_DOUBLE,
+ DYN_COL_STRING,
+ DYN_COL_DECIMAL,
+ DYN_COL_DATETIME,
+ DYN_COL_DATE,
+ DYN_COL_TIME
+};
+
+typedef enum enum_dynamic_column_type DYNAMIC_COLUMN_TYPE;
+
+struct st_dynamic_column_value
+{
+ DYNAMIC_COLUMN_TYPE type;
+ union
+ {
+ long long long_value;
+ unsigned long long ulong_value;
+ double double_value;
+ struct {
+ LEX_STRING string_value;
+ CHARSET_INFO *charset;
+ };
+ struct {
+ decimal_digit_t decimal_buffer[DECIMAL_BUFF_LENGTH];
+ decimal_t decimal_value;
+ };
+ MYSQL_TIME time_value;
+ };
+};
+
+typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE;
+
+enum enum_dyncol_func_result
+dynamic_column_create(DYNAMIC_COLUMN *str,
+ uint column_nr, DYNAMIC_COLUMN_VALUE *value);
+
+enum enum_dyncol_func_result
+dynamic_column_create_many(DYNAMIC_COLUMN *str,
+ uint column_count,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values);
+
+enum enum_dyncol_func_result
+dynamic_column_update(DYNAMIC_COLUMN *org, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *value);
+enum enum_dyncol_func_result
+dynamic_column_update_many(DYNAMIC_COLUMN *str,
+ uint add_column_count,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values);
+
+enum enum_dyncol_func_result
+dynamic_column_delete(DYNAMIC_COLUMN *org, uint column_nr);
+
+enum enum_dyncol_func_result
+dynamic_column_exists(DYNAMIC_COLUMN *org, uint column_nr);
+
+/* List of not NULL columns */
+enum enum_dyncol_func_result
+dynamic_column_list(DYNAMIC_COLUMN *org, DYNAMIC_ARRAY *array_of_uint);
+
+/*
+ if the column do not exists it is NULL
+*/
+enum enum_dyncol_func_result
+dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *store_it_here);
+
+#define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A)))
+#define dynamic_column_column_free(V) dynstr_free(V)
+
+/***************************************************************************
+ Internal functions, don't use if you don't know what you are doing...
+***************************************************************************/
+
+#define dynamic_column_reassociate(V,P,L, A) dynstr_reassociate((V),(P),(L),(A))
+
+#define dynamic_column_value_init(V) (V)->type= DYN_COL_NULL
+
+/*
+ Prepare value for using as decimal
+*/
+void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value);
+
+#endif
diff --git a/include/maria.h b/include/maria.h
index 1896eb7ed60..470f76669f3 100644
--- a/include/maria.h
+++ b/include/maria.h
@@ -26,6 +26,7 @@ extern "C" {
#include <m_ctype.h>
#include "../storage/maria/ma_pagecache.h"
#include "my_handler.h"
+#include "my_compare.h"
#include "ft_global.h"
#include <myisamchk.h>
#include <mysql/plugin.h>
diff --git a/include/my_base.h b/include/my_base.h
index c17897670ba..0029d01d75e 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -446,7 +446,8 @@ enum ha_base_keytype {
#define HA_ERR_ROW_NOT_VISIBLE 177
#define HA_ERR_TOO_MANY_CONCURRENT_TRXS 178 /*Too many active concurrent transactions */
#define HA_ERR_ABORTED_BY_USER 179
-#define HA_ERR_LAST 179 /* Copy of last error nr */
+#define HA_ERR_DISK_FULL 180
+#define HA_ERR_LAST 180 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
diff --git a/include/my_bit.h b/include/my_bit.h
index 2e464e89049..266cfa8ff27 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -1,3 +1,19 @@
+/* Copyright (c) 2007, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
/*
Some useful bit functions
*/
@@ -42,9 +58,12 @@ STATIC_INLINE uint my_count_bits(ulonglong v)
#endif
}
-STATIC_INLINE uint my_count_bits_ushort(ushort v)
+STATIC_INLINE uint my_count_bits_uint32(uint32 v)
{
- return _my_bits_nbits[v];
+ return (uint) (uchar) (_my_bits_nbits[(uchar) v] +
+ _my_bits_nbits[(uchar) (v >> 8)] +
+ _my_bits_nbits[(uchar) (v >> 16)] +
+ _my_bits_nbits[(uchar) (v >> 24)]);
}
@@ -104,6 +123,6 @@ extern uint32 my_round_up_to_next_power(uint32 v);
uint32 my_clear_highest_bit(uint32 v);
uint32 my_reverse_bits(uint32 key);
extern uint my_count_bits(ulonglong v);
-extern uint my_count_bits_ushort(ushort v);
+extern uint my_count_bits_uint32(uint32 v);
#endif /* HAVE_INLINE */
C_MODE_END
diff --git a/include/my_bitmap.h b/include/my_bitmap.h
index 39ee1d2f7fc..09a2ff3fe65 100644
--- a/include/my_bitmap.h
+++ b/include/my_bitmap.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -151,9 +152,10 @@ bitmap_is_set(const MY_BITMAP *map,uint bit)
static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
{
- *(map1)->last_word_ptr|= (map1)->last_word_mask;
- *(map2)->last_word_ptr|= (map2)->last_word_mask;
- return memcmp((map1)->bitmap, (map2)->bitmap, 4*no_words_in_map((map1)))==0;
+ if (memcmp(map1->bitmap, map2->bitmap, 4*(no_words_in_map(map1)-1)) != 0)
+ return FALSE;
+ return ((*map1->last_word_ptr | map1->last_word_mask) ==
+ (*map2->last_word_ptr | map2->last_word_mask));
}
#define bitmap_clear_all(MAP) \
diff --git a/include/my_compare.h b/include/my_compare.h
new file mode 100644
index 00000000000..7e886d1e0dc
--- /dev/null
+++ b/include/my_compare.h
@@ -0,0 +1,121 @@
+/* Copyright (c) Monty Program Ab; 1991-2011
+ Copyright (C) 2002-2006 MySQL AB
+ Copyright (c) 2011, Oracle and/or its affiliates.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _my_compare_h
+#define _my_compare_h
+
+#include "myisampack.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct st_HA_KEYSEG /* Key-portion */
+{
+ CHARSET_INFO *charset;
+ uint32 start; /* Start of key in record */
+ uint32 null_pos; /* position to NULL indicator */
+ uint16 bit_pos; /* Position to bit part */
+ uint16 flag;
+ uint16 length; /* Keylength */
+ uint8 type; /* Type of key (for sort) */
+ uint8 language;
+ uint8 null_bit; /* bitmask to test for NULL */
+ uint8 bit_start,bit_end; /* if bit field */
+ uint8 bit_length; /* Length of bit part */
+} HA_KEYSEG;
+
+#define get_key_length(length,key) \
+{ if (*(const uchar*) (key) != 255) \
+ length= (uint) *(const uchar*) ((key)++); \
+ else \
+ { length= mi_uint2korr((key)+1); (key)+=3; } \
+}
+
+#define get_key_length_rdonly(length,key) \
+{ if (*(const uchar*) (key) != 255) \
+ length= ((uint) *(const uchar*) ((key))); \
+ else \
+ { length= mi_uint2korr((key)+1); } \
+}
+
+#define get_key_pack_length(length,length_pack,key) \
+{ if (*(const uchar*) (key) != 255) \
+ { length= (uint) *(const uchar*) ((key)++); length_pack= 1; }\
+ else \
+ { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
+}
+
+#define store_key_length_inc(key,length) \
+{ if ((length) < 255) \
+ { *(key)++= (length); } \
+ else \
+ { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
+}
+
+#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
+
+#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
+ (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
+ ((1 << (bit_len)) - 1))
+
+#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
+{ \
+ (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
+ ((bits) << (bit_ofs)); \
+ if ((bit_ofs) + (bit_len) > 8) \
+ (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
+ ((bits) >> (8 - (bit_ofs))); \
+}
+
+#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
+ set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
+
+extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint,
+ const uchar *, uint , my_bool, my_bool);
+extern int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a,
+ register const uchar *b, uint key_length,
+ uint32 nextflag, uint *diff_pos);
+extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a);
+
+/**
+ Return values of index_cond_func_xxx functions.
+
+ 0=ICP_NO_MATCH - index tuple doesn't satisfy the pushed index condition (the
+ engine should discard the tuple and go to the next one)
+ 1=ICP_MATCH - index tuple satisfies the pushed index condition (the
+ engine should fetch and return the record)
+ 2=ICP_OUT_OF_RANGE - index tuple is out range that we're scanning, e.g. this
+ if we're scanning "t.key BETWEEN 10 AND 20" and got a
+ "t.key=21" tuple (the engine should stop scanning and
+ return HA_ERR_END_OF_FILE right away).
+ -1= ICP_ERROR - Reserved for internal errors in engines. Should not be
+ returned by index_cond_func_xxx
+*/
+
+typedef enum icp_result {
+ ICP_ERROR=-1,
+ ICP_NO_MATCH=0,
+ ICP_MATCH=1,
+ ICP_OUT_OF_RANGE=2
+} ICP_RESULT;
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _my_compare_h */
diff --git a/include/my_decimal_limits.h b/include/my_decimal_limits.h
new file mode 100644
index 00000000000..d9dabe92373
--- /dev/null
+++ b/include/my_decimal_limits.h
@@ -0,0 +1,31 @@
+#ifndef my_decimal_limits_h
+#define my_decimal_limits_h
+
+#define DECIMAL_LONGLONG_DIGITS 22
+#define DECIMAL_LONG_DIGITS 10
+#define DECIMAL_LONG3_DIGITS 8
+
+/** maximum length of buffer in our big digits (uint32). */
+#define DECIMAL_BUFF_LENGTH 9
+
+/* the number of digits that my_decimal can possibly contain */
+#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
+
+
+/**
+ maximum guaranteed precision of number in decimal digits (number of our
+ digits * number of decimal digits in one our big digit - number of decimal
+ digits in one our big digit decreased by 1 (because we always put decimal
+ point on the border of our big digits))
+*/
+#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
+#define DECIMAL_MAX_SCALE 30
+#define DECIMAL_NOT_SPECIFIED 31
+
+/**
+ maximum length of string representation (number of maximum decimal
+ digits + 1 position for sign + 1 position for decimal point)
+*/
+#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
+
+#endif
diff --git a/include/my_global.h b/include/my_global.h
index 8b71410dbf0..1fa3f750b44 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -854,10 +854,10 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define strtok_r(A,B,C) strtok((A),(B))
#endif
-/* This is from the old m-machine.h file */
-
-#if SIZEOF_LONG_LONG > 4
+#if SIZEOF_LONG_LONG >= 8
#define HAVE_LONG_LONG 1
+#else
+#error WHAT? sizeof(long long) < 8 ???
#endif
/*
diff --git a/include/my_handler.h b/include/my_handler.h
index 5fc0565538d..ca324c5b881 100644
--- a/include/my_handler.h
+++ b/include/my_handler.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2006 MySQL AB
+/* Copyright (c) Monty Program Ab; 1991-2011
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -18,12 +18,6 @@
#ifndef _my_handler_h
#define _my_handler_h
-#include "myisampack.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
There is a hard limit for the maximum number of keys as there are only
8 bits in the index file header for the number of keys in a table.
@@ -47,76 +41,6 @@ extern "C" {
#define HA_MAX_KEY_BUFF (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
#define HA_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */
-typedef struct st_HA_KEYSEG /* Key-portion */
-{
- CHARSET_INFO *charset;
- uint32 start; /* Start of key in record */
- uint32 null_pos; /* position to NULL indicator */
- uint16 bit_pos; /* Position to bit part */
- uint16 flag;
- uint16 length; /* Keylength */
- uint8 type; /* Type of key (for sort) */
- uint8 language;
- uint8 null_bit; /* bitmask to test for NULL */
- uint8 bit_start,bit_end; /* if bit field */
- uint8 bit_length; /* Length of bit part */
-} HA_KEYSEG;
-
-#define get_key_length(length,key) \
-{ if (*(const uchar*) (key) != 255) \
- length= (uint) *(const uchar*) ((key)++); \
- else \
- { length= mi_uint2korr((key)+1); (key)+=3; } \
-}
-
-#define get_key_length_rdonly(length,key) \
-{ if (*(const uchar*) (key) != 255) \
- length= ((uint) *(const uchar*) ((key))); \
- else \
- { length= mi_uint2korr((key)+1); } \
-}
-
-#define get_key_pack_length(length,length_pack,key) \
-{ if (*(const uchar*) (key) != 255) \
- { length= (uint) *(const uchar*) ((key)++); length_pack= 1; }\
- else \
- { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
-}
-
-#define store_key_length_inc(key,length) \
-{ if ((length) < 255) \
- { *(key)++= (length); } \
- else \
- { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
-}
-
-#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
-
-#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
- (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
- ((1 << (bit_len)) - 1))
-
-#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
-{ \
- (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
- ((bits) << (bit_ofs)); \
- if ((bit_ofs) + (bit_len) > 8) \
- (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
- ((bits) >> (8 - (bit_ofs))); \
-}
-
-#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
- set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
-
-extern int ha_compare_text(CHARSET_INFO *, const uchar *, uint,
- const uchar *, uint , my_bool, my_bool);
-extern int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a,
- register const uchar *b, uint key_length,
- uint32 nextflag, uint *diff_pos);
-
-extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a);
-extern void my_handler_error_register(void);
-extern void my_handler_error_unregister(void);
/*
Inside an in-memory data record, memory pointers to pieces of the
record (like BLOBs) are stored in their native byte order and in
@@ -124,32 +48,9 @@ extern void my_handler_error_unregister(void);
*/
#define portable_sizeof_char_ptr 8
-/**
- Return values of index_cond_func_xxx functions.
-
- 0=ICP_NO_MATCH - index tuple doesn't satisfy the pushed index condition (the
- engine should discard the tuple and go to the next one)
- 1=ICP_MATCH - index tuple satisfies the pushed index condition (the engine
- should fetch and return the record)
- 2=ICP_OUT_OF_RANGE - index tuple is out range that we're scanning, e.g. this
- if we're scanning "t.key BETWEEN 10 AND 20" and got a
- "t.key=21" tuple (the engine should stop scanning and return
- HA_ERR_END_OF_FILE right away).
-
- -1= ICP_ERROR - Reserved for internal errors in engines. Should not be
- returned by index_cond_func_xxx
-*/
-
-typedef enum icp_result {
- ICP_ERROR=-1,
- ICP_NO_MATCH=0,
- ICP_MATCH=1,
- ICP_OUT_OF_RANGE=2
-} ICP_RESULT;
-
+/* Register / unregister errors for my_error() */
-#ifdef __cplusplus
-}
-#endif
+extern void my_handler_error_register(void);
+extern void my_handler_error_unregister(void);
#endif /* _my_handler_h */
diff --git a/include/my_pthread.h b/include/my_pthread.h
index fffb883912a..139e5d08437 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -75,37 +75,11 @@ typedef volatile LONG my_pthread_once_t;
#define MY_PTHREAD_ONCE_INPROGRESS 1
#define MY_PTHREAD_ONCE_DONE 2
-/*
- Struct and macros to be used in combination with the
- windows implementation of pthread_cond_timedwait
-*/
-
-/*
- Declare a union to make sure FILETIME is properly aligned
- so it can be used directly as a 64 bit value. The value
- stored is in 100ns units.
- */
-union ft64 {
- FILETIME ft;
- __int64 i64;
-};
-
struct timespec {
- union ft64 tv;
- /* The max timeout value in millisecond for pthread_cond_timedwait */
- long max_timeout_msec;
+ time_t tv_sec;
+ long tv_nsec;
};
-#define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \
- (ABSTIME).tv.i64= (TIME)+(__int64)(NSEC)/100; \
- (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
-} while(0)
-
-#define set_timespec_nsec(ABSTIME,NSEC) do { \
- union ft64 tv; \
- GetSystemTimeAsFileTime(&tv.ft); \
- set_timespec_time_nsec((ABSTIME), tv.i64, (NSEC)); \
-} while(0)
void win_pthread_init(void);
int win_pthread_setspecific(void *A,void *B,uint length);
@@ -442,7 +416,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#ifndef set_timespec_nsec
#define set_timespec_nsec(ABSTIME,NSEC) \
- set_timespec_time_nsec((ABSTIME),my_getsystime(),(NSEC))
+ set_timespec_time_nsec((ABSTIME), my_hrtime().val*1000 + (NSEC))
#endif /* !set_timespec_nsec */
/* adapt for two different flavors of struct timespec */
@@ -455,11 +429,10 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif /* HAVE_TIMESPEC_TS_SEC */
#ifndef set_timespec_time_nsec
-#define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \
- ulonglong nsec= (NSEC); \
- ulonglong now= (TIME) + (nsec/100); \
- (ABSTIME).MY_tv_sec= (now / ULL(10000000)); \
- (ABSTIME).MY_tv_nsec= (now % ULL(10000000) * 100 + (nsec % 100)); \
+#define set_timespec_time_nsec(ABSTIME,NSEC) do { \
+ ulonglong now= (NSEC); \
+ (ABSTIME).MY_tv_sec= (now / 1000000000ULL); \
+ (ABSTIME).MY_tv_nsec= (now % 1000000000ULL); \
} while(0)
#endif /* !set_timespec_time_nsec */
diff --git a/include/my_sys.h b/include/my_sys.h
index 65455990b04..41e04265946 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -863,6 +863,8 @@ extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
extern void dynstr_free(DYNAMIC_STRING *str);
+extern void dynstr_reassociate(DYNAMIC_STRING *str, char **res, size_t *length,
+ size_t *alloc_length);
#ifdef HAVE_MLOCK
extern void *my_malloc_lock(size_t length,myf flags);
extern void my_free_lock(void *ptr,myf flags);
@@ -929,15 +931,23 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);
-extern time_t my_time(myf flags);
-extern ulonglong my_getsystime(void);
-extern ulonglong my_getcputime(void);
-extern ulonglong my_micro_time();
-extern ulonglong my_micro_time_and_time(time_t *time_arg);
-time_t my_time_possible_from_micro(ulonglong microtime);
extern my_bool my_gethwaddr(uchar *to);
extern int my_getncpus();
+#define HRTIME_RESOLUTION 1000000ULL /* microseconds */
+typedef struct {ulonglong val;} my_hrtime_t;
+void my_time_init();
+extern my_hrtime_t my_hrtime();
+extern ulonglong my_interval_timer(void);
+extern ulonglong my_getcputime(void);
+
+#define microsecond_interval_timer() (my_interval_timer()/1000)
+#define hrtime_to_time(X) ((X).val/HRTIME_RESOLUTION)
+#define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION))
+#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
+#define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION))
+#define my_time(X) hrtime_to_time(my_hrtime())
+
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
diff --git a/include/my_time.h b/include/my_time.h
index 58995f1bf62..c71ac4ace17 100644
--- a/include/my_time.h
+++ b/include/my_time.h
@@ -47,14 +47,28 @@ typedef long my_time_t;
#define TIMESTAMP_MAX_YEAR 2038
#define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
#define TIMESTAMP_MAX_VALUE INT_MAX32
-#define TIMESTAMP_MIN_VALUE 1
+#define TIMESTAMP_MIN_VALUE 0
/* two-digit years < this are 20..; >= this are 19.. */
#define YY_PART_YEAR 70
+/*
+ check for valid times only if the range of time_t is greater than
+ the range of my_time_t
+*/
+#if SIZEOF_TIME_T > 4 || defined(TIME_T_UNSIGNED)
+# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \
+ ((x) <= TIMESTAMP_MAX_VALUE && \
+ (x) >= TIMESTAMP_MIN_VALUE)
+#else
+# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \
+ ((x) >= TIMESTAMP_MIN_VALUE)
+#endif
+
/* Flags to str_to_datetime */
#define TIME_FUZZY_DATE 1
#define TIME_DATETIME_ONLY 2
+#define TIME_TIME_ONLY 4
/* Must be same as MODE_NO_ZERO_IN_DATE */
#define TIME_NO_ZERO_IN_DATE (65536L*2*2*2*2*2*2*2)
/* Must be same as MODE_NO_ZERO_DATE */
@@ -68,28 +82,46 @@ typedef long my_time_t;
#define TIME_MAX_HOUR 838
#define TIME_MAX_MINUTE 59
#define TIME_MAX_SECOND 59
-#define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + \
- TIME_MAX_SECOND)
+#define TIME_MAX_SECOND_PART 999999
+#define TIME_SECOND_PART_FACTOR (TIME_MAX_SECOND_PART+1)
+#define TIME_SECOND_PART_DIGITS 6
+#define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + TIME_MAX_SECOND)
#define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \
TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND)
my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
ulong flags, int *was_cut);
enum enum_mysql_timestamp_type
+str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
+ ulong flag, int *warning);
+enum enum_mysql_timestamp_type
str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
- uint flags, int *was_cut);
-longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
+ ulong flags, int *was_cut);
+longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res,
uint flags, int *was_cut);
+
+static inline
+longlong double_to_datetime(double nr, MYSQL_TIME *ltime, uint flags, int *cut)
+{
+ if (nr < 0 || nr > LONGLONG_MAX)
+ nr= (double)LONGLONG_MAX;
+ return number_to_datetime((longlong) floor(nr),
+ (ulong)((nr-floor(nr))*TIME_SECOND_PART_FACTOR),
+ ltime, flags, cut);
+}
+
+int number_to_time(my_bool neg, longlong nr, ulong sec_part,
+ MYSQL_TIME *ltime, int *was_cut);
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *);
ulonglong TIME_to_ulonglong(const MYSQL_TIME *);
+double TIME_to_double(const MYSQL_TIME *my_time);
+longlong pack_time(MYSQL_TIME *my_time);
+MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time);
-my_bool str_to_time(const char *str,uint length, MYSQL_TIME *l_time,
- int *warning);
-
-int check_time_range(struct st_mysql_time *, int *warning);
+int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning);
long calc_daynr(uint year,uint month,uint day);
uint calc_days_in_year(uint year);
@@ -122,8 +154,7 @@ static inline my_bool validate_timestamp_range(const MYSQL_TIME *t)
}
my_time_t
-my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone,
- my_bool *in_dst_time_gap);
+my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, uint *error_code);
void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type);
@@ -136,11 +167,28 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type);
sent using binary protocol fit in this buffer.
*/
#define MAX_DATE_STRING_REP_LENGTH 30
+#define AUTO_SEC_PART_DIGITS 31 /* same as NOT_FIXED_DEC */
-int my_time_to_str(const MYSQL_TIME *l_time, char *to);
+int my_time_to_str(const MYSQL_TIME *l_time, char *to, uint digits);
int my_date_to_str(const MYSQL_TIME *l_time, char *to);
-int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
-int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
+int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits);
+int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits);
+
+static inline longlong sec_part_shift(longlong second_part, uint digits)
+{
+ return second_part / (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
+}
+static inline longlong sec_part_unshift(longlong second_part, uint digits)
+{
+ return second_part * (longlong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
+}
+static inline ulong sec_part_truncate(ulong second_part, uint digits)
+{
+ /* the cast here should be unnecessary! */
+ return second_part - second_part % (ulong)log_10_int[TIME_SECOND_PART_DIGITS - digits];
+}
+
+#define hrtime_to_my_time(X) ((my_time_t)hrtime_to_time(X))
/*
Available interval types used in any statement.
diff --git a/include/myisam.h b/include/myisam.h
index bf31a96b792..9fc17fdf2d6 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -31,6 +31,7 @@ extern "C" {
#include "keycache.h"
#endif
#include "my_handler.h"
+#include "my_compare.h"
#include <myisamchk.h>
#include <mysql/plugin.h>
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index f9f38b67f96..7b29c1f2ce9 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -100,7 +100,8 @@ int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
struct my_rnd_struct;
enum Item_result
{
- STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT
+ STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT,
+ TIME_RESULT
};
typedef struct st_udf_args
{
diff --git a/include/mysql_com.h b/include/mysql_com.h
index c85014a662b..96d9afce5e6 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -447,7 +447,8 @@ struct my_rnd_struct;
enum Item_result
{
- STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT
+ STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT,
+ TIME_RESULT
#ifdef MYSQL_SERVER
,IMPOSSIBLE_RESULT /* Yes, we know this is ugly, don't tell us */
#endif
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 0d4f6f399af..4589d1c86af 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -68,6 +68,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c
../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c
../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
+ ../strings/decimal.c
../mysys/default.c errmsg.c ../mysys/errors.c ../mysys/my_sync.c
../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c
get_password.c ../strings/int2str.c ../strings/is_prefix.c
@@ -79,12 +80,13 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c
../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c
../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c
- ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c
+ ../mysys/my_fopen.c ../mysys/my_fstream.c
../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c
../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c
../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c
../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c
../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c
+ ../mysys/ma_dyncol.c
../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c
../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c
../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c
@@ -110,18 +112,16 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES})
ADD_DEPENDENCIES(mysqlclient GenError)
-TARGET_LINK_LIBRARIES(mysqlclient)
-ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES})
-ADD_DEPENDENCIES(mysqlclient_notls GenError)
-TARGET_LINK_LIBRARIES(mysqlclient_notls)
+SET(SHARED_SOURCES dll.c libmysql.def)
+ADD_VERSION_INFO(libmysql SHARED SHARED_SOURCES)
+ADD_LIBRARY(libmysql SHARED ${SHARED_SOURCES})
-ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def)
IF(WIN32)
SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS")
ENDIF(WIN32)
ADD_DEPENDENCIES(libmysql GenError)
-TARGET_LINK_LIBRARIES(libmysql wsock32)
+TARGET_LINK_LIBRARIES(libmysql mysqlclient ws2_32)
ADD_DEFINITIONS(-DHAVE_DLOPEN)
MYSQL_INSTALL_TARGETS(mysqlclient DESTINATION lib COMPONENT Development)
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 41590815bcb..4f20379146f 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -48,7 +48,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
ctype-ucs2.lo ctype-gb2312.lo ctype-gbk.lo \
ctype-sjis.lo ctype-tis620.lo ctype-ujis.lo \
ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo \
- strmov_overlapp.lo
+ strmov_overlapp.lo decimal.lo
mystringsextra= strto.c
mystringsheaders= strings_def.h
@@ -65,12 +65,12 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \
thr_mutex.lo mulalloc.lo string.lo \
- default.lo default_modify.lo \
+ default.lo default_modify.lo ma_dyncol.lo \
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
charset.lo charset-def.lo hash.lo mf_iocache.lo \
mf_iocache2.lo my_seek.lo my_sleep.lo \
my_pread.lo mf_cache.lo md5.lo sha1.lo my_rnd.lo \
- my_getopt.lo my_gethostbyname.lo my_port.lo \
+ my_getopt.lo my_port.lo \
my_rename.lo my_chsize.lo my_sync.lo my_getsystime.lo
sqlobjects = net.lo
sql_cmn_objects = pack.lo client.lo my_time.lo client_plugin.lo
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 51ddc0ec951..c68bc4ad2ce 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3549,7 +3549,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
case MYSQL_TYPE_TIME:
{
MYSQL_TIME *tm= (MYSQL_TIME *)buffer;
- str_to_time(value, length, tm, &err);
+ str_to_time(value, length, tm, TIME_FUZZY_DATE, &err);
*param->error= test(err);
break;
}
@@ -3681,7 +3681,8 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
case MYSQL_TYPE_DATETIME:
{
int error;
- value= number_to_datetime(value, (MYSQL_TIME *) buffer, TIME_FUZZY_DATE,
+ value= number_to_datetime(value, 0,
+ (MYSQL_TIME *) buffer, TIME_FUZZY_DATE,
&error);
*param->error= test(error);
break;
@@ -3904,7 +3905,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param,
fetch_string_with_conversion:
*/
char buff[MAX_DATE_STRING_REP_LENGTH];
- uint length= my_TIME_to_str(my_time, buff);
+ uint length= my_TIME_to_str(my_time, buff, field->decimals);
/* Resort to string conversion */
fetch_string_with_conversion(param, (char *)buff, length);
break;
@@ -4381,7 +4382,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
field->max_length= MAX_DOUBLE_STRING_REP_LENGTH;
break;
case MYSQL_TYPE_TIME:
- field->max_length= 15; /* 19:23:48.123456 */
+ field->max_length= 17; /* -819:23:48.123456 */
param->skip_result= skip_result_with_length;
break;
case MYSQL_TYPE_DATE:
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index c5662993072..545f48627c2 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -144,7 +144,8 @@ SET(LIBMYSQLD_SOURCES libmysqld.c emb_qcache.cc lib_sql.cc
../sql/multi_range_read.cc
../sql/opt_index_cond_pushdown.cc
../sql/opt_subselect.cc
- ../sql/create_options.cc
+ ../sql/create_options.cc ../sql/rpl_utility.cc
+ ../sql/rpl_reporting.cc
../sql/sql_expression_cache.cc
${GEN_SOURCES}
${LIB_SOURCES})
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index e54082b84a8..f47d4f85415 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -55,7 +55,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
item_geofunc.cc item_subselect.cc item_row.cc\
item_xmlfunc.cc \
key.cc lock.cc log.cc sql_state.c \
- log_event.cc rpl_record.cc \
+ log_event.cc rpl_record.cc rpl_utility.cc rpl_reporting.cc \
log_event_old.cc rpl_record_old.cc \
protocol.cc net_serv.cc opt_range.cc \
opt_subselect.cc \
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index ecf668490e6..627f67cf170 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -46,6 +46,7 @@ extern "C" void unireg_clear(int exit_code)
{
DBUG_ENTER("unireg_clear");
clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
+ clean_up_mutexes();
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
DBUG_VOID_RETURN;
}
@@ -574,6 +575,7 @@ void end_embedded_server()
my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR));
copy_arguments_ptr=0;
clean_up(0);
+ clean_up_mutexes();
}
diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def
index 754aa6b3c29..08325cc6180 100644
--- a/libmysqld/libmysqld.def
+++ b/libmysqld/libmysqld.def
@@ -1,5 +1,4 @@
LIBRARY LIBMYSQLD
-DESCRIPTION 'MySQL 5.1 Embedded Server Library'
VERSION 5.1
EXPORTS
mysql_thread_end
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index d3b41cfcb5f..664d69f1a93 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2000-2006 MySQL AB
+# Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2009-2011, Monty Program Ab
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -10,10 +11,9 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-# MA 02111-1307, USA
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## Process this file with automake to create Makefile.in
@@ -84,7 +84,6 @@ TEST_DIRS = t r include std_data std_data/parts collections \
std_data/funcs_1 \
extra/binlog_tests/ extra/rpl_tests \
suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
- suite/bugs suite/bugs/data suite/bugs/t suite/bugs/r \
suite/federated \
suite/pbxt/t suite/pbxt/r suite/pbxt \
suite/vcol suite/vcol/t suite/vcol/r suite/vcol/inc \
diff --git a/mysql-test/collections/README.experimental b/mysql-test/collections/README.experimental
index 2f5ee7b00ab..924e062b76a 100644
--- a/mysql-test/collections/README.experimental
+++ b/mysql-test/collections/README.experimental
@@ -15,9 +15,13 @@ The syntax is as follows:
and any subsequent characters are ignored.
4) The full test case name including the suite and execution mode
- must be specified, for example:
+ may be specified, for example:
main.alias 'row' # bug#00000
+4b) Now, combinations will also be covered if only the test name is
+ specified, for example:
+ rpl.rpl_ps # Covers 'row', 'mix' and 'stmt'
+
5) As an exception to item 4, the last character of the test case
specification may be an asterisk (*). In that case, all test cases that
start with the same characters up to the last letter before the asterisk
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index aa2f2e9f724..fb8c6845a5f 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -2,6 +2,8 @@
# in alphabetical order. This also helps with merge conflict resolution.
binlog.binlog_multi_engine # joro : NDB tests marked as experimental as agreed with bochklin
+binlog.binlog_bug23533 # skozlov: BUG#12371924
+
funcs_1.charset_collation_1 # depends on compile-time decisions
funcs_1.is_cml_ndb # joro : NDB tests marked as experimental as agreed with bochklin
@@ -21,8 +23,9 @@ main.outfile_loaddata @solaris # joro : Bug #46895
ndb.* # joro : NDB tests marked as experimental as agreed with bochklin
-rpl.rpl_innodb_bug28430* @solaris # Bug#46029
-rpl.rpl_row_sp011 @solaris # Joro : Bug #54138
+rpl.rpl_innodb_bug28430 @solaris # Bug#46029
+rpl.rpl_row_sp011 @solaris # Joro : Bug #45445
+rpl.rpl_stop_slave # Sven : BUG#12345981
rpl_ndb.* # joro : NDB tests marked as experimental as agreed with bochklin
rpl_ndb.rpl_ndb_log # Bug#38998
diff --git a/mysql-test/collections/default.weekly b/mysql-test/collections/default.weekly
index f10bc0776a0..a2765bcaf0c 100755
--- a/mysql-test/collections/default.weekly
+++ b/mysql-test/collections/default.weekly
@@ -1,4 +1,3 @@
-perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st
perl mysql-test-run.pl --timer --force --comment=big-tests --experimental=collections/default.experimental --vardir=var-big-tests --big-test --testcase-timeout=60 --suite-timeout=600 parts.partition_alter1_2_ndb parts.part_supported_sql_func_innodb parts.partition_alter1_2_innodb parts.partition_alter4_innodb parts.partition_alter1_1_2_ndb parts.partition_alter1_1_2_innodb parts.partition_alter1_1_ndb rpl_ndb.rpl_truncate_7ndb_2 main.archive-big main.sum_distinct-big main.mysqlbinlog_row_big main.alter_table-big main.variables-big main.type_newdecimal-big main.read_many_rows_innodb main.log_tables-big main.count_distinct3 main.events_time_zone main.merge-big main.create-big main.events_stress main.ssl-big funcs_1.myisam_views-big
perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-stmt-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam
perl mysql-test-run.pl --timer --force --parallel=auto --comment=eits-rpl-binlog-row-tests-myisam-engine --experimental=collections/default.experimental --vardir=var-binlog-row-eits-tests-myisam-engine --suite=engines/iuds,engines/funcs --suite-timeout=500 --max-test-fail=0 --retry-failure=0 --mysqld=--default-storage-engine=myisam --do-test=rpl --mysqld=--binlog-format=row
diff --git a/mysql-test/collections/mysql-5.1-bugteam.daily b/mysql-test/collections/mysql-5.1-bugteam.daily
deleted file mode 100644
index 0503bd49f73..00000000000
--- a/mysql-test/collections/mysql-5.1-bugteam.daily
+++ /dev/null
@@ -1,5 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed --embedded --experimental=collections/default.experimental
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_binlog_row --vardir=var-rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 --experimental=collections/default.experimental
diff --git a/mysql-test/collections/mysql-5.1-bugteam.push b/mysql-test/collections/mysql-5.1-bugteam.push
deleted file mode 100644
index d01b98eb87f..00000000000
--- a/mysql-test/collections/mysql-5.1-bugteam.push
+++ /dev/null
@@ -1,4 +0,0 @@
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --suite=main --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed --suite=main --embedded --experimental=collections/default.experimental --skip-ndb
-perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1 --experimental=collections/default.experimental --skip-ndb
diff --git a/mysql-test/collections/mysql-next-mr-wl2540.push b/mysql-test/collections/mysql-next-mr-wl2540.push
new file mode 100644
index 00000000000..2eb41427687
--- /dev/null
+++ b/mysql-test/collections/mysql-next-mr-wl2540.push
@@ -0,0 +1,6 @@
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum --mysqld=--binlog-checksum=CRC32 --vardir=var-rpl_binlog_checksum --suite=binlog,rpl --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded --vardir=var-emebbed --embedded --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row --mysqld=--binlog-format=row --suite=rpl,binlog --skip-test-list=collections/disabled-per-push.list
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1
diff --git a/mysql-test/collections/mysql-trunk.daily b/mysql-test/collections/mysql-trunk.daily
new file mode 100644
index 00000000000..47d189a2c65
--- /dev/null
+++ b/mysql-test/collections/mysql-trunk.daily
@@ -0,0 +1,7 @@
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded --vardir=var-emebbed --embedded
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1 --vardir=var-funcs_1 --suite=funcs_1
+perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_ndb_row --vardir=var-rpl_ndb_row --mysqld=--binlog-format=row --suite=rpl_ndb,ndb
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row --mysqld=--binlog-format=row --suite=rpl,binlog --skip-ndb
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_checksum --mysqld=--binlog-checksum=CRC32 --vardir=var-rpl_binlog_checksum --suite=binlog,rpl
diff --git a/mysql-test/collections/mysql-trunk.weekly b/mysql-test/collections/mysql-trunk.weekly
new file mode 100644
index 00000000000..7186ad422b0
--- /dev/null
+++ b/mysql-test/collections/mysql-trunk.weekly
@@ -0,0 +1,2 @@
+perl mysql-test-run.pl --timer --force --comment=1st --experimental=collections/default.experimental 1st
+perl mysql-test-run.pl --timer --force --comment=all_binlog_checksum --experimental=collections/default.experimental --mysqld=--binlog-checksum=CRC32 --vardir=var-all_binlog_checksum --suite=main,binlog,innodb,federated,rpl,sys_vars,perfschema
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index fd6ba1c17fa..a5011a1231d 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -83,17 +83,22 @@ set @bcs = @@binlog_cache_size;
set global binlog_cache_size=4096;
reset master;
-create table t1 (a int) engine=innodb;
+create table t1 (a int, b char(255)) engine=innodb;
+
+flush status;
+show status like "binlog_cache_use";
-let $1=400;
+let $1=100;
disable_query_log;
begin;
while ($1)
{
- eval insert into t1 values( $1 );
+ eval insert into t1 values( $1, 'just to fill void to make transaction occupying at least two buffers of the trans cache' );
dec $1;
}
commit;
+--echo *** the following must show the counter value = 1 ***
+show status like "binlog_cache_use";
enable_query_log;
--source include/show_binlog_events.inc
@@ -343,6 +348,7 @@ SHOW SESSION VARIABLES LIKE "%_checks";
--echo # INSERT INTO t1 VALUES(2)
--echo # foreign_key_checks=1 and unique_checks=1
--echo # It should not change current session's variables, even error happens
+call mtr.add_suppression("Slave SQL.*Could not execute Write_rows event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
--error 1062
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
index 96c85e024e9..c7e7a491ce1 100644
--- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
+++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
@@ -311,6 +311,7 @@ select get_lock("a",10);
begin;
insert into t1 values(8);
insert into t2 select * from t1;
+
disconnect con3;
connection con4;
diff --git a/mysql-test/extra/rpl_tests/rpl_conflicts.test b/mysql-test/extra/rpl_tests/rpl_conflicts.test
index 943d254736d..866a31e92b0 100644
--- a/mysql-test/extra/rpl_tests/rpl_conflicts.test
+++ b/mysql-test/extra/rpl_tests/rpl_conflicts.test
@@ -93,6 +93,7 @@ if (`SELECT @@global.binlog_format != 'ROW' OR @@global.slave_exec_mode = 'STRIC
source include/wait_for_slave_sql_error.inc;
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
--echo Last_SQL_Error = $err (expected "duplicate key" error)
+ call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
SELECT * FROM t1;
--echo ---- Resolve the conflict on the slave and restart SQL thread ----
@@ -137,6 +138,7 @@ connection slave;
# replication continues.
if (`SELECT @@global.binlog_format = 'ROW' AND @@global.slave_exec_mode = 'STRICT'`) {
--echo ---- Wait until slave stops with an error ----
+ call mtr.add_suppression("Can.t find record in .t1., Error_code: 1032");
let $slave_sql_errno= 1032; # ER_KEY_NOT_FOUND
source include/wait_for_slave_sql_error.inc;
diff --git a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test
index eb50149655e..1c103512318 100644
--- a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test
+++ b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test
@@ -121,6 +121,16 @@ SELECT f1,f2,f3,f4,f5,f6,f7,f8,f9,
hex(f10),hex(f11) FROM t1 ORDER BY f3 LIMIT 20;
#connection slave;
+
+--disable_query_log
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 2 type mismatch.* 1535");
+call mtr.add_suppression("Slave.*Can.t DROP .c7.; check that column.key exists.* Error_code: 1091");
+call mtr.add_suppression("Slave.*Unknown column .c7. in .t15.* Error_code: 1054");
+call mtr.add_suppression("Slave.*Key column .c6. doesn.t exist in table.* Error_code: 1072");
+call mtr.add_suppression("Slave I/O: Get master clock failed with error:.* Error_code: 2013");
+call mtr.add_suppression("Slave I/O: Get master SERVER_ID failed with error:.* Error_code: 2013");
+--enable_query_log
+
sync_slave_with_master;
--echo
--echo * Select count and 20 rows from Slave *
diff --git a/mysql-test/extra/rpl_tests/rpl_extra_col_slave.test b/mysql-test/extra/rpl_tests/rpl_extra_col_slave.test
index 882ef2c4e63..cb2421d5d74 100644
--- a/mysql-test/extra/rpl_tests/rpl_extra_col_slave.test
+++ b/mysql-test/extra/rpl_tests/rpl_extra_col_slave.test
@@ -766,6 +766,10 @@ RESET MASTER;
connection slave;
START SLAVE;
+call mtr.add_suppression("Slave SQL.*Error .Unknown table .t6.. on query.* Error_code: 1051");
+call mtr.add_suppression("Slave SQL.*Error .Duplicate column name .c6.. on query.* Error_code: 1060");
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column . ...e mismatch.* Error_code: 1535");
+
--echo *** Master Data Insert ***
connection master;
set @b1 = 'b1b1b1b1';
diff --git a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
index 06253c5defb..5cbda2d591f 100644
--- a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
+++ b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
@@ -15,6 +15,7 @@ create table t3 (a int) engine=merge union(t1);
create table t4 (a int);
# We force the slave to open t3 (because we want to try confusing him) with this :
insert into t4 select * from t3;
+--let $rename_event_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
rename table t1 to t5, t2 to t1;
# RENAME may have confused the master (this is a known bug): so FLUSH tables,
# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_duplicate.test b/mysql-test/extra/rpl_tests/rpl_insert_duplicate.test
new file mode 100644
index 00000000000..77140174f4b
--- /dev/null
+++ b/mysql-test/extra/rpl_tests/rpl_insert_duplicate.test
@@ -0,0 +1,64 @@
+# BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
+# In SBR, if a statement does not fail, it is always written to the binary log,
+# regardless if rows are changed or not. If there is a failure, a statement is
+# only written to the binary log if a non-transactional (.e.g. MyIsam) engine
+# is updated. INSERT ON DUPLICATE KEY UPDATE was not following the rule above
+# and was not written to the binary log, if then engine was Innodb.
+#
+# In this test case, we check if INSERT ON DUPLICATE KEY UPDATE that does not
+# change anything is still written to the binary log.
+
+# Prepare environment
+--connection master
+
+eval CREATE TABLE t1 (
+ a INT UNSIGNED NOT NULL PRIMARY KEY
+) ENGINE=$engine_type;
+
+eval CREATE TABLE t2 (
+ a INT UNSIGNED
+) ENGINE=$engine_type;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+# An insert duplicate that does not update anything must be written to the binary
+# log in SBR and MIXED modes. We check this property by summing a before and after
+# the update and comparing the binlog positions. The sum should be the same at both
+# points and the statement should be in the binary log.
+--let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1)
+--let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1)
+--let $statement_file=INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a
+--eval $statement_file
+
+--let $assert_cond= SUM(a) = 1 FROM t1
+--let $assert_text= Sum of elements in t1 should be 1.
+--source include/assert.inc
+
+if (`SELECT @@BINLOG_FORMAT = 'ROW'`)
+{
+ --let $binlog_position_cmp= =
+ --let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start
+ --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
+}
+if (`SELECT @@BINLOG_FORMAT != 'ROW' && UPPER('$engine_type') = UPPER('Innodb')`)
+{
+ --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 1, 1\', Info, 1]\' LIKE \'%$statement_file\'
+ --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
+}
+if (`SELECT @@BINLOG_FORMAT != 'ROW' && UPPER('$engine_type') = UPPER('MyIsam')`)
+{
+ --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 0, 1\', Info, 1]\' LIKE \'%$statement_file\'
+ --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
+}
+--source include/assert.inc
+
+# Compare master and slave
+--sync_slave_with_master
+--let $diff_tables= master:test.t1 , slave:test.t1
+--source include/diff_tables.inc
+
+# Clean up
+--connection master
+drop table t1, t2;
+--sync_slave_with_master
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_ignore.test b/mysql-test/extra/rpl_tests/rpl_insert_ignore.test
index 43d45ef6c60..1eb66358423 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_ignore.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_ignore.test
@@ -5,6 +5,7 @@
# Slave needs to be started with --innodb to store table in InnoDB.
# Same test for MyISAM (which had no bug).
+--connection master
eval CREATE TABLE t1 (
a int unsigned not null auto_increment primary key,
b int unsigned,
@@ -32,38 +33,49 @@ INSERT INTO t2 VALUES (5, 4);
INSERT INTO t2 VALUES (6, 6);
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
-
-# Compare results
-
-SELECT * FROM t1 ORDER BY a;
-
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-# Now do the same for MyISAM
-
-connection master;
-drop table t1;
-eval CREATE TABLE t1 (
- a int unsigned not null auto_increment primary key,
- b int unsigned,
- unique (b)
-) ENGINE=$engine_type2;
-
-INSERT INTO t1 VALUES (1, 1);
-INSERT INTO t1 VALUES (2, 2);
-INSERT INTO t1 VALUES (3, 3);
-INSERT INTO t1 VALUES (4, 4);
-
-INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
-
-SELECT * FROM t1 ORDER BY a;
-
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-connection master;
+--let $assert_cond= COUNT(*) = 6 FROM t1
+--let $assert_text= Count of elements in t1 should be 6.
+--source include/assert.inc
+
+# Compare master and slave
+--sync_slave_with_master
+--let $diff_tables= master:test.t1 , slave:test.t1
+--source include/diff_tables.inc
+
+# BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
+# An insert ignore that does not update anything must be written to the binary log in SBR
+# and MIXED modes. We check this property by counting occurrences in t1 before and after
+# the insert and comparing the binlog positions. The count should be the same in both points
+# and the statement should be in the binary log.
+--connection master
+--let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1)
+--let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1)
+--let $statement_file=INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a
+--eval $statement_file
+
+--let $assert_cond= COUNT(*) = 6 FROM t1
+--let $assert_text= Count of elements in t1 should be 6.
+--source include/assert.inc
+
+if (`SELECT @@BINLOG_FORMAT = 'ROW'`)
+{
+ --let $binlog_position_cmp= =
+ --let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start
+ --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
+}
+if (`SELECT @@BINLOG_FORMAT != 'ROW' && UPPER('$engine_type') = UPPER('Innodb')`)
+{
+ --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 2, 1\', Info, 1]\' LIKE \'%$statement_file\'
+ --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
+}
+if (`SELECT @@BINLOG_FORMAT != 'ROW' && UPPER('$engine_type') = UPPER('MyIsam')`)
+{
+ --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 1, 1\', Info, 1]\' LIKE \'%$statement_file\'
+ --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
+}
+--source include/assert.inc
+
+# Clean up
+--connection master
drop table t1, t2;
-sync_slave_with_master;
-
-# End of 4.1 tests
+--sync_slave_with_master
diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test
index 4a21123e8a1..ae04c1b4aaa 100644
--- a/mysql-test/extra/rpl_tests/rpl_loaddata.test
+++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test
@@ -63,6 +63,8 @@ eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos;
connection slave;
# 1062 = ER_DUP_ENTRY
+call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .10. for key .b.. on query.* Error_code: 1062");
+call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.*error code=1062.*Error on slave:.*Error_code: 0");
--let $slave_sql_errno= 1062
--source include/wait_for_slave_sql_error_and_skip.inc
diff --git a/mysql-test/extra/rpl_tests/rpl_record_compare.test b/mysql-test/extra/rpl_tests/rpl_record_compare.test
index f29e4fb791a..210aee025d0 100644
--- a/mysql-test/extra/rpl_tests/rpl_record_compare.test
+++ b/mysql-test/extra/rpl_tests/rpl_record_compare.test
@@ -62,4 +62,24 @@ UPDATE t1 SET c1= 0;
DROP TABLE t1;
-- sync_slave_with_master
+#
+# BUG#11766865: 60091: RBR + NO PK + UPDATE NULL VALUE --> SLAVE BREAK WITH ERROR HA_ERR_END_OF_
+#
+
+--connection master
+--source include/rpl_reset.inc
+--connection master
+
+--eval CREATE TABLE t1 (c1 int(11) NOT NULL, c2 int(11) NOT NULL, c3 int(11) DEFAULT '-1') ENGINE=$engine DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1,2,NULL);
+UPDATE t1 SET c1=1, c2=2, c3=-1 WHERE c1=1 AND c2=2 AND ISNULL(c3);
+
+--sync_slave_with_master
+
+--let $diff_tables=master:test.t1, slave:test.t1
+--source include/diff_tables.inc
+
+--connection master
+DROP TABLE t1;
+--sync_slave_with_master
diff --git a/mysql-test/extra/rpl_tests/rpl_reset_slave.test b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
index 04ab8751e39..182fde40193 100644
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
@@ -10,6 +10,9 @@
-- source include/master-slave.inc
sync_slave_with_master;
+--disable_query_log
+call mtr.add_suppression('Slave I/O: Get master BINLOG_CHECKSUM failed with error');
+--enable_query_log
let $status_items= Master_User, Master_Host;
source include/show_slave_status.inc;
diff --git a/mysql-test/extra/rpl_tests/rpl_row_basic.test b/mysql-test/extra/rpl_tests/rpl_row_basic.test
index 540975f24fb..e72258df06e 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_basic.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_basic.test
@@ -378,7 +378,9 @@ INSERT INTO t3 VALUES (1, "", 1);
INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2);
connection slave;
-# 1535 = ER_BINLOG_ROW_WRONG_TABLE_DEF
+# 1535 = ER_BINLOG_ROW_WRONG_TABLE_DEF
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 1 size mismatch.* Error_code: 1535");
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.* Error_code: 1032");
--let $slave_sql_errno= 1535
--let $show_slave_sql_error= 1
--source include/wait_for_slave_sql_error.inc
diff --git a/mysql-test/extra/rpl_tests/rpl_row_tabledefs.test b/mysql-test/extra/rpl_tests/rpl_row_tabledefs.test
index ee6205c79d8..4e15a5a98ff 100644
--- a/mysql-test/extra/rpl_tests/rpl_row_tabledefs.test
+++ b/mysql-test/extra/rpl_tests/rpl_row_tabledefs.test
@@ -147,6 +147,7 @@ sync_slave_with_master;
connection master;
INSERT INTO t4 VALUES (4);
connection slave;
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column [012] type mismatch.* Error_code: 1535");
--let $slave_skip_counter= 2
--let $slave_sql_errno= 1535
--let $show_slave_sql_error= 1
diff --git a/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test b/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test
index d4140785878..cc69c08fe7c 100644
--- a/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test
+++ b/mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test
@@ -25,6 +25,7 @@ drop table t1;
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
+call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.* error code=1062.*Error on slave:.* Error_code: 0");
let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
--echo Error: "$error" (expected different error codes on master and slave)
diff --git a/mysql-test/include/binlog_start_pos.inc b/mysql-test/include/binlog_start_pos.inc
index f6d1c4c68a3..add5a42a426 100644
--- a/mysql-test/include/binlog_start_pos.inc
+++ b/mysql-test/include/binlog_start_pos.inc
@@ -11,16 +11,18 @@
# Format_description_log_event length =
# 19 /* event common header */ +
# 57 /* misc stuff in the Format description header */ +
-# number of events.
+# number of events +
+# 1 /* Checksum algorithm */ +
+# 4 /* CRC32 length */
#
# With current number of events = 160,
#
-# binlog_start_pos = 4 + 19 + 57 + 160 = 240.
+# binlog_start_pos = 4 + 19 + 57 + 160 + 1 + 4 = 245.
#
##############################################################################
-let $binlog_start_pos=240;
+let $binlog_start_pos=245;
--disable_query_log
-SET @binlog_start_pos=240;
+SET @binlog_start_pos=245;
--enable_query_log
diff --git a/mysql-test/include/check_shared_row_lock.inc b/mysql-test/include/check_shared_row_lock.inc
index efc7e13b3aa..1c9d9b0c3c6 100644
--- a/mysql-test/include/check_shared_row_lock.inc
+++ b/mysql-test/include/check_shared_row_lock.inc
@@ -33,7 +33,8 @@ connection default;
# least it acquires S-locks on some of rows.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state in ("Sending data","statistics", "preparing") and
+ where state in ("Sending data","statistics", "preparing", "updating",
+ "executing", "Searching rows for update") and
info = "$wait_statement";
--source include/wait_condition.inc
diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc
index d412eae8364..7924f9bc96f 100644
--- a/mysql-test/include/commit.inc
+++ b/mysql-test/include/commit.inc
@@ -502,16 +502,16 @@ call p_verify_status_increment(2, 2, 2, 2);
--echo # 12. Read-write statement: IODKU, change 0 rows.
--echo #
insert t1 set a=2 on duplicate key update a=2;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
--echo # 13. Read-write statement: INSERT IGNORE, change 0 rows.
--echo #
insert ignore t1 set a=2;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
--echo # 14. Read-write statement: INSERT IGNORE, change 1 row.
--echo #
diff --git a/mysql-test/include/gis_keys.inc b/mysql-test/include/gis_keys.inc
index c75311f062a..ad00c7e1ef9 100644
--- a/mysql-test/include/gis_keys.inc
+++ b/mysql-test/include/gis_keys.inc
@@ -44,3 +44,19 @@ SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
DROP TABLE t1, t2;
--echo End of 5.0 tests
+
+
+--echo #
+--echo # Test for bug #58650 "Failing assertion: primary_key_no == -1 ||
+--echo # primary_key_no == 0".
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+--echo # The minimal test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a));
+drop table t1;
+--echo # The original test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)));
+create unique index a on t1(a);
+drop table t1;
diff --git a/mysql-test/include/have_binlog_checksum_off.inc b/mysql-test/include/have_binlog_checksum_off.inc
new file mode 100644
index 00000000000..c7c444c8785
--- /dev/null
+++ b/mysql-test/include/have_binlog_checksum_off.inc
@@ -0,0 +1,4 @@
+if (`select variable_value not like 'NONE' from information_schema.GLOBAL_VARIABLES
+ where variable_name='binlog_checksum'`){
+ skip Can not run the test when server activated checksumming;
+}
diff --git a/mysql-test/include/have_dbi_dbd-mysql.inc b/mysql-test/include/have_dbi_dbd-mysql.inc
new file mode 100644
index 00000000000..212e36ac353
--- /dev/null
+++ b/mysql-test/include/have_dbi_dbd-mysql.inc
@@ -0,0 +1,78 @@
+#
+# Originally created by John Embretsen, 2011-01-26.
+#
+# Checks for the existence of Perl modules DBI and DBD::mysql as seen from the
+# perl installation used by "external" executable perl scripts, i.e. scripts
+# that are executed as standalone scripts interpreted by the perl installation
+# specified by the "shebang" line in the top of these scripts.
+#
+# If either module is not found, the test will be skipped.
+#
+# For use in tests that call perl scripts that require these modules.
+#
+# This file is intended to work on Unix. Windows may need different treatment.
+# Reasoning:
+# - "shebangs" are not relevant on Windows, but need to be handled here.
+# - Perl scripts cannot be made executable on Windows, interpreter must be
+# specified.
+#
+# Note that if there are multiple perl installations and not all have the
+# required modules, this check may fail even if the perl in path does have
+# the modules available. This may happen if the perl specified by the script's
+# shebang (e.g. #!/usr/bin/perl) does not have these modules, and script is
+# called without specifying the perl interpreter. However, this will be
+# a correct result in cases where a test calls a script with a similar shebang.
+#
+################################################################################
+
+--source include/not_windows.inc
+
+# We jump through some hoops since there is no direct way to check if an
+# external command went OK or not from a mysql-test file:
+#
+# - In theory, we could do as simple as "exec perl -MDBI -MDBD::mysql -e 1",
+# however we cannot check the result (exit code) from within a test script.
+# Also, this may not yield the same result as other uses of perl due to the
+# shebang issue mentioned above.
+# - Instead we use a separate helper perl script that checks for the modules.
+# - If the modules are found, the perl script leaves a file which sets a
+# variable that can be read by this file.
+# If the modules are not found, the perl script does not set this variable,
+# but leaves an empty file instead.
+#
+# This is done because there is apparently no direct way to transfer
+# information from perl to the test script itself.
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+
+# We do not use embedded perl in this script because that would not have yielded
+# correct results for a situation where an external Perl script is called like
+# "scriptname" instead of "perl scriptname" and the shebang in the script points
+# to a specific perl that may be different than the perl in PATH.
+#
+# Instead, we call a separate helper script which checks for the modules in its
+# own environment. We call it without "perl" in front.
+
+--let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl
+--let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt
+
+# Make the script executable and execute it.
+--chmod 0755 $perlChecker
+--exec $perlChecker
+
+# Source the resulting temporary file and look for a variable being set.
+--source $resultFile
+
+if (!$dbidbd) {
+ --skip Test needs Perl modules DBI and DBD::mysql
+}
+
+# Clean up
+--remove_file $resultFile
+
+--enable_query_log
+--enable_result_log
+--enable_warnings
+
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc
index 5befcce2dd5..a86e4818d15 100644
--- a/mysql-test/include/mix1.inc
+++ b/mysql-test/include/mix1.inc
@@ -634,6 +634,10 @@ drop table t1;
drop table bug29807;
create table bug29807 (a int);
drop table bug29807;
+--disable_query_log
+call mtr.add_suppression("InnoDB: Error: table .test...bug29807. does not exist in the InnoDB internal");
+call mtr.add_suppression("Cannot find or open table test\/bug29807 from");
+--enable_query_log
#
diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql
index 39ba623f247..4615a27f693 100644
--- a/mysql-test/include/mtr_warnings.sql
+++ b/mysql-test/include/mtr_warnings.sql
@@ -53,7 +53,7 @@ END
-- Insert patterns that should always be suppressed
--
INSERT INTO global_suppressions VALUES
- ("'SELECT UNIX_TIMESTAMP\\(\\)' failed on master"),
+ (".SELECT UNIX_TIMESTAMP... failed on master"),
("Aborted connection"),
("Client requested master to start replication from impossible position"),
("Could not find first log file name in binary log"),
@@ -107,11 +107,8 @@ INSERT INTO global_suppressions VALUES
("Slave: The incident LOST_EVENTS occured on the master"),
("Slave: Unknown error.* 1105"),
("Slave: Can't drop database.* database doesn't exist"),
- ("Slave SQL:.*(Error_code: \[\[:digit:\]\]+|Query:.*)"),
- ("Sort aborted"),
("Time-out in NDB"),
("Warning:\s+One can only use the --user.*root"),
- ("Warning:\s+Setting lower_case_table_names=2"),
("Warning:\s+Table:.* on (delete|rename)"),
("You have an error in your SQL syntax"),
("deprecated"),
@@ -124,55 +121,21 @@ INSERT INTO global_suppressions VALUES
("slave SQL thread aborted"),
("Slave: .*Duplicate entry"),
- /*
- Special case, made as specific as possible, for:
- Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
- server coredump
- */
-
- ("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49"),
-
("Statement may not be safe to log in statement format"),
- /* test case for Bug#bug29807 copies a stray frm into database */
- ("InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal"),
- ("Cannot find or open table test\/bug29807 from"),
-
/* innodb foreign key tests that fail in ALTER or RENAME produce this */
("InnoDB: Error: in ALTER TABLE `test`.`t[123]`"),
("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
("InnoDB: Error: table `test`.`t[123]` does not exist in the InnoDB internal"),
- /* Test case for Bug#14233 produces the following warnings: */
- ("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"),
- ("Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc"),
- ("Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc"),
-
/*
BUG#32080 - Excessive warnings on Solaris: setrlimit could not
change the size of core files
*/
("setrlimit could not change the size of core files to 'infinity'"),
- /*
- rpl_extrColmaster_*.test, the slave thread produces warnings
- when it get updates to a table that has more columns on the
- master
- */
- ("Slave: Unknown column 'c7' in 't15' Error_code: 1054"),
- ("Slave: Can't DROP 'c7'.* 1091"),
- ("Slave: Key column 'c6'.* 1072"),
("The slave I.O thread stops because a fatal error is encountered when it try to get the value of SERVER_ID variable from master."),
- (".SELECT UNIX_TIMESTAMP... failed on master, do not trust column Seconds_Behind_Master of SHOW SLAVE STATUS"),
-
- /* Test case for Bug#31590 in order_by.test produces the following error */
- ("Out of sort memory; increase server sort buffer size"),
- /* Special case for Bug #26402 in show_check.test
- - Question marks are not valid file name parts on Windows. Ignore
- this error message.
- */
- ("Can't find file: '.\\\\test\\\\\\?{8}.frm'"),
("Slave: Unknown table 't1' Error_code: 1051"),
/* Maria storage engine dependent tests */
@@ -209,7 +172,9 @@ INSERT INTO global_suppressions VALUES
("Slave I/O: Get master clock failed with error:.*"),
("Slave I/O: Get master COLLATION_SERVER failed with error:.*"),
("Slave I/O: Get master TIME_ZONE failed with error:.*"),
-
+ ("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum on master.*"),
+ ("Slave I/O: Get master BINLOG_CHECKSUM failed with error.*"),
+ ("Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error.*"),
("THE_LAST_SUPPRESSION")||
diff --git a/mysql-test/include/mysqlhotcopy.inc b/mysql-test/include/mysqlhotcopy.inc
index 2596994b59a..779ed7f36e0 100644
--- a/mysql-test/include/mysqlhotcopy.inc
+++ b/mysql-test/include/mysqlhotcopy.inc
@@ -4,12 +4,26 @@
--source include/not_windows.inc
--source include/not_embedded.inc
+--source include/have_dbi_dbd-mysql.inc
-if ($MYSQLHOTCOPY)
+if (!$MYSQLHOTCOPY)
{
+ # Fail the test if the mysqlhotcopy script is missing.
+ # If the tool's location changes, mysql-test-run.pl must be updated to
+ # reflect this (look for "MYSQLHOTCOPY").
die due to missing mysqlhotcopy tool;
}
+# NOTE (johnemb, 2011-01-26):
+# In this test mysqlhotcopy (a perl script) is executed as a standalone
+# executable, i.e. not necessarily using the perl interpreter in PATH,
+# because that is how the documentation demonstrates it.
+#
+# We include have_dbi_dbd-mysql.inc above so that the test will
+# be skipped if Perl modules required by the mysqlhotcopy tool are not
+# found when the script is run this way.
+
+
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--disable_warnings
DROP DATABASE IF EXISTS hotcopy_test;
@@ -95,7 +109,7 @@ DROP DATABASE hotcopy_save;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
--list_files $MYSQLD_DATADIR/hotcopy_save
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
---error 9,2304
+--error 9,11,2304
--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
--exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
diff --git a/mysql-test/include/not_crashrep.inc b/mysql-test/include/not_crashrep.inc
new file mode 100644
index 00000000000..e126f339a5f
--- /dev/null
+++ b/mysql-test/include/not_crashrep.inc
@@ -0,0 +1,24 @@
+# Check if CrashReporter is enabled and would open a window
+
+perl;
+sub skip_test {
+ # Only relevant on Mac OS X
+ return 0 unless $^O eq 'darwin';
+ my $crep= `defaults read com.apple.CrashReporter DialogType`;
+ return 0 if $?;
+ chomp ($crep);
+ $crep= lc $crep;
+ return ($crep eq 'basic' || $crep eq 'developer');
+}
+my $skip= skip_test();
+open (F, ">" . $ENV{'MYSQL_TMP_DIR'} . "/crashrep.inc");
+print F "let \$crashrep= $skip;\n";
+close F;
+EOF
+
+--source $MYSQL_TMP_DIR/crashrep.inc
+--remove_file $MYSQL_TMP_DIR/crashrep.inc
+
+if ($crashrep) {
+ --skip CrashReporter would popup a window
+}
diff --git a/mysql-test/include/ps_conv.inc b/mysql-test/include/ps_conv.inc
index 9ac943d5bdd..2e42542d19a 100644
--- a/mysql-test/include/ps_conv.inc
+++ b/mysql-test/include/ps_conv.inc
@@ -106,7 +106,7 @@ drop table t5 ;
# c1 tinyint, c2 smallint, c3 mediumint, c4 int,
# c5 integer, c6 bigint, c7 float, c8 double,
# c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4),
-# c13 date, c14 datetime, c15 timestamp(14), c16 time,
+# c13 date, c14 datetime, c15 timestamp, c16 time,
# c17 year, c18 tinyint, c19 bool, c20 char,
# c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext,
# c25 blob, c26 text, c27 mediumblob, c28 mediumtext,
@@ -672,7 +672,6 @@ select '-- insert into string columns --' as test_sequence ;
--enable_query_log
######## INSERT into .. string columns values(CHAR(n),LONGTEXT) ########
---disable_query_log
insert into t9
( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
values
@@ -860,8 +859,6 @@ values
execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
@arg00, @arg00, @arg00, @arg00 ;
---enable_query_log
-
######## SELECT of all inserted records ########
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
@@ -980,14 +977,13 @@ delete from t9 ;
######################### test of date/time columns ########################
# #
-# c13 date, c14 datetime, c15 timestamp(14), c16 time, c17 year #
+# c13 date, c14 datetime, c15 timestamp, c16 time, c17 year #
# #
############################################################################
--disable_query_log
select '-- insert into date/time columns --' as test_sequence ;
--enable_query_log
######## INSERT into .. date/time columns values(VARCHAR(19),LONGTEXT) ########
---disable_query_log
set @arg00= '1991-01-01 01:01:01' ;
insert into t9
( c1, c13, c14, c15, c16, c17 )
@@ -1143,12 +1139,9 @@ values
( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
---enable_query_log
-
######## SELECT of all inserted records ########
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
-
--disable_query_log
select '-- select .. where date/time column = .. --' as test_sequence ;
--enable_query_log
@@ -1156,19 +1149,19 @@ select '-- select .. where date/time column = .. --' as test_sequence ;
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ########
@@ -1177,21 +1170,39 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+
+
+######## SELECT .. WHERE column(date/time/..)=value(CHAR(n)/LONGTEXT) ########
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+
+
+######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ########
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
######## SELECT .. WHERE column(year)=value(INT(10)/BIGINT) ########
diff --git a/mysql-test/include/restart_slave_sql.inc b/mysql-test/include/restart_slave_sql.inc
new file mode 100644
index 00000000000..55e87f4b57f
--- /dev/null
+++ b/mysql-test/include/restart_slave_sql.inc
@@ -0,0 +1,43 @@
+# ==== Purpose ====
+#
+# Provide a earier way to restart SQL thread when you want to stop sql thread
+# and then start it immediately.
+#
+# Sources stop_slave_sql.inc to stop SQL thread on the current connection.
+# Then issues START SLAVE SQL_THREAD and then waits until
+# the SQL threads have started, or until a timeout is reached.
+#
+# Please use this instead of 'STOP|START SLAVE SQL_THREAD', to reduce the risk of
+# test case bugs.
+#
+#
+# ==== Usage ====
+#
+# [--let $slave_timeout= NUMBER]
+# [--let $rpl_debug= 1]
+# --source include/restart_slave_sql.inc
+#
+# Parameters:
+# $slave_timeout
+# See include/wait_for_slave_param.inc
+#
+# $rpl_debug
+# See include/rpl_init.inc
+
+
+--let $include_filename= restart_slave.inc
+--source include/begin_include_file.inc
+
+
+if (!$rpl_debug)
+{
+ --disable_query_log
+}
+
+source include/stop_slave_sql.inc;
+START SLAVE SQL_THREAD;
+source include/wait_for_slave_sql_to_start.inc;
+
+
+--let $include_filename= restart_slave.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/rpl_connection_master.inc b/mysql-test/include/rpl_connection_master.inc
new file mode 100644
index 00000000000..fa09cc8a610
--- /dev/null
+++ b/mysql-test/include/rpl_connection_master.inc
@@ -0,0 +1,2 @@
+let $rpl_connection_name= master;
+source include/rpl_connection.inc;
diff --git a/mysql-test/include/rpl_connection_slave.inc b/mysql-test/include/rpl_connection_slave.inc
new file mode 100644
index 00000000000..8dcfb3b611b
--- /dev/null
+++ b/mysql-test/include/rpl_connection_slave.inc
@@ -0,0 +1,2 @@
+let $rpl_connection_name= slave;
+source include/rpl_connection.inc;
diff --git a/mysql-test/include/rpl_connection_slave1.inc b/mysql-test/include/rpl_connection_slave1.inc
new file mode 100644
index 00000000000..a408d14596b
--- /dev/null
+++ b/mysql-test/include/rpl_connection_slave1.inc
@@ -0,0 +1,2 @@
+let $rpl_connection_name= slave1;
+source include/rpl_connection.inc;
diff --git a/mysql-test/include/rpl_sync.inc b/mysql-test/include/rpl_sync.inc
index a05bee23981..be2904528ff 100644
--- a/mysql-test/include/rpl_sync.inc
+++ b/mysql-test/include/rpl_sync.inc
@@ -88,7 +88,7 @@ while ($_rpl_i) {
{
--echo Sync IO: $_rpl_slave_io_running; Sync SQL: $_rpl_slave_sql_running
}
- --let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' = 'Yes', 1, '')`
+ --let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' != 'No', 1, '')`
--let $_rpl_slave_sql_running= `SELECT IF('$_rpl_slave_sql_running' = 'Yes', 1, '')`
if ($_rpl_slave_io_running)
{
diff --git a/mysql-test/include/show_binlog_events2.inc b/mysql-test/include/show_binlog_events2.inc
index 96e42e93f90..c32d12537fd 100644
--- a/mysql-test/include/show_binlog_events2.inc
+++ b/mysql-test/include/show_binlog_events2.inc
@@ -1,4 +1,4 @@
---let $binlog_start=240
+--let $binlog_start=245
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
diff --git a/mysql-test/include/subselect_mat_cost.inc b/mysql-test/include/subselect_mat_cost.inc
new file mode 100644
index 00000000000..04b116e9527
--- /dev/null
+++ b/mysql-test/include/subselect_mat_cost.inc
@@ -0,0 +1,152 @@
+-- echo
+-- echo /* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+-- echo
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+-- echo
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+
+-- echo
+-- echo /*
+-- echo B. "Natural" examples of subqueries without grouping that
+-- echo cannot be flattened into semijoin.
+-- echo */
+
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+-- echo
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+-- echo UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+-- echo
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+-- echo
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+
+-- echo
+-- echo /* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+-- echo
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+-- echo
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+-- echo
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+-- echo
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+-- echo
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+
+-- echo
+-- echo /*
+-- echo D. Subqueries for which materialization is not possible, and the
+-- echo optimizer reverts to in-to-exists.
+-- echo */
+# The first two cases are rejected during the prepare phase by the procedure
+# subquery_types_allow_materialization().
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+-- echo
+# The following two subqueries return the result of a string function with a
+# blob argument, where the return type may be != blob. These are rejected during
+# cost-based optimization when attempting to create a temporary table.
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+-- echo
+
+
+-- echo
+-- echo /* E. Edge cases. */
+-- echo
+
+-- echo /* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+--error ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+set @@optimizer_switch = @save_optimizer_switch;
+
+-- echo /* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+
+-- echo /* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+-- echo UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+
+-- echo /* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+
+-- echo /* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+-- echo TODO this test produces wrong result due to missing logic to handle the case
+-- echo when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+select a1 from t1 where a1 in (select max(b1) from t2);
+-- echo
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+
+-- echo /* E.6 make_join_select detects impossible WHERE. *
+
+-- echo TODO
+
+-- echo /* E.7 constant optimization detects "no matching row in const table". */
+
+-- echo TODO
+
+-- echo /* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+
+-- echo
+-- echo /* F. UPDATE/DELETE with subqueries. */
+-- echo
+
+-- echo TODO
+-- echo
diff --git a/mysql-test/include/type_hrtime.inc b/mysql-test/include/type_hrtime.inc
new file mode 100644
index 00000000000..cd631f25632
--- /dev/null
+++ b/mysql-test/include/type_hrtime.inc
@@ -0,0 +1,128 @@
+
+--source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+
+--error ER_TOO_BIG_PRECISION
+eval create table t1 (a $type(7));
+
+eval create table t1 (a $type(3), key(a));
+insert t1 values ('2010-12-11 00:20:03.1234');
+insert t1 values ('2010-12-11 15:47:11.1234');
+insert t1 values (20101211010203.45678);
+insert t1 values (20101211030405.789e0);
+insert t1 values (99991231235959e1);
+select * from t1;
+--replace_regex /121000/121094/ /457000/457031/ /789000/789062/
+select truncate(a, 6) from t1; # Field::val_real()
+select a DIV 1 from t1; # Field::val_int()
+select group_concat(distinct a) from t1; # Field::cmp()
+alter table t1 engine=innodb;
+select * from t1 order by a;
+select * from t1 order by a+0;
+drop table t1;
+eval create table t1 (a $type(4)) engine=innodb;
+insert t1 values ('2010-12-11 01:02:03.456789');
+select * from t1;
+select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
+select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
+
+#
+# metadata
+#
+show create table t1;
+show columns from t1;
+--query_vertical select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1'
+
+#
+# update/delete
+#
+select a, a+interval 9876543 microsecond from t1;
+update t1 set a=a+interval 9876543 microsecond;
+select * from t1;
+select a, a + interval 2 year from t1;
+insert t1 select a + interval 2 year from t1;
+select * from t1;
+delete from t1 where a < 20110101;
+select * from t1;
+
+#
+# create ... select
+#
+create table t2 select * from t1;
+create table t3 like t1;
+
+show create table t2;
+show create table t3;
+drop table t2, t3;
+
+# math, aggregation
+insert t1 values ('2010-12-13 14:15:16.222222');
+select a, a+0, a-1, a*1, a/2 from t1;
+select max(a), min(a), sum(a), avg(a) from t1;
+create table t2 select a, a+0, a-1, a*1, a/2 from t1;
+create table t3 select max(a), min(a), sum(a), avg(a) from t1;
+show create table t2;
+show create table t3;
+
+drop table t1, t2, t3;
+
+# insert, alter with conversion
+--vertical_results
+eval create table t1 (f0_$type $type(0), f1_$type $type(1), f2_$type $type(2), f3_$type $type(3), f4_$type $type(4), f5_$type $type(5), f6_$type $type(6));
+insert t1 values ( '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432');
+select * from t1;
+eval select cast(f0_$type as time(4)) time4_f0_$type, cast(f1_$type as datetime(3)) datetime3_f1_$type, cast(f2_$type as date) date_f2_$type, cast(f4_$type as double) double_f3_$type, cast(f4_$type as decimal(40,5)) decimal5_f4_$type, cast(f5_$type as signed) bigint_f5_$type, cast(f6_$type as char(255)) varchar_f6_$type from t1;
+eval create table t2 (time4_f0_$type time(4), datetime3_f1_$type datetime(3), date_f2_$type date, double_f3_$type double, decimal5_f4_$type decimal(40,5), bigint_f5_$type bigint, varchar_f6_$type varchar(255));
+insert t2 select * from t1;
+select * from t2;
+eval alter table t1 change f0_$type time4_f0_$type time(4), change f1_$type datetime3_f1_$type datetime(3), change f2_$type date_f2_$type date, change f3_$type double_f3_$type double, change f4_$type decimal5_f4_$type decimal(40,5), change f5_$type bigint_f5_$type bigint, change f6_$type varchar_f6_$type varchar(255);
+select * from t1;
+eval alter table t1 modify time4_f0_$type $type(0), modify datetime3_f1_$type $type(1), modify date_f2_$type $type(2), modify double_f3_$type $type(3), modify decimal5_f4_$type $type(4), modify bigint_f5_$type $type(5), modify varchar_f6_$type $type(6);
+select * from t1;
+delete from t1;
+insert t1 select * from t2;
+select * from t1;
+drop table t1, t2;
+--horizontal_results
+
+#
+# SP
+#
+eval create table t1 (a $type(6), b $type(6));
+eval create procedure foo(x $type, y $type(4)) insert into t1 values (x, y);
+call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
+select * from t1;
+delimiter |;
+eval create procedure bar(a int, c $type(5))
+begin
+ declare b $type(4);
+ set b = c + interval a microsecond;
+ insert t1 values (b, c + interval a microsecond);
+end|
+delimiter ;|
+call bar(1111111, '2011-01-02 3:4:5.123456');
+select * from t1;
+drop procedure foo;
+drop procedure bar;
+eval create function xyz(s char(20)) returns $type(4)
+ return addtime('2010-10-10 10:10:10.101010', s);
+select xyz('1:1:1.010101');
+drop function xyz;
+
+#
+# Views
+#
+
+create view v1 as select * from t1 group by a,b;
+select * from v1;
+show columns from v1;
+create table t2 select * from v1;
+show create table t2;
+select * from t2;
+
+drop view v1;
+drop table t1, t2;
+
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm
index e6497e8866a..ca3db8ff92f 100644
--- a/mysql-test/lib/My/ConfigFactory.pm
+++ b/mysql-test/lib/My/ConfigFactory.pm
@@ -1,4 +1,20 @@
# -*- cperl -*-
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
package My::ConfigFactory;
use strict;
diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm
index 3ac9e385070..c0f6535b96e 100644
--- a/mysql-test/lib/My/CoreDump.pm
+++ b/mysql-test/lib/My/CoreDump.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/File/Path.pm b/mysql-test/lib/My/File/Path.pm
index 6e6d23ad9f0..14fb43e8d98 100644
--- a/mysql-test/lib/My/File/Path.pm
+++ b/mysql-test/lib/My/File/Path.pm
@@ -1,4 +1,19 @@
# -*- cperl -*-
+# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
package My::File::Path;
use strict;
diff --git a/mysql-test/lib/My/Find.pm b/mysql-test/lib/My/Find.pm
index 8557584bbc8..8e6cd0c651d 100644
--- a/mysql-test/lib/My/Find.pm
+++ b/mysql-test/lib/My/Find.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,8 +28,6 @@ use My::Platform;
use base qw(Exporter);
our @EXPORT= qw(my_find_bin my_find_dir my_find_file NOT_REQUIRED);
-our $vs_config_dir;
-
my $bin_extension= ".exe" if IS_WINDOWS;
# Helper function to be used for fourth parameter to find functions
@@ -158,7 +156,7 @@ sub my_find_paths {
# User can select to look in a special build dir
# which is a subdirectory of any of the paths
my @extra_dirs;
- my $build_dir= $vs_config_dir || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR};
+ my $build_dir= $::opt_vs_config || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR};
push(@extra_dirs, $build_dir) if defined $build_dir;
if (defined $extension){
diff --git a/mysql-test/lib/My/Options.pm b/mysql-test/lib/My/Options.pm
index 40f05c41d1c..6e8cf7ec919 100644
--- a/mysql-test/lib/My/Options.pm
+++ b/mysql-test/lib/My/Options.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2008 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm
index 371120ab644..cbe8f929d71 100644
--- a/mysql-test/lib/My/Platform.pm
+++ b/mysql-test/lib/My/Platform.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index 0e1e27cccd2..baeb452fde0 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -1,14 +1,16 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2009, 2011 Monty Program Ab
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; version 2
+# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
@@ -84,17 +86,17 @@ sub is_child {
my @safe_process_cmd;
my $safe_kill;
-my $bindir;
-if(defined $ENV{MTR_BINDIR})
-{
- # This is an out-of-source build. Build directory
- # is given in MTR_BINDIR env.variable
- $bindir = $ENV{MTR_BINDIR}."/mysql-test";
-}
-else
-{
- $bindir = ".";
-}
+my $bindir;
+if(defined $ENV{MTR_BINDIR})
+{
+ # This is an out-of-source build. Build directory
+ # is given in MTR_BINDIR env.variable
+ $bindir = $ENV{MTR_BINDIR}."/mysql-test";
+}
+else
+{
+ $bindir = ".";
+}
# Find the safe process binary or script
sub find_bin {
diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm
index 9a6871264b8..c0c70e48082 100644
--- a/mysql-test/lib/My/SafeProcess/Base.pm
+++ b/mysql-test/lib/My/SafeProcess/Base.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt
index 8a9341245be..6edf9d45683 100644
--- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt
+++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt
@@ -1,3 +1,4 @@
+# Copyright (C) 2008 MySQL AB
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
diff --git a/mysql-test/lib/My/SafeProcess/Makefile.am b/mysql-test/lib/My/SafeProcess/Makefile.am
index 33cab066611..2a2f2d47345 100644
--- a/mysql-test/lib/My/SafeProcess/Makefile.am
+++ b/mysql-test/lib/My/SafeProcess/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2000-2006 MySQL AB
+# Copyright (C) 2008 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
index 963a02c8099..9b013b960bf 100755
--- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 MySQL AB
+/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc
index 12b335ec444..0ff3a818d2d 100644
--- a/mysql-test/lib/My/SafeProcess/safe_process.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 MySQL AB
+/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
index 896bd599f4f..931705e1911 100755
--- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 MySQL AB
+/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/SysInfo.pm b/mysql-test/lib/My/SysInfo.pm
index f1ba5fb610f..b8569e415e8 100644
--- a/mysql-test/lib/My/SysInfo.pm
+++ b/mysql-test/lib/My/SysInfo.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2008 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/My/Test.pm b/mysql-test/lib/My/Test.pm
index c8bfbd34521..07f2697d6fe 100644
--- a/mysql-test/lib/My/Test.pm
+++ b/mysql-test/lib/My/Test.pm
@@ -1,4 +1,18 @@
# -*- cperl -*-
+# Copyright (C) 2008 MySQL AB
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
diff --git a/mysql-test/lib/mtr_gcov.pl b/mysql-test/lib/mtr_gcov.pl
index 2f211b7566d..b4fdcd2e04c 100644
--- a/mysql-test/lib/mtr_gcov.pl
+++ b/mysql-test/lib/mtr_gcov.pl
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004, 2006 MySQL AB
+# Copyright (C) 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/mtr_gprof.pl b/mysql-test/lib/mtr_gprof.pl
index 5820a4007b8..a5e05b28723 100644
--- a/mysql-test/lib/mtr_gprof.pl
+++ b/mysql-test/lib/mtr_gprof.pl
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004 MySQL AB
+# Copyright (C) 2004 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl
index 21581798ddc..6a6b3a3d028 100644
--- a/mysql-test/lib/mtr_io.pl
+++ b/mysql-test/lib/mtr_io.pl
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2004-2007 MySQL AB, 2008 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/mtr_match.pm b/mysql-test/lib/mtr_match.pm
index 40afd4e0336..6fc9832ac43 100644
--- a/mysql-test/lib/mtr_match.pm
+++ b/mysql-test/lib/mtr_match.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
+# Copyright (C) 2004-2008 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index 388d252502a..b84eec563b2 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -1,15 +1,17 @@
# -*- cperl -*-
-# Copyright (C) 2004-2006 MySQL AB
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
+# Copyright (c) 2004, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2009-2011, Monty Program Ab
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; version 2
+# of the License.
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index a90c367178d..e8979fca5fb 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -1,15 +1,16 @@
# -*- cperl -*-
-# Copyright 2004-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+# Copyright (c) 2009-2011, Monty Program Ab
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -32,6 +33,7 @@ our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line
use mtr_match;
use My::Platform;
use POSIX qw[ _exit ];
+use IO::Handle qw[ flush ];
require "mtr_io.pl";
my $tot_real_time= 0;
@@ -125,7 +127,8 @@ sub mtr_report_test ($) {
# Find out if this test case is an experimental one, so we can treat
# the failure as an expected failure instead of a regression.
for my $exp ( @$::experimental_test_cases ) {
- if ( $exp ne $test_name ) {
+ # Include pattern match for combinations
+ if ( $exp ne $test_name && $test_name !~ /^$exp / ) {
# if the expression is not the name of this test case, but has
# an asterisk at the end, determine if the characters up to
# but excluding the asterisk are the same
@@ -490,6 +493,7 @@ sub mtr_warning (@) {
# Print error to screen and then exit
sub mtr_error (@) {
+ IO::Handle::flush(\*STDOUT) if IS_WINDOWS;
print STDERR _name(). _timestamp().
"mysql-test-run: *** ERROR: ". join(" ", @_). "\n";
if (IS_WINDOWS)
diff --git a/mysql-test/lib/mtr_stress.pl b/mysql-test/lib/mtr_stress.pl
index 702bc178ae5..ab4214791d0 100644
--- a/mysql-test/lib/mtr_stress.pl
+++ b/mysql-test/lib/mtr_stress.pl
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2006 MySQL AB
+# Copyright (C) 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm
index 6b60157422d..506af448266 100644
--- a/mysql-test/lib/mtr_unique.pm
+++ b/mysql-test/lib/mtr_unique.pm
@@ -1,5 +1,5 @@
# -*- cperl -*-
-# Copyright (C) 2006 MySQL AB
+# Copyright (C) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl
index 5671f58bbfe..e9a264ac60b 100755
--- a/mysql-test/lib/v1/mysql-test-run.pl
+++ b/mysql-test/lib/v1/mysql-test-run.pl
@@ -5285,8 +5285,8 @@ sub valgrind_arguments {
else
{
mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
- mtr_add_arg($args, "--alignment=8");
mtr_add_arg($args, "--leak-check=yes");
+ #mtr_add_arg($args, "--db-attach=yes");
mtr_add_arg($args, "--num-callers=16");
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
if -f "$glob_mysql_test_dir/valgrind.supp";
diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mysql-stress-test.pl
index 378eed9ef68..af25a991302 100755
--- a/mysql-test/mysql-stress-test.pl
+++ b/mysql-test/mysql-stress-test.pl
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+
# ======================================================================
# MySQL server stress test system
# ======================================================================
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 7012fe27126..e2b2a3c2262 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1,5 +1,23 @@
#!/usr/bin/perl
# -*- cperl -*-
+
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+# Copyright (c) 2009-2011 Monty Program Ab
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
#
##############################################################################
#
@@ -171,6 +189,7 @@ my $opt_cursor_protocol;
my $opt_view_protocol;
our $opt_debug;
+our $opt_debug_server;
our @opt_cases; # The test cases names in argv
our $opt_embedded_server;
@@ -999,6 +1018,7 @@ sub command_line_setup {
# Debugging
'debug' => \$opt_debug,
+ 'debug-server' => \$opt_debug_server,
'gdb' => \$opt_gdb,
'client-gdb' => \$opt_client_gdb,
'manual-gdb' => \$opt_manual_gdb,
@@ -1165,6 +1185,20 @@ sub command_line_setup {
"$basedir/sql/share/charsets",
"$basedir/share/charsets");
+ # --debug implies we run debug server
+ $opt_debug_server= 1 if $opt_debug;
+
+ if (using_extern())
+ {
+ # Connect to the running mysqld and find out what it supports
+ collect_mysqld_features_from_running_server();
+ }
+ else
+ {
+ # Run the mysqld to find out what features are available
+ collect_mysqld_features();
+ }
+
if ( $opt_comment )
{
mtr_report();
@@ -1190,7 +1224,7 @@ sub command_line_setup {
chomp;
# remove comments (# foo) at the beginning of the line, or after a
# blank at the end of the line
- s/( +|^)#.*$//;
+ s/(\s+|^)#.*$//;
# If @ platform specifier given, use this entry only if it contains
# @<platform> or @!<xxx> where xxx != platform
if (/\@.*/)
@@ -1201,8 +1235,8 @@ sub command_line_setup {
s/\@.*$//;
}
# remove whitespace
- s/^ +//;
- s/ +$//;
+ s/^\s+//;
+ s/\s+$//;
# if nothing left, don't need to remember this line
if ( $_ eq "" ) {
next;
@@ -1670,7 +1704,7 @@ sub collect_mysqld_features {
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
- mtr_add_arg($args, "--datadir=%s/tmp", $opt_vardir);
+ mtr_add_arg($args, "--datadir=.");
mtr_add_arg($args, "--basedir=%s", $basedir);
mtr_add_arg($args, "--language=%s", $path_language);
mtr_add_arg($args, "--skip-grant-tables");
@@ -1809,7 +1843,7 @@ sub find_mysqld {
my @mysqld_names= ("mysqld", "mysqld-max-nt", "mysqld-max",
"mysqld-nt");
- if ( $opt_debug ){
+ if ( $opt_debug_server ){
# Put mysqld-debug first in the list of binaries to look for
mtr_verbose("Adding mysqld-debug first in list of binaries to look for");
unshift(@mysqld_names, "mysqld-debug");
@@ -1879,9 +1913,12 @@ sub executable_setup () {
sub client_debug_arg($$) {
my ($args, $client_name)= @_;
+ # Workaround for Bug #50627: drop any debug opt
+ return if $client_name =~ /^mysqlbinlog/;
+
if ( $opt_debug ) {
mtr_add_arg($args,
- "--debug=d:t:A,%s/log/%s.trace",
+ "--loose-debug=d:t:A,%s/log/%s.trace",
$path_vardir_trace, $client_name)
}
}
@@ -2051,6 +2088,13 @@ sub environment_setup {
push(@ld_library_paths, "$basedir/libmysql/.libs/",
"$basedir/libmysql_r/.libs/",
"$basedir/zlib/.libs/");
+ if ($^O eq "darwin")
+ {
+ # it is MAC OS and we have to add dynamic libraries paths
+ push @ld_library_paths, grep {<$_/*.dylib>}
+ (<$bindir/storage/*/.libs/>,<$bindir/plugin/*/.libs/>,
+ <$bindir/plugin/*/*/.libs/>,<$bindir/storage/*/*/.libs>);
+ }
}
else
{
@@ -2244,10 +2288,12 @@ sub environment_setup {
# mysqlhotcopy
# ----------------------------------------------------
my $mysqlhotcopy=
- mtr_pl_maybe_exists("$bindir/scripts/mysqlhotcopy");
- # Since mysqltest interprets the real path as "false" in an if,
- # use 1 ("true") to indicate "not exists" so it can be tested for
- $ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy || 1;
+ mtr_pl_maybe_exists("$basedir/scripts/mysqlhotcopy") ||
+ mtr_pl_maybe_exists("$path_client_bindir/mysqlhotcopy");
+ if ($mysqlhotcopy)
+ {
+ $ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy;
+ }
# ----------------------------------------------------
# perror
@@ -2541,9 +2587,9 @@ sub check_debug_support ($) {
#mtr_report(" - binaries are not debug compiled");
$debug_compiled_binaries= 0;
- if ( $opt_debug )
+ if ( $opt_debug_server )
{
- mtr_error("Can't use --debug, binaries does not support it");
+ mtr_error("Can't use --debug[-server], binary does not support it");
}
return;
}
@@ -4303,8 +4349,9 @@ sub get_log_from_proc ($$) {
# error log and write all lines that look
# suspicious into $error_log.warnings
#
-sub extract_warning_lines ($) {
- my ($error_log) = @_;
+
+sub extract_warning_lines ($$) {
+ my ($error_log, $append) = @_;
# Open the servers .err log file and read all lines
# belonging to current tets into @lines
@@ -4341,13 +4388,16 @@ sub extract_warning_lines ($) {
# Write all suspicious lines to $error_log.warnings file
my $warning_log = "$error_log.warnings";
- my $Fwarn = IO::File->new($warning_log, "w")
+ my $Fwarn = IO::File->new($warning_log, $append ? "a+" : "w")
or die("Could not open file '$warning_log' for writing: $!");
- print $Fwarn "Suspicious lines from $error_log\n";
+ if (!$append)
+ {
+ print $Fwarn "Suspicious lines from $error_log\n";
+ }
my @patterns =
(
- qr/^Warning:|mysqld: Warning|\[Warning\]/,
+ qr/^Warning|mysqld: Warning|\[Warning\]/,
qr/^Error:|\[ERROR\]/,
qr/^==\d+==\s+\S/, # valgrind errors
qr/InnoDB: Warning|InnoDB: Error/,
@@ -4448,7 +4498,7 @@ sub start_check_warnings ($$) {
my $log_error= $mysqld->value('#log-error');
# To be communicated to the test
$ENV{MTR_LOG_ERROR}= $log_error;
- extract_warning_lines($log_error);
+ extract_warning_lines($log_error, 0);
my $args;
mtr_init_args(\$args);
@@ -4603,7 +4653,7 @@ sub check_warnings_post_shutdown {
foreach my $mysqld ( mysqlds())
{
my ($testlist, $match_lines)=
- extract_warning_lines($mysqld->value('#log-error'));
+ extract_warning_lines($mysqld->value('#log-error'), 1);
$testname_hash->{$_}= 1 for @$testlist;
$report.= join('', @$match_lines);
}
@@ -4634,8 +4684,10 @@ sub check_expected_crash_and_restart {
{
mtr_verbose("Crash was expected, file '$expect_file' exists");
- for (my $waits = 0; $waits < 50; $waits++)
+ for (my $waits = 0; $waits < 50; mtr_milli_sleep(100), $waits++)
{
+ # Race condition seen on Windows: try again until file not empty
+ next if -z $expect_file;
# If last line in expect file starts with "wait"
# sleep a little and try again, thus allowing the
# test script to control when the server should start
@@ -4644,10 +4696,11 @@ sub check_expected_crash_and_restart {
if ($last_line =~ /^wait/ )
{
mtr_verbose("Test says wait before restart") if $waits == 0;
- mtr_milli_sleep(100);
next;
}
+ # Ignore any partial or unknown command
+ next unless $last_line =~ /^restart/;
# If last line begins "restart:", the rest of the line is read as
# extra command line options to add to the restarted mysqld.
# Anything other than 'wait' or 'restart:' (with a colon) will
@@ -4999,6 +5052,8 @@ sub mysqld_start ($$) {
my @all_opts= @$extra_opts;
if (exists $mysqld->{'restart_opts'}) {
push (@all_opts, @{$mysqld->{'restart_opts'}});
+ mtr_verbose(My::Options::toStr("mysqld_start restart",
+ @{$mysqld->{'restart_opts'}}));
}
mysqld_arguments($args,$mysqld,\@all_opts);
@@ -5965,6 +6020,8 @@ Options for debugging the product
client-gdb Start mysqltest client in gdb
ddd Start mysqld in ddd
debug Dump trace output for all servers and client programs
+ debug-server Use debug version of server, but without turning on
+ tracing
debugger=NAME Start mysqld in the selected debugger
gdb Start the mysqld(s) in gdb
manual-debug Let user manually start mysqld in debugger, before
diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result
index 1820782d2f8..f82439090f6 100644
--- a/mysql-test/r/analyse.result
+++ b/mysql-test/r/analyse.result
@@ -123,3 +123,29 @@ CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE();
ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT
DROP TABLE t1;
End of 5.0 tests
+#
+# Bug#11765202: Dbug_violation_helper::~Dbug_violation_helper(): Assertion `!_entered' failed.
+#
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 't1'
+CREATE TABLE t1 (a VARCHAR(2) CHARSET UTF8 NOT NULL);
+INSERT INTO t1 VALUES ('e'),('e'),('e-');
+SELECT * FROM t1 PROCEDURE ANALYSE();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+test.t1.a e e- 1 2 0 0 1.3333 NULL ENUM('e','e-') NOT NULL
+DROP TABLE t1;
+#
+# Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
+#
+CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
+CREATE TABLE t2(f2 INT) ENGINE=INNODB;
+INSERT INTO t2 VALUES (1);
+SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+test.t1.f1 NULL NULL 0 0 0 1 0.0 0.0 CHAR(0)
+SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+test.t2.f2 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
+DROP TABLE t1, t2;
+End of 5.1 tests
diff --git a/mysql-test/r/archive_gis.result b/mysql-test/r/archive_gis.result
index af231ad6ce4..e4cf705a76f 100644
--- a/mysql-test/r/archive_gis.result
+++ b/mysql-test/r/archive_gis.result
@@ -236,7 +236,7 @@ explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelo
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00
Warnings:
-Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
+Note 1003 select st_dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,st_geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,st_isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,st_astext(st_envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
SELECT fid, X(g) FROM gis_point ORDER by fid;
fid X(g)
101 10
@@ -253,7 +253,7 @@ explain extended select X(g),Y(g) FROM gis_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00
Warnings:
-Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
+Note 1003 select st_x(`test`.`gis_point`.`g`) AS `X(g)`,st_y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
fid AsText(StartPoint(g))
105 POINT(0 0)
@@ -288,7 +288,7 @@ explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),Num
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
+Note 1003 select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,st_astext(st_endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,st_length(`test`.`gis_line`.`g`) AS `GLength(g)`,st_numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,st_astext(st_pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,st_isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
@@ -318,7 +318,7 @@ explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumI
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
+Note 1003 select st_astext(st_centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,st_area(`test`.`gis_polygon`.`g`) AS `Area(g)`,st_astext(st_exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,st_numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,st_astext(st_interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
fid IsClosed(g)
114 0
@@ -357,7 +357,7 @@ explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
+Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
fid AsText(GeometryN(g, 2))
111 POINT(10 10)
@@ -385,17 +385,17 @@ explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
+Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_astext(st_geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
-120 120 1 1 0 1 0 0 1 0
+120 120 0 0 0 1 0 1 1 0
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
-121 121 1 1 0 1 0 0 1 0
+121 121 0 0 0 1 0 1 1 0
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
@@ -405,7 +405,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
+Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,st_within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,st_contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
a INTEGER PRIMARY KEY AUTO_INCREMENT,
@@ -500,7 +500,6 @@ mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
-center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
@@ -518,7 +517,6 @@ touches
down2,left2,right2,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
-big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 8f9b75fc664..ac03f3f924a 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -362,12 +362,12 @@ select cast(19999999999999999999 as signed);
cast(19999999999999999999 as signed)
9223372036854775807
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '19999999999999999999' to INT. Value truncated.
select cast(-19999999999999999999 as signed);
cast(-19999999999999999999 as signed)
-9223372036854775808
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-19999999999999999999' to INT. Value truncated.
select -9223372036854775808;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def -9223372036854775808 8 20 20 N 32897 0 63
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index dd61396e485..877a6badc16 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -1,9 +1,13 @@
select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED)
18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST('10 ' as unsigned integer);
CAST('10 ' as unsigned integer)
10
@@ -12,9 +16,15 @@ Warning 1292 Truncated incorrect INTEGER value: '10 '
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
18446744073709551611 18446744073709551611
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
18446744073709551610 18446744073709551612
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select ~5, cast(~5 as signed);
~5 cast(~5 as signed)
18446744073709551610 -6
@@ -23,12 +33,129 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
+select cast(18446744073709551615 as signed);
+cast(18446744073709551615 as signed)
+-1
select cast(5 as unsigned) -6.0;
cast(5 as unsigned) -6.0
-1.0
select cast(NULL as signed), cast(1/0 as signed);
cast(NULL as signed) cast(1/0 as signed)
NULL NULL
+select cast(1 as double(5,2));
+cast(1 as double(5,2))
+1.00
+select cast("5.2222" as double(5,2));
+cast("5.2222" as double(5,2))
+5.22
+select cast(12.444 as double(5,2));
+cast(12.444 as double(5,2))
+12.44
+select cast(cast(12.444 as decimal(10,3)) as double(5,2));
+cast(cast(12.444 as decimal(10,3)) as double(5,2))
+12.44
+select cast(null as double(5,2));
+cast(null as double(5,2))
+NULL
+select cast(12.444 as double);
+cast(12.444 as double)
+12.444
+select cast(cast("20:01:01" as time) as datetime);
+cast(cast("20:01:01" as time) as datetime)
+0000-00-00 20:01:01
+select cast(cast("8:46:06.23434" AS time) as decimal(32,10));
+cast(cast("8:46:06.23434" AS time) as decimal(32,10))
+84606.0000000000
+select cast(cast("2011-04-05 8:46:06.23434" AS datetime) as decimal(32,6));
+cast(cast("2011-04-05 8:46:06.23434" AS datetime) as decimal(32,6))
+20110405084606.000000
+#
+# Check handling of cast with microseconds
+#
+select cast(cast(20010203101112.121314 as double) as datetime);
+cast(cast(20010203101112.121314 as double) as datetime)
+2001-02-03 10:11:12
+select cast(cast(010203101112.12 as double) as datetime);
+cast(cast(010203101112.12 as double) as datetime)
+0001-02-03 10:11:12
+select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime);
+cast(cast(20010203101112.121314 as decimal(32,6)) as datetime)
+2001-02-03 10:11:12
+select cast(20010203101112.121314 as datetime);
+cast(20010203101112.121314 as datetime)
+2001-02-03 10:11:12
+select cast(110203101112.121314 as datetime);
+cast(110203101112.121314 as datetime)
+0011-02-03 10:11:12
+select cast(cast(010203101112.12 as double) as datetime);
+cast(cast(010203101112.12 as double) as datetime)
+0001-02-03 10:11:12
+select cast("2011-02-03 10:11:12.123456" as datetime);
+cast("2011-02-03 10:11:12.123456" as datetime)
+2011-02-03 10:11:12
+select cast("2011-02-03 10:11:12.123456" as datetime(0));
+cast("2011-02-03 10:11:12.123456" as datetime(0))
+2011-02-03 10:11:12
+select cast("2011-02-03 10:11:12.123456" as datetime(5));
+cast("2011-02-03 10:11:12.123456" as datetime(5))
+2011-02-03 10:11:12.12345
+select cast("2011-02-03 10:11:12.123456" as datetime(6));
+cast("2011-02-03 10:11:12.123456" as datetime(6))
+2011-02-03 10:11:12.123456
+select cast("2011-02-03 10:11:12" as datetime(6));
+cast("2011-02-03 10:11:12" as datetime(6))
+2011-02-03 10:11:12.000000
+select cast(cast(20010203101112.1 as double) as datetime(1));
+cast(cast(20010203101112.1 as double) as datetime(1))
+2001-02-03 10:11:12.1
+select cast(cast(010203101112.12 as double) as datetime(2));
+cast(cast(010203101112.12 as double) as datetime(2))
+0001-02-03 10:11:12.12
+select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime(6));
+cast(cast(20010203101112.121314 as decimal(32,6)) as datetime(6))
+2001-02-03 10:11:12.121314
+select cast(20010203101112.121314 as datetime(6));
+cast(20010203101112.121314 as datetime(6))
+2001-02-03 10:11:12.121314
+select cast(110203101112.121314 as datetime(6));
+cast(110203101112.121314 as datetime(6))
+0011-02-03 10:11:12.121314
+select cast(cast(010203101112.12 as double) as datetime(6));
+cast(cast(010203101112.12 as double) as datetime(6))
+0001-02-03 10:11:12.120000
+select cast("2011-02-03 10:11:12.123456" as time);
+cast("2011-02-03 10:11:12.123456" as time)
+10:11:12
+select cast("2011-02-03 10:11:12.123456" as time(6));
+cast("2011-02-03 10:11:12.123456" as time(6))
+10:11:12.123456
+select cast("10:11:12.123456" as time);
+cast("10:11:12.123456" as time)
+10:11:12
+select cast("10:11:12.123456" as time(0));
+cast("10:11:12.123456" as time(0))
+10:11:12
+select cast("10:11:12.123456" as time(5));
+cast("10:11:12.123456" as time(5))
+10:11:12.12345
+select cast("10:11:12.123456" as time(6));
+cast("10:11:12.123456" as time(6))
+10:11:12.123456
+select cast("10:11:12" as time(6));
+cast("10:11:12" as time(6))
+10:11:12.000000
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime) as time);
+cast(cast("2011-04-05 8:46:06.123456" AS datetime) as time)
+08:46:06
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime) as time(6));
+cast(cast("2011-04-05 8:46:06.123456" AS datetime) as time(6))
+08:46:06.000000
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime(6)) as time);
+cast(cast("2011-04-05 8:46:06.123456" AS datetime(6)) as time)
+08:46:06
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime(6)) as time(6));
+cast(cast("2011-04-05 8:46:06.123456" AS datetime(6)) as time(6))
+08:46:06.123456
select cast(NULL as unsigned), cast(1/0 as unsigned);
cast(NULL as unsigned) cast(1/0 as unsigned)
NULL NULL
@@ -111,6 +238,113 @@ select 10E+0+'a';
10
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
+select cast("a" as double(5,2));
+cast("a" as double(5,2))
+0.00
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'a'
+select cast(1000 as decimal(5,2));
+cast(1000 as decimal(5,2))
+999.99
+Warnings:
+Error 1264 Out of range value for column 'cast(1000 as decimal(5,2))' at row 1
+select cast(-1000 as decimal(5,2));
+cast(-1000 as decimal(5,2))
+-999.99
+Warnings:
+Error 1264 Out of range value for column 'cast(-1000 as decimal(5,2))' at row 1
+select cast(1000 as double(5,2));
+cast(1000 as double(5,2))
+999.99
+Warnings:
+Warning 1264 Out of range value for column 'cast(1000 as double(5,2))' at row 1
+select cast(-1000 as double(5,2));
+cast(-1000 as double(5,2))
+-999.99
+Warnings:
+Warning 1264 Out of range value for column 'cast(-1000 as double(5,2))' at row 1
+select cast(010203101112.121314 as datetime);
+cast(010203101112.121314 as datetime)
+0001-02-03 10:11:12
+select cast(120010203101112.121314 as datetime);
+cast(120010203101112.121314 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '120010203101112.121314'
+select cast(cast(1.1 as decimal) as datetime);
+cast(cast(1.1 as decimal) as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+select cast(cast(-1.1 as decimal) as datetime);
+cast(cast(-1.1 as decimal) as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '-1'
+select cast('0' as date);
+cast('0' as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+select cast('' as date);
+cast('' as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: ''
+select cast('0' as datetime);
+cast('0' as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+select cast('' as datetime);
+cast('' as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: ''
+select cast('0' as time);
+cast('0' as time)
+00:00:00
+select cast('' as time);
+cast('' as time)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect time value: ''
+select cast(NULL as DATE);
+cast(NULL as DATE)
+NULL
+select cast(NULL as DATETIME);
+cast(NULL as DATETIME)
+NULL
+select cast(NULL as TIME);
+cast(NULL as TIME)
+NULL
+select cast(NULL as BINARY);
+cast(NULL as BINARY)
+NULL
+select cast(cast(120010203101112.121314 as double) as datetime);
+cast(cast(120010203101112.121314 as double) as datetime)
+NULL
+select cast(cast(1.1 as double) as datetime);
+cast(cast(1.1 as double) as datetime)
+0000-00-00 00:00:01
+select cast(cast(-1.1 as double) as datetime);
+cast(cast(-1.1 as double) as datetime)
+NULL
+explain extended select cast(10 as double(5,2));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(10 as double(5,2)) AS `cast(10 as double(5,2))`
+explain extended select cast(10 as double);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(10 as double) AS `cast(10 as double)`
+explain extended select cast(10 as decimal(5,2));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(10 as decimal(5,2)) AS `cast(10 as decimal(5,2))`
select cast('18446744073709551616' as unsigned);
cast('18446744073709551616' as unsigned)
18446744073709551615
@@ -146,6 +380,18 @@ cast('' as signed)
0
Warnings:
Warning 1292 Truncated incorrect INTEGER value: ''
+select cast(1 as double(5,6));
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
+select cast(1 as decimal(5,6));
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
+select cast(1 as double(66,6));
+ERROR 42000: Too big precision 66 specified for '1'. Maximum is 65.
+select cast(1 as decimal(66,6));
+ERROR 42000: Too big precision 66 specified for '1'. Maximum is 65.
+select cast(1 as decimal(64,63));
+ERROR 42000: Too big scale 63 specified for '1'. Maximum is 30.
+select cast(1 as double(64,63));
+ERROR 42000: Too big scale 63 specified for '1'. Maximum is 30.
set names binary;
select cast(_latin1'test' as char character set latin2);
cast(_latin1'test' as char character set latin2)
@@ -254,13 +500,7 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
1
select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03"
-0
-select cast(NULL as DATE);
-cast(NULL as DATE)
-NULL
-select cast(NULL as BINARY);
-cast(NULL as BINARY)
-NULL
+1
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
@@ -337,6 +577,21 @@ Warning 1105 Cast to signed converted positive out-of-range integer to it's nega
select cast(1.0e+300 as signed int);
cast(1.0e+300 as signed int)
9223372036854775807
+create table t1 select cast(1 as unsigned), cast(1 as signed), cast(1 as double(5,2)), cast(1 as decimal(5,3)), cast("A" as binary), cast("A" as char(100)), cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME), cast("1:2:3" as TIME);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `cast(1 as unsigned)` int(1) unsigned NOT NULL DEFAULT '0',
+ `cast(1 as signed)` int(1) NOT NULL DEFAULT '0',
+ `cast(1 as double(5,2))` double(5,2) DEFAULT NULL,
+ `cast(1 as decimal(5,3))` decimal(5,3) NOT NULL DEFAULT '0.000',
+ `cast("A" as binary)` varbinary(1) NOT NULL DEFAULT '',
+ `cast("A" as char(100))` varbinary(100) NOT NULL DEFAULT '',
+ `cast("2001-1-1" as DATE)` date DEFAULT NULL,
+ `cast("2001-1-1" as DATETIME)` datetime DEFAULT NULL,
+ `cast("1:2:3" as TIME)` time DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
CREATE TABLE t1 (f1 double);
INSERT INTO t1 SET f1 = -1.0e+30 ;
INSERT INTO t1 SET f1 = +1.0e+30 ;
@@ -452,3 +707,29 @@ SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1
1
DROP TABLE t1;
End of 5.1 tests
+select cast("2101-00-01 02:03:04" as datetime);
+cast("2101-00-01 02:03:04" as datetime)
+2101-00-01 02:03:04
+select cast(cast("2101-00-01 02:03:04" as datetime) as time);
+cast(cast("2101-00-01 02:03:04" as datetime) as time)
+02:03:04
+SELECT CAST(CAST('20:05:05' AS TIME) as date);
+CAST(CAST('20:05:05' AS TIME) as date)
+0000-00-00
+set sql_mode= TRADITIONAL;
+select cast("2101-00-01 02:03:04" as datetime);
+cast("2101-00-01 02:03:04" as datetime)
+2101-00-01 02:03:04
+select cast(cast("2101-00-01 02:03:04" as datetime) as time);
+cast(cast("2101-00-01 02:03:04" as datetime) as time)
+02:03:04
+SELECT CAST(CAST('20:05:05' AS TIME) as date);
+CAST(CAST('20:05:05' AS TIME) as date)
+0000-00-00
+set sql_mode=DEFAULT;
+create table t1 (f1 time, f2 date, f3 datetime);
+insert into t1 values ('11:22:33','2011-12-13','2011-12-13 11:22:33');
+select cast(f1 as unsigned), cast(f2 as unsigned), cast(f3 as unsigned) from t1;
+cast(f1 as unsigned) cast(f2 as unsigned) cast(f3 as unsigned)
+112233 20111213 20111213112233
+drop table t1;
diff --git a/mysql-test/r/client_xml.result b/mysql-test/r/client_xml.result
index aa4bdb2bd61..7f74a092af7 100644
--- a/mysql-test/r/client_xml.result
+++ b/mysql-test/r/client_xml.result
@@ -21,9 +21,9 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
- <field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" />
- <field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" />
- <field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" />
+ <field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result
index 1f0b2c8019b..d21af5ef555 100644
--- a/mysql-test/r/commit_1innodb.result
+++ b/mysql-test/r/commit_1innodb.result
@@ -518,21 +518,21 @@ SUCCESS
# 12. Read-write statement: IODKU, change 0 rows.
#
insert t1 set a=2 on duplicate key update a=2;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
# 13. Read-write statement: INSERT IGNORE, change 0 rows.
#
insert ignore t1 set a=2;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
# 14. Read-write statement: INSERT IGNORE, change 1 row.
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index aab2ba0cad7..5d4ffa6b9d3 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1890,5 +1890,24 @@ create table t3 (a int) row_format=page;
drop table t1,t2,t3;
# -- End of Bug#45829
+# new table creation/renaming blocked if old encoded table present
+create table `t-1` (a int) engine=myisam;
+insert into `t-1` values (1);
+show tables;
+Tables_in_test
+t-1
+flush tables;
+convert table files in mysql 5.0 file name encoding
+show tables;
+Tables_in_test
+#mysql50#t-1
+create table `t-1` (a int);
+ERROR 42S01: Table '#mysql50#t-1' already exists
+create table t1 (a int);
+alter table t1 rename `t-1`;
+ERROR 42S01: Table '#mysql50#t-1' already exists
+rename table t1 to `t-1`;
+ERROR 42S01: Table '#mysql50#t-1' already exists
+drop table `#mysql50#t-1`, t1;
End of 5.1 tests
diff --git a/mysql-test/r/csv_not_null.result b/mysql-test/r/csv_not_null.result
index af583a36837..aed9bcb1587 100644
--- a/mysql-test/r/csv_not_null.result
+++ b/mysql-test/r/csv_not_null.result
@@ -19,13 +19,16 @@ INSERT INTO t1 VALUES();
SELECT * FROM t1;
a b c d e f
0 foo 0000-00-00
+INSERT INTO t1 VALUES(default,default,default,default,default,default);
SELECT * FROM t1;
a b c d e f
0 foo 0000-00-00
+0 foo 0000-00-00
INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31');
SELECT * FROM t1;
a b c d e f
0 foo 0000-00-00
+0 foo 0000-00-00
0 abc def ghi bar 1999-12-31
# === insert failures ===
INSERT INTO t1 VALUES(NULL,'ab','a','b','foo','2007-01-01');
diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result
index 7f0cdf3f17b..46ca1f25ef4 100644
--- a/mysql-test/r/ctype_cp1250_ch.result
+++ b/mysql-test/r/ctype_cp1250_ch.result
@@ -238,3 +238,6 @@ select a from t1 where a like "abcdefghá";
a
abcdefghá
drop table t1;
+set global LC_MESSAGES=convert((@@global.log_bin_trust_function_creators)
+using cp1250);
+ERROR HY000: Unknown system variable 'LC_MESSAGES'
diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result
index dc12f9ceb03..2e91ecb7bc0 100644
--- a/mysql-test/r/ctype_cp1251.result
+++ b/mysql-test/r/ctype_cp1251.result
@@ -375,6 +375,8 @@ FD FD FD D18D FD
FE FE FE D18E FE
FF FF FF D18F FF
DROP TABLE t1;
+set global LC_TIME_NAMES=convert((-8388608) using cp1251);
+ERROR HY000: Unknown locale: '-8388608'
#
# End of 5.1 tests
#
diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result
index 20eb73f4c42..6e4432c3091 100644
--- a/mysql-test/r/ctype_cp932_binlog_stm.result
+++ b/mysql-test/r/ctype_cp932_binlog_stm.result
@@ -44,6 +44,9 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t4 VALUES ( NAME_CONST('in
master-bin.000001 # Query # # use `test`; DROP PROCEDURE bug18293
master-bin.000001 # Query # # use `test`; DROP TABLE t4
End of 5.0 tests
+call mtr.add_suppression("Error in Log_event::read_log_event\\\(\\\): 'Found invalid");
+SHOW BINLOG EVENTS FROM 504;
+ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932;
INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result
index 21aa38b7fe6..21109f596c1 100644
--- a/mysql-test/r/ctype_eucjpms.result
+++ b/mysql-test/r/ctype_eucjpms.result
@@ -9859,3 +9859,5 @@ hex(convert(_eucjpms 0xA5FE41 using ucs2))
select hex(convert(_eucjpms 0x8FABF841 using ucs2));
hex(convert(_eucjpms 0x8FABF841 using ucs2))
003F0041
+set global LC_TIME_NAMES=convert((convert((0x63) using eucjpms)) using utf8);
+ERROR HY000: Unknown locale: 'c'
diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result
index 89e05bf4484..dbec746cdae 100644
--- a/mysql-test/r/ctype_many.result
+++ b/mysql-test/r/ctype_many.result
@@ -1683,3 +1683,18 @@ ARMENIAN CAPIT DA 2
ARMENIAN CAPIT ECH 2
ARMENIAN CAPIT ZA 2
DROP TABLE t1;
+#
+# Start of 5.1 tests
+#
+#
+# Bug#58371 Assertion failed: !s.uses_buffer_owned_by(this) with format string function
+#
+SET NAMES latin1;
+DO CONVERT(CAST(SUBSTRING_INDEX(FORMAT(1,'1111'), FORMAT('','Zpq'),1)
+AS BINARY(0)) USING utf8);
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'Zpq'
+Warning 1292 Truncated incorrect BINARY(0) value: '1.'
+#
+# End of 5.1 tests
+#
diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result
index 1469e335f23..087813d742b 100644
--- a/mysql-test/r/ctype_sjis.result
+++ b/mysql-test/r/ctype_sjis.result
@@ -218,4 +218,10 @@ hex(a) hex(lower(a)) hex(upper(a))
8352835E 8352835E 8352835E
8372835E 8372835E 8372835E
DROP TABLE t1;
+#
+# Bug#11766519 - Bug#59648: MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED.
+#
+SELECT QUOTE('ƒ\');
+QUOTE('ƒ\')
+'ƒ\'
# End of 5.1 tests
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index cc33980c1a2..fe1584301fa 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -990,8 +990,8 @@ old_password(name)
????????
select quote(name) from bug20536;
quote(name)
-????????
-????????????????
+'test1'
+'\'test\\_2\''
drop table bug20536;
set names ucs2;
ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2'
@@ -1238,6 +1238,17 @@ CREATE VIEW v1 AS SELECT 1 from t1
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+#
+# Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
+#
+SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850));
+HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850))
+00
+SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED);
+CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED)
+0
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: ''
End of 5.0 tests
Start of 5.1 tests
SET NAMES utf8;
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result
index a919a6f8c5e..dd346cb94dc 100644
--- a/mysql-test/r/date_formats.result
+++ b/mysql-test/r/date_formats.result
@@ -196,16 +196,16 @@ date format datetime
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
-2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
-2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
-2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
10:20:10 %H:%i:%s 0000-00-00 10:20:10
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
10:20:10 %T 0000-00-00 10:20:10
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
10:20:10AM %r 0000-00-00 10:20:10
-10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
+10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
15 September 2001 %d %M %Y 2001-09-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
@@ -421,14 +421,14 @@ date format str_to_date
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
Warnings:
-Warning 1292 Incorrect datetime value: '10:20:10AM'
+Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
select date,format,concat(str_to_date(date, format),'') as con from t1;
date format con
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
Warnings:
-Warning 1292 Incorrect datetime value: '10:20:10AM'
+Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
drop table t1;
select get_format(DATE, 'USA') as a;
a
@@ -471,14 +471,14 @@ str_to_date("2003-01-02", "%Y-%m-%d") as f3,
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
describe t1;
Field Type Null Key Default Extra
-f1 datetime YES NULL
-f2 time YES NULL
+f1 datetime(6) YES NULL
+f2 time(6) YES NULL
f3 date YES NULL
f4 date YES NULL
f5 time YES NULL
select * from t1;
f1 f2 f3 f4 f5
-2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00
+2003-01-02 10:11:12.001200 10:11:12.001200 2003-01-02 0000-00-02 58:00:00
drop table t1;
create table t1 select "02 10" as a, "%d %H" as b;
select str_to_date(a,b) from t1;
@@ -487,7 +487,7 @@ str_to_date(a,b)
create table t2 select str_to_date(a,b) from t1;
describe t2;
Field Type Null Key Default Extra
-str_to_date(a,b) datetime YES NULL
+str_to_date(a,b) datetime(6) YES NULL
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
@@ -495,7 +495,7 @@ str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
str_to_date("02 10", "%d %f") as f6;
f1 f2 f3 f4 f5 f6
-2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12 58:11:12 48:00:00.100000
+2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12.000000 58:11:12 48:00:00.100000
Warnings:
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012'
drop table t1, t2;
diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result
index fe24c17a1c5..4a4a425362d 100644
--- a/mysql-test/r/ddl_i18n_koi8r.result
+++ b/mysql-test/r/ddl_i18n_koi8r.result
@@ -724,7 +724,7 @@ utf8_general_ci utf8_general_ci
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest1`;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -757,8 +757,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -791,7 +791,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
@@ -800,7 +800,7 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest2`;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -833,8 +833,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -867,7 +867,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
@@ -1742,7 +1742,7 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1770,8 +1770,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1799,7 +1799,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
@@ -1821,7 +1821,7 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1849,8 +1849,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1878,7 +1878,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
@@ -2486,7 +2486,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER
USE `mysqltest1`;
/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2512,9 +2512,9 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2540,7 +2540,7 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;
/*!50106 SET TIME_ZONE= @save_time_zone */ ;
@@ -2553,7 +2553,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER
USE `mysqltest2`;
/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2579,9 +2579,9 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2607,7 +2607,7 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;
/*!50106 SET TIME_ZONE= @save_time_zone */ ;
diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result
index cf4272bf90c..7969ccafa09 100644
--- a/mysql-test/r/ddl_i18n_utf8.result
+++ b/mysql-test/r/ddl_i18n_utf8.result
@@ -724,7 +724,7 @@ utf8_general_ci utf8_general_ci
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest1`;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -757,8 +757,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -791,7 +791,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
@@ -800,7 +800,7 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest2`;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -833,8 +833,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -867,7 +867,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
@@ -1742,7 +1742,7 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1770,8 +1770,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1799,7 +1799,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
@@ -1821,7 +1821,7 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1849,8 +1849,8 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1878,7 +1878,7 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
@@ -2486,7 +2486,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER
USE `mysqltest1`;
/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2512,9 +2512,9 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2540,7 +2540,7 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;
/*!50106 SET TIME_ZONE= @save_time_zone */ ;
@@ -2553,7 +2553,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER
USE `mysqltest2`;
/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2579,9 +2579,9 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2607,7 +2607,7 @@ END */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
DELIMITER ;
/*!50106 SET TIME_ZONE= @save_time_zone */ ;
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 043231fd268..fe803ed37a5 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -57,9 +57,8 @@ a b a b
3 c 3 c
explain select * from t1 as x1, (select * from t1) as x2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY x1 ALL NULL NULL NULL NULL 4
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 4
+1 SIMPLE x1 ALL NULL NULL NULL NULL 4
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
drop table if exists t2,t3;
select * from (select 1) as a;
1
@@ -91,7 +90,7 @@ a b
2 b
explain select * from (select * from t1 union select * from t1) a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8
2 DERIVED t1 ALL NULL NULL NULL NULL 4
3 UNION t1 ALL NULL NULL NULL NULL 4
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
@@ -113,9 +112,8 @@ a b
3 c
explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t2 system NULL NULL NULL NULL 1
-2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 system NULL NULL NULL NULL 1
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
drop table t1, t2;
create table t1(a int not null, t char(8), index(a));
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
@@ -142,8 +140,7 @@ a t
20 20
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
-2 DERIVED t1 ALL NULL NULL NULL NULL 10000
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
(SELECT * FROM (SELECT 1 as a) as a )
@@ -172,30 +169,30 @@ insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd'
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
pla_id mat_id
-100 1
-101 1
102 1
-103 2
+101 1
+100 1
104 2
+103 2
105 3
SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
pla_id test
-100 1
-101 1
102 1
-103 2
+101 1
+100 1
104 2
+103 2
105 3
explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
drop table t1,t2;
@@ -230,9 +227,8 @@ count(*)
2
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where
-2 DERIVED A ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE A ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.A.E2 1 Using where
3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
drop table t1;
create table t1 (a int);
@@ -245,8 +241,8 @@ a a
2 2
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-1 PRIMARY <derived4> ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
+1 PRIMARY <derived4> ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
4 DERIVED t1 ALL NULL NULL NULL NULL 2
5 UNION t1 ALL NULL NULL NULL NULL 2
NULL UNION RESULT <union4,5> ALL NULL NULL NULL NULL NULL
@@ -311,7 +307,7 @@ a 7.0000
b 3.5000
explain SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 289 Using temporary; Using filesort
2 DERIVED x ALL NULL NULL NULL NULL 17 Using temporary; Using filesort
2 DERIVED y ALL NULL NULL NULL NULL 17 Using where; Using join buffer (flat, BNL join)
drop table t1;
@@ -322,8 +318,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
explain select a from (select a from t2 where a>1) tt;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
drop table t2;
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
insert into t1 values (128, 'rozn', 2, curdate(), 10),
@@ -412,3 +407,21 @@ MIN(i)
1
DROP TABLE t1;
# End of 5.0 tests
+#
+# LP bug #793436: query with a derived table for which optimizer proves
+# that it contains not more than 1 row
+#
+CREATE TABLE t1 (a int, KEY (a)) ;
+INSERT INTO t1 VALUES (3), (1);
+CREATE TABLE t2 (a int);
+INSERT INTO t2 VALUES (3);
+EXPLAIN
+SELECT * FROM (SELECT DISTINCT * FROM t2) t, t1 WHERE t1.a = t.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 1
+1 PRIMARY t1 ref a a 5 const 1 Using index
+2 DERIVED t2 system NULL NULL NULL NULL 1
+SELECT * FROM (SELECT DISTINCT * FROM t2) t, t1 WHERE t1.a = t.a;
+a a
+3 3
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
new file mode 100644
index 00000000000..5e3fc1e8cf1
--- /dev/null
+++ b/mysql-test/r/derived_view.result
@@ -0,0 +1,591 @@
+drop table if exists t1,t2;
+drop view if exists v1,v2,v3,v4;
+create table t1(f1 int, f11 int);
+create table t2(f2 int, f22 int);
+insert into t1 values(1,1),(2,2),(3,3),(5,5),(9,9),(7,7);
+insert into t1 values(17,17),(13,13),(11,11),(15,15),(19,19);
+insert into t2 values(1,1),(3,3),(2,2),(4,4),(8,8),(6,6);
+insert into t2 values(12,12),(14,14),(10,10),(18,18),(16,16);
+Tests:
+for merged derived tables
+explain for simple derived
+explain select * from (select * from t1) tt;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11
+select * from (select * from t1) tt;
+f1 f11
+1 1
+2 2
+3 3
+5 5
+9 9
+7 7
+17 17
+13 13
+11 11
+15 15
+19 19
+explain for multitable derived
+explain extended select * from (select * from t1 join t2 on f1=f2) tt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f2` = `test`.`t1`.`f1`)
+select * from (select * from t1 join t2 on f1=f2) tt;
+f1 f11 f2 f22
+1 1 1 1
+3 3 3 3
+2 2 2 2
+explain for derived with where
+explain extended
+select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` = 2) and (`test`.`t1`.`f1` in (2,3)))
+select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+f1 f11
+2 2
+join of derived
+explain extended
+select * from (select * from t1 where f1 in (2,3)) tt join
+(select * from t1 where f1 in (1,2)) aa on tt.f1=aa.f1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`f1` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` in (1,2)) and (`test`.`t1`.`f1` in (2,3)))
+select * from (select * from t1 where f1 in (2,3)) tt join
+(select * from t1 where f1 in (1,2)) aa on tt.f1=aa.f1;
+f1 f11 f1 f11
+2 2 2 2
+flush status;
+explain extended
+select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` = 2) and (`test`.`t1`.`f1` in (2,3)))
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 0
+flush status;
+select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+f1 f11
+2 2
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 12
+for merged views
+create view v1 as select * from t1;
+create view v2 as select * from t1 join t2 on f1=f2;
+create view v3 as select * from t1 where f1 in (2,3);
+create view v4 as select * from t2 where f2 in (2,3);
+explain for simple views
+explain extended select * from v1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1`
+select * from v1;
+f1 f11
+1 1
+2 2
+3 3
+5 5
+9 9
+7 7
+17 17
+13 13
+11 11
+15 15
+19 19
+explain for multitable views
+explain extended select * from v2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`f2` = `test`.`t1`.`f1`)
+select * from v2;
+f1 f11 f2 f22
+1 1 1 1
+3 3 3 3
+2 2 2 2
+explain for views with where
+explain extended select * from v3 where f11 in (1,3);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f11` in (1,3)) and (`test`.`t1`.`f1` in (2,3)))
+select * from v3 where f11 in (1,3);
+f1 f11
+3 3
+explain for joined views
+explain extended
+select * from v3 join v4 on f1=f2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`f2` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` in (2,3)) and (`test`.`t1`.`f1` in (2,3)))
+select * from v3 join v4 on f1=f2;
+f1 f11 f2 f22
+3 3 3 3
+2 2 2 2
+flush status;
+explain extended select * from v4 where f2 in (1,3);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 11 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where ((`test`.`t2`.`f2` in (1,3)) and (`test`.`t2`.`f2` in (2,3)))
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 0
+flush status;
+select * from v4 where f2 in (1,3);
+f2 f22
+3 3
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 12
+for materialized derived tables
+explain for simple derived
+explain extended select * from (select * from t1 group by f1) tt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` group by `test`.`t1`.`f1`) `tt`
+select * from (select * from t1 having f1=f1) tt;
+f1 f11
+1 1
+2 2
+3 3
+5 5
+9 9
+7 7
+17 17
+13 13
+11 11
+15 15
+19 19
+explain showing created indexes
+explain extended
+select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 100.00
+2 DERIVED t2 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from `test`.`t1` join (select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` group by `test`.`t2`.`f2`) `tt` where (`tt`.`f2` = `test`.`t1`.`f1`)
+select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+f1 f11 f2 f22
+1 1 1 1
+2 2 2 2
+3 3 3 3
+explain showing late materialization
+flush status;
+explain select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2
+2 DERIVED t2 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 0
+flush status;
+select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+f1 f11 f2 f22
+1 1 1 1
+2 2 2 2
+3 3 3 3
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 11
+Handler_read_next 3
+Handler_read_prev 0
+Handler_read_rnd 11
+Handler_read_rnd_next 36
+for materialized views
+drop view v1,v2,v3;
+create view v1 as select * from t1 group by f1;
+create view v2 as select * from t2 group by f2;
+create view v3 as select t1.f1,t1.f11 from t1 join t1 as t11 where t1.f1=t11.f1
+having t1.f1<100;
+explain for simple derived
+explain extended select * from v1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `v1`.`f1` AS `f1`,`v1`.`f11` AS `f11` from `test`.`v1`
+select * from v1;
+f1 f11
+1 1
+2 2
+3 3
+5 5
+7 7
+9 9
+11 11
+13 13
+15 15
+17 17
+19 19
+explain showing created indexes
+explain extended select * from t1 join v2 on f1=f2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2 100.00
+2 DERIVED t2 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`v2`.`f2` AS `f2`,`v2`.`f22` AS `f22` from `test`.`t1` join `test`.`v2` where (`v2`.`f2` = `test`.`t1`.`f1`)
+select * from t1 join v2 on f1=f2;
+f1 f11 f2 f22
+1 1 1 1
+2 2 2 2
+3 3 3 3
+explain extended
+select * from t1,v3 as v31,v3 where t1.f1=v31.f1 and t1.f1=v3.f1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 10 100.00
+1 PRIMARY <derived3> ref key0 key0 5 test.t1.f1 10 100.00
+3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00
+3 DERIVED t11 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+2 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED t11 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`v31`.`f1` AS `f1`,`v31`.`f11` AS `f11`,`v3`.`f1` AS `f1`,`v3`.`f11` AS `f11` from `test`.`t1` join `test`.`v3` `v31` join `test`.`v3` where ((`v31`.`f1` = `test`.`t1`.`f1`) and (`v3`.`f1` = `test`.`t1`.`f1`))
+flush status;
+select * from t1,v3 as v31,v3 where t1.f1=v31.f1 and t1.f1=v3.f1;
+f1 f11 f1 f11 f1 f11
+1 1 1 1 1 1
+2 2 2 2 2 2
+3 3 3 3 3 3
+5 5 5 5 5 5
+9 9 9 9 9 9
+7 7 7 7 7 7
+17 17 17 17 17 17
+13 13 13 13 13 13
+11 11 11 11 11 11
+15 15 15 15 15 15
+19 19 19 19 19 19
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 22
+Handler_read_next 22
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 60
+explain showing late materialization
+flush status;
+explain select * from t1 join v2 on f1=f2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2
+2 DERIVED t2 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 0
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 0
+flush status;
+select * from t1 join v2 on f1=f2;
+f1 f11 f2 f22
+1 1 1 1
+2 2 2 2
+3 3 3 3
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 11
+Handler_read_next 3
+Handler_read_prev 0
+Handler_read_rnd 11
+Handler_read_rnd_next 36
+explain extended select * from v1 join v4 on f1=f2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t2.f2 2 100.00
+2 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `v1`.`f1` AS `f1`,`v1`.`f11` AS `f11`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`v1` join `test`.`t2` where ((`v1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f2` in (2,3)))
+select * from v1 join v4 on f1=f2;
+f1 f11 f2 f22
+3 3 3 3
+2 2 2 2
+merged derived in merged derived
+explain extended select * from (select * from
+(select * from t1 where f1 < 7) tt where f1 > 2) zz;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7))
+select * from (select * from
+(select * from t1 where f1 < 7) tt where f1 > 2) zz;
+f1 f11
+3 3
+5 5
+materialized derived in merged derived
+explain extended select * from (select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2) zz;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE <derived3> ALL NULL NULL NULL NULL 11 100.00 Using where
+3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+Warnings:
+Note 1003 select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where (`test`.`t1`.`f1` < 7) group by `test`.`t1`.`f1`) `tt` where (`tt`.`f1` > 2)
+select * from (select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2) zz;
+f1 f11
+3 3
+5 5
+merged derived in materialized derived
+explain extended select * from (select * from
+(select * from t1 where f1 < 7) tt where f1 > 2 group by f1) zz;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+Warnings:
+Note 1003 select `zz`.`f1` AS `f1`,`zz`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where ((`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7)) group by `test`.`t1`.`f1`) `zz`
+select * from (select * from
+(select * from t1 where f1 < 7) tt where f1 > 2 group by f1) zz;
+f1 f11
+3 3
+5 5
+materialized derived in materialized derived
+explain extended select * from (select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) zz;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED <derived3> ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+Warnings:
+Note 1003 select `zz`.`f1` AS `f1`,`zz`.`f11` AS `f11` from (select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where (`test`.`t1`.`f1` < 7) group by `test`.`t1`.`f1`) `tt` where (`tt`.`f1` > 2) group by `tt`.`f1`) `zz`
+select * from (select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) zz;
+f1 f11
+3 3
+5 5
+mat in merged derived join mat in merged derived
+explain extended select * from
+(select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) x
+join
+(select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) z
+on x.f1 = z.f1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE <derived3> ALL key0 NULL NULL NULL 11 100.00 Using where
+1 SIMPLE <derived5> ref key0 key0 5 tt.f1 2 100.00
+5 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+Warnings:
+Note 1003 select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11`,`tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where (`test`.`t1`.`f1` < 7) group by `test`.`t1`.`f1`) `tt` join (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where (`test`.`t1`.`f1` < 7) group by `test`.`t1`.`f1`) `tt` where ((`tt`.`f1` = `tt`.`f1`) and (`tt`.`f1` > 2) and (`tt`.`f1` > 2))
+flush status;
+select * from
+(select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) x
+join
+(select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) z
+on x.f1 = z.f1;
+f1 f11 f1 f11
+3 3 3 3
+5 5 5 5
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 2
+Handler_read_next 2
+Handler_read_prev 0
+Handler_read_rnd 8
+Handler_read_rnd_next 39
+flush status;
+merged in merged derived join merged in merged derived
+explain extended select * from
+(select * from
+(select * from t1 where f1 < 7 ) tt where f1 > 2 ) x
+join
+(select * from
+(select * from t1 where f1 < 7 ) tt where f1 > 2 ) z
+on x.f1 = z.f1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11`,`test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` join `test`.`t1` where ((`test`.`t1`.`f1` = `test`.`t1`.`f1`) and (`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7) and (`test`.`t1`.`f1` > 2) and (`test`.`t1`.`f1` < 7))
+select * from
+(select * from
+(select * from t1 where f1 < 7 ) tt where f1 > 2 ) x
+join
+(select * from
+(select * from t1 where f1 < 7 ) tt where f1 > 2 ) z
+on x.f1 = z.f1;
+f1 f11 f1 f11
+3 3 3 3
+5 5 5 5
+materialized in materialized derived join
+materialized in materialized derived
+explain extended select * from
+(select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) x
+join
+(select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) z
+on x.f1 = z.f1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL key0 NULL NULL NULL 11 100.00 Using where
+1 PRIMARY <derived4> ref key0 key0 5 x.f1 2 100.00
+4 DERIVED <derived5> ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+5 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+2 DERIVED <derived3> ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+Warnings:
+Note 1003 select `x`.`f1` AS `f1`,`x`.`f11` AS `f11`,`z`.`f1` AS `f1`,`z`.`f11` AS `f11` from (select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where (`test`.`t1`.`f1` < 7) group by `test`.`t1`.`f1`) `tt` where (`tt`.`f1` > 2) group by `tt`.`f1`) `x` join (select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f11` AS `f11` from `test`.`t1` where (`test`.`t1`.`f1` < 7) group by `test`.`t1`.`f1`) `tt` where (`tt`.`f1` > 2) group by `tt`.`f1`) `z` where (`z`.`f1` = `x`.`f1`)
+select * from
+(select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) x
+join
+(select * from
+(select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) z
+on x.f1 = z.f1;
+f1 f11 f1 f11
+3 3 3 3
+5 5 5 5
+merged view in materialized derived
+explain extended
+select * from (select * from v4 group by 1) tt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED t2 ALL NULL NULL NULL NULL 11 100.00 Using where; Using temporary; Using filesort
+Warnings:
+Note 1003 select `tt`.`f2` AS `f2`,`tt`.`f22` AS `f22` from (select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where (`test`.`t2`.`f2` in (2,3)) group by 1) `tt`
+select * from (select * from v4 group by 1) tt;
+f2 f22
+2 2
+3 3
+materialized view in merged derived
+explain extended
+select * from ( select * from v1 where f1 < 7) tt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE <derived3> ALL NULL NULL NULL NULL 11 100.00 Using where
+3 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `v1`.`f1` AS `f1`,`v1`.`f11` AS `f11` from `test`.`v1` where (`v1`.`f1` < 7)
+select * from ( select * from v1 where f1 < 7) tt;
+f1 f11
+1 1
+2 2
+3 3
+5 5
+merged view in a merged view in a merged derived
+create view v6 as select * from v4 where f2 < 7;
+explain extended select * from (select * from v6) tt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 11 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22` from `test`.`t2` where ((`test`.`t2`.`f2` < 7) and (`test`.`t2`.`f2` in (2,3)))
+select * from (select * from v6) tt;
+f2 f22
+3 3
+2 2
+materialized view in a merged view in a materialized derived
+create view v7 as select * from v1;
+explain extended select * from (select * from v7 group by 1) tt;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 100.00
+2 DERIVED <derived4> ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+4 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `tt`.`f1` AS `f1`,`tt`.`f11` AS `f11` from (select `v1`.`f1` AS `f1`,`v1`.`f11` AS `f11` from `test`.`v1` group by 1) `tt`
+select * from (select * from v7 group by 1) tt;
+f1 f11
+1 1
+2 2
+3 3
+5 5
+7 7
+9 9
+11 11
+13 13
+15 15
+17 17
+19 19
+join of above two
+explain extended select * from v6 join v7 on f2=f1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 11 100.00 Using where
+1 SIMPLE <derived5> ref key0 key0 5 test.t2.f2 2 100.00
+5 DERIVED t1 ALL NULL NULL NULL NULL 11 100.00 Using temporary; Using filesort
+Warnings:
+Note 1003 select `test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f22` AS `f22`,`v1`.`f1` AS `f1`,`v1`.`f11` AS `f11` from `test`.`t2` join `test`.`v1` where ((`v1`.`f1` = `test`.`t2`.`f2`) and (`test`.`t2`.`f2` < 7) and (`test`.`t2`.`f2` in (2,3)))
+select * from v6 join v7 on f2=f1;
+f2 f22 f1 f11
+3 3 3 3
+2 2 2 2
+test two keys
+explain select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 xx on tt.f22=xx.f1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.f1 2
+1 PRIMARY xx ALL NULL NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join)
+2 DERIVED t2 ALL NULL NULL NULL NULL 11 Using temporary; Using filesort
+select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 xx on tt.f22=xx.f1;
+f1 f11 f2 f22 f1 f11
+1 1 1 1 1 1
+2 2 2 2 2 2
+3 3 3 3 3 3
+TODO: Add test with 64 tables mergeable view to test fall back to
+materialization on tables > MAX_TABLES merge
+drop table t1,t2;
+drop view v1,v2,v3,v4,v6,v7;
+#
+# LP bug #794909: crash when defining possible keys for
+# a materialized view/derived_table
+#
+CREATE TABLE t1 (f1 int) ;
+INSERT INTO t1 VALUES (149), (150), (224), (29);
+CREATE TABLE t2 (f1 int, KEY (f1));
+INSERT INTO t2 VALUES (149), (NULL), (224);
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN
+SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index f1 f1 5 NULL 3 Using where; Using index
+1 PRIMARY <derived2> ref key0 key0 5 test.t2.f1 2
+2 DERIVED t1 ALL NULL NULL NULL NULL 4
+SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1;
+f1 f1
+149 149
+224 224
+DROP VIEW v1;
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index ac87ea049a0..eafd16440b0 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -794,3 +794,53 @@ DROP TABLE t1;
SET @@sort_buffer_size = @old_sort_buffer_size;
SET @@max_heap_table_size = @old_max_heap_table_size;
End of 5.1 tests
+create table t1 (a varchar(100));
+insert t1 values ('2010-10-10'), ('20101010');
+select * from t1 where a = DATE('2010-10-10');
+a
+2010-10-10
+20101010
+select distinct a from t1 where a = DATE('2010-10-10');
+a
+2010-10-10
+20101010
+explain select distinct a from t1 where a = DATE('2010-10-10');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using temporary
+drop table t1;
+# date = string
+create table t1 (a date);
+insert t1 values ('2010-10-10'), ('20101010');
+explain select distinct a from t1 where a = '2010-10-10';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
+drop table t1;
+# double = string
+create table t1 (a double);
+insert t1 values (2), (2);
+explain select distinct a from t1 where a = '2';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
+# double = int
+explain select distinct a from t1 where a = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
+# string = double
+alter table t1 modify a varchar(100);
+explain select distinct a from t1 where a = 2e0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using temporary
+drop table t1;
+create table t1 (f1 varchar(40));
+insert into t1 values ('2010-10-10 00:00:00.0001'),('2010-10-10 00:00:00.0002'),('2010-10-10 00:00:00.0003');
+select time(f1) from t1 ;
+time(f1)
+00:00:00.000100
+00:00:00.000200
+00:00:00.000300
+select distinct time(f1) from t1 ;
+time(f1)
+00:00:00.000100
+00:00:00.000200
+00:00:00.000300
+drop table t1;
diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result
new file mode 100644
index 00000000000..d38660adcc6
--- /dev/null
+++ b/mysql-test/r/dyncol.result
@@ -0,0 +1,1337 @@
+#
+# column create
+#
+select hex(COLUMN_CREATE(1, NULL AS char character set utf8));
+hex(COLUMN_CREATE(1, NULL AS char character set utf8))
+000000
+select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8));
+hex(COLUMN_CREATE(1, "afaf" AS char character set utf8))
+0001000100030861666166
+select hex(COLUMN_CREATE(1, 1212 AS char character set utf8));
+hex(COLUMN_CREATE(1, 1212 AS char character set utf8))
+0001000100033F31323132
+select hex(COLUMN_CREATE(1, 12.12 AS char character set utf8));
+hex(COLUMN_CREATE(1, 12.12 AS char character set utf8))
+0001000100033F31322E3132
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS char character set utf8));
+hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS char character set utf8))
+0001000100033F3939393939393939393939393939393939393939393939393939393939
+select hex(COLUMN_CREATE(1, NULL AS unsigned int));
+hex(COLUMN_CREATE(1, NULL AS unsigned int))
+000000
+select hex(COLUMN_CREATE(1, 1212 AS unsigned int));
+hex(COLUMN_CREATE(1, 1212 AS unsigned int))
+000100010001BC04
+select hex(COLUMN_CREATE(1, 7 AS unsigned int));
+hex(COLUMN_CREATE(1, 7 AS unsigned int))
+00010001000107
+select hex(COLUMN_CREATE(1, 8 AS unsigned int));
+hex(COLUMN_CREATE(1, 8 AS unsigned int))
+00010001000108
+select hex(COLUMN_CREATE(1, 127 AS unsigned int));
+hex(COLUMN_CREATE(1, 127 AS unsigned int))
+0001000100017F
+select hex(COLUMN_CREATE(1, 128 AS unsigned int));
+hex(COLUMN_CREATE(1, 128 AS unsigned int))
+00010001000180
+select hex(COLUMN_CREATE(1, 12.12 AS unsigned int));
+hex(COLUMN_CREATE(1, 12.12 AS unsigned int))
+0001000100010C
+select hex(COLUMN_CREATE(1, ~0));
+hex(COLUMN_CREATE(1, ~0))
+000100010001FFFFFFFFFFFFFFFF
+select hex(COLUMN_CREATE(1, -1));
+hex(COLUMN_CREATE(1, -1))
+00010001000001
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int));
+hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int))
+000100010001FFFFFFFFFFFFFF7F
+Warnings:
+Error 1916 Got overflow when converting '99999999999999999999999999999' to INT. Value truncated.
+select hex(COLUMN_CREATE(1, NULL AS int));
+hex(COLUMN_CREATE(1, NULL AS int))
+000000
+select hex(COLUMN_CREATE(1, 1212 AS int));
+hex(COLUMN_CREATE(1, 1212 AS int))
+0001000100007809
+select hex(COLUMN_CREATE(1, 7 AS int));
+hex(COLUMN_CREATE(1, 7 AS int))
+0001000100000E
+select hex(COLUMN_CREATE(1, 8 AS int));
+hex(COLUMN_CREATE(1, 8 AS int))
+00010001000010
+select hex(COLUMN_CREATE(1, 127 AS int));
+hex(COLUMN_CREATE(1, 127 AS int))
+000100010000FE
+select hex(COLUMN_CREATE(1, 128 AS int));
+hex(COLUMN_CREATE(1, 128 AS int))
+0001000100000001
+select hex(COLUMN_CREATE(1, 12.12 AS int));
+hex(COLUMN_CREATE(1, 12.12 AS int))
+00010001000018
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS int));
+hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS int))
+000100010000FEFFFFFFFFFFFFFF
+Warnings:
+Error 1916 Got overflow when converting '99999999999999999999999999999' to INT. Value truncated.
+select hex(COLUMN_CREATE(1, NULL AS double));
+hex(COLUMN_CREATE(1, NULL AS double))
+000000
+select hex(COLUMN_CREATE(1, 1212 AS double));
+hex(COLUMN_CREATE(1, 1212 AS double))
+0001000100020000000000F09240
+select hex(COLUMN_CREATE(1, 12.12 AS double));
+hex(COLUMN_CREATE(1, 12.12 AS double))
+0001000100023D0AD7A3703D2840
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS double));
+hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS double))
+00010001000221D7E6FAE031F445
+select hex(COLUMN_CREATE(1, NULL AS decimal));
+hex(COLUMN_CREATE(1, NULL AS decimal))
+000000
+select hex(COLUMN_CREATE(1, 1212 AS decimal));
+hex(COLUMN_CREATE(1, 1212 AS decimal))
+0001000100040900800004BC
+select hex(COLUMN_CREATE(1, 7 AS decimal));
+hex(COLUMN_CREATE(1, 7 AS decimal))
+000100010004090080000007
+select hex(COLUMN_CREATE(1, 8 AS decimal));
+hex(COLUMN_CREATE(1, 8 AS decimal))
+000100010004090080000008
+select hex(COLUMN_CREATE(1, 127 AS decimal));
+hex(COLUMN_CREATE(1, 127 AS decimal))
+00010001000409008000007F
+select hex(COLUMN_CREATE(1, 128 AS decimal));
+hex(COLUMN_CREATE(1, 128 AS decimal))
+000100010004090080000080
+select hex(COLUMN_CREATE(1, 12.12 AS decimal));
+hex(COLUMN_CREATE(1, 12.12 AS decimal))
+00010001000402028C0C
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS decimal));
+hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS decimal))
+0001000100041D00E33B9AC9FF3B9AC9FF3B9AC9FF
+select hex(COLUMN_CREATE(1, NULL AS date));
+hex(COLUMN_CREATE(1, NULL AS date))
+000000
+select hex(COLUMN_CREATE(1, "2011-04-05" AS date));
+hex(COLUMN_CREATE(1, "2011-04-05" AS date))
+00010001000685B60F
+select hex(COLUMN_CREATE(1, NULL AS time));
+hex(COLUMN_CREATE(1, NULL AS time))
+000000
+select hex(COLUMN_CREATE(1, "0:45:49.000001" AS time));
+hex(COLUMN_CREATE(1, "0:45:49.000001" AS time))
+000100010007010010B70000
+select hex(COLUMN_CREATE(1, NULL AS datetime));
+hex(COLUMN_CREATE(1, NULL AS datetime))
+000000
+select hex(COLUMN_CREATE(1, "2011-04-05 0:45:49.000001" AS datetime));
+hex(COLUMN_CREATE(1, "2011-04-05 0:45:49.000001" AS datetime))
+00010001000585B60F010010B70000
+select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
+2, 1212 AS unsigned int,
+3, 1212 AS int,
+4, 12.12 AS double,
+4+1, 12.12 AS decimal,
+6, "2011-04-05" AS date,
+7, "- 0:45:49.000001" AS time,
+8, "2011-04-05 0:45:49.000001" AS datetime));
+hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
+2, 1212 AS unsigned int,
+3, 1212 AS int,
+4, 12.12 AS double,
+4+1, 12.12 AS decimal,
+6, "2011-04-05" AS date,
+7, "- 0:45:49.000001" AS time,
+8, "2011-04-05 0:45:49.000001" AS datetime))
+01080001000300020029000300380004004A0005008C000600AE000700C7000800F5000861666166BC0478093D0AD7A3703D284002028C0C85B60F010010B7000485B60F010010B70000
+explain extended
+select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
+2, 1212 AS unsigned int,
+3, 1212 AS int,
+4, 12.12 AS double,
+4+1, 12.12 AS decimal,
+6, "2011-04-05" AS date,
+7, "- 0:45:49.000001" AS time,
+8, "2011-04-05 0:45:49.000001" AS datetime));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select hex(column_create(1,'afaf' AS char charset utf8 ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,(4 + 1),12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
+2, 1212 AS unsigned int,
+3, 1212 AS int,
+4, 12.12 AS double,
+4+1, 12.12 AS decimal,
+6, "2011-04-05" AS date,
+7, "- 0:45:49.000001" AS time,
+8, "2011-04-05 0:45:49.000001" AS datetime))`
+select hex(column_create(1, 0.0 AS decimal));
+hex(column_create(1, 0.0 AS decimal))
+000100010004
+select hex(column_create(1, 1.0 AS decimal));
+hex(column_create(1, 1.0 AS decimal))
+00010001000401018100
+#
+# column get uint
+#
+select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
+column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int)
+1212
+explain extended
+select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212 AS unsigned int),1) as unsigned) AS `column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int)`
+explain extended
+select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212 AS unsigned int),1) as unsigned) AS `column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned)`
+select column_get(column_create(1, 1212 AS decimal), 1 as unsigned int);
+column_get(column_create(1, 1212 AS decimal), 1 as unsigned int)
+1212
+select column_get(column_create(1, 1212 AS double), 1 as unsigned int);
+column_get(column_create(1, 1212 AS double), 1 as unsigned int)
+1212
+select column_get(column_create(1, 1212 AS int), 1 as unsigned int);
+column_get(column_create(1, 1212 AS int), 1 as unsigned int)
+1212
+select column_get(column_create(1, "1212" AS char), 1 as unsigned int);
+column_get(column_create(1, "1212" AS char), 1 as unsigned int)
+1212
+select column_get(column_create(1, "2011-04-05" AS date), 1 as unsigned int);
+column_get(column_create(1, "2011-04-05" AS date), 1 as unsigned int)
+20110405
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as unsigned int);
+column_get(column_create(1, "8:46:06.23434" AS time), 1 as unsigned int)
+84606
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as unsigned int);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as unsigned int)
+20110405084606
+select column_get(column_create(1, NULL AS unsigned int), 1 as unsigned int);
+column_get(column_create(1, NULL AS unsigned int), 1 as unsigned int)
+NULL
+# column geint truncation & warnings
+select column_get(column_create(1, -1212 AS int), 1 as unsigned int);
+column_get(column_create(1, -1212 AS int), 1 as unsigned int)
+18446744073709550404
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as unsigned int);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as unsigned int)
+18446744073709551615
+Warnings:
+Error 1916 Got overflow when converting '99999999999999999999999999999' to UNSIGNED INT. Value truncated.
+select column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as unsigned int);
+column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as unsigned int)
+1000
+select column_get(column_create(1, -1 AS decimal), 1 as unsigned int);
+column_get(column_create(1, -1 AS decimal), 1 as unsigned int)
+0
+Warnings:
+Error 1916 Got overflow when converting '-1' to UNSIGNED INT. Value truncated.
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as unsigned int);
+column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as unsigned int)
+18446744073709551615
+Warnings:
+Warning 1916 Got overflow when converting '1e+29' to UNSIGNED INT. Value truncated.
+select column_get(column_create(1, 999.9 AS double), 1 as unsigned int);
+column_get(column_create(1, 999.9 AS double), 1 as unsigned int)
+1000
+select column_get(column_create(1, -1 AS double), 1 as unsigned int);
+column_get(column_create(1, -1 AS double), 1 as unsigned int)
+0
+Warnings:
+Warning 1916 Got overflow when converting '-1' to UNSIGNED INT. Value truncated.
+select column_get(column_create(1, "1212III" AS char), 1 as unsigned int);
+column_get(column_create(1, "1212III" AS char), 1 as unsigned int)
+1212
+Warnings:
+Warning 1918 Encountered illegal value '1212III' when converting to UNSIGNED INT
+#
+# column get int
+#
+select column_get(column_create(1, 1212 AS int), 1 as int);
+column_get(column_create(1, 1212 AS int), 1 as int)
+1212
+explain extended
+select column_get(column_create(1, 1212 AS int), 1 as int);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212 AS int),1) as signed) AS `column_get(column_create(1, 1212 AS int), 1 as int)`
+explain extended
+select column_get(column_create(1, 1212 AS int), 1 as signed int);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212 AS int),1) as signed) AS `column_get(column_create(1, 1212 AS int), 1 as signed int)`
+select column_get(column_create(1, -1212 AS int), 1 as int);
+column_get(column_create(1, -1212 AS int), 1 as int)
+-1212
+select column_get(column_create(1, 1212 AS decimal), 1 as int);
+column_get(column_create(1, 1212 AS decimal), 1 as int)
+1212
+select column_get(column_create(1, 1212 AS double), 1 as int);
+column_get(column_create(1, 1212 AS double), 1 as int)
+1212
+select column_get(column_create(1, 1212 AS unsigned int), 1 as int);
+column_get(column_create(1, 1212 AS unsigned int), 1 as int)
+1212
+select column_get(column_create(1, "1212" AS char), 1 as int);
+column_get(column_create(1, "1212" AS char), 1 as int)
+1212
+select column_get(column_create(1, "-1212" AS char), 1 as int);
+column_get(column_create(1, "-1212" AS char), 1 as int)
+-1212
+select column_get(column_create(1, "2011-04-05" AS date), 1 as int);
+column_get(column_create(1, "2011-04-05" AS date), 1 as int)
+20110405
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as int);
+column_get(column_create(1, "8:46:06.23434" AS time), 1 as int)
+84606
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as int);
+column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as int)
+84606
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as int);
+column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as int)
+-8084606
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as int);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as int)
+20110405084606
+select column_get(column_create(1, NULL AS int), 1 as int);
+column_get(column_create(1, NULL AS int), 1 as int)
+NULL
+#column gett truncation & warnings
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as int);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as int)
+-1
+Warnings:
+Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as int);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as int)
+9223372036854775807
+Warnings:
+Error 1916 Got overflow when converting '99999999999999999999999999999' to INT. Value truncated.
+select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as int);
+column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as int)
+-9223372036854775808
+Warnings:
+Error 1916 Got overflow when converting '-99999999999999999999999999999' to INT. Value truncated.
+select column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as int);
+column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as int)
+1000
+select column_get(column_create(1, 999.9 AS double), 1 as int);
+column_get(column_create(1, 999.9 AS double), 1 as int)
+1000
+select column_get(column_create(1, -99999999999999999999999999999 AS double), 1 as int);
+column_get(column_create(1, -99999999999999999999999999999 AS double), 1 as int)
+-9223372036854775808
+Warnings:
+Warning 1916 Got overflow when converting '-1e+29' to INT. Value truncated.
+select column_get(column_create(1, "-1212III" AS char), 1 as int);
+column_get(column_create(1, "-1212III" AS char), 1 as int)
+-1212
+Warnings:
+Warning 1918 Encountered illegal value '-1212III' when converting to INT
+select column_get(column_create(1, "1212III" AS char), 1 as int);
+column_get(column_create(1, "1212III" AS char), 1 as int)
+1212
+Warnings:
+Warning 1918 Encountered illegal value '1212III' when converting to INT
+select column_get(COLUMN_CREATE(1, ~0), 1 as signed);
+column_get(COLUMN_CREATE(1, ~0), 1 as signed)
+-1
+Warnings:
+Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
+select column_get(COLUMN_CREATE(1, ~0), 1 as unsigned);
+column_get(COLUMN_CREATE(1, ~0), 1 as unsigned)
+18446744073709551615
+select column_get(COLUMN_CREATE(1, -1), 1 as signed);
+column_get(COLUMN_CREATE(1, -1), 1 as signed)
+-1
+select column_get(COLUMN_CREATE(1, -1), 1 as unsigned);
+column_get(COLUMN_CREATE(1, -1), 1 as unsigned)
+18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+#
+#column get char
+#
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8);
+column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8)
+1212
+explain extended
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,'1212' AS char charset utf8 ),1) as char charset utf8) AS `column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8)`
+select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8);
+column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8)
+1212
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as char charset utf8);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as char charset utf8)
+18446744073709551615
+select column_get(column_create(1, 1212 AS int), 1 as char charset utf8);
+column_get(column_create(1, 1212 AS int), 1 as char charset utf8)
+1212
+select column_get(column_create(1, -1212 AS int), 1 as char charset utf8);
+column_get(column_create(1, -1212 AS int), 1 as char charset utf8)
+-1212
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as char charset utf8);
+column_get(column_create(1, 9223372036854775807 AS int), 1 as char charset utf8)
+9223372036854775807
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as char charset utf8);
+column_get(column_create(1, -9223372036854775808 AS int), 1 as char charset utf8)
+-9223372036854775808
+select column_get(column_create(1, 1212.12 AS decimal), 1 as char charset utf8);
+column_get(column_create(1, 1212.12 AS decimal), 1 as char charset utf8)
+1212.12
+select column_get(column_create(1, 1212.12 AS double), 1 as char charset utf8);
+column_get(column_create(1, 1212.12 AS double), 1 as char charset utf8)
+1212.12
+select column_get(column_create(1, "2011-04-05" AS date), 1 as char charset utf8);
+column_get(column_create(1, "2011-04-05" AS date), 1 as char charset utf8)
+2011-04-05
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as char charset utf8);
+column_get(column_create(1, "8:46:06.23434" AS time), 1 as char charset utf8)
+08:46:06.234340
+select column_get(column_create(1, "8:46:06.23434" AS time(0)), 1 as char charset utf8);
+column_get(column_create(1, "8:46:06.23434" AS time(0)), 1 as char charset utf8)
+08:46:06.234340
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as char charset utf8);
+column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as char charset utf8)
+08:46:06.234340
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as char charset utf8);
+column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as char charset utf8)
+-808:46:06.234340
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as char charset utf8);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as char charset utf8)
+2011-04-05 08:46:06.234340
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(0)), 1 as char charset utf8);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(0)), 1 as char charset utf8)
+2011-04-05 08:46:06.234340
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as char charset utf8);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as char charset utf8)
+2011-04-05 08:46:06.234340
+select column_get(column_create(1, NULL AS char charset utf8), 1 as char charset utf8);
+column_get(column_create(1, NULL AS char charset utf8), 1 as char charset utf8)
+NULL
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary);
+column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary)
+1212
+explain extended
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,'1212' AS char charset utf8 ),1) as char charset binary) AS `column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary)`
+#
+# column get real
+#
+select column_get(column_create(1, 1212.12 AS double), 1 as double);
+column_get(column_create(1, 1212.12 AS double), 1 as double)
+1212.12
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as double);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as double) AS `column_get(column_create(1, 1212.12 AS double), 1 as double)`
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as double(6,2));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as double(6,2)) AS `column_get(column_create(1, 1212.12 AS double), 1 as double(6,2))`
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as double);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as double)
+1.84467440737096e+19
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as double);
+column_get(column_create(1, 9223372036854775807 AS int), 1 as double)
+9.22337203685478e+18
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as double);
+column_get(column_create(1, -9223372036854775808 AS int), 1 as double)
+-9.22337203685478e+18
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as double);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as double)
+1e+29
+select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as double);
+column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as double)
+-1e+29
+select column_get(column_create(1, "2011-04-05" AS date), 1 as double);
+column_get(column_create(1, "2011-04-05" AS date), 1 as double)
+20110405
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as double);
+column_get(column_create(1, "8:46:06.23434" AS time), 1 as double)
+84606.23434
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as double);
+column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as double)
+84606.23434
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as double);
+column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as double)
+-8084606.23434
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double)
+20110405084606.2
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as double);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as double)
+20110405084606.2
+select round(column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double(20,6)),3);
+round(column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double(20,6)),3)
+20110405084606.234
+select column_get(column_create(1, NULL AS double), 1 as double);
+column_get(column_create(1, NULL AS double), 1 as double)
+NULL
+# column get real truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as double);
+column_get(column_create(1, "1223.5aa" AS char), 1 as double)
+1223.5
+Warnings:
+Warning 1918 Encountered illegal value '1223.5aa' when converting to DOUBLE
+select column_get(column_create(1, "aa" AS char), 1 as double);
+column_get(column_create(1, "aa" AS char), 1 as double)
+0
+Warnings:
+Warning 1918 Encountered illegal value 'aa' when converting to DOUBLE
+select column_get(column_create(1, "1223.5555" AS double), 1 as double(5,2));
+column_get(column_create(1, "1223.5555" AS double), 1 as double(5,2))
+999.99
+Warnings:
+Warning 1264 Out of range value for column 'column_get(column_create(1, "1223.5555" AS double), 1 as double(5,2))' at row 1
+select column_get(column_create(1, "1223.5555" AS double), 1 as double(3,2));
+column_get(column_create(1, "1223.5555" AS double), 1 as double(3,2))
+9.99
+Warnings:
+Warning 1264 Out of range value for column 'column_get(column_create(1, "1223.5555" AS double), 1 as double(3,2))' at row 1
+#
+# column get decimal
+#
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
+column_get(column_create(1, 1212.12 AS double), 1 as decimal)
+1212
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
+column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2))
+1212.12
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as decimal(10,0)) AS `column_get(column_create(1, 1212.12 AS double), 1 as decimal)`
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(column_get(column_create(1,1212.12 AS double),1) as decimal(6,2)) AS `column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2))`
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal(20,0));
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal(20,0))
+18446744073709551615
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal(32,0));
+column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal(32,0))
+9223372036854775807
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal(32,0));
+column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal(32,0))
+-9223372036854775808
+select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as decimal(40,10));
+column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as decimal(40,10))
+-99999999999999999999999999999.0000000000
+select column_get(column_create(1, "2011-04-05" AS date), 1 as decimal(32,6));
+column_get(column_create(1, "2011-04-05" AS date), 1 as decimal(32,6))
+20110405.000000
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as decimal(32,6));
+column_get(column_create(1, "8:46:06.23434" AS time), 1 as decimal(32,6))
+84606.234340
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as decimal(32,6));
+column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as decimal(32,6))
+84606.234340
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as decimal(32,6));
+column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as decimal(32,6))
+-8084606.234340
+select column_get(column_create(1, "2011-04-05 8:46:06.123456" AS datetime), 1 as decimal(32,6));
+column_get(column_create(1, "2011-04-05 8:46:06.123456" AS datetime), 1 as decimal(32,6))
+20110405084606.123456
+select column_get(column_create(1, "2011-04-05 8:46:06.123456" AS datetime(6)), 1 as decimal(32,6));
+column_get(column_create(1, "2011-04-05 8:46:06.123456" AS datetime(6)), 1 as decimal(32,6))
+20110405084606.123456
+select column_get(column_create(1, "2011-04-05 8:46:06.12345678" AS datetime(6)), 1 as decimal(32,8));
+column_get(column_create(1, "2011-04-05 8:46:06.12345678" AS datetime(6)), 1 as decimal(32,8))
+20110405084606.12345600
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2011-04-05 8:46:06.12345678'
+select column_get(column_create(1, NULL as decimal), 1 as decimal(32,10));
+column_get(column_create(1, NULL as decimal), 1 as decimal(32,10))
+NULL
+select column_get(column_create(1, "1223.5555" as decimal(10,5)), 1 as decimal(6,2));
+column_get(column_create(1, "1223.5555" as decimal(10,5)), 1 as decimal(6,2))
+1223.56
+# column get decimal truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as decimal(32,10));
+column_get(column_create(1, "1223.5aa" AS char), 1 as decimal(32,10))
+1223.5000000000
+Warnings:
+Warning 1918 Encountered illegal value '1223.5aa' when converting to DECIMAL
+select column_get(column_create(1, "aa" AS char), 1 as decimal(32,10));
+column_get(column_create(1, "aa" AS char), 1 as decimal(32,10))
+0.0000000000
+Warnings:
+Warning 1918 Encountered illegal value 'aa' when converting to DECIMAL
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal)
+9999999999
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal)' at row 1
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal);
+column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal)
+9999999999
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal)' at row 1
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal);
+column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal)
+-9999999999
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal)' at row 1
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as decimal);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as decimal)
+9999999999
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as decimal)' at row 1
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as decimal);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as decimal)
+9999999999
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as decimal)' at row 1
+select column_get(column_create(1, "1223.5555" as double), 1 as decimal(5,2));
+column_get(column_create(1, "1223.5555" as double), 1 as decimal(5,2))
+999.99
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, "1223.5555" as double), 1 as decimal(5,2))' at row 1
+select column_get(column_create(1, "-1223.5555" as double), 1 as decimal(5,2));
+column_get(column_create(1, "-1223.5555" as double), 1 as decimal(5,2))
+-999.99
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, "-1223.5555" as double), 1 as decimal(5,2))' at row 1
+select column_get(column_create(1, "1223.5555" AS double), 1 as decimal(3,2));
+column_get(column_create(1, "1223.5555" AS double), 1 as decimal(3,2))
+9.99
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, "1223.5555" AS double), 1 as decimal(3,2))' at row 1
+select column_get(column_create(1, "1223.5555" AS decimal(10,5)), 1 as decimal(3,2));
+column_get(column_create(1, "1223.5555" AS decimal(10,5)), 1 as decimal(3,2))
+9.99
+Warnings:
+Error 1264 Out of range value for column 'column_get(column_create(1, "1223.5555" AS decimal(10,5)), 1 as decimal(3,2))' at row 1
+select column_get(column_create(1, 0.0 AS decimal,2, 0.0 as decimal), 1 as decimal);
+column_get(column_create(1, 0.0 AS decimal,2, 0.0 as decimal), 1 as decimal)
+0
+#
+# column get datetime
+#
+select column_get(column_create(1, 20010203101112.121314 as double), 1 as datetime);
+column_get(column_create(1, 20010203101112.121314 as double), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as datetime);
+column_get(column_create(1, 20010203101112.121314 as decimal), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, 20010203101112 as unsigned int), 1 as datetime);
+column_get(column_create(1, 20010203101112 as unsigned int), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, 20010203101112 as int), 1 as datetime);
+column_get(column_create(1, 20010203101112 as int), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, "20010203101112" as char), 1 as datetime);
+column_get(column_create(1, "20010203101112" as char), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as datetime);
+column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as datetime);
+column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as datetime);
+column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as datetime)
+2001-02-03 10:11:12
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime)
+2011-04-05 08:46:06
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime(0));
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime(0))
+2011-04-05 08:46:06
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime(6));
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime(6))
+2011-04-05 08:46:06.234340
+select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as datetime)
+2011-00-00 08:46:06
+select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as datetime)
+2011-00-01 08:46:06
+select column_get(column_create(1, 20010203 as unsigned int), 1 as datetime);
+column_get(column_create(1, 20010203 as unsigned int), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, 20010203 as int), 1 as datetime);
+column_get(column_create(1, 20010203 as int), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, 20010203), 1 as datetime);
+column_get(column_create(1, 20010203), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, 20010203.0), 1 as datetime);
+column_get(column_create(1, 20010203.0), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, 20010203.0 as double), 1 as datetime);
+column_get(column_create(1, 20010203.0 as double), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, "2001-02-03"), 1 as datetime);
+column_get(column_create(1, "2001-02-03"), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, "20010203"), 1 as datetime);
+column_get(column_create(1, "20010203"), 1 as datetime)
+2001-02-03 00:00:00
+select column_get(column_create(1, 0), 1 as datetime);
+column_get(column_create(1, 0), 1 as datetime)
+0000-00-00 00:00:00
+select column_get(column_create(1, "2001021"), 1 as datetime);
+column_get(column_create(1, "2001021"), 1 as datetime)
+2020-01-02 01:00:00
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as datetime);
+column_get(column_create(1, "8:46:06.23434" AS time), 1 as datetime)
+0000-00-00 08:46:06
+select column_get(column_create(1, "-808:46:06.23434" AS time), 1 as datetime);
+column_get(column_create(1, "-808:46:06.23434" AS time), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '-808:46:06'
+set @@sql_mode="allow_invalid_dates";
+select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as datetime)
+2011-02-30 18:46:06
+select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as datetime);
+column_get(column_create(1, "0000-00-000" AS CHAR), 1 as datetime)
+0000-00-00 00:00:00
+select column_get(column_create(1, "2001-00-02" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2001-00-02" AS CHAR), 1 as datetime)
+2001-00-02 00:00:00
+set @@sql_mode="";
+# column get datetime truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as datetime);
+column_get(column_create(1, "1223.5aa" AS char), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1223.5aa'
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as datetime);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1.84467440737096e+19'
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as datetime);
+column_get(column_create(1, 9223372036854775807 AS int), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '9223372036854775807'
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as datetime);
+column_get(column_create(1, -9223372036854775808 AS int), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '-9223372036854775808'
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as datetime);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '99999999999999999999999999999'
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as datetime);
+column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1e+29'
+select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2011-02-32 8:46:06.23434'
+select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2011-13-01 8:46:06.23434'
+select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as datetime);
+column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2011-02-30 8:46:06.23434'
+select column_get(column_create(1, "20010231"), 1 as datetime);
+column_get(column_create(1, "20010231"), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '20010231'
+select column_get(column_create(1, "0" AS CHAR), 1 as datetime);
+column_get(column_create(1, "0" AS CHAR), 1 as datetime)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+#
+# column get date
+#
+select column_get(column_create(1, 20010203101112.121314 as double), 1 as date);
+column_get(column_create(1, 20010203101112.121314 as double), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as date);
+column_get(column_create(1, 20010203101112.121314 as decimal), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203101112 as unsigned int), 1 as date);
+column_get(column_create(1, 20010203101112 as unsigned int), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203101112 as int), 1 as date);
+column_get(column_create(1, 20010203101112 as int), 1 as date)
+2001-02-03
+select column_get(column_create(1, "20010203101112" as char), 1 as date);
+column_get(column_create(1, "20010203101112" as char), 1 as date)
+2001-02-03
+select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as date);
+column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as date)
+2001-02-03
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as date);
+column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as date)
+2001-02-03
+select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as date);
+column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as date)
+2001-02-03
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as date);
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as date)
+2011-04-05
+select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as date);
+column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as date)
+2011-00-00
+select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as date);
+column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as date)
+2011-00-01
+select column_get(column_create(1, 20010203 as unsigned int), 1 as date);
+column_get(column_create(1, 20010203 as unsigned int), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203 as int), 1 as date);
+column_get(column_create(1, 20010203 as int), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203), 1 as date);
+column_get(column_create(1, 20010203), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203.0), 1 as date);
+column_get(column_create(1, 20010203.0), 1 as date)
+2001-02-03
+select column_get(column_create(1, 20010203.0 as double), 1 as date);
+column_get(column_create(1, 20010203.0 as double), 1 as date)
+2001-02-03
+select column_get(column_create(1, "2001-02-03"), 1 as date);
+column_get(column_create(1, "2001-02-03"), 1 as date)
+2001-02-03
+select column_get(column_create(1, "20010203"), 1 as date);
+column_get(column_create(1, "20010203"), 1 as date)
+2001-02-03
+select column_get(column_create(1, 0), 1 as date);
+column_get(column_create(1, 0), 1 as date)
+0000-00-00
+select column_get(column_create(1, "2001021"), 1 as date);
+column_get(column_create(1, "2001021"), 1 as date)
+2020-01-02
+set @@sql_mode="allow_invalid_dates";
+select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as date);
+column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as date)
+2011-02-30
+select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as date);
+column_get(column_create(1, "0000-00-000" AS CHAR), 1 as date)
+0000-00-00
+select column_get(column_create(1, "2001-00-02" AS CHAR), 1 as date);
+column_get(column_create(1, "2001-00-02" AS CHAR), 1 as date)
+2001-00-02
+set @@sql_mode="";
+# column get date truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as date);
+column_get(column_create(1, "1223.5aa" AS char), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1223.5aa'
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as date);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1.84467440737096e+19'
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as date);
+column_get(column_create(1, 9223372036854775807 AS int), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '9223372036854775807'
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as date);
+column_get(column_create(1, -9223372036854775808 AS int), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '-9223372036854775808'
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as date);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '99999999999999999999999999999'
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as date);
+column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1e+29'
+select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as date);
+column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2011-02-32 8:46:06.23434'
+select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as date);
+column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2011-13-01 8:46:06.23434'
+select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as date);
+column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2011-02-30 8:46:06.23434'
+select column_get(column_create(1, "20010231"), 1 as date);
+column_get(column_create(1, "20010231"), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '20010231'
+select column_get(column_create(1, "0" AS CHAR), 1 as date);
+column_get(column_create(1, "0" AS CHAR), 1 as date)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+#
+# column get time
+#
+select column_get(column_create(1, 20010203101112.121314 as double), 1 as time);
+column_get(column_create(1, 20010203101112.121314 as double), 1 as time)
+10:11:12
+select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as time);
+column_get(column_create(1, 20010203101112.121314 as decimal), 1 as time)
+10:11:12
+select column_get(column_create(1, 20010203101112 as unsigned int), 1 as time);
+column_get(column_create(1, 20010203101112 as unsigned int), 1 as time)
+10:11:12
+select column_get(column_create(1, 8080102 as unsigned int), 1 as time);
+column_get(column_create(1, 8080102 as unsigned int), 1 as time)
+808:01:02
+select column_get(column_create(1, 20010203101112 as int), 1 as time);
+column_get(column_create(1, 20010203101112 as int), 1 as time)
+10:11:12
+select column_get(column_create(1, -8080102 as int), 1 as time);
+column_get(column_create(1, -8080102 as int), 1 as time)
+-808:01:02
+select column_get(column_create(1, "20010203101112" as char), 1 as time);
+column_get(column_create(1, "20010203101112" as char), 1 as time)
+10:11:12
+select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as time);
+column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as time)
+10:11:12
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time);
+column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time)
+10:11:12
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time(6));
+column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time(6))
+10:11:12.121314
+select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as time);
+column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as time)
+10:11:12
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as time(6));
+column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as time(6))
+08:46:06.234340
+select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as time(6));
+column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as time(6))
+08:46:06.234340
+select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as time(6));
+column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as time(6))
+08:46:06.234340
+select column_get(column_create(1, "830:46:06.23434" AS CHAR), 1 as time(6));
+column_get(column_create(1, "830:46:06.23434" AS CHAR), 1 as time(6))
+830:46:06.234340
+select column_get(column_create(1, "830:46:06" AS CHAR), 1 as time(6));
+column_get(column_create(1, "830:46:06" AS CHAR), 1 as time(6))
+830:46:06.000000
+select cast("-830:46:06.23434" AS time(6));
+cast("-830:46:06.23434" AS time(6))
+-830:46:06.234340
+select 1,cast("-830:46:06.23434" AS time(6));
+1 cast("-830:46:06.23434" AS time(6))
+1 -830:46:06.234340
+select hex(column_create(1, "-830:46:06.23434" AS CHAR));
+hex(column_create(1, "-830:46:06.23434" AS CHAR))
+000100010003082D3833303A34363A30362E3233343334
+select column_get(column_create(1, "-830:46:06.23434" AS CHAR), 1 as time(6));
+column_get(column_create(1, "-830:46:06.23434" AS CHAR), 1 as time(6))
+-830:46:06.234340
+select column_get(column_create(1, "0" AS CHAR), 1 as time);
+column_get(column_create(1, "0" AS CHAR), 1 as time)
+00:00:00
+select column_get(column_create(1, "6" AS CHAR), 1 as time);
+column_get(column_create(1, "6" AS CHAR), 1 as time)
+00:00:06
+select column_get(column_create(1, "1:6" AS CHAR), 1 as time);
+column_get(column_create(1, "1:6" AS CHAR), 1 as time)
+01:06:00
+select column_get(column_create(1, "2:1:6" AS CHAR), 1 as time);
+column_get(column_create(1, "2:1:6" AS CHAR), 1 as time)
+02:01:06
+select column_get(column_create(1, 0), 1 as time);
+column_get(column_create(1, 0), 1 as time)
+00:00:00
+select column_get(column_create(1, "2001021"), 1 as time);
+column_get(column_create(1, "2001021"), 1 as time)
+200:10:21
+set @@sql_mode="allow_invalid_dates";
+select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as time);
+column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as time)
+18:46:06
+set @@sql_mode="";
+# column get date truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as time);
+column_get(column_create(1, "1223.5aa" AS char), 1 as time)
+00:12:23
+Warnings:
+Warning 1292 Truncated incorrect time value: '1223.5aa'
+select column_get(column_create(1, "1223.5aa" AS char), 1 as time(3));
+column_get(column_create(1, "1223.5aa" AS char), 1 as time(3))
+00:12:23.500
+Warnings:
+Warning 1292 Truncated incorrect time value: '1223.5aa'
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as time);
+column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as time)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1.84467440737096e+19'
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as time);
+column_get(column_create(1, 9223372036854775807 AS int), 1 as time)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '9223372036854775807'
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as time);
+column_get(column_create(1, -9223372036854775808 AS int), 1 as time)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '-9223372036854775808'
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as time);
+column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as time)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '99999999999999999999999999999'
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as time);
+column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as time)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1e+29'
+select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as time);
+column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as time)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect time value: '2011-02-32 8:46:06.23434'
+select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as time);
+column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as time)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect time value: '2011-13-01 8:46:06.23434'
+select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as time);
+column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as time)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect time value: '2011-02-30 8:46:06.23434'
+select column_get(column_create(1, "2001-02-03"), 1 as time);
+column_get(column_create(1, "2001-02-03"), 1 as time)
+00:20:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '2001-02-03'
+select column_get(column_create(1, "20010203"), 1 as time);
+column_get(column_create(1, "20010203"), 1 as time)
+838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '20010203'
+# column add
+select hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer));
+hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer))
+00020001000002001078097809
+select hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer));
+hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer))
+0001000100007809
+select hex(column_add(column_create(1, 1212 as integer), 1, NULL as integer));
+hex(column_add(column_create(1, 1212 as integer), 1, NULL as integer))
+000000
+select hex(column_add(column_create(1, 1212 as integer), 2, NULL as integer));
+hex(column_add(column_create(1, 1212 as integer), 2, NULL as integer))
+0001000100007809
+select hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer));
+hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer))
+000200010000020008167809
+select column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 1 as integer);
+column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 1 as integer)
+11
+select column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 2 as integer);
+column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 2 as integer)
+1212
+select hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer, 2, 11 as integer));
+hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer, 2, 11 as integer))
+000200010000020010780916
+select hex(column_add(column_create(1, NULL as integer), 1, 1212 as integer, 2, 11 as integer));
+hex(column_add(column_create(1, NULL as integer), 1, 1212 as integer, 2, 11 as integer))
+000200010000020010780916
+select hex(column_add(column_create(1, 1212 as integer, 2, 1212 as integer), 1, 11 as integer));
+hex(column_add(column_create(1, 1212 as integer, 2, 1212 as integer), 1, 11 as integer))
+000200010000020008167809
+select hex(column_add(column_create(1, 1), 1, null));
+hex(column_add(column_create(1, 1), 1, null))
+000000
+select column_list(column_add(column_create(1, 1), 1, null));
+column_list(column_add(column_create(1, 1), 1, null))
+
+select column_list(column_add(column_create(1, 1), 1, ""));
+column_list(column_add(column_create(1, 1), 1, ""))
+1
+select hex(column_add("", 1, 1));
+hex(column_add("", 1, 1))
+00010001000002
+# column delete
+select hex(column_delete(column_create(1, 1212 as integer, 2, 1212 as integer), 1));
+hex(column_delete(column_create(1, 1212 as integer, 2, 1212 as integer), 1))
+0001000200007809
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2))
+0002000100000300080206
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 3));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 3))
+0002000100000200080204
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 4));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 4))
+000300010000020008030010020406
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 1));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 1))
+00010003000006
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 3));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 3))
+00010001000002
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3))
+000000
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3, 10));
+hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3, 10))
+000000
+select hex(column_delete(column_create(1, 1), 1));
+hex(column_delete(column_create(1, 1), 1))
+000000
+select hex(column_delete("", 1));
+hex(column_delete("", 1))
+
+# column exists
+select column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 1);
+column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 1)
+1
+select column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 4);
+column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 4)
+0
+# column list
+select column_list(column_create(1, 1212 as integer, 2, 1212 as integer));
+column_list(column_create(1, 1212 as integer, 2, 1212 as integer))
+1,2
+select column_list(column_create(1, 1212 as integer));
+column_list(column_create(1, 1212 as integer))
+1
+select column_list(column_create(1, NULL as integer));
+column_list(column_create(1, NULL as integer))
+
+#
+# check error handling
+#
+select HEX(COLUMN_CREATE(1, 5, 1, 5));
+ERROR 22007: Illegal value used as argument of dynamic column function
+select HEX(COLUMN_CREATE("", 1, 5, 1, 5));
+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 COLUMN_LIST("a");
+ERROR HY000: Encountered illegal format of dynamic column string
+select column_delete("a", 1);
+ERROR HY000: Encountered illegal format of dynamic column string
+select hex(column_delete("", 1));
+hex(column_delete("", 1))
+
+select hex(column_delete("", -1));
+ERROR 22007: Illegal value used as argument of dynamic column function
+select hex(column_create(-1, 1));
+ERROR 22007: Illegal value used as argument of dynamic column function
+select hex(column_create(65536, 1));
+ERROR 22007: Illegal value used as argument of dynamic column function
+select hex(column_add("", -1, 1));
+ERROR 22007: Illegal value used as argument of dynamic column function
+select hex(column_add("", 65536, 1));
+ERROR 22007: Illegal value used as argument of dynamic column function
+select hex(column_get("", -1 as int));
+hex(column_get("", -1 as int))
+NULL
+#
+# Test with table
+#
+create table t1 (id int primary key, str mediumblob);
+insert into t1 values (1, ''), (2, ''), (3, ''), (4, ''), (5, null);
+select id, str, column_get(str, 1 as int) from t1;
+id str column_get(str, 1 as int)
+1 NULL
+2 NULL
+3 NULL
+4 NULL
+5 NULL NULL
+update t1 set str=column_create(1, id, 2, "a") where id < 3;
+update t1 set str=column_add(str, 1, id, 2, "b") where id >= 4;
+select id, column_get(str, 1 as int), column_get(str, 2 as char) from t1 where column_exists(str,1) or column_exists(str,2);
+id column_get(str, 1 as int) column_get(str, 2 as char)
+1 1 a
+2 2 a
+4 4 b
+update t1 set str=column_create(1, id, 10, "test") where id = 5;
+insert into t1 values (6, column_create(10, "test2"));
+update t1 set str=column_add(str, 2, 'c', 1, column_get(str, 1 as int) + 1, 3, 100) where id > 2;
+select id, length(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1;
+id length(str) column_get(str, 1 as int) column_get(str, 2 as char) column_get(str, 3 as int)
+1 12 1 a NULL
+2 12 2 a NULL
+3 12 NULL c 100
+4 16 5 c 100
+5 24 6 c 100
+6 21 NULL c 100
+select column_get(str, 2 as char), sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char);
+column_get(str, 2 as char) sum(column_get(str, 1 as int))
+a 3
+c 11
+select column_get(str, 2 as char), sum(column_get(str, 1 as int)) from t1 where column_exists(str, 2) <> 0 group by 1;
+column_get(str, 2 as char) sum(column_get(str, 1 as int))
+a 3
+c 11
+select sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char) order by sum(column_get(str, 1 as int)) desc;
+sum(column_get(str, 1 as int))
+11
+3
+select sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char) having sum(column_get(str, 1 as int)) > 2;
+sum(column_get(str, 1 as int))
+3
+11
+select sum(column_get(str, 1 as int)) from t1 where column_get(str, 3 as int) > 50 group by column_get(str, 2 as char);
+sum(column_get(str, 1 as int))
+11
+select id, column_list(str) from t1 where id= 5;
+id column_list(str)
+5 1,2,3,10
+update t1 set str=column_delete(str, 3, 4, 2) where id= 5;
+select id, length(str), column_list(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1;
+id length(str) column_list(str) column_get(str, 1 as int) column_get(str, 2 as char) column_get(str, 3 as int)
+1 12 1,2 1 a NULL
+2 12 1,2 2 a NULL
+3 12 2,3 NULL c 100
+4 16 1,2,3 5 c 100
+5 15 1,10 6 NULL NULL
+6 21 2,3,10 NULL c 100
+update t1 set str=column_add(str, 4, 45 as char, 2, 'c') where id= 5;
+select id, length(str), column_list(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1 where id = 5;
+id length(str) column_list(str) column_get(str, 1 as int) column_get(str, 2 as char) column_get(str, 3 as int)
+5 26 1,2,4,10 6 c NULL
+select id, length(str), column_list(str), column_exists(str, 4) from t1;
+id length(str) column_list(str) column_exists(str, 4)
+1 12 1,2 0
+2 12 1,2 0
+3 12 2,3 0
+4 16 1,2,3 0
+5 26 1,2,4,10 1
+6 21 2,3,10 0
+select sum(column_get(str, 1 as int)), column_list(str) from t1 group by 2;
+sum(column_get(str, 1 as int)) column_list(str)
+3 1,2
+5 1,2,3
+6 1,2,4,10
+NULL 2,3
+NULL 2,3,10
+select id, hex(str) from t1;
+id hex(str)
+1 00020001000002000B020861
+2 00020001000002000B040861
+3 0002000200030300100863C8
+4 00030001000002000B0300180A0863C8
+5 00040001000002000B04001B0A00330C08633F34350874657374
+6 0003000200030300100A001B0863C8087465737432
+update t1 set str=column_add(str, 4, repeat("a", 100000)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("a", 100000);
+id
+5
+select id from t1 where column_get(str,4 as char(100)) = repeat("a", 100);
+id
+5
+Warnings:
+Warning 1292 Truncated incorrect CHAR(100) value: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
+update t1 set str=column_add(str, 4, repeat("b", 10000)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("b", 10000);
+id
+5
+update t1 set str=column_add(str, 4, repeat("c", 100)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("c", 100);
+id
+5
+update t1 set str=column_add(str, 4, repeat("d", 10000)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("d", 10000);
+id
+5
+update t1 set str=column_add(str, 4, repeat("e", 10), 5, repeat("f", 100000)) where id=5;
+select id from t1 where column_get(str,5 as char(100000)) = repeat("f", 100000);
+id
+5
+select id, column_list(str), length(str) from t1 where id=5;
+id column_list(str) length(str)
+5 1,2,4,5,10 100048
+update t1 set str=column_delete(str, 5) where id=5;
+select id, column_list(str), length(str) from t1 where id=5;
+id column_list(str) length(str)
+5 1,2,4,10 34
+drop table t1;
+#
+# LP#778905: Assertion `value->year <= 9999' failed in
+# dynamic_column_date_store
+#
+SELECT COLUMN_GET( 'a' , 2 AS DATE );
+ERROR HY000: Encountered illegal format of dynamic column string
+SELECT COLUMN_CREATE( 1 , COLUMN_GET( 'a' , 2 AS DATE ) );
+ERROR HY000: Encountered illegal format of dynamic column string
+#
+# LP#778912: Assertion `field_pos < field_count' failed in
+# Protocol_text::store in maria-5.3-mwl34
+#
+CREATE TABLE t1 ( f1 blob );
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 SET f1 = COLUMN_CREATE( 2 , 'cde' );
+SELECT HEX(COLUMN_ADD(f1, 1, 'abc')), COLUMN_LIST(f1) FROM t1;
+HEX(COLUMN_ADD(f1, 1, 'abc')) COLUMN_LIST(f1)
+NULL NULL
+0002000100030200230861626308636465 2
+SELECT COLUMN_ADD(f1, 1, 'abc'), COLUMN_LIST(f1) FROM t1;
+DROP TABLE t1;
+#
+# Some dynamic strings that caused crashes in the past
+#
+set @a=0x0102000200030004000F0D086B74697A6A7176746F6B687563726A746E7A746A666163726C6F7A6B62636B6B756B666779666977617369796F67756C726D62677A72756E63626D78636D7077706A6F736C6D636464696770786B6371637A6A6A6463737A6A676879716462637178646C666E6B6C726A637677696E7271746C616D646368687A6C707869786D666F666261797470616A63797673737A796D74747475666B717573687A79696E7276706F796A6E767361796A6F6D646F6378677A667074746363736A796D67746C786F697873686464616265616A7A6F7168707A6B776B6376737A6B72666C6F666C69636163686F6B666D627166786A71616F;
+select column_add(@a, 3, "a");
+ERROR HY000: Encountered illegal format of dynamic column string
+#
+# LP#781233 mysqld: decimal.c:1459: decimal_bin_size:
+# Assertion `scale >= 0 && precision > 0 && scale <= precision' ...
+#
+set @a=0x00020008000009000C2C010080;
+select COLUMN_GET(@a, 9 AS DECIMAL);
+COLUMN_GET(@a, 9 AS DECIMAL)
+0
+select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL)));
+hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL)))
+000100000004
+select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL(19,0))));
+hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL(19,0))))
+000100000004
+select hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal)));
+hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal)))
+000100000004
+select hex(COLUMN_CREATE(0, 0.0 as decimal));
+hex(COLUMN_CREATE(0, 0.0 as decimal))
+000100000004
diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result
index 022a32d9c9b..4f21fd57b88 100644
--- a/mysql-test/r/errors.result
+++ b/mysql-test/r/errors.result
@@ -24,7 +24,7 @@ select count(*),b from t1;
ERROR 42S22: Unknown column 'b' in 'field list'
drop table t1;
create table t1 (a int(256));
-ERROR 42000: Display width out of range for column 'a' (max = 255)
+ERROR 42000: Display width out of range for 'a' (max = 255)
set sql_mode='traditional';
create table t1 (a varchar(66000));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
diff --git a/mysql-test/r/events_1.result b/mysql-test/r/events_1.result
index e7b645f5556..efc53ab7246 100644
--- a/mysql-test/r/events_1.result
+++ b/mysql-test/r/events_1.result
@@ -309,7 +309,7 @@ ERROR HY000: Unknown event 'intact_check'
DROP EVENT no_such_event;
ERROR HY000: Unknown event 'no_such_event'
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
-ERROR HY000: Failed to store event name. Error code 2 from storage engine.
+ERROR HY000: Failed to store event name. Error code 1 from storage engine.
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
ERROR HY000: Unknown event 'intact_check_1'
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result
index da53790acd6..dee72b698ba 100644
--- a/mysql-test/r/events_bugs.result
+++ b/mysql-test/r/events_bugs.result
@@ -746,6 +746,15 @@ event_name originator
ev1 4294967295
DROP EVENT ev1;
SET GLOBAL server_id = @old_server_id;
+CREATE DATABASE event_test12;
+USE event_test12;
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+CREATE DATABASE event_test1;
+USE event_test1;
+SHOW EVENTS;
+Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+DROP DATABASE event_test1;
+DROP DATABASE event_test12;
DROP DATABASE events_test;
SET GLOBAL event_scheduler= 'ON';
SET @@global.concurrent_insert= @concurrent_insert;
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result
index 25fc524bc9b..d18af9fd4e1 100644
--- a/mysql-test/r/explain.result
+++ b/mysql-test/r/explain.result
@@ -64,7 +64,7 @@ explain extended select * from v1 where f2=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
+Note 1003 select 1 AS `f1`,1 AS `f2` from `test`.`t1` where 1
explain extended select * from t1 where 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
@@ -74,7 +74,7 @@ explain extended select * from t1 where 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
+Note 1003 select 1 AS `f1`,1 AS `f2` from `test`.`t1` where 1
explain extended select * from t1 having 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
@@ -84,7 +84,7 @@ explain extended select * from t1 having 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` having 1
+Note 1003 select 1 AS `f1`,1 AS `f2` from `test`.`t1` having 1
drop view v1;
drop table t1;
CREATE TABLE t1(c INT);
@@ -102,7 +102,7 @@ INSERT INTO t2 VALUES (),(),();
EXPLAIN SELECT 1 FROM
(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2;
id select_type table type possible_keys key key_len ref rows Extra
-X X X X X X X X X const row not found
+X X X X X X X X X
X X X X X X X X X
X X X X X X X X X Range checked for each record (index map: 0xFFFFFFFFFF)
DROP TABLE t2;
@@ -114,7 +114,7 @@ INSERT INTO t2 VALUES (1),(2);
EXPLAIN EXTENDED SELECT 1
FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
@@ -122,7 +122,7 @@ Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT
EXPLAIN EXTENDED SELECT 1
FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
@@ -132,7 +132,7 @@ prepare s1 from
FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1';
execute s1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
@@ -142,14 +142,14 @@ prepare s1 from
FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1';
execute s1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
execute s1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
@@ -176,11 +176,15 @@ SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
EXPLAIN EXTENDED SELECT 1 FROM t1
WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
-ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 SUBQUERY t1 system NULL NULL NULL NULL 0 0.00 const row not found
+2 SUBQUERY t system NULL NULL NULL NULL 0 0.00 const row not found
+Warnings:
+Note 1003 select 1 AS `1` from `test`.`t1` where 0
SHOW WARNINGS;
Level Code Message
-Error 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
-Note 1003 select 1 AS `1` from `test`.`t1` where <not>(<exists>(...))
+Note 1003 select 1 AS `1` from `test`.`t1` where 0
SET SESSION sql_mode=@old_sql_mode;
DROP TABLE t1;
End of 5.0 tests.
@@ -262,7 +266,7 @@ WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST (""))
WHERE t1.f1 GROUP BY t1.f1));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
-2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
+2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where
PREPARE stmt FROM
'EXPLAIN SELECT 1 FROM t1
@@ -272,12 +276,12 @@ PREPARE stmt FROM
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
-2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
+2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
-2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
+2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM
@@ -288,13 +292,27 @@ PREPARE stmt FROM
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
-2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
+2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
-2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
+2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.1 tests.
+#
+# Bug#776295: EXPLAIN EXTENDED with always false multiple equality
+# in the WHERE condition of a derived table
+#
+CREATE TABLE t1 (a int) ;
+CREATE TABLE t2 (a int) ;
+INSERT INTO t2 VALUES (8);
+EXPLAIN EXTENDED
+SELECT * FROM ( SELECT t1.a FROM t1,t2 WHERE t2.a = t1.a ) AS t;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select NULL AS `a` from `test`.`t1` join `test`.`t2` where 0
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result
index b4e61d0e4fc..5c87939c75b 100644
--- a/mysql-test/r/func_compress.result
+++ b/mysql-test/r/func_compress.result
@@ -102,6 +102,8 @@ a
foo
Warnings:
Error 1259 ZLIB: Input data corrupted
+Error 1259 ZLIB: Input data corrupted
+Error 1259 ZLIB: Input data corrupted
explain select *, uncompress(a) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
diff --git a/mysql-test/r/func_default.result b/mysql-test/r/func_default.result
index a8f59f73e88..872cd324275 100644
--- a/mysql-test/r/func_default.result
+++ b/mysql-test/r/func_default.result
@@ -8,7 +8,7 @@ explain extended select default(str), default(strnull), default(intg), default(r
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default('0') AS `default(intg)`,default('0') AS `default(rel)` from `test`.`t1`
+Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default(0) AS `default(intg)`,default(0) AS `default(rel)` from `test`.`t1`
select * from t1 where str <> default(str);
str strnull intg rel
0 0
diff --git a/mysql-test/r/func_encrypt_ucs2.result b/mysql-test/r/func_encrypt_ucs2.result
new file mode 100644
index 00000000000..384e931452e
--- /dev/null
+++ b/mysql-test/r/func_encrypt_ucs2.result
@@ -0,0 +1,19 @@
+#
+# Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
+#
+SELECT CHAR_LENGTH(DES_ENCRYPT(0, CHAR('1' USING ucs2)));
+CHAR_LENGTH(DES_ENCRYPT(0, CHAR('1' USING ucs2)))
+9
+SELECT CONVERT(DES_ENCRYPT(0, CHAR('1' USING ucs2)),UNSIGNED);
+CONVERT(DES_ENCRYPT(0, CHAR('1' USING ucs2)),UNSIGNED)
+0
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '?T?iK?j??'
+SELECT CHAR_LENGTH(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' USING ucs2)));
+CHAR_LENGTH(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' USING ucs2)))
+4
+SELECT CONVERT(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' using ucs2)), UNSIGNED);
+CONVERT(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' using ucs2)), UNSIGNED)
+0
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'test'
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index 6604446ed8d..4af2a4c3a66 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -983,10 +983,10 @@ INSERT INTO t1 VALUES (),();
EXPLAIN EXTENDED SELECT 1 FROM
(SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
-2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort; Distinct
-2 DERIVED td ALL NULL NULL NULL NULL 2 100.00 Distinct; Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
+2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+2 DERIVED td ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select 1 AS `1` from (select distinct group_concat(`test`.`td`.`f1` separator ',') AS `GROUP_CONCAT(td.f1)` from `test`.`t1` join `test`.`t1` `td` group by `test`.`td`.`f1`) `d` join `test`.`t1`
SELECT 1 FROM
@@ -1005,7 +1005,7 @@ EXPLAIN EXTENDED SELECT 1 FROM
(SELECT GROUP_CONCAT(t1.a ORDER BY t1.a ASC) FROM
t1 t2, t1 GROUP BY t1.a) AS d;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
@@ -1035,7 +1035,7 @@ DROP TABLE t1;
CREATE TABLE t1(f1 int);
INSERT INTO t1 values (0),(0);
SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d));
-ERROR 22007: Illegal non geometric '(select 1 from (select (1 = group_concat(`test`.`t1`.`f1` separator ',')) AS `1 IN (GROUP_CONCAT(t1.f1))` from `test`.`t1` join `test`.`t1` `t` group by `t`.`f1`) `d`)' value found during parsing
+ERROR 22007: Illegal non geometric '(select 1 from (select (1 = group_concat(`test`.`t1`.`f1` separator ',')) AS `1 IN (GROUP_CONCAT(t1.f1))` from `test`.`t1` join `test`.`t1` `t` group by `test`.`t`.`f1`) `d`)' value found during parsing
DROP TABLE t1;
#
# Bug#58396 group_concat and explain extended are still crashy
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 4a1c375ea5f..24e146159ea 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -1530,7 +1530,8 @@ insert into t1 values
(02,2002,20020101,"2002-01-01 23:59:59"),
(60,2060,20600101,"2060-01-01 11:11:11"),
(70,1970,19700101,"1970-11-11 22:22:22"),
-(NULL,NULL,NULL,NULL);
+(NULL,NULL,NULL,NULL),
+(71,1971,19710101,"1971-11-11 22:22:22");
select min(f1),max(f1) from t1;
min(f1) max(f1)
70 60
@@ -1553,36 +1554,49 @@ a b gt lt eq
60 98 1 0 0
70 98 0 1 0
NULL 98 NULL NULL 0
+71 98 0 1 0
98 00 0 1 0
00 00 0 0 1
02 00 1 0 0
60 00 1 0 0
70 00 0 1 0
NULL 00 NULL NULL 0
+71 00 0 1 0
98 02 0 1 0
00 02 0 1 0
02 02 0 0 1
60 02 1 0 0
70 02 0 1 0
NULL 02 NULL NULL 0
+71 02 0 1 0
98 60 0 1 0
00 60 0 1 0
02 60 0 1 0
60 60 0 0 1
70 60 0 1 0
NULL 60 NULL NULL 0
+71 60 0 1 0
98 70 1 0 0
00 70 1 0 0
02 70 1 0 0
60 70 1 0 0
70 70 0 0 1
NULL 70 NULL NULL 0
+71 70 1 0 0
98 NULL NULL NULL 0
00 NULL NULL NULL 0
02 NULL NULL NULL 0
60 NULL NULL NULL 0
70 NULL NULL NULL 0
NULL NULL NULL NULL 1
+71 NULL NULL NULL 0
+98 71 1 0 0
+00 71 1 0 0
+02 71 1 0 0
+60 71 1 0 0
+70 71 0 1 0
+NULL 71 NULL NULL 0
+71 71 0 0 1
select a.f1 as a, b.f2 as b, a.f1 > b.f2 as gt,
a.f1 < b.f2 as lt, a.f1<=>b.f2 as eq
from t1 a, t1 b;
@@ -1593,36 +1607,49 @@ a b gt lt eq
60 1998 1 0 0
70 1998 0 1 0
NULL 1998 NULL NULL 0
+71 1998 0 1 0
98 2000 0 1 0
00 2000 0 0 1
02 2000 1 0 0
60 2000 1 0 0
70 2000 0 1 0
NULL 2000 NULL NULL 0
+71 2000 0 1 0
98 2002 0 1 0
00 2002 0 1 0
02 2002 0 0 1
60 2002 1 0 0
70 2002 0 1 0
NULL 2002 NULL NULL 0
+71 2002 0 1 0
98 2060 0 1 0
00 2060 0 1 0
02 2060 0 1 0
60 2060 0 0 1
70 2060 0 1 0
NULL 2060 NULL NULL 0
+71 2060 0 1 0
98 1970 1 0 0
00 1970 1 0 0
02 1970 1 0 0
60 1970 1 0 0
70 1970 0 0 1
NULL 1970 NULL NULL 0
+71 1970 1 0 0
98 NULL NULL NULL 0
00 NULL NULL NULL 0
02 NULL NULL NULL 0
60 NULL NULL NULL 0
70 NULL NULL NULL 0
NULL NULL NULL NULL 1
+71 NULL NULL NULL 0
+98 1971 1 0 0
+00 1971 1 0 0
+02 1971 1 0 0
+60 1971 1 0 0
+70 1971 0 1 0
+NULL 1971 NULL NULL 0
+71 1971 0 0 1
select a.f1 as a, b.f3 as b, a.f1 > b.f3 as gt,
a.f1 < b.f3 as lt, a.f1<=>b.f3 as eq
from t1 a, t1 b;
@@ -1633,36 +1660,49 @@ a b gt lt eq
60 1998-01-01 1 0 0
70 1998-01-01 0 1 0
NULL 1998-01-01 NULL NULL 0
+71 1998-01-01 0 1 0
98 2000-01-01 0 1 0
00 2000-01-01 0 1 0
02 2000-01-01 1 0 0
60 2000-01-01 1 0 0
70 2000-01-01 0 1 0
NULL 2000-01-01 NULL NULL 0
+71 2000-01-01 0 1 0
98 2002-01-01 0 1 0
00 2002-01-01 0 1 0
02 2002-01-01 0 1 0
60 2002-01-01 1 0 0
70 2002-01-01 0 1 0
NULL 2002-01-01 NULL NULL 0
+71 2002-01-01 0 1 0
98 2060-01-01 0 1 0
00 2060-01-01 0 1 0
02 2060-01-01 0 1 0
60 2060-01-01 0 1 0
70 2060-01-01 0 1 0
NULL 2060-01-01 NULL NULL 0
+71 2060-01-01 0 1 0
98 1970-01-01 1 0 0
00 1970-01-01 1 0 0
02 1970-01-01 1 0 0
60 1970-01-01 1 0 0
70 1970-01-01 0 1 0
NULL 1970-01-01 NULL NULL 0
+71 1970-01-01 1 0 0
98 NULL NULL NULL 0
00 NULL NULL NULL 0
02 NULL NULL NULL 0
60 NULL NULL NULL 0
70 NULL NULL NULL 0
NULL NULL NULL NULL 1
+71 NULL NULL NULL 0
+98 1971-01-01 1 0 0
+00 1971-01-01 1 0 0
+02 1971-01-01 1 0 0
+60 1971-01-01 1 0 0
+70 1971-01-01 0 1 0
+NULL 1971-01-01 NULL NULL 0
+71 1971-01-01 0 1 0
select a.f1 as a, b.f4 as b, a.f1 > b.f4 as gt,
a.f1 < b.f4 as lt, a.f1<=>b.f4 as eq
from t1 a, t1 b;
@@ -1673,36 +1713,49 @@ a b gt lt eq
60 1998-01-01 00:00:00 1 0 0
70 1998-01-01 00:00:00 0 1 0
NULL 1998-01-01 00:00:00 NULL NULL 0
+71 1998-01-01 00:00:00 0 1 0
98 2000-01-01 00:00:01 0 1 0
00 2000-01-01 00:00:01 0 1 0
02 2000-01-01 00:00:01 1 0 0
60 2000-01-01 00:00:01 1 0 0
70 2000-01-01 00:00:01 0 1 0
NULL 2000-01-01 00:00:01 NULL NULL 0
+71 2000-01-01 00:00:01 0 1 0
98 2002-01-01 23:59:59 0 1 0
00 2002-01-01 23:59:59 0 1 0
02 2002-01-01 23:59:59 0 1 0
60 2002-01-01 23:59:59 1 0 0
70 2002-01-01 23:59:59 0 1 0
NULL 2002-01-01 23:59:59 NULL NULL 0
+71 2002-01-01 23:59:59 0 1 0
98 2060-01-01 11:11:11 0 1 0
00 2060-01-01 11:11:11 0 1 0
02 2060-01-01 11:11:11 0 1 0
60 2060-01-01 11:11:11 0 1 0
70 2060-01-01 11:11:11 0 1 0
NULL 2060-01-01 11:11:11 NULL NULL 0
+71 2060-01-01 11:11:11 0 1 0
98 1970-11-11 22:22:22 1 0 0
00 1970-11-11 22:22:22 1 0 0
02 1970-11-11 22:22:22 1 0 0
60 1970-11-11 22:22:22 1 0 0
70 1970-11-11 22:22:22 0 1 0
NULL 1970-11-11 22:22:22 NULL NULL 0
+71 1970-11-11 22:22:22 1 0 0
98 NULL NULL NULL 0
00 NULL NULL NULL 0
02 NULL NULL NULL 0
60 NULL NULL NULL 0
70 NULL NULL NULL 0
NULL NULL NULL NULL 1
+71 NULL NULL NULL 0
+98 1971-11-11 22:22:22 1 0 0
+00 1971-11-11 22:22:22 1 0 0
+02 1971-11-11 22:22:22 1 0 0
+60 1971-11-11 22:22:22 1 0 0
+70 1971-11-11 22:22:22 0 1 0
+NULL 1971-11-11 22:22:22 NULL NULL 0
+71 1971-11-11 22:22:22 0 1 0
select *, f1 = f2 from t1;
f1 f2 f3 f4 f1 = f2
98 1998 1998-01-01 1998-01-01 00:00:00 1
@@ -1711,6 +1764,7 @@ f1 f2 f3 f4 f1 = f2
60 2060 2060-01-01 2060-01-01 11:11:11 1
70 1970 1970-01-01 1970-11-11 22:22:22 1
NULL NULL NULL NULL NULL
+71 1971 1971-01-01 1971-11-11 22:22:22 1
drop table t1;
#
# Bug #54465: assert: field_types == 0 || field_types[field_pos] ==
@@ -1737,6 +1791,26 @@ SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b11111111111111111111111111111111
SELECT MIN(GET_LOCK('aaaaaaaaaaaaaaaaa',0) / '0b1111111111111111111111111111111111111111111111111111111111111111111111111' ^ (RAND()));
SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa');
#
+# Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS
+#
+CREATE TABLE t1 (a BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (18446668621106209655);
+SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1;
+MAX(LENGTH(a)) LENGTH(MAX(a)) MIN(a) MAX(a) CONCAT(MIN(a)) CONCAT(MAX(a))
+20 20 18446668621106209655 18446668621106209655 18446668621106209655 18446668621106209655
+DROP TABLE t1;
+#
+# Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+#
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63
+MAX(f1)
+2001
+DROP TABLE t1;
+#
End of 5.1 tests
#
# BUG#46680 - Assertion failed in file item_subselect.cc,
@@ -1755,6 +1829,8 @@ CREATE TABLE empty1 (a int);
INSERT INTO t1 VALUES (1,'c'),(2,NULL);
INSERT INTO t2 VALUES (3,'m'),(4,NULL);
INSERT INTO t3 VALUES (1,'n');
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
#
# 1) Test that subquery materialization is setup for query with
@@ -1812,10 +1888,6 @@ id select_type table type possible_keys key key_len ref rows Extra
# 3) Test that subquery materialization is setup for query with
# premature optimize() exit due to "Select tables optimized away"
#
-# NOTE: The result of this query is actually wrong; it should be NULL
-# See BUG#47762. Even so, the test case is still needed to test
-# that the HAVING subquery does not crash the server
-#
SELECT MIN(pk)
FROM t1
WHERE pk=NULL
@@ -1856,9 +1928,8 @@ HAVING ('m') IN (
SELECT v
FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
+1 PRIMARY empty1 system NULL NULL NULL NULL 0 const row not found
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2
-2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
#
# 5) Test that subquery materialization is setup for query with
@@ -1882,8 +1953,10 @@ HAVING ('m') IN (
SELECT v
FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+set @@optimizer_switch=@save_optimizer_switch;
#
# Cleanup for BUG#46680
#
diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result
index 955a784f04c..5941b4d784a 100644
--- a/mysql-test/r/func_if.result
+++ b/mysql-test/r/func_if.result
@@ -177,12 +177,19 @@ IF((ROUND(t1.a,2)=1), 2,
IF((R
DROP TABLE t1;
CREATE TABLE t1 (c LONGTEXT);
-INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890');
+INSERT INTO t1 VALUES(1), (2), (3), (4), ('1234567890123456789');
+SELECT IF(1, CAST(c AS UNSIGNED), 0) FROM t1;
+IF(1, CAST(c AS UNSIGNED), 0)
+1
+2
+3
+4
+1234567890123456789
SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
MAX(IF(1, CAST(c AS UNSIGNED), 0))
-12345678901234567890
+1234567890123456789
SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
MAX(IFNULL(CAST(c AS UNSIGNED), 0))
-12345678901234567890
+1234567890123456789
DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result
index f65255b272f..77e6bac09da 100644
--- a/mysql-test/r/func_in.result
+++ b/mysql-test/r/func_in.result
@@ -479,7 +479,7 @@ SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29');
a
1972-02-06
Warnings:
-Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1
+Warning 1292 Incorrect datetime value: '19772-07-29'
DROP TABLE t1,t2,t3,t4;
CREATE TABLE t1 (id int not null);
INSERT INTO t1 VALUES (1),(2);
@@ -544,15 +544,9 @@ id select_type table type possible_keys key key_len ref rows Extra
select f2 from t2 where f2 in ('a','b');
f2
0
-Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'a'
-Warning 1292 Truncated incorrect DOUBLE value: 'b'
explain select f2 from t2 where f2 in ('a','b');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
-Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'a'
-Warning 1292 Truncated incorrect DOUBLE value: 'b'
select f2 from t2 where f2 in (1,'b');
f2
0
@@ -770,4 +764,10 @@ CASE a WHEN a THEN a END
NULL
DROP TABLE t1;
#
+# Bug #11766212 59270: NOT IN (YEAR( ... ), ... ) PRODUCES MANY VALGRIND WARNINGS
+#
+SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
+1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1)
+1
+#
End of 5.1 tests
diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result
index 21da211160b..76174982e8e 100644
--- a/mysql-test/r/func_like.result
+++ b/mysql-test/r/func_like.result
@@ -182,4 +182,9 @@ INSERT INTO t2 VALUES (1), (2), (3);
SELECT 1 FROM t2 JOIN t1 ON 1 LIKE a GROUP BY a;
1
DROP TABLE t1, t2;
+#
+# Bug#59149 valgrind warnings with "like .. escape .." function
+#
+SELECT '' LIKE '1' ESCAPE COUNT(1);
+ERROR HY000: Incorrect arguments to ESCAPE
End of 5.1 tests
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index 3a626084c9e..8115c6a0300 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -285,33 +285,55 @@ set names default;
select cast(-2 as unsigned), 18446744073709551614, -2;
cast(-2 as unsigned) 18446744073709551614 -2
18446744073709551614 18446744073709551614 -2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2)
18446744073709551614 18446744073709551614 2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2)
18446744073709551614 18446744073709551614 -2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2)
18446744073709551614 18446744073709551614 -2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2)
18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2)
4294967296 4294967296 NULL
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1)
18446744073709551614 18446744073709551614 -2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2)
4 4 0
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1)
18446744073709551614 18446744073709551614 -2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2)
4 4 0
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
round(10000000000000000000, -19) truncate(10000000000000000000, -19)
10000000000000000000 10000000000000000000
@@ -363,12 +385,18 @@ round(4, -4294967200) truncate(4, -4294967200)
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3)
2 2 -2
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
5 5 1
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
2.13598703592091e+96 2.13598703592091e+96 -32
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
SELECT a DIV 900 y FROM t1 GROUP BY y;
@@ -488,7 +516,7 @@ SELECT -9999999999999999991 DIV -1;
-9999999999999999991 DIV -1
-9223372036854775808
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999991' to INT. Value truncated.
SELECT -9223372036854775808 DIV -1;
-9223372036854775808 DIV -1
-9223372036854775808
@@ -511,4 +539,33 @@ t1 CREATE TABLE `t1` (
`C` varchar(23) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+#
+# Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+#
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+#
+# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+#
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+ROUND(f1, f1)
+0.0
+1.0
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+ROUND(f1, f1)
+0.0
+1.0
+DROP TABLE t1;
+#
+# Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
+#
+SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
+ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'))
+-4939092.0000
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'a'
End of 5.1 tests
diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result
index 87b88692a34..f0c1abd84fe 100644
--- a/mysql-test/r/func_sapdb.result
+++ b/mysql-test/r/func_sapdb.result
@@ -113,10 +113,10 @@ subtime("01:00:00.999999", "02:00:00.999998")
-00:59:59.999999
select subtime("02:01:01.999999", "01:01:01.999999");
subtime("02:01:01.999999", "01:01:01.999999")
-01:00:00.000000
+01:00:00
select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
-838:59:59
+838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '8807:59:59.999999'
select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
@@ -184,8 +184,8 @@ microsecond("1997-12-31 23:59:59.000001")
1
create table t1
select makedate(1997,1) as f1,
-addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
-addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
+addtime(cast("1997-12-31 23:59:59.000001" as datetime(6)), "1 1:1:1.000002") as f2,
+addtime(cast("23:59:59.999999" as time(6)) , "1 1:1:1.000002") as f3,
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
maketime(10,11,12) as f6,
@@ -195,17 +195,17 @@ time("1997-12-31 23:59:59.000001") as f9;
describe t1;
Field Type Null Key Default Extra
f1 date YES NULL
-f2 datetime YES NULL
-f3 time YES NULL
-f4 time YES NULL
-f5 time YES NULL
+f2 datetime(6) YES NULL
+f3 time(6) YES NULL
+f4 time(6) YES NULL
+f5 time(6) YES NULL
f6 time YES NULL
-f7 datetime YES NULL
+f7 datetime(6) YES NULL
f8 date YES NULL
-f9 time YES NULL
+f9 time(6) YES NULL
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8 f9
-1997-01-01 1998-01-02 01:01:00 49:01:01 46:58:57 -24:00:00 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
+1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
insert into test values
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
@@ -250,6 +250,8 @@ a
select microsecond(19971231235959.01) as a;
a
10000
+Warnings:
+Warning 1292 Truncated incorrect time value: '19971231235959.01'
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
a
1997-12-31 00:00:10.090000
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index bbfd3880d2e..6c84ebaa18b 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1533,7 +1533,7 @@ select locate('lo','hello',-18446744073709551615);
locate('lo','hello',-18446744073709551615)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select locate('lo','hello',18446744073709551615);
locate('lo','hello',18446744073709551615)
0
@@ -1541,22 +1541,22 @@ select locate('lo','hello',-18446744073709551616);
locate('lo','hello',-18446744073709551616)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select locate('lo','hello',18446744073709551616);
locate('lo','hello',18446744073709551616)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select locate('lo','hello',-18446744073709551617);
locate('lo','hello',-18446744073709551617)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select locate('lo','hello',18446744073709551617);
locate('lo','hello',18446744073709551617)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select left('hello', 10);
left('hello', 10)
hello
@@ -1588,8 +1588,8 @@ select left('hello', -18446744073709551615);
left('hello', -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select left('hello', 18446744073709551615);
left('hello', 18446744073709551615)
hello
@@ -1597,26 +1597,26 @@ select left('hello', -18446744073709551616);
left('hello', -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select left('hello', 18446744073709551616);
left('hello', 18446744073709551616)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select left('hello', -18446744073709551617);
left('hello', -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select left('hello', 18446744073709551617);
left('hello', 18446744073709551617)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select right('hello', 10);
right('hello', 10)
hello
@@ -1648,8 +1648,8 @@ select right('hello', -18446744073709551615);
right('hello', -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select right('hello', 18446744073709551615);
right('hello', 18446744073709551615)
hello
@@ -1657,26 +1657,26 @@ select right('hello', -18446744073709551616);
right('hello', -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select right('hello', 18446744073709551616);
right('hello', 18446744073709551616)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select right('hello', -18446744073709551617);
right('hello', -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select right('hello', 18446744073709551617);
right('hello', 18446744073709551617)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 2, -1);
substring('hello', 2, -1)
@@ -1708,8 +1708,8 @@ select substring('hello', -18446744073709551615, 1);
substring('hello', -18446744073709551615, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 1);
substring('hello', 18446744073709551615, 1)
@@ -1717,26 +1717,26 @@ select substring('hello', -18446744073709551616, 1);
substring('hello', -18446744073709551616, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 1);
substring('hello', 18446744073709551616, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, 1);
substring('hello', -18446744073709551617, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 1);
substring('hello', 18446744073709551617, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 1, -1);
substring('hello', 1, -1)
@@ -1762,8 +1762,8 @@ select substring('hello', 1, -18446744073709551615);
substring('hello', 1, -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 1, 18446744073709551615);
substring('hello', 1, 18446744073709551615)
hello
@@ -1771,26 +1771,26 @@ select substring('hello', 1, -18446744073709551616);
substring('hello', 1, -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 1, 18446744073709551616);
substring('hello', 1, 18446744073709551616)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', 1, -18446744073709551617);
substring('hello', 1, -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 1, 18446744073709551617);
substring('hello', 1, 18446744073709551617)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', -1, -1);
substring('hello', -1, -1)
@@ -1816,10 +1816,10 @@ select substring('hello', -18446744073709551615, -18446744073709551615);
substring('hello', -18446744073709551615, -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 18446744073709551615);
substring('hello', 18446744073709551615, 18446744073709551615)
@@ -1827,34 +1827,34 @@ select substring('hello', -18446744073709551616, -18446744073709551616);
substring('hello', -18446744073709551616, -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 18446744073709551616);
substring('hello', 18446744073709551616, 18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, -18446744073709551617);
substring('hello', -18446744073709551617, -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 18446744073709551617);
substring('hello', 18446744073709551617, 18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, 1, 'hi');
insert('hello', -1, 1, 'hi')
hello
@@ -1880,7 +1880,7 @@ select insert('hello', -18446744073709551615, 1, 'hi');
insert('hello', -18446744073709551615, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 1, 'hi');
insert('hello', 18446744073709551615, 1, 'hi')
hello
@@ -1888,22 +1888,22 @@ select insert('hello', -18446744073709551616, 1, 'hi');
insert('hello', -18446744073709551616, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 1, 'hi');
insert('hello', 18446744073709551616, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, 1, 'hi');
insert('hello', -18446744073709551617, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 1, 'hi');
insert('hello', 18446744073709551617, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', 1, -1, 'hi');
insert('hello', 1, -1, 'hi')
hi
@@ -1929,7 +1929,7 @@ select insert('hello', 1, -18446744073709551615, 'hi');
insert('hello', 1, -18446744073709551615, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 1, 18446744073709551615, 'hi');
insert('hello', 1, 18446744073709551615, 'hi')
hi
@@ -1937,22 +1937,22 @@ select insert('hello', 1, -18446744073709551616, 'hi');
insert('hello', 1, -18446744073709551616, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 1, 18446744073709551616, 'hi');
insert('hello', 1, 18446744073709551616, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', 1, -18446744073709551617, 'hi');
insert('hello', 1, -18446744073709551617, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 1, 18446744073709551617, 'hi');
insert('hello', 1, 18446744073709551617, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, -1, 'hi');
insert('hello', -1, -1, 'hi')
hello
@@ -1978,8 +1978,8 @@ select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
hello
@@ -1987,26 +1987,26 @@ select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select repeat('hello', -1);
repeat('hello', -1)
@@ -2038,8 +2038,8 @@ select repeat('hello', -18446744073709551615);
repeat('hello', -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select repeat('hello', 18446744073709551615);
repeat('hello', 18446744073709551615)
NULL
@@ -2049,27 +2049,27 @@ select repeat('hello', -18446744073709551616);
repeat('hello', -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select repeat('hello', 18446744073709551616);
repeat('hello', 18446744073709551616)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select repeat('hello', -18446744073709551617);
repeat('hello', -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select repeat('hello', 18446744073709551617);
repeat('hello', 18446744073709551617)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-1);
space(-1)
@@ -2102,8 +2102,8 @@ select space(-18446744073709551615);
space(-18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select space(18446744073709551615);
space(18446744073709551615)
NULL
@@ -2113,27 +2113,27 @@ select space(-18446744073709551616);
space(-18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select space(18446744073709551616);
space(18446744073709551616)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-18446744073709551617);
space(-18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select space(18446744073709551617);
space(18446744073709551617)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -1, '1');
rpad('hello', -1, '1')
@@ -2166,8 +2166,8 @@ select rpad('hello', -18446744073709551615, '1');
rpad('hello', -18446744073709551615, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select rpad('hello', 18446744073709551615, '1');
rpad('hello', 18446744073709551615, '1')
NULL
@@ -2177,27 +2177,27 @@ select rpad('hello', -18446744073709551616, '1');
rpad('hello', -18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select rpad('hello', 18446744073709551616, '1');
rpad('hello', 18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551617, '1');
rpad('hello', -18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select rpad('hello', 18446744073709551617, '1');
rpad('hello', 18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -1, '1');
lpad('hello', -1, '1')
@@ -2230,8 +2230,8 @@ select lpad('hello', -18446744073709551615, '1');
lpad('hello', -18446744073709551615, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select lpad('hello', 18446744073709551615, '1');
lpad('hello', 18446744073709551615, '1')
NULL
@@ -2241,27 +2241,27 @@ select lpad('hello', -18446744073709551616, '1');
lpad('hello', -18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select lpad('hello', 18446744073709551616, '1');
lpad('hello', 18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551617, '1');
lpad('hello', -18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select lpad('hello', 18446744073709551617, '1');
lpad('hello', 18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
@@ -2549,14 +2549,12 @@ create table t1(f1 tinyint default null)engine=myisam;
insert into t1 values (-1),(null);
explain select 1 as a from t1,(select decode(f1,f1) as b from t1) a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
explain select 1 as a from t1,(select encode(f1,f1) as b from t1) a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
drop table t1;
#
# Bug#49141: Encode function is significantly slower in 5.1 compared to 5.0
@@ -2612,4 +2610,20 @@ CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3))
1
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: ''
+#
+# Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail
+# and other crashes
+#
+CREATE TABLE t1 ( a TEXT );
+SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt';
+SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' );
+insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' )
+x
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: 'b'
+LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
+SELECT * FROM t1;
+a
+aaaaaaaaaaaaaa
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result
index a97e6869d09..5ac1bd7a0ac 100644
--- a/mysql-test/r/func_test.result
+++ b/mysql-test/r/func_test.result
@@ -87,7 +87,7 @@ explain extended select - a from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select -('1') AS `- a` from `test`.`t1`
+Note 1003 select -(1) AS `- a` from `test`.`t1`
drop table t1;
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index a97c040d9ac..e511da4588e 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -8,20 +8,39 @@ period_add("9602",-12) period_diff(199505,"9404")
199502 13
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(now())
-0.000000 0 0
+0 0 0
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
-1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112.000000
+1994-03-02 10:11:12.000000 1994-03-02 10:11:12 19940302101112.000000
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
sec_to_time(time_to_sec("0:30:47")/6.21);
sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21)
-02:30:01 23001.000000 54742 00:04:57
+02:30:01 23001 54742.000000 00:04:57.423510
+select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899);
+sec_to_time(9001.1) time_to_sec('15:12:22.123456') time_to_sec(15.5566778899)
+02:30:01.1 54742.123456 15.556677
select sec_to_time(time_to_sec('-838:59:59'));
sec_to_time(time_to_sec('-838:59:59'))
--838:59:59
+-838:59:59.000000
+select sec_to_time('9001.1'), sec_to_time('1234567890123.123');
+sec_to_time('9001.1') sec_to_time('1234567890123.123')
+02:30:01.100000 838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '1234567890123.123'
+select sec_to_time(90011e-1), sec_to_time(1234567890123e30);
+sec_to_time(90011e-1) sec_to_time(1234567890123e30)
+02:30:01.100000 838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '1.234567890123e+42'
+select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999');
+sec_to_time(1234567890123) sec_to_time('99999999999999999999999999999')
+838:59:59 838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '1234567890123'
+Warning 1292 Truncated incorrect time value: '99999999999999999999999999999'
select now()-curdate()*1000000-curtime();
now()-curdate()*1000000-curtime()
-0.000000
+0
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
strcmp(current_timestamp(),concat(current_date()," ",current_time()))
0
@@ -52,6 +71,9 @@ DAYOFYEAR("1997-03-03") WEEK("1998-03-03") QUARTER(980303)
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322)
23 3 22
+select TIME(230322), TIME(230322.33), TIME("230322.33");
+TIME(230322) TIME(230322.33) TIME("230322.33")
+23:03:22 23:03:22.33 23:03:22.330000
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
week(19980101) week(19970101) week(19980101,1) week(19970101,1)
0 0 1 1
@@ -137,18 +159,18 @@ Saturday 5
select monthname("1972-03-04"),monthname("1972-03-04")+0;
monthname("1972-03-04") monthname("1972-03-04")+0
March 3
-select time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
-00|12|0|12|00|AM|12:00:00 AM|00|00:00:00
-select time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
-01|01|1|1|02|AM|01:02:03 AM|03|01:02:03
-select time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
-13|01|13|1|14|PM|01:14:15 PM|15|13:14:15
-select time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
-01|01|1|1|00|AM|01:00:15 AM|15|01:00:15
+select time_format(000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+time_format(000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T') date_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
+00|12|0|12|00|AM|12:00:00 AM|00|00:00:00 00|12|0|12|00|AM|12:00:00 AM|00|00:00:00
+select time_format(010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+time_format(010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T') date_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
+01|01|1|1|02|AM|01:02:03 AM|03|01:02:03 01|01|1|1|02|AM|01:02:03 AM|03|01:02:03
+select time_format(131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+time_format(131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T') date_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
+13|01|13|1|14|PM|01:14:15 PM|15|13:14:15 13|01|13|1|14|PM|01:14:15 PM|15|13:14:15
+select time_format(010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+time_format(010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T') date_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T')
+01|01|1|1|00|AM|01:00:15 AM|15|01:00:15 01|01|1|1|00|AM|01:00:15 AM|15|01:00:15
select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w')
13|01|13|1|14|PM|01:14:15 PM|15|13:14:15| January|Saturday|31st|1998|98|Sat|Jan|031|01|31|01|15|6
@@ -543,10 +565,10 @@ select @a:=FROM_UNIXTIME(1);
1970-01-01 03:00:01
select unix_timestamp(@a);
unix_timestamp(@a)
-1
+1.000000
select unix_timestamp('1969-12-01 19:00:01');
unix_timestamp('1969-12-01 19:00:01')
-0
+NULL
select from_unixtime(-1);
from_unixtime(-1)
NULL
@@ -567,31 +589,31 @@ unix_timestamp(from_unixtime(2147483648))
NULL
select unix_timestamp('2039-01-20 01:00:00');
unix_timestamp('2039-01-20 01:00:00')
-0
+NULL
select unix_timestamp('1968-01-20 01:00:00');
unix_timestamp('1968-01-20 01:00:00')
-0
+NULL
select unix_timestamp('2038-02-10 01:00:00');
unix_timestamp('2038-02-10 01:00:00')
-0
+NULL
select unix_timestamp('1969-11-20 01:00:00');
unix_timestamp('1969-11-20 01:00:00')
-0
+NULL
select unix_timestamp('2038-01-20 01:00:00');
unix_timestamp('2038-01-20 01:00:00')
-0
+NULL
select unix_timestamp('1969-12-30 01:00:00');
unix_timestamp('1969-12-30 01:00:00')
-0
+NULL
select unix_timestamp('2038-01-17 12:00:00');
unix_timestamp('2038-01-17 12:00:00')
-2147331600
+2147331600.000000
select unix_timestamp('1970-01-01 03:00:01');
unix_timestamp('1970-01-01 03:00:01')
-1
+1.000000
select unix_timestamp('2038-01-19 07:14:07');
unix_timestamp('2038-01-19 07:14:07')
-0
+NULL
SELECT CHARSET(DAYNAME(19700101));
CHARSET(DAYNAME(19700101))
latin1
@@ -798,9 +820,7 @@ TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
2
select date_add(time,INTERVAL 1 SECOND) from t1;
date_add(time,INTERVAL 1 SECOND)
-NULL
-Warnings:
-Warning 1264 Out of range value for column 'time' at row 1
+06:07:09
drop table t1;
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
@@ -814,7 +834,7 @@ create table t1 select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
describe t1;
Field Type Null Key Default Extra
-a date NO 0000-00-00
+a date YES NULL
b date YES NULL
select * from t1;
a b
@@ -941,10 +961,10 @@ sec_to_time(1) + 0, from_unixtime(1) + 0;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `now() - now()` double(23,6) NOT NULL DEFAULT '0.000000',
- `curtime() - curtime()` double(23,6) NOT NULL DEFAULT '0.000000',
- `sec_to_time(1) + 0` double(23,6) DEFAULT NULL,
- `from_unixtime(1) + 0` double(23,6) DEFAULT NULL
+ `now() - now()` decimal(20,0) NOT NULL DEFAULT '0',
+ `curtime() - curtime()` decimal(11,0) NOT NULL DEFAULT '0',
+ `sec_to_time(1) + 0` decimal(11,0) DEFAULT NULL,
+ `from_unixtime(1) + 0` decimal(20,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
SELECT SEC_TO_TIME(3300000);
@@ -954,7 +974,7 @@ Warnings:
Warning 1292 Truncated incorrect time value: '3300000'
SELECT SEC_TO_TIME(3300000)+0;
SEC_TO_TIME(3300000)+0
-8385959.000000
+8385959
Warnings:
Warning 1292 Truncated incorrect time value: '3300000'
SELECT SEC_TO_TIME(3600 * 4294967296);
@@ -964,31 +984,31 @@ Warnings:
Warning 1292 Truncated incorrect time value: '15461882265600'
SELECT TIME_TO_SEC('916:40:00');
TIME_TO_SEC('916:40:00')
-3020399
+3020399.999999
Warnings:
Warning 1292 Truncated incorrect time value: '916:40:00'
SELECT ADDTIME('500:00:00', '416:40:00');
ADDTIME('500:00:00', '416:40:00')
-838:59:59
+838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '916:40:00'
SELECT ADDTIME('916:40:00', '416:40:00');
ADDTIME('916:40:00', '416:40:00')
-838:59:59
+838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '916:40:00'
-Warning 1292 Truncated incorrect time value: '1255:39:59'
+Warning 1292 Truncated incorrect time value: '1255:39:59.999999'
SELECT SUBTIME('916:40:00', '416:40:00');
SUBTIME('916:40:00', '416:40:00')
-422:19:59
+422:19:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '916:40:00'
SELECT SUBTIME('-916:40:00', '416:40:00');
SUBTIME('-916:40:00', '416:40:00')
--838:59:59
+-838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '-916:40:00'
-Warning 1292 Truncated incorrect time value: '-1255:39:59'
+Warning 1292 Truncated incorrect time value: '-1255:39:59.999999'
SELECT MAKETIME(916,0,0);
MAKETIME(916,0,0)
838:59:59
@@ -1014,6 +1034,7 @@ SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
MAKETIME(CAST(-1 AS UNSIGNED), 0, 0)
838:59:59
Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect time value: '18446744073709551615:00:00'
SELECT EXTRACT(HOUR FROM '100000:02:03');
EXTRACT(HOUR FROM '100000:02:03')
@@ -1033,6 +1054,8 @@ SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
SEC_TO_TIME(CAST(-1 AS UNSIGNED))
838:59:59
Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect time value: '18446744073709551615'
SET NAMES latin1;
SET character_set_results = NULL;
@@ -1081,7 +1104,9 @@ NULL
select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
week(20061108), week(20061108.01), week(20061108085411.000002);
isnull(week(now() + 0)) isnull(week(now() + 0.2)) week(20061108) week(20061108.01) week(20061108085411.000002)
-0 0 45 45 45
+0 0 45 NULL 45
+Warnings:
+Warning 1292 Incorrect datetime value: '20061108.01'
End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
@@ -1218,6 +1243,13 @@ set time_zone= @@global.time_zone;
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
NULL
+Warnings:
+Error 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
+select str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute;
+str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute
+NULL
+Warnings:
+Error 1411 Incorrect datetime value: '1997-00-04 22:23:00' for function str_to_date
create table t1 (field DATE);
insert into t1 values ('2006-11-06');
select * from t1 where field < '2006-11-06 04:08:36.0';
@@ -1301,6 +1333,24 @@ SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
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 'FRAC_SECOND' at line 1
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
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 'FRAC_SECOND' at line 1
+#
+# Bug #52315 part 2 : utc_date() crashes when system time > year 2037
+#
+SET TIMESTAMP=-147490000;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483648;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483646;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483647;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=-1;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=1;
+SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0;
End of 5.0 tests
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
@@ -1357,4 +1407,248 @@ Warning 1292 Truncated incorrect time value: ''
Warning 1292 Truncated incorrect time value: ''
Warning 1292 Truncated incorrect time value: ''
DROP TABLE t1;
+#
+# Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
+#
+SELECT STR_TO_DATE(SPACE(2),'1');
+STR_TO_DATE(SPACE(2),'1')
+0000-00-00
+#
+# Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
+#
+SET GLOBAL SQL_MODE='';
+DO STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
+SET GLOBAL SQL_MODE=DEFAULT;
+#
+# Bug#11766087 59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
+#
+SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
+FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1)
+NULL
+#
+# Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+#
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+#
+# Bug#11766124 59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
+#
+SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
+ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR)
+NULL
+#
+# Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
+#
+SELECT DATE_FORMAT('0000-00-11', '%W');
+DATE_FORMAT('0000-00-11', '%W')
+NULL
+SELECT DATE_FORMAT('0000-00-11', '%a');
+DATE_FORMAT('0000-00-11', '%a')
+NULL
+SELECT DATE_FORMAT('0000-00-11', '%w');
+DATE_FORMAT('0000-00-11', '%w')
+NULL
End of 5.1 tests
+select time('10:10:10') > 10;
+time('10:10:10') > 10
+1
+select time('10:10:10') > 1010;
+time('10:10:10') > 1010
+1
+select time('10:10:09') > 101010;
+time('10:10:09') > 101010
+0
+select time('10:10:10') > 101010;
+time('10:10:10') > 101010
+0
+select time('10:10:11') > 101010;
+time('10:10:11') > 101010
+1
+select time(' 1 02:03:04') + interval 9 microsecond;
+time(' 1 02:03:04') + interval 9 microsecond
+26:03:04.000009
+select time(' 1 02:03:04') - interval 9 microsecond;
+time(' 1 02:03:04') - interval 9 microsecond
+26:03:03.999991
+select time('-1 02:03:04') + interval 9 microsecond;
+time('-1 02:03:04') + interval 9 microsecond
+-26:03:03.999991
+select time('-1 02:03:04') - interval 9 microsecond;
+time('-1 02:03:04') - interval 9 microsecond
+-26:03:04.000009
+select time(' 1 02:03:04') + interval '4:4:4' hour_second;
+time(' 1 02:03:04') + interval '4:4:4' hour_second
+30:07:08
+select time(' 1 02:03:04') - interval '4:4:4' hour_second;
+time(' 1 02:03:04') - interval '4:4:4' hour_second
+21:59:00
+select time('-1 02:03:04') + interval '4:4:4' hour_second;
+time('-1 02:03:04') + interval '4:4:4' hour_second
+-21:59:00
+select time('-1 02:03:04') - interval '4:4:4' hour_second;
+time('-1 02:03:04') - interval '4:4:4' hour_second
+-30:07:08
+select time(' 1 02:03:04') + interval 2 day;
+time(' 1 02:03:04') + interval 2 day
+74:03:04
+select time(' 1 02:03:04') - interval 2 day;
+time(' 1 02:03:04') - interval 2 day
+-21:56:56
+select time('-1 02:03:04') + interval 2 day;
+time('-1 02:03:04') + interval 2 day
+21:56:56
+select time('-1 02:03:04') - interval 2 day;
+time('-1 02:03:04') - interval 2 day
+-74:03:04
+select time('10 02:03:04') + interval 30 day;
+time('10 02:03:04') + interval 30 day
+NULL
+Warnings:
+Warning 1441 Datetime function: time field overflow
+select time('10 02:03:04') + interval 1 year;
+time('10 02:03:04') + interval 1 year
+NULL
+Warnings:
+Warning 1441 Datetime function: time field overflow
+select cast('131415.123e0' as time);
+cast('131415.123e0' as time)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect time value: '131415.123e0'
+select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
+cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04'
+0
+select least(time('1:2:3'), '01:02:04', null) div 1;
+least(time('1:2:3'), '01:02:04', null) div 1
+NULL
+select truncate(least(time('1:2:3'), '01:02:04', null), 6);
+truncate(least(time('1:2:3'), '01:02:04', null), 6)
+NULL
+select cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1));
+cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1))
+NULL
+select unix_timestamp(null);
+unix_timestamp(null)
+NULL
+select truncate(date('2010-40-10'), 6);
+truncate(date('2010-40-10'), 6)
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2010-40-10'
+select extract(month from '2010-40-50');
+extract(month from '2010-40-50')
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '2010-40-50'
+select subtime('0000-00-10 10:10:10', '30 10:00:00');
+subtime('0000-00-10 10:10:10', '30 10:00:00')
+NULL
+select cast(str_to_date(NULL, '%H:%i:%s') as time);
+cast(str_to_date(NULL, '%H:%i:%s') as time)
+NULL
+create table t1 (f1 datetime, key (f1));
+insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49');
+select * from t1 where f1 > time('-23:00:06');
+f1
+2000-09-12 00:00:00
+2007-04-25 05:08:49
+drop table t1;
+select maketime(20,61,10)+0;
+maketime(20,61,10)+0
+NULL
+create table t1 (f2 int not null) ;
+insert into t1 values (0),(0);
+select last_day(f2) from t1;
+last_day(f2)
+NULL
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+select last_day(f2) from t1 where last_day(f2) is null;
+last_day(f2)
+NULL
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+select * from t1 order by last_day (f2);
+f2
+0
+0
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+drop table t1;
+select convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetime)), 'UTC', 'Europe/Moscow');
+convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetime)), 'UTC', 'Europe/Moscow')
+NULL
+create table t1 (f1 integer, f2 date);
+insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05'),(6, '2011-05-06');
+select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
+f1 f2
+1 2011-05-05
+2 2011-05-05
+3 2011-05-05
+4 2011-05-05
+5 2011-05-05
+drop table t1;
+create table t1 (f1 timestamp);
+insert into t1 values ('0000-00-00 00:00:00');
+select least(1, f1) from t1;
+least(1, f1)
+0000-00-00 00:00:00
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+drop table t1;
+select now() > coalesce(time('21:43:24'), date('2010-05-03'));
+now() > coalesce(time('21:43:24'), date('2010-05-03'))
+1
+create table t1 (f1 timestamp);
+select * from t1 where f1 > f1 and f1 <=> timestampadd(hour, 9 , '2010-01-01 16:55:35');
+f1
+drop table t1;
+create table t1 (f1 date);
+insert into t1 values ('0000-00-00');
+select timestampadd(week, 1, f1) from t1;
+timestampadd(week, 1, f1)
+NULL
+select timestampadd(week, 1, date("0000-00-00"));
+timestampadd(week, 1, date("0000-00-00"))
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0000-00-00'
+drop table t1;
+create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
+insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');
+select least(greatest(f3, f2, f4), f5) from t1;
+least(greatest(f3, f2, f4), f5)
+0000-00-00 00:00:00
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+drop table t1;
+select day(coalesce(null));
+day(coalesce(null))
+NULL
+select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
+timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'))
+2002-08-20 00:00:00
+create table t1 (f1 datetime);
+insert into t1 values ('0000-00-00 00:00:00');
+select cast(f1 AS time) from t1;
+cast(f1 AS time)
+00:00:00
+drop table t1;
+select greatest(cast("0-0-0" as date), cast("10:20:05" as time));
+greatest(cast("0-0-0" as date), cast("10:20:05" as time))
+0000-00-00
+select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '0000-00-00';
+greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '0000-00-00'
+1
+select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6));
+cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6))
+0000-00-00 00:00:00.000000
+select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
+microsecond('12:00:00.123456') microsecond('2009-12-31 23:59:59.000010')
+123456 10
diff --git a/mysql-test/r/func_time_hires.result b/mysql-test/r/func_time_hires.result
new file mode 100644
index 00000000000..73b82a6ac1f
--- /dev/null
+++ b/mysql-test/r/func_time_hires.result
@@ -0,0 +1,208 @@
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01.123456');
+select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
+sec_to_time(12345) 03:25:45
+sec_to_time(12345.6789) 03:25:45.6789
+sec_to_time(1234567e-2) 03:25:45.670000
+select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
+current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
+time_to_sec('12:34:56.789');
+now() 2011-01-01 01:01:01
+curtime(0) 01:01:01
+utc_timestamp(1) 2010-12-31 22:01:01.1
+utc_time(2) 22:01:01.12
+current_time(3) 01:01:01.123
+current_timestamp(4) 2011-01-01 01:01:01.1234
+localtime(5) 2011-01-01 01:01:01.12345
+localtimestamp(6) 2011-01-01 01:01:01.123456
+time_to_sec('12:34:56') 45296.000000
+time_to_sec('12:34:56.789') 45296.789000
+select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
+sec_to_time(time_to_sec('1:2:3')) 01:02:03.000000
+sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.567890
+select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
+time_to_sec(sec_to_time(11111)) 11111
+time_to_sec(sec_to_time(11111.22222)) 11111.22222
+select current_timestamp(7);
+ERROR 42000: Too big precision 7 specified for 'now'. Maximum is 6.
+select curtime(7);
+ERROR 42000: Too big precision 7 specified for 'curtime'. Maximum is 6.
+drop table if exists t1;
+create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
+sec_to_time(1234567e-2), now(), curtime(0),
+utc_timestamp(1), utc_time(2), current_time(3),
+current_timestamp(4), localtime(5), localtimestamp(6),
+time_to_sec(123456), time_to_sec('12:34:56.789');
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `sec_to_time(12345)` time DEFAULT NULL,
+ `sec_to_time(12345.6789)` time(4) DEFAULT NULL,
+ `sec_to_time(1234567e-2)` time(6) DEFAULT NULL,
+ `now()` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `curtime(0)` time NOT NULL DEFAULT '00:00:00',
+ `utc_timestamp(1)` datetime(1) NOT NULL DEFAULT '0000-00-00 00:00:00.0',
+ `utc_time(2)` time(2) NOT NULL DEFAULT '00:00:00.00',
+ `current_time(3)` time(3) NOT NULL DEFAULT '00:00:00.000',
+ `current_timestamp(4)` datetime(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000',
+ `localtime(5)` datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000',
+ `localtimestamp(6)` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
+ `time_to_sec(123456)` bigint(17) DEFAULT NULL,
+ `time_to_sec('12:34:56.789')` decimal(22,6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+sec_to_time(12345) 03:25:45
+sec_to_time(12345.6789) 03:25:45.6789
+sec_to_time(1234567e-2) 03:25:45.670000
+now() 2011-01-01 01:01:01
+curtime(0) 01:01:01
+utc_timestamp(1) 2010-12-31 22:01:01.1
+utc_time(2) 22:01:01.12
+current_time(3) 01:01:01.123
+current_timestamp(4) 2011-01-01 01:01:01.1234
+localtime(5) 2011-01-01 01:01:01.12345
+localtimestamp(6) 2011-01-01 01:01:01.123456
+time_to_sec(123456) 45296
+time_to_sec('12:34:56.789') 45296.789000
+drop table t1;
+select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));;
+unix_timestamp('2011-01-01 01:01:01') 1293832861.000000
+unix_timestamp('2011-01-01 01:01:01.123456') 1293832861.123456
+unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))) 1293832861
+unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4))) 1293832861.1234
+select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));;
+from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01.000000
+from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')) 2011-01-01 01:01:01.123456
+from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))) 2011-01-01 01:01:01
+from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4)))) 2011-01-01 01:01:01.1234
+select sec_to_time(3020399.99999), sec_to_time(3020399.999999), sec_to_time(3020399.9999999);
+sec_to_time(3020399.99999) sec_to_time(3020399.999999) sec_to_time(3020399.9999999)
+838:59:59.99999 838:59:59.999999 838:59:59.999999
+select sec_to_time(-3020399.99999), sec_to_time(-3020399.999999), sec_to_time(-3020399.9999999);
+sec_to_time(-3020399.99999) sec_to_time(-3020399.999999) sec_to_time(-3020399.9999999)
+-838:59:59.99999 -838:59:59.999999 -838:59:59.999999
+select 20010101000203.000000004 + interval 1 day;
+20010101000203.000000004 + interval 1 day
+2001-01-02 00:02:03.000000
+select 20010101000203.4 + interval 1 day;
+20010101000203.4 + interval 1 day
+2001-01-02 00:02:03.4
+set @a=cast('2011-01-02 12:13:14' as datetime);
+select @a + interval 1 minute;
+@a + interval 1 minute
+2011-01-02 12:14:14
+select @a + interval 10 microsecond;
+@a + interval 10 microsecond
+2011-01-02 12:13:14.000010
+select @a + interval 10 microsecond + interval 999990 microsecond;
+@a + interval 10 microsecond + interval 999990 microsecond
+2011-01-02 12:13:15.000000
+set @a='2011-01-02 12:13:14.123456';
+create table t1 select CAST(@a AS DATETIME) as dauto,
+CAST(@a AS DATETIME(0)) as d0,
+CAST(@a AS DATETIME(1)) as d1,
+CAST(@a AS DATETIME(2)) as d2,
+CAST(@a AS DATETIME(3)) as d3,
+CAST(@a AS DATETIME(4)) as d4,
+CAST(@a AS DATETIME(5)) as d5,
+CAST(@a AS DATETIME(6)) as d6,
+CAST(@a AS TIME) as tauto,
+CAST(@a AS TIME(0)) as t0,
+CAST(@a AS TIME(1)) as t1,
+CAST(@a AS TIME(2)) as t2,
+CAST(@a AS TIME(3)) as t3,
+CAST(@a AS TIME(4)) as t4,
+CAST(@a AS TIME(5)) as t5,
+CAST(@a AS TIME(6)) as t6;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `dauto` datetime DEFAULT NULL,
+ `d0` datetime DEFAULT NULL,
+ `d1` datetime(1) DEFAULT NULL,
+ `d2` datetime(2) DEFAULT NULL,
+ `d3` datetime(3) DEFAULT NULL,
+ `d4` datetime(4) DEFAULT NULL,
+ `d5` datetime(5) DEFAULT NULL,
+ `d6` datetime(6) DEFAULT NULL,
+ `tauto` time DEFAULT NULL,
+ `t0` time DEFAULT NULL,
+ `t1` time(1) DEFAULT NULL,
+ `t2` time(2) DEFAULT NULL,
+ `t3` time(3) DEFAULT NULL,
+ `t4` time(4) DEFAULT NULL,
+ `t5` time(5) DEFAULT NULL,
+ `t6` time(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+dauto 2011-01-02 12:13:14
+d0 2011-01-02 12:13:14
+d1 2011-01-02 12:13:14.1
+d2 2011-01-02 12:13:14.12
+d3 2011-01-02 12:13:14.123
+d4 2011-01-02 12:13:14.1234
+d5 2011-01-02 12:13:14.12345
+d6 2011-01-02 12:13:14.123456
+tauto 12:13:14
+t0 12:13:14
+t1 12:13:14.1
+t2 12:13:14.12
+t3 12:13:14.123
+t4 12:13:14.1234
+t5 12:13:14.12345
+t6 12:13:14.123456
+drop table t1;
+explain extended select cast(cast(@a as datetime(4)) as time(0));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select cast(cast((@a) as datetime(4)) as time) AS `cast(cast(@a as datetime(4)) as time(0))`
+select cast(cast(@a as time(2)) as time(6));
+cast(cast(@a as time(2)) as time(6))
+12:13:14.120000
+select CAST(@a AS DATETIME(7));
+ERROR 42000: Too big precision 7 specified for '(@a)'. Maximum is 6.
+SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
+CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00')
+2011-01-02 15:00:00
+SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
+CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00')
+2011-01-02 15:00:00.123000
+SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
+CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00')
+2011-01-02 15:00:00.123456
+SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
+CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00')
+2010-10-10 13:10:10.1234
+create table t1 (a varchar(200));
+insert t1 values (now(6));
+select * from t1;
+a
+2011-01-01 01:01:01.123456
+drop table t1;
+create table t1 (f1 timestamp(6));
+insert into t1 values ('2002-07-15 21:00:00');
+select time(f1) from t1;
+time(f1)
+21:00:00.000000
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+time(f1)
+21:00:00.000000
+21:00:01.000000
+alter table t1 modify f1 timestamp;
+select time(f1) from t1;
+time(f1)
+21:00:00
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+time(f1)
+21:00:00
+21:00:01
+alter table t1 modify f1 varchar(100);
+select time(f1) from t1;
+time(f1)
+21:00:00
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+time(f1)
+21:00:00.000000
+21:00:01.000000
+drop table t1;
diff --git a/mysql-test/r/func_timestamp.result b/mysql-test/r/func_timestamp.result
index 495fedea9e6..18fcbd947e7 100644
--- a/mysql-test/r/func_timestamp.result
+++ b/mysql-test/r/func_timestamp.result
@@ -7,7 +7,7 @@ SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
FROM t1;
Date Unix
-1998-9-16 09:26:00 905927160
-1998-9-16 09:26:00 905927160
+1998-9-16 09:26:00 905927160.000000
+1998-9-16 09:26:00 905927160.000000
drop table t1;
set time_zone= @@global.time_zone;
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
index 21193cd8ec2..31e79a52b49 100644
--- a/mysql-test/r/gis-rtree.result
+++ b/mysql-test/r/gis-rtree.result
@@ -170,7 +170,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 34 NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
-11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -698,7 +697,7 @@ count(*)
DROP TABLE t2;
drop table if exists t1;
Warnings:
-Note 1051 Unknown table 'test.t1'
+Note 1051 Unknown table 't1'
CREATE TABLE t1 (a geometry NOT NULL, SPATIAL (a));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index daf66b16d62..d30431e5419 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -258,7 +258,7 @@ fid AsText(EndPoint(g))
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line;
fid GLength(g)
-105 24.14213562373095
+105 24.142135623731
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line;
@@ -284,7 +284,7 @@ Note 1003 select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `AsText(Star
SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.416666666666668 25.416666666666668)
+109 POINT(25.4166666666667 25.4166666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon;
fid Area(g)
@@ -318,8 +318,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g))
-117 POINT(55.58852775304245 17.426536064113982)
-118 POINT(55.58852775304245 17.426536064113982)
+117 POINT(55.5885277530424 17.426536064114)
+118 POINT(55.5885277530424 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g)
@@ -384,10 +384,10 @@ Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
-120 120 1 1 0 1 0 1 1 0
+120 120 0 0 0 1 0 1 1 0
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
-121 121 1 1 0 1 0 1 1 0
+121 121 0 0 0 1 0 1 1 0
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
@@ -395,9 +395,9 @@ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
-1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (BNL, regular buffers)
+1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,mbrwithin(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,mbrcontains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
+Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,st_within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,st_contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
gp point,
@@ -651,11 +651,11 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
-85998 MULTIPOLYGON 1 POINT(115.31877315203187 -36.23747282102153)
+85998 MULTIPOLYGON 1 POINT(115.318773152032 -36.2374728210215)
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85984;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
-85984 MULTIPOLYGON 1 POINT(-114.87787186923313 36.33101763469059)
+85984 MULTIPOLYGON 1 POINT(-114.877871869233 36.3310176346905)
drop table t1;
create table t1 (fl geometry not null);
insert into t1 values (1);
@@ -802,17 +802,6 @@ create table t1 (g geometry not null);
insert into t1 values(default);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
-CREATE TABLE t1 (a GEOMETRY);
-CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1;
-CREATE VIEW v2 AS SELECT a FROM t1;
-DESCRIBE v1;
-Field Type Null Key Default Extra
-GeomFromwkb(ASBINARY(a)) geometry YES NULL
-DESCRIBE v2;
-Field Type Null Key Default Extra
-a geometry YES NULL
-DROP VIEW v1,v2;
-DROP TABLE t1;
create table t1 (name VARCHAR(100), square GEOMETRY);
INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));
INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
@@ -852,7 +841,6 @@ mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
-center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
@@ -870,7 +858,6 @@ touches
down2,left2,right2,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
-big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
@@ -960,6 +947,18 @@ COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
+#
+# Test for bug #58650 "Failing assertion: primary_key_no == -1 ||
+# primary_key_no == 0".
+#
+drop table if exists t1;
+# The minimal test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a));
+drop table t1;
+# The original test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)));
+create unique index a on t1(a);
+drop table t1;
create table `t1` (`col002` point)engine=myisam;
insert into t1 values (),(),();
select min(`col002`) from t1 union select `col002` from t1;
@@ -1014,6 +1013,22 @@ SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000
SET @a=POLYFROMWKB(@a);
SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
SET @a=POLYFROMWKB(@a);
+create table t1(a polygon NOT NULL)engine=myisam;
+insert into t1 values (geomfromtext("point(0 1)"));
+insert into t1 values (geomfromtext("point(1 0)"));
+select * from (select polygon(t1.a) as p from t1 order by t1.a) d;
+p
+NULL
+NULL
+drop table t1;
+#
+# Test for bug #59888 "debug assertion when attempt to create spatial index
+# on char > 31 bytes".
+#
+create table t1(a char(32) not null) engine=myisam;
+create spatial index i on t1 (a);
+ERROR 42000: A SPATIAL index may only contain a geometrical type column
+drop table t1;
End of 5.1 tests
CREATE TABLE t1(
col0 BINARY NOT NULL,
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 7369fb4cd61..0d9b99721cb 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -1327,6 +1327,199 @@ DROP DATABASE mysqltest2;
DROP USER testuser@localhost;
use test;
+#
+# Test for bug #36544 "DROP USER does not remove stored function
+# privileges".
+#
+create database mysqltest1;
+create function mysqltest1.f1() returns int return 0;
+create procedure mysqltest1.p1() begin end;
+#
+# 1) Check that DROP USER properly removes privileges on both
+# stored procedures and functions.
+#
+create user mysqluser1@localhost;
+grant execute on function mysqltest1.f1 to mysqluser1@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser1@localhost;
+# Quick test that granted privileges are properly reflected
+# in privilege tables and in in-memory structures.
+show grants for mysqluser1@localhost;
+Grants for mysqluser1@localhost
+GRANT USAGE ON *.* TO 'mysqluser1'@'localhost'
+GRANT EXECUTE ON PROCEDURE `mysqltest1`.`p1` TO 'mysqluser1'@'localhost'
+GRANT EXECUTE ON FUNCTION `mysqltest1`.`f1` TO 'mysqluser1'@'localhost'
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+db routine_name routine_type proc_priv
+mysqltest1 f1 FUNCTION Execute
+mysqltest1 p1 PROCEDURE Execute
+#
+# Create connection 'bug_36544_con1' as 'mysqluser1@localhost'.
+call mysqltest1.p1();
+select mysqltest1.f1();
+mysqltest1.f1()
+0
+#
+# Switch to connection 'default'.
+drop user mysqluser1@localhost;
+#
+# Test that dropping of user is properly reflected in
+# both privilege tables and in in-memory structures.
+#
+# Switch to connection 'bug36544_con1'.
+# The connection cold be alive but should not be able to
+# access to any of the stored routines.
+call mysqltest1.p1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1'
+select mysqltest1.f1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.f1'
+#
+# Switch to connection 'default'.
+#
+# Now create user with the same name and check that he
+# has not inherited privileges.
+create user mysqluser1@localhost;
+show grants for mysqluser1@localhost;
+Grants for mysqluser1@localhost
+GRANT USAGE ON *.* TO 'mysqluser1'@'localhost'
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+db routine_name routine_type proc_priv
+#
+# Create connection 'bug_36544_con2' as 'mysqluser1@localhost'.
+# Newly created user should not be able to access any of the routines.
+call mysqltest1.p1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1'
+select mysqltest1.f1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.f1'
+#
+# Switch to connection 'default'.
+#
+# 2) Check that RENAME USER properly updates privileges on both
+# stored procedures and functions.
+#
+grant execute on function mysqltest1.f1 to mysqluser1@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser1@localhost;
+#
+# Create one more user to make in-memory hashes non-trivial.
+# User names 'mysqluser11' and 'mysqluser10' were selected
+# to trigger bug discovered during code inspection.
+create user mysqluser11@localhost;
+grant execute on function mysqltest1.f1 to mysqluser11@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser11@localhost;
+# Also create a couple of tables to test for another bug
+# discovered during code inspection (again table names were
+# chosen especially to trigger the bug).
+create table mysqltest1.t11 (i int);
+create table mysqltest1.t22 (i int);
+grant select on mysqltest1.t22 to mysqluser1@localhost;
+grant select on mysqltest1.t11 to mysqluser1@localhost;
+# Quick test that granted privileges are properly reflected
+# in privilege tables and in in-memory structures.
+show grants for mysqluser1@localhost;
+Grants for mysqluser1@localhost
+GRANT USAGE ON *.* TO 'mysqluser1'@'localhost'
+GRANT SELECT ON `mysqltest1`.`t11` TO 'mysqluser1'@'localhost'
+GRANT SELECT ON `mysqltest1`.`t22` TO 'mysqluser1'@'localhost'
+GRANT EXECUTE ON PROCEDURE `mysqltest1`.`p1` TO 'mysqluser1'@'localhost'
+GRANT EXECUTE ON FUNCTION `mysqltest1`.`f1` TO 'mysqluser1'@'localhost'
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+db routine_name routine_type proc_priv
+mysqltest1 f1 FUNCTION Execute
+mysqltest1 p1 PROCEDURE Execute
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
+db table_name table_priv
+mysqltest1 t11 Select
+mysqltest1 t22 Select
+#
+# Switch to connection 'bug36544_con2'.
+call mysqltest1.p1();
+select mysqltest1.f1();
+mysqltest1.f1()
+0
+select * from mysqltest1.t11;
+i
+select * from mysqltest1.t22;
+i
+#
+# Switch to connection 'default'.
+rename user mysqluser1@localhost to mysqluser10@localhost;
+#
+# Test that there are no privileges left for mysqluser1.
+#
+# Switch to connection 'bug36544_con2'.
+# The connection cold be alive but should not be able to
+# access to any of the stored routines or tables.
+call mysqltest1.p1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1'
+select mysqltest1.f1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.f1'
+select * from mysqltest1.t11;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't11'
+select * from mysqltest1.t22;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't22'
+#
+# Switch to connection 'default'.
+#
+# Now create user with the old name and check that he
+# has not inherited privileges.
+create user mysqluser1@localhost;
+show grants for mysqluser1@localhost;
+Grants for mysqluser1@localhost
+GRANT USAGE ON *.* TO 'mysqluser1'@'localhost'
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+db routine_name routine_type proc_priv
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
+db table_name table_priv
+#
+# Create connection 'bug_36544_con3' as 'mysqluser1@localhost'.
+# Newly created user should not be able to access to any of the
+# stored routines or tables.
+call mysqltest1.p1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1'
+select mysqltest1.f1();
+ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.f1'
+select * from mysqltest1.t11;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't11'
+select * from mysqltest1.t22;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't22'
+#
+# Switch to connection 'default'.
+#
+# Now check that privileges became associated with a new user
+# name - mysqluser10.
+#
+show grants for mysqluser10@localhost;
+Grants for mysqluser10@localhost
+GRANT USAGE ON *.* TO 'mysqluser10'@'localhost'
+GRANT SELECT ON `mysqltest1`.`t22` TO 'mysqluser10'@'localhost'
+GRANT SELECT ON `mysqltest1`.`t11` TO 'mysqluser10'@'localhost'
+GRANT EXECUTE ON PROCEDURE `mysqltest1`.`p1` TO 'mysqluser10'@'localhost'
+GRANT EXECUTE ON FUNCTION `mysqltest1`.`f1` TO 'mysqluser10'@'localhost'
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser10' and host='localhost';
+db routine_name routine_type proc_priv
+mysqltest1 f1 FUNCTION Execute
+mysqltest1 p1 PROCEDURE Execute
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser10' and host='localhost';
+db table_name table_priv
+mysqltest1 t11 Select
+mysqltest1 t22 Select
+#
+# Create connection 'bug_36544_con4' as 'mysqluser10@localhost'.
+call mysqltest1.p1();
+select mysqltest1.f1();
+mysqltest1.f1()
+0
+select * from mysqltest1.t11;
+i
+select * from mysqltest1.t22;
+i
+#
+# Switch to connection 'default'.
+#
+# Clean-up.
+drop user mysqluser1@localhost;
+drop user mysqluser10@localhost;
+drop user mysqluser11@localhost;
+drop database mysqltest1;
End of 5.0 tests
set names utf8;
grant select on test.* to юзер_юзер@localhost;
@@ -1423,11 +1616,7 @@ fn2()
2
DROP USER 'userbug33464'@'localhost';
DROP FUNCTION fn1;
-Warnings:
-Warning 1403 There is no such grant defined for user 'userbug33464' on host 'localhost' on routine 'fn1'
DROP FUNCTION fn2;
-Warnings:
-Warning 1403 There is no such grant defined for user 'userbug33464' on host 'localhost' on routine 'fn2'
DROP PROCEDURE sp3;
DROP USER 'userbug33464'@'localhost';
USE test;
diff --git a/mysql-test/r/grant_cache_no_prot.result b/mysql-test/r/grant_cache_no_prot.result
index 32bb9cce90e..281468ee2e1 100644
--- a/mysql-test/r/grant_cache_no_prot.result
+++ b/mysql-test/r/grant_cache_no_prot.result
@@ -174,7 +174,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
-Qcache_not_cached 7
+Qcache_not_cached 4
----- establish connection user4 (user=mysqltest_1) -----
select "user4";
user4
@@ -205,7 +205,7 @@ Variable_name Value
Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
-Qcache_not_cached 8
+Qcache_not_cached 5
----- close connections -----
----- switch to connection default -----
set names binary;
diff --git a/mysql-test/r/grant_cache_ps_prot.result b/mysql-test/r/grant_cache_ps_prot.result
index 281468ee2e1..2d8c543e9e4 100644
--- a/mysql-test/r/grant_cache_ps_prot.result
+++ b/mysql-test/r/grant_cache_ps_prot.result
@@ -174,7 +174,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
-Qcache_not_cached 4
+Qcache_not_cached 3
----- establish connection user4 (user=mysqltest_1) -----
select "user4";
user4
@@ -205,7 +205,7 @@ Variable_name Value
Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
-Qcache_not_cached 5
+Qcache_not_cached 4
----- close connections -----
----- switch to connection default -----
set names binary;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index f22a8b0fb55..33376b22bc6 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1543,8 +1543,7 @@ EXPLAIN SELECT 1 FROM t1 WHERE a IN
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index
-1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 144
+1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1)
CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2;
@@ -1873,4 +1872,40 @@ ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;
COUNT(*)
2
DROP TABLE t1;
+#
+# Bug#59839: Aggregation followed by subquery yields wrong result
+#
+CREATE TABLE t1 (
+a INT,
+b INT,
+c INT,
+KEY (a, b)
+);
+INSERT INTO t1 VALUES
+( 1, 1, 1 ),
+( 1, 2, 2 ),
+( 1, 3, 3 ),
+( 1, 4, 6 ),
+( 1, 5, 5 ),
+( 1, 9, 13 ),
+( 2, 1, 6 ),
+( 2, 2, 7 ),
+( 2, 3, 8 );
+EXPLAIN
+SELECT a, AVG(t1.b),
+(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c,
+(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c
+FROM t1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL a 10 NULL 9 Using index
+3 DEPENDENT SUBQUERY t12 ref a a 10 func,func 2 Using index condition
+2 DEPENDENT SUBQUERY t11 ref a a 10 func,func 2 Using index condition
+SELECT a, AVG(t1.b),
+(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c,
+(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c
+FROM t1 GROUP BY a;
+a AVG(t1.b) t11c t12c
+1 4.0000 6 6
+2 2.0000 7 7
+DROP TABLE t1;
# End of 5.1 tests
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index 974521ec120..0b3df689089 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -1360,12 +1360,158 @@ group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c = t1.c )
+group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
+1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c > 'b1' )
+group by a1,a2,b;
+a1 a2 b min(c) max(c)
+a a a a111 d111
+a a b e112 h112
+a b a i121 l121
+a b b m122 p122
+b a a a211 d211
+b a b e212 h212
+b b a i221 l221
+b b b m222 p222
+c a a a311 d311
+c a b e312 h312
+c b a i321 l321
+c b b m322 p322
+d a a a411 d411
+d a b e412 h412
+d b a i421 l421
+d b b m422 p422
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+a1 a2 b c min(c) max(c)
+a a b h112 e112 h112
+a b b p122 m122 p122
+b a b h212 e212 h212
+b b b p222 m222 p222
+c a b h312 e312 h312
+c b b p322 m322 p322
+d a b h412 e412 h412
+d b b p422 m422 p422
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+where t2.c in (select c from t3 where t3.c > t1.b) and
+t2.c > 'b1' )
+group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+where t2.c in (select c from t3 where t3.c > t1.b) and
+t2.c > 'b1' )
+group by a1,a2,b;
+a1 a2 b c min(c) max(c)
+a a a d111 a111 d111
+a a b h112 e112 h112
+a b a l121 i121 l121
+a b b p122 m122 p122
+b a a d211 a211 d211
+b a b h212 e212 h212
+b b a l221 i221 l221
+b b b p222 m222 p222
+c a a d311 a311 d311
+c a b h312 e312 h312
+c b a l321 i321 l321
+c b b p322 m322 p322
+d a a d411 a411 d411
+d a b h412 e412 h412
+d b a l421 i421 l421
+d b b p422 m422 p422
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+a1 a2 b c min(c) max(c)
+a a a a111 a111 d111
+a a b e112 e112 h112
+a b a i121 i121 l121
+a b b m122 m122 p122
+b a a a211 a211 d211
+b a b e212 e212 h212
+b b a i221 i221 l221
+b b b m222 m222 p222
+c a a a311 a311 d311
+c a b e312 e312 h312
+c b a i321 i321 l321
+c b b m322 m322 p322
+d a a a411 a411 d411
+d a b e412 e412 h412
+d b a i421 i421 l421
+d b b m422 m422 p422
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+where t2.c in (select c from t3 where t3.c > t1.c) and
+t2.c > 'b1' )
+group by a1,a2,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+where t2.c in (select c from t3 where t3.c > t1.c) and
+t2.c > 'b1' )
+group by a1,a2,b;
+a1 a2 b c min(c) max(c)
+a a a a111 a111 d111
+a a b e112 e112 h112
+a b a i121 i121 l121
+a b b m122 m122 p122
+b a a a211 a211 d211
+b a b e212 e212 h212
+b b a i221 i221 l221
+b b b m222 m222 p222
+c a a a311 a311 d311
+c a b e312 e312 h312
+c b a i321 i321 l321
+c b b m322 m322 o322
+d a a a411 a411 d411
+d a b e412 e412 h412
+d b a i421 i421 l421
+d b b m422 m422 o422
explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
@@ -2246,17 +2392,17 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
-2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
+2 SUBQUERY t1 index NULL a 10 NULL 1 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index
-2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
+2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
@@ -2266,7 +2412,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
AND t1_outer1.b = t1_outer2.b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
+1 PRIMARY t1_outer1 ref a a 5 const 1 Using index
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join)
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index c7850b7ce03..fc2df2b7fc2 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -473,7 +473,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE table2 const PRIMARY PRIMARY 4 const 1 100.00 Using filesort
1 SIMPLE table1 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
-Note 1003 select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having (('7' = 8) and (`test`.`table1`.`f1` >= 6))
+Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = 9)) group by `test`.`table1`.`f1`,7 having ((7 = 8) and (`test`.`table1`.`f1` >= 6))
EXPLAIN EXTENDED
SELECT table1.f1, table2.f2
FROM t1 AS table1
@@ -485,7 +485,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE table2 const PRIMARY PRIMARY 4 const 1 100.00 Using filesort
1 SIMPLE table1 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
-Note 1003 select `test`.`table1`.`f1` AS `f1`,'7' AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = '9')) group by `test`.`table1`.`f1`,'7' having ('7' = 8)
+Note 1003 select `test`.`table1`.`f1` AS `f1`,7 AS `f2` from `test`.`t1` `table1` join `test`.`t1` `table2` where ((`test`.`table1`.`f3` = 9)) group by `test`.`table1`.`f1`,7 having (7 = 8)
DROP TABLE t1;
#
# Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355
@@ -547,4 +547,26 @@ FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
HAVING field1 < 7;
field1
DROP TABLE t1,t2;
+#
+# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
+#
+CREATE TABLE t1 (f1 INT, f2 INT);
+INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
+CREATE TABLE t2 (f1 INT, f2 INT);
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+f1
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+f1
+SELECT t1.f1
+FROM t1
+HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+f1
+DROP TABLE t1,t2;
End of 5.1 tests
diff --git a/mysql-test/r/index_intersect.result b/mysql-test/r/index_intersect.result
index 713674430cf..bc053c49748 100644
--- a/mysql-test/r/index_intersect.result
+++ b/mysql-test/r/index_intersect.result
@@ -371,7 +371,7 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where; Rowid-ordered scan
+1 SIMPLE City range Population,Name,Country Name # NULL # Using index condition; Using where; Rowid-ordered scan
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
ID Name Country Population
diff --git a/mysql-test/r/index_intersect_innodb.result b/mysql-test/r/index_intersect_innodb.result
index c2aa281c7f3..85184d79cce 100644
--- a/mysql-test/r/index_intersect_innodb.result
+++ b/mysql-test/r/index_intersect_innodb.result
@@ -372,7 +372,7 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where
+1 SIMPLE City index_merge Population,Name,Country Population,Name,Country # NULL # Using sort_intersect(Population,Name,Country); Using where
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
ID Name Country Population
diff --git a/mysql-test/r/index_merge_innodb.result b/mysql-test/r/index_merge_innodb.result
index 17663076ca3..d935cdbddbc 100644
--- a/mysql-test/r/index_merge_innodb.result
+++ b/mysql-test/r/index_merge_innodb.result
@@ -691,8 +691,7 @@ SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX(primary,idx)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
-2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 11419 Using sort_union(idx,PRIMARY); Using where
+1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 11419 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX(primary,idx)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
@@ -703,8 +702,7 @@ SELECT COUNT(*) FROM
(SELECT * FROM t1 IGNORE INDEX(idx)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL # Select tables optimized away
-2 DERIVED t1 ALL PRIMARY NULL NULL NULL # Using where
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL # Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 IGNORE INDEX(idx)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result
index 4871f42cffc..8682219054f 100644
--- a/mysql-test/r/index_merge_myisam.result
+++ b/mysql-test/r/index_merge_myisam.result
@@ -287,8 +287,7 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
+1 SIMPLE t1 index_merge i1,i2,i8 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
create table t3 like t0;
insert into t3 select * from t0;
alter table t3 add key9 int not null, add index i9(key9);
@@ -1484,7 +1483,7 @@ EXPLAIN SELECT t1.f1 FROM t1
WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
-2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 1 Using where
+2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 const 1 Using where
DROP TABLE t1,t2;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index b32e25ef07e..87675143853 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -216,8 +216,8 @@ Field Type Collation Null Key Default Extra Privileges Comment
c varchar(64) utf8_general_ci NO select,insert,update,references
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
show columns from mysqltest.t1 where field like "%a%";
Field Type Null Key Default Extra
a int(11) YES NULL
@@ -1288,8 +1288,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases; Using filesort
explain select * from (select table_name from information_schema.tables) as a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
-2 DERIVED tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
+1 SIMPLE tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
drop view v1;
create table t1 (f1 int(11));
create table t2 (f1 int(11), f2 int(11));
@@ -1489,9 +1488,9 @@ WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
TABLE_COLLATION
utf8_bin
select * from information_schema.columns where table_schema = NULL;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
diff --git a/mysql-test/r/innodb_mrr.result b/mysql-test/r/innodb_mrr.result
index 4f1006878b4..e4993016723 100644
--- a/mysql-test/r/innodb_mrr.result
+++ b/mysql-test/r/innodb_mrr.result
@@ -665,8 +665,8 @@ set join_buffer_size=@my_save_join_buffer_size;
#
create table t1 (pk int primary key, b int, c int default 0, index idx(b)) engine=innodb;
insert into t1(pk,b) values (3, 30), (2, 20), (9, 90), (7, 70), (4, 40), (5, 50), (10, 100), (12, 120);
-set @my_save_optimizer_use_mrr=@@optimizer_use_mrr;
-set optimizer_use_mrr='disable';
+set @bug665669_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=off';
explain select * from t1 where b > 1000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx idx 5 NULL 1 Using index condition
@@ -680,7 +680,7 @@ pk b c
3 30 0
4 40 0
drop table t1;
-set optimizer_use_mrr = @my_save_optimizer_use_mrr;
+set optimizer_switch = @bug665669_tmp;
#
# Bug#43360 - Server crash with a simple multi-table update
#
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index 935e3ee3b62..e3ef617503f 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -1314,7 +1314,7 @@ WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 Using where
1 PRIMARY t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-2 SUBQUERY t1 index NULL PRIMARY 4 NULL 2 Using index
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
f1 f2 f1 f2
diff --git a/mysql-test/r/join_cache.result b/mysql-test/r/join_cache.result
index 3bc8392e25a..bb28ed36f62 100644
--- a/mysql-test/r/join_cache.result
+++ b/mysql-test/r/join_cache.result
@@ -3032,7 +3032,7 @@ t6.formattypeid IN (2) AND (t3.formatid IN (31, 8, 76)) AND
t1.metaid = t2.metaid AND t1.affiliateid = '2';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 system PRIMARY NULL NULL NULL 1
-1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 1
+1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 1 Using index condition
1 SIMPLE t4 ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formats_idx 1 const 1 Using index condition; Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t5 eq_ref PRIMARY,t5_formattypeid PRIMARY 4 test.t4.formatclassid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result
index 9d60059ac28..3dc6a6338cb 100644
--- a/mysql-test/r/join_nested.result
+++ b/mysql-test/r/join_nested.result
@@ -854,7 +854,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on((((`test`.`t3`.`a` = 1) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`))) and (`test`.`t3`.`b` is not null))) where 1
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM (t3,t4)
LEFT JOIN
@@ -966,7 +966,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
CREATE INDEX idx_b ON t8(b);
EXPLAIN EXTENDED
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
@@ -1015,7 +1015,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
CREATE INDEX idx_b ON t1(b);
CREATE INDEX idx_a ON t0(a);
EXPLAIN EXTENDED
@@ -1065,7 +1065,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
FROM t0,t1
diff --git a/mysql-test/r/join_nested_jcl6.result b/mysql-test/r/join_nested_jcl6.result
index 3345540af96..26c0a9cadfe 100644
--- a/mysql-test/r/join_nested_jcl6.result
+++ b/mysql-test/r/join_nested_jcl6.result
@@ -239,7 +239,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
-Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and (`test`.`t8`.`b` = `test`.`t7`.`b`)) and (`test`.`t7`.`b` is not null))) where 1
+Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t8`.`b` = `test`.`t7`.`b`) and (`test`.`t7`.`b` is not null))) where 1
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM (t6, t7)
LEFT JOIN
@@ -560,7 +560,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) where ((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)))
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t0,t1
@@ -656,7 +656,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
SELECT t9.a,t9.b
FROM t9;
a b
@@ -847,7 +847,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2)
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2)
CREATE INDEX idx_b ON t2(b);
EXPLAIN EXTENDED
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
@@ -861,7 +861,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on((((`test`.`t3`.`a` = 1) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`))) and (`test`.`t3`.`b` is not null))) where 1
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM (t3,t4)
LEFT JOIN
@@ -923,7 +923,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
CREATE INDEX idx_b ON t4(b);
CREATE INDEX idx_b ON t5(b);
EXPLAIN EXTENDED
@@ -973,7 +973,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
CREATE INDEX idx_b ON t8(b);
EXPLAIN EXTENDED
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
@@ -1022,7 +1022,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
CREATE INDEX idx_b ON t1(b);
CREATE INDEX idx_a ON t0(a);
EXPLAIN EXTENDED
@@ -1072,7 +1072,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 ref idx_b idx_b 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on((((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))) and (`test`.`t7`.`b` is not null)))) on((((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t7`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b
FROM t0,t1
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 691bedbe428..c8e174f5a58 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -1302,7 +1302,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `f1`,NULL AS `f2`,'3' AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL)) where ((coalesce('1',NULL),'3') in ((1,3),(2,2)))
+Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where ((coalesce(1,NULL),3) in ((1,3),(2,2)))
SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
f1 f2 f3 f1 f2
diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result
index 7ca0b89df97..eb04e7170a7 100644
--- a/mysql-test/r/join_outer_jcl6.result
+++ b/mysql-test/r/join_outer_jcl6.result
@@ -1309,7 +1309,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `f1`,NULL AS `f2`,'3' AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(multiple equal(NULL)) where ((coalesce('1',NULL),'3') in ((1,3),(2,2)))
+Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where ((coalesce(1,NULL),3) in ((1,3),(2,2)))
SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
f1 f2 f3 f1 f2
diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result
index fcc09a0244d..46313411e7d 100644
--- a/mysql-test/r/key.result
+++ b/mysql-test/r/key.result
@@ -598,7 +598,7 @@ VALUES
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
SELECT 1 as RES FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result
index 40c278380b1..4826fc8fb4b 100644
--- a/mysql-test/r/loaddata.result
+++ b/mysql-test/r/loaddata.result
@@ -5,8 +5,8 @@ Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
-Warning 1265 Data truncated for column 'a' at row 2
-Warning 1265 Data truncated for column 'b' at row 2
+Warning 1264 Out of range value for column 'a' at row 2
+Warning 1264 Out of range value for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
SELECT * from t1;
@@ -20,7 +20,7 @@ load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
-Warning 1265 Data truncated for column 'b' at row 2
+Warning 1264 Out of range value for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
SELECT * from t1;
a b c d
@@ -532,4 +532,20 @@ a
0
1
DROP TABLE t1;
+#
+# Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
+#
+CREATE TABLE t1(f1 INT);
+SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
+LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
+DROP TABLE t1;
+#
+# Bug#11765141 - 58072: LOAD DATA INFILE: LEAKS IO CACHE MEMORY
+# WHEN ERROR OCCURS
+#
+SELECT '1\n' INTO DUMPFILE 'MYSQLTEST_VARDIR/tmp/bug11735141.txt';
+create table t1(a point);
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug11735141.txt' INTO TABLE t1;
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
+drop table t1;
End of 5.1 tests
diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result
index 7ec07fb5273..1828a5f11e0 100644
--- a/mysql-test/r/lock.result
+++ b/mysql-test/r/lock.result
@@ -194,3 +194,13 @@ ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
UNLOCK TABLES;
DROP TABLE t1,t2;
End of 5.1 tests.
+create table t1 (a int) engine=myisam;
+lock tables t1 write concurrent, t1 as t2 read;
+lock tables t1 read local;
+unlock tables;
+unlock tables;
+lock tables t1 read local;
+lock tables t1 write concurrent, t1 as t2 read;
+unlock tables;
+unlock tables;
+drop table t1;
diff --git a/mysql-test/r/lock_multi_bug38499.result b/mysql-test/r/lock_multi_bug38499.result
index 9b3f57c8e53..6922312b298 100644
--- a/mysql-test/r/lock_multi_bug38499.result
+++ b/mysql-test/r/lock_multi_bug38499.result
@@ -2,7 +2,9 @@ SET @odl_sync_frm = @@global.sync_frm;
SET @@global.sync_frm = OFF;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1( a INT, b INT );
+CREATE TABLE t2( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
# 1. test regular tables
# 1.1. test altering of columns that multiupdate doesn't use
# 1.1.1. normal mode
@@ -18,5 +20,5 @@ ALTER TABLE t1 ADD COLUMN a INT;
# 2.2. test altering of columns that multiupdate uses
# 2.2.1. normal mode
# 2.2.2. PS mode
-DROP TABLE t1;
+DROP TABLE t1,t2;
SET @@global.sync_frm = @odl_sync_frm;
diff --git a/mysql-test/r/lock_sync.result b/mysql-test/r/lock_sync.result
index 752f278a2b4..8b662cc8a82 100644
--- a/mysql-test/r/lock_sync.result
+++ b/mysql-test/r/lock_sync.result
@@ -629,3 +629,30 @@ drop procedure p1;
drop procedure p2;
drop table t1, t2, t3, t4, t5, te;
set @@global.concurrent_insert= @old_concurrent_insert;
+#
+# Bug#11763784 56541: ASSERTION TABLE->DB_STAT FAILED IN
+# SQL_BASE.CC::OPEN_TABLE() DURING I_S Q
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (1), (2);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
+# Connection con2
+SET DEBUG_SYNC= 'before_open_in_get_all_tables SIGNAL is_waits WAIT_FOR is_cont';
+# Sending:
+SELECT * FROM information_schema.table_constraints JOIN t1 ON table_name = a;
+# Connection con1
+SET DEBUG_SYNC= 'now WAIT_FOR is_waits';
+# Sending:
+DROP TRIGGER t1_bi;
+# Connection default
+# Wait until DROP TRIGGER is blocked, waiting for t1
+SET DEBUG_SYNC= 'now SIGNAL is_cont';
+# Connection con2
+# Reaping SELECT * FROM information_schema.table_constraints JOIN t1...
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE a
+# Connection con1
+# Reaping DROP TRIGGER t1_bi
+# Connection default
+DROP TABLE t1;
+SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/r/log_slow.result b/mysql-test/r/log_slow.result
index b6341109556..276dc5db3a7 100644
--- a/mysql-test/r/log_slow.result
+++ b/mysql-test/r/log_slow.result
@@ -45,10 +45,10 @@ select @@log_slow_verbosity;
innodb
show fields from mysql.slow_log;
Field Type Null Key Default Extra
-start_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
+start_time timestamp(6) NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
user_host mediumtext NO NULL
-query_time time NO NULL
-lock_time time NO NULL
+query_time time(6) NO NULL
+lock_time time(6) NO NULL
rows_sent int(11) NO NULL
rows_examined int(11) NO NULL
db varchar(512) NO NULL
diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result
index 654f9d127d3..6987ab94d74 100644
--- a/mysql-test/r/log_state.result
+++ b/mysql-test/r/log_state.result
@@ -55,7 +55,7 @@ sleep(@long_query_time + 1)
0
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
-TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(@long_query_time + 1)
+TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 select sleep(@long_query_time + 1)
# Switch to connection default
show global variables
where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result
index c6eaf9b6625..4b83ce31bd0 100644
--- a/mysql-test/r/log_tables.result
+++ b/mysql-test/r/log_tables.result
@@ -53,7 +53,7 @@ ERROR HY000: You can't use locks with log tables.
show create table mysql.general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
- `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
@@ -62,7 +62,7 @@ general_log CREATE TABLE `general_log` (
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
show fields from mysql.general_log;
Field Type Null Key Default Extra
-event_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
+event_time timestamp(6) NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
user_host mediumtext NO NULL
thread_id int(11) NO NULL
server_id int(10) unsigned NO NULL
@@ -71,10 +71,10 @@ argument mediumtext NO NULL
show create table mysql.slow_log;
Table Create Table
slow_log CREATE TABLE `slow_log` (
- `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
- `query_time` time NOT NULL,
- `lock_time` time NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
@@ -85,10 +85,10 @@ slow_log CREATE TABLE `slow_log` (
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show fields from mysql.slow_log;
Field Type Null Key Default Extra
-start_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
+start_time timestamp(6) NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
user_host mediumtext NO NULL
-query_time time NO NULL
-lock_time time NO NULL
+query_time time(6) NO NULL
+lock_time time(6) NO NULL
rows_sent int(11) NO NULL
rows_examined int(11) NO NULL
db varchar(512) NO NULL
@@ -147,7 +147,7 @@ sleep(2)
0
select * from mysql.slow_log;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
-TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 mysql 0 0 1 select sleep(2)
+TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 mysql 0 0 1 select sleep(2)
set @@session.long_query_time = @saved_long_query_time;
alter table mysql.general_log engine=myisam;
ERROR HY000: You cannot 'ALTER' a log table if logging is enabled
@@ -164,7 +164,7 @@ set global slow_query_log='OFF';
show create table mysql.general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
- `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
@@ -174,10 +174,10 @@ general_log CREATE TABLE `general_log` (
show create table mysql.slow_log;
Table Create Table
slow_log CREATE TABLE `slow_log` (
- `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
- `query_time` time NOT NULL,
- `lock_time` time NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
@@ -191,7 +191,7 @@ alter table mysql.slow_log engine=myisam;
show create table mysql.general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
- `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
@@ -201,10 +201,10 @@ general_log CREATE TABLE `general_log` (
show create table mysql.slow_log;
Table Create Table
slow_log CREATE TABLE `slow_log` (
- `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
- `query_time` time NOT NULL,
- `lock_time` time NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
@@ -264,7 +264,7 @@ drop table mysql.slow_log;
ERROR 42S02: Unknown table 'slow_log'
use mysql;
CREATE TABLE `general_log` (
-`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
+`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
@@ -273,11 +273,11 @@ ON UPDATE CURRENT_TIMESTAMP,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
CREATE TABLE `slow_log` (
-`start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
+`start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
-`query_time` time NOT NULL,
-`lock_time` time NOT NULL,
+`query_time` time(6) NOT NULL,
+`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
@@ -429,9 +429,9 @@ My own slow query sleep(2)
My own slow query 0
SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text seq
-START_TIME USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 2
-START_TIME USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 3
-START_TIME USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 4
+START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 2
+START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 3
+START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 4
SET GLOBAL slow_query_log = 0;
SET SESSION long_query_time =@saved_long_query_time;
FLUSH LOGS;
@@ -525,10 +525,10 @@ DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`;
DROP DATABASE IF EXISTS `db_17876`;
CREATE DATABASE db_17876;
CREATE TABLE `db_17876.slow_log_data` (
-`start_time` timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+`start_time` timestamp(6) default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`user_host` mediumtext ,
-`query_time` time ,
-`lock_time` time ,
+`query_time` time(6) ,
+`lock_time` time(6) ,
`rows_sent` int(11) ,
`rows_examined` int(11) ,
`db` varchar(512) default NULL,
@@ -538,7 +538,7 @@ CREATE TABLE `db_17876.slow_log_data` (
`sql_text` mediumtext
);
CREATE TABLE `db_17876.general_log_data` (
-`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext,
`thread_id` int(11) DEFAULT NULL,
`server_id` int(11) DEFAULT NULL,
@@ -547,7 +547,7 @@ CREATE TABLE `db_17876.general_log_data` (
);
CREATE procedure `db_17876.archiveSlowLog`()
BEGIN
-DECLARE start_time, query_time, lock_time CHAR(20);
+DECLARE start_time, query_time, lock_time CHAR(28);
DECLARE user_host MEDIUMTEXT;
DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT;
DECLARE dbname MEDIUMTEXT;
@@ -580,7 +580,7 @@ TRUNCATE mysql.slow_log;
END //
CREATE procedure `db_17876.archiveGeneralLog`()
BEGIN
-DECLARE event_time CHAR(20);
+DECLARE event_time CHAR(28);
DECLARE user_host, argument MEDIUMTEXT;
DECLARE thread_id, server_id INT;
DECLARE sql_text BLOB;
diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result
index c9a46b70fab..ee555a9006c 100644
--- a/mysql-test/r/lowercase_table2.result
+++ b/mysql-test/r/lowercase_table2.result
@@ -175,3 +175,33 @@ TABLE_SCHEMA TABLE_NAME
mysqltest_lc2 myUC
use test;
drop database mysqltest_LC2;
+#
+# Bug #11758687: 50924: object names not resolved correctly
+# on lctn2 systems
+#
+CREATE DATABASE BUP_XPFM_COMPAT_DB2;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.TABLE2 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.table1 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE bup_xpfm_compat_db2.table3 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.trigger1 AFTER INSERT
+ON BUP_XPFM_COMPAT_DB2.table1 FOR EACH ROW
+update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TRIGGER2 AFTER INSERT
+ON BUP_XPFM_COMPAT_DB2.TABLE2 FOR EACH ROW
+update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TrigGer3 AFTER INSERT
+ON BUP_XPFM_COMPAT_DB2.TaBle3 FOR EACH ROW
+update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+SELECT trigger_schema, trigger_name, event_object_table FROM
+INFORMATION_SCHEMA.TRIGGERS
+WHERE trigger_schema COLLATE utf8_bin = 'BUP_XPFM_COMPAT_DB2'
+ ORDER BY trigger_schema, trigger_name;
+trigger_schema trigger_name event_object_table
+BUP_XPFM_COMPAT_DB2 trigger1 table1
+BUP_XPFM_COMPAT_DB2 TRIGGER2 TABLE2
+BUP_XPFM_COMPAT_DB2 TrigGer3 table3
+DROP DATABASE BUP_XPFM_COMPAT_DB2;
+End of 5.1 tests
diff --git a/mysql-test/r/maria_mrr.result b/mysql-test/r/maria_mrr.result
index 58f20bc6abb..667f49177c3 100644
--- a/mysql-test/r/maria_mrr.result
+++ b/mysql-test/r/maria_mrr.result
@@ -370,7 +370,6 @@ DROP TABLE t1,t2,t3;
# BUG#671361: virtual int Mrr_ordered_index_reader::refill_buffer(): Assertion `!know_key_tuple_params
# (works only on Maria because we need 1024-byte long key)
#
-SET SESSION optimizer_use_mrr = 'force';
SET SESSION join_cache_level = 6;
SET SESSION join_buffer_size = 1024;
CREATE TABLE t1 (
diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result
index 2f9fb6b67f5..fdb020500ee 100644
--- a/mysql-test/r/metadata.result
+++ b/mysql-test/r/metadata.result
@@ -21,7 +21,7 @@ def test t1 t1 g g 5 4 0 Y 32768 3 63
def test t1 t1 h h 246 7 0 Y 0 4 63
def test t1 t1 i i 13 4 0 Y 32864 0 63
def test t1 t1 j j 10 10 0 Y 128 0 63
-def test t1 t1 k k 7 19 0 N 9441 0 63
+def test t1 t1 k k 7 19 0 N 9377 0 63
def test t1 t1 l l 12 19 0 Y 128 0 63
def test t1 t1 m m 254 1 0 Y 256 0 8
def test t1 t1 n n 254 3 0 Y 2048 0 8
@@ -205,8 +205,14 @@ CREATE TABLE t1 (f1 INT);
CREATE VIEW v1 AS SELECT f1 FROM t1;
SELECT f1 FROM v1 va;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test v1 va f1 f1 3 11 0 Y 32768 0 63
+def test va va f1 f1 3 11 0 Y 32768 0 63
f1
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests
+select cast('01:01:01' as time), cast('01:01:01' as time(2));
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def cast('01:01:01' as time) 11 10 8 Y 128 0 63
+def cast('01:01:01' as time(2)) 11 13 11 Y 128 2 63
+cast('01:01:01' as time) cast('01:01:01' as time(2))
+01:01:01 01:01:01.00
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index df3d7be6714..bdb59eed946 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -667,7 +667,12 @@ CREATE TABLE t1 (f1 DATE);
INSERT INTO t1 VALUES('2001-01-01');
UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
Warnings:
-Warning 1292 Truncated incorrect datetime value: '1'
+Warning 1292 Incorrect datetime value: '1'
+CREATE view v1 as SELECT f1() FROM t1;
+UPDATE (SELECT 1 FROM t1 WHERE f1 = (select * from v1)) x, t1 SET f1 = 1;
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+DROP VIEW v1;
DROP FUNCTION f1;
DROP TABLE t1;
end of tests
diff --git a/mysql-test/r/myisam_mrr.result b/mysql-test/r/myisam_mrr.result
index 2f1560ea981..38e1841dd41 100644
--- a/mysql-test/r/myisam_mrr.result
+++ b/mysql-test/r/myisam_mrr.result
@@ -347,10 +347,10 @@ WHERE t2.int_key IS NULL
GROUP BY t2.pk
);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-2 SUBQUERY t2 ref int_key int_key 5 1 100.00 Using index condition; Using where; Using filesort
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+2 SUBQUERY t2 ref int_key int_key 5 const 1 100.00 Using index condition; Using where; Using filesort
Warnings:
-Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where 0
+Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where exists(select `test`.`t2`.`pk` from `test`.`t2` where isnull(`test`.`t2`.`int_key`) group by `test`.`t2`.`pk`)
DROP TABLE t1, t2;
#
# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation
diff --git a/mysql-test/r/mysqladmin.result b/mysql-test/r/mysqladmin.result
index 57927f8aa67..748152bffcc 100644
--- a/mysql-test/r/mysqladmin.result
+++ b/mysql-test/r/mysqladmin.result
@@ -2,3 +2,11 @@ mysqld is alive
mysqladmin: unknown variable 'database=db1'
Warning: mysqladmin: unknown variable 'loose-database=db2'
mysqld is alive
+#
+# Bug#58221 : mysqladmin --sleep=x --count=x keeps looping
+#
+# Executing mysqladmin with --sleep=1 and --count=2.
+# Done.
+# Displaying the output :
+mysqld is alive
+mysqld is alive
diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result
index 7e228792b0d..21219e9ede4 100644
--- a/mysql-test/r/mysqlbinlog.result
+++ b/mysql-test/r/mysqlbinlog.result
@@ -657,3 +657,15 @@ master-bin.000002 # Query # # CREATE DATABASE test1
master-bin.000002 # Query # # use `test1`; CREATE TABLE t1(id int)
master-bin.000002 # Query # # use `test1`; DROP TABLE t1
master-bin.000002 # Query # # DROP DATABASE test1
+RESET MASTER;
+USE test;
+CREATE TABLE t1 (a INT);
+SET GLOBAL SERVER_ID = 2;
+DROP TABLE t1;
+FLUSH LOGS;
+SHOW TABLES IN test;
+Tables_in_test
+t1
+SHOW TABLES IN test;
+Tables_in_test
+SET GLOBAL SERVER_ID = 1;
diff --git a/mysql-test/r/mysqlbinlog_row_big.result b/mysql-test/r/mysqlbinlog_row_big.result
index 46fa0dc79cd..0bdbfdcee3a 100644
--- a/mysql-test/r/mysqlbinlog_row_big.result
+++ b/mysql-test/r/mysqlbinlog_row_big.result
@@ -36,8 +36,8 @@ c1 LONGTEXT
#
# Insert some big rows.
#
-256MB
-INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
+64MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 4194304));
affected rows: 1
32MB
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));
@@ -53,7 +53,7 @@ affected rows: 1
# Do not display the column value itself, just its length.
#
SELECT LENGTH(c1) FROM t1;
-LENGTH(c1) 268435456
+LENGTH(c1) 67108864
LENGTH(c1) 33554432
LENGTH(c1) 4194304
LENGTH(c1) 524288
@@ -69,7 +69,7 @@ info: Rows matched: 4 Changed: 4 Warnings: 0
# Do not display the column value itself, just its length.
#
SELECT LENGTH(c1) FROM t1;
-LENGTH(c1) 536870912
+LENGTH(c1) 134217728
LENGTH(c1) 1048576
LENGTH(c1) 67108864
LENGTH(c1) 8388608
diff --git a/mysql-test/r/mysqldump-max.result b/mysql-test/r/mysqldump-max.result
index cc5fe207800..6722f308358 100644
--- a/mysql-test/r/mysqldump-max.result
+++ b/mysql-test/r/mysqldump-max.result
@@ -334,10 +334,10 @@ DROP TABLE t1;
DROP TABLE t2;
SHOW BINLOG EVENTS LIMIT 6,3;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 658 Query 1 726 BEGIN
-master-bin.000001 726 Query 1 823 use `test`; INSERT INTO t2 VALUES (1,0), (2,0)
-master-bin.000001 823 Xid 1 850 COMMIT /* XID */
--- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=850;
+master-bin.000001 663 Query 1 731 BEGIN
+master-bin.000001 731 Query 1 828 use `test`; INSERT INTO t2 VALUES (1,0), (2,0)
+master-bin.000001 828 Xid 1 855 COMMIT /* XID */
+-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=855;
SELECT * FROM t1 ORDER BY a;
a
1
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 2b041aee05a..9723c40721c 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -15,7 +15,7 @@ INSERT INTO t1 VALUES (1), (2);
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
- <field Field="a" Type="int(11)" Null="YES" Key="MUL" Extra="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="MUL" Extra="" Comment="" />
<key Table="t1" Non_unique="1" Key_name="a" Seq_in_index="1" Column_name="a" Collation="A" Null="YES" Index_type="BTREE" Comment="" />
</table_structure>
<table_data name="t1">
@@ -151,9 +151,9 @@ INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
- <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
- <field Field="b" Type="text" Null="YES" Key="" Extra="" />
- <field Field="c" Type="varchar(3)" Null="YES" Key="" Extra="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="b" Type="text" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="c" Type="varchar(3)" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
@@ -179,7 +179,7 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
- <field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" />
+ <field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
@@ -1613,10 +1613,10 @@ CREATE TABLE `t2` (
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="mysqldump_test_db">
<table_structure name="t1">
- <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_structure name="t2">
- <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
</database>
</mysqldump>
@@ -1624,10 +1624,10 @@ CREATE TABLE `t2` (
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="mysqldump_test_db">
<table_structure name="t1">
- <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_structure name="t2">
- <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
</database>
</mysqldump>
@@ -3645,8 +3645,8 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
- <field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" />
- <field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" />
+ <field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
@@ -4577,5 +4577,57 @@ LENGTH(a)
800
DROP TABLE t1, t2;
#
+# Bug #13618 : mysqldump --xml ommit comment on table field
+#
+CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="test">
+ <table_structure name="comment_table">
+ <field Field="i" Type="int(11)" Null="YES" Key="" Extra="" Comment="FIELD COMMENT" />
+ </table_structure>
+ <table_data name="comment_table">
+ </table_data>
+</database>
+</mysqldump>
+DROP TABLE `comment_table`;
+#
+# BUG#11766310 : 59398: MYSQLDUMP 5.1 CAN'T HANDLE A DASH ("-") IN
+# DATABASE NAMES IN ALTER DATABASE
+#
+CREATE DATABASE `test-database`;
+USE `test-database`;
+CREATE TABLE `test` (`c1` VARCHAR(10)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END |
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `test` (
+ `c1` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = latin1 */ ;
+/*!50003 SET character_set_results = latin1 */ ;
+/*!50003 SET collation_connection = latin1_swedish_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = '' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+DROP DATABASE `test-database`;
+USE `test`;
+#
# End of 5.1 tests
#
diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result
index c113f18bd3f..4634b062012 100644
--- a/mysql-test/r/mysqlslap.result
+++ b/mysql-test/r/mysqlslap.result
@@ -219,3 +219,23 @@ DROP SCHEMA IF EXISTS `mysqlslap`;
DROP PROCEDURE IF EXISTS p1;
CREATE PROCEDURE p1() SELECT 1;
DROP PROCEDURE p1;
+#
+# Bug #11765157 - 58090: mysqlslap drops schema specified in
+# create_schema if auto-generate-sql also set.
+#
+# 'bug58090' database should not be present.
+SHOW DATABASES;
+Database
+information_schema
+mtr
+mysql
+test
+# 'bug58090' database should be present.
+SHOW DATABASES;
+Database
+information_schema
+bug58090
+mtr
+mysql
+test
+DROP DATABASE bug58090;
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 6de116b4d7a..c32553f077e 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -8,16 +8,19 @@ otto
select otto from (select 1 as otto) as t1;
otto
1
+select friedrich from (select 1 as otto) as t1;
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed: 1054: Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1;
otto
1
+select otto from (select 1 as otto) as t1;
mysqltest: At line 1: query 'select otto from (select 1 as otto) as t1' succeeded - should have failed with sqlstate 42S22...
mysqltest: At line 1: expecting a SQL-state (00000) from query 'remove_file MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp' which cannot produce one...
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
+select friedrich from (select 1 as otto) as t1;
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed with wrong sqlstate 42S22: 'Unknown column 'friedrich' in 'field list'', instead of 00000...
select otto from (select 1 as otto) as t1;
otto
@@ -135,6 +138,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_!errno_masked_error" ;
after_!errno_masked_error
1146
+select 3 from t1;
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1000...
garbage ;
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 'garbage' at line 1
@@ -143,6 +147,7 @@ after_--enable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
+select 3 from t1;
mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064...
hello
hello
@@ -312,12 +317,34 @@ failing query in let
create table t1 (a varchar(100));
insert into t1 values ('`select 42`');
`select 42`
+insert into t1 values ('$dollar');
+$dollar
+`select 42`
drop table t1;
mysqltest: At line 1: Error running query 'failing query': 1064 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 'failing query' at line 1
mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open './non_existingFile' for reading, errno: 2
-mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
-mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: 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 'garbage' at line 1
+mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql":
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from MYSQLTEST_VARDIR/tmp/recursive.sql at line 1:
+included from <stdin> at line 1:
+At line 1: Source directives are nesting too deep
+garbage ;
+mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql":
+included from <stdin> at line 1:
+At line 1: query 'garbage ' failed: 1064: 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 'garbage' at line 1
2 = outer loop variable after while
here is the sourced script
@@ -411,12 +438,15 @@ Beta is true
while with string, only once
1
Testing while with not
-mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest_while.inc": At line 64: Nesting too deeply
+mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest_while.inc":
+included from <stdin> at line 1:
+At line 64: Nesting too deeply
mysqltest: At line 1: missing '(' in while
mysqltest: At line 1: missing ')' in while
mysqltest: At line 1: Missing '{' after while. Found "dec $i"
mysqltest: At line 1: Stray '}' - end of block before beginning
mysqltest: At line 1: Stray 'end' command - end of block before beginning
+{;
mysqltest: At line 1: query '{' failed: 1064: 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
mysqltest: At line 1: Missing '{' after while. Found "echo hej"
mysqltest: At line 3: Missing end of block
@@ -460,8 +490,12 @@ mysqltest: At line 1: query 'connect con2,localhost,root,,illegal_db' failed: 1
mysqltest: At line 1: Illegal argument for port: 'illegal_port'
mysqltest: At line 1: Illegal option to connect: SMTP
200 connects succeeded
-mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
-mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
+mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql":
+included from <stdin> at line 1:
+At line 3: connection 'test_con1' not found in connection pool
+mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql":
+included from <stdin> at line 1:
+At line 2: Connection test_con1 already exists
show tables;
ERROR 3D000: No database selected
connect con1,localhost,root,,;
@@ -506,6 +540,10 @@ this will be executed
this will be executed
mysqltest: The test didn't produce any output
Failing multi statement query
+create table t1 (a int primary key);
+insert into t1 values (1);
+select 'select-me';
+insertz 'error query'||||
mysqltest: At line 3: query 'create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
@@ -576,8 +614,8 @@ Abcd
select * from t1;;
f1
Abcd
-mysqltest: At line 2: Cannot run query on connection between send and reap
select * from t1;;
+mysqltest: At line 2: Cannot run query on connection between send and reap
drop table t1;
mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file'
mysqltest: At line 1: Missing required argument 'directory' to command 'remove_files_wildcard'
diff --git a/mysql-test/r/not_embedded_server.result b/mysql-test/r/not_embedded_server.result
index 60c92bd0196..7219e29b2a6 100644
--- a/mysql-test/r/not_embedded_server.result
+++ b/mysql-test/r/not_embedded_server.result
@@ -4,3 +4,7 @@ select 1;
SHOW VARIABLES like 'slave_skip_errors';
Variable_name Value
slave_skip_errors OFF
+#
+# Bug#58026: massive recursion and crash in regular expression handling
+#
+SELECT '1' RLIKE RPAD('1', 10000, '(');
diff --git a/mysql-test/r/optimizer_switch.result b/mysql-test/r/optimizer_switch.result
index 0ae1d54fc7a..937b4dfeffa 100644
--- a/mysql-test/r/optimizer_switch.result
+++ b/mysql-test/r/optimizer_switch.result
@@ -4,19 +4,19 @@
#
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='index_merge=off,index_merge_union=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='index_merge_union=on';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,index_merge_sort_union=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch=4;
ERROR 42000: Variable 'optimizer_switch' can't be set to the value of '4'
set optimizer_switch=NULL;
@@ -43,60 +43,60 @@ set optimizer_switch=default;
set optimizer_switch='index_merge=off,index_merge_union=off,default';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch=default;
select @@global.optimizer_switch;
@@global.optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set @@global.optimizer_switch=default;
select @@global.optimizer_switch;
@@global.optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
#
# Check index_merge's @@optimizer_switch flags
#
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
BUG#37120 optimizer_switch allowable values not according to specification
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,materialization=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,semijoin=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,loosescan=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,semijoin=off,materialization=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,materialization=off,semijoin=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=off,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,semijoin=off,materialization=off,loosescan=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,semijoin=off,loosescan=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch='default,materialization=off,loosescan=off';
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=off,materialization=off,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
set optimizer_switch=default;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,firstmatch=on,loosescan=on,materialization=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 32e86469d6e..9a39cb4f16c 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -1,4 +1,5 @@
drop table if exists t1,t2,t3;
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
CREATE TABLE t1 (
id int(6) DEFAULT '0' NOT NULL,
idservice int(5),
@@ -1112,7 +1113,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index k2 k3 5 NULL 73 Using where
EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range k2 k2 5 NULL 386 Using index condition; Using where; Rowid-ordered scan; Using filesort
+1 SIMPLE t2 range k2 k2 5 NULL 386 Using index condition; Rowid-ordered scan; Using filesort
SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20;
id c3
6 14
@@ -1508,6 +1509,24 @@ WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
ORDER BY t2.c LIMIT 1;
d
52.5
+SELECT t1.*,t2.* FROM t1, t2
+WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
+ORDER BY t2.c LIMIT 5;
+a b a b c d
+ppfcz1 DE ppfcz1 14 6 52.5
+ppfcz1 DE ppfcz1 14 7 55.5
+ppfcz1 DE ppfcz1 14 8 57.5
+ppfcz1 DE ppfcz1 14 9 59.5
+ppfcz1 DE ppfcz1 14 10 61.5
+SELECT t1.*, t2.* FROM t3 AS t1, t2 AS t2
+WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
+ORDER BY t2.c LIMIT 5;
+a b a b c d
+ppfcz1 DE ppfcz1 14 6 52.5
+ppfcz1 DE ppfcz1 14 7 55.5
+ppfcz1 DE ppfcz1 14 8 57.5
+ppfcz1 DE ppfcz1 14 9 59.5
+ppfcz1 DE ppfcz1 14 10 61.5
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (
id1 INT NULL,
@@ -1654,7 +1673,7 @@ SELECT * FROM t1 r JOIN t1 s ON r.a = s.a
WHERE s.a IN (2,9) OR s.a < 100 AND s.a != 0
ORDER BY 1 LIMIT 10;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE r index PRIMARY PRIMARY 4 NULL 10 120.00 Using where; Using index
+1 SIMPLE r index PRIMARY PRIMARY 4 NULL 10 100.00 Using where; Using index
1 SIMPLE s eq_ref PRIMARY PRIMARY 4 test.r.a 1 100.00 Using index
Warnings:
Note 1003 select `test`.`r`.`a` AS `a`,`test`.`s`.`a` AS `a` from `test`.`t1` `r` join `test`.`t1` `s` where ((`test`.`s`.`a` = `test`.`r`.`a`) and ((`test`.`r`.`a` in (2,9)) or ((`test`.`r`.`a` < 100) and (`test`.`r`.`a` <> 0)))) order by 1 limit 10
@@ -1673,4 +1692,29 @@ a a
11 11
14 14
DROP TABLE t1;
+#
+# Bug #59110: Memory leak of QUICK_SELECT_I allocated memory
+# and
+# Bug #59308: Incorrect result for
+SELECT DISTINCT <col>... ORDER BY <col> DESC
+
+# Use Valgrind to detect #59110!
+#
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index a a 5 NULL 10 Using where; Using index; Using filesort
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+a 1
+10 1
+9 1
+8 1
+7 1
+6 1
+5 1
+4 1
+3 1
+2 1
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/packet.result b/mysql-test/r/packet.result
index ecbb47d4ee0..d673ab42691 100644
--- a/mysql-test/r/packet.result
+++ b/mysql-test/r/packet.result
@@ -3,6 +3,7 @@ set @net_buffer_length=@@global.net_buffer_length;
set global max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
set global net_buffer_length=100;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100'
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index 7e703de0876..1f5b359199d 100644
--- a/mysql-test/r/parser.result
+++ b/mysql-test/r/parser.result
@@ -556,9 +556,13 @@ DROP TABLE IF EXISTS t1;
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
NULL
+Warnings:
+Error 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE;
STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE
NULL
+Warnings:
+Error 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
"1997-12-31 23:59:59" + INTERVAL 1 SECOND
1998-01-01 00:00:00
diff --git a/mysql-test/r/parser_precedence.result b/mysql-test/r/parser_precedence.result
index cf301ec677b..979084d0346 100644
--- a/mysql-test/r/parser_precedence.result
+++ b/mysql-test/r/parser_precedence.result
@@ -1,4 +1,5 @@
drop table if exists t1_30237_bool;
+set sql_mode=NO_UNSIGNED_SUBTRACTION;
create table t1_30237_bool(A boolean, B boolean, C boolean);
insert into t1_30237_bool values
(FALSE, FALSE, FALSE),
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 27ada9d1129..0ac7c8e8770 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -1,5 +1,43 @@
drop table if exists t1, t2;
#
+# Bug#59297: Can't find record in 'tablename' on update inner join
+#
+CREATE TABLE t1 (
+a char(2) NOT NULL,
+b char(2) NOT NULL,
+c int(10) unsigned NOT NULL,
+d varchar(255) DEFAULT NULL,
+e varchar(1000) DEFAULT NULL,
+PRIMARY KEY (a, b, c),
+KEY (a),
+KEY (a, b)
+)
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 20 */;
+INSERT INTO t1 (a, b, c, d, e) VALUES
+('07', '03', 343, '1', '07_03_343'),
+('01', '04', 343, '2', '01_04_343'),
+('01', '06', 343, '3', '01_06_343'),
+('01', '07', 343, '4', '01_07_343'),
+('01', '08', 343, '5', '01_08_343'),
+('01', '09', 343, '6', '01_09_343'),
+('03', '03', 343, '7', '03_03_343'),
+('03', '06', 343, '8', '03_06_343'),
+('03', '07', 343, '9', '03_07_343'),
+('04', '03', 343, '10', '04_03_343'),
+('04', '06', 343, '11', '04_06_343'),
+('05', '03', 343, '12', '05_03_343'),
+('11', '03', 343, '13', '11_03_343'),
+('11', '04', 343, '14', '11_04_343')
+;
+UPDATE t1 AS A,
+(SELECT '03' AS a, '06' AS b, 343 AS c, 'last' AS d) AS B
+SET A.e = B.d
+WHERE A.a = '03'
+AND A.b = '06'
+AND A.c = 343;
+DROP TABLE t1;
+#
# Bug#57113: ha_partition::extra(ha_extra_function):
# Assertion `m_extra_cache' failed
CREATE TABLE t1
@@ -2140,3 +2178,21 @@ INSERT INTO t1 VALUES(0);
DROP TABLE t1;
SET GLOBAL myisam_use_mmap=default;
End of 5.1 tests
+#
+# BUG#598247: partition.test produces valgrind errors in 5.3-based branches
+#
+CREATE TABLE t1 (
+a INT DEFAULT NULL,
+b DOUBLE DEFAULT NULL,
+c INT DEFAULT NULL,
+KEY idx2(b,a)
+) engine=myisam PARTITION BY HASH(c) PARTITIONS 3;
+INSERT INTO t1 VALUES (6,8,9);
+INSERT INTO t1 VALUES (6,8,10);
+SELECT 1 FROM t1 JOIN t1 AS t2 USING (a);
+1
+1
+1
+1
+1
+drop table t1;
diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result
index 0426ce42071..0791b979da1 100644
--- a/mysql-test/r/partition_error.result
+++ b/mysql-test/r/partition_error.result
@@ -1,5 +1,18 @@
drop table if exists t1;
#
+# Bug#57924: crash when creating partitioned table with
+# multiple columns in the partition key
+#
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, a);
+ERROR HY000: Field in list of fields for partition function not found in table
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(A, b);
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, A);
+ERROR HY000: Field in list of fields for partition function not found in table
+#
# Bug#54483: valgrind errors when making warnings for multiline inserts
# into partition
#
@@ -38,14 +51,14 @@ PARTITION BY RANGE (DAYOFWEEK(a))
(PARTITION a1 VALUES LESS THAN (60));
INSERT INTO t1 VALUES ('test'),('a'),('5');
Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
-Warning 1264 Out of range value for column 'a' at row 2
-Warning 1264 Out of range value for column 'a' at row 3
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'a' at row 2
+Warning 1265 Data truncated for column 'a' at row 3
SHOW WARNINGS;
Level Code Message
-Warning 1264 Out of range value for column 'a' at row 1
-Warning 1264 Out of range value for column 'a' at row 2
-Warning 1264 Out of range value for column 'a' at row 3
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'a' at row 2
+Warning 1265 Data truncated for column 'a' at row 3
DROP TABLE t1;
CREATE TABLE t1 (a TIME)
PARTITION BY RANGE (DAYOFWEEK(a))
diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result
index 98be0326ef0..f31d1bd530b 100644
--- a/mysql-test/r/plugin.result
+++ b/mysql-test/r/plugin.result
@@ -75,9 +75,9 @@ SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
#illegal value fixed
CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
Warnings:
-Warning 1653 Incorrect value '10000000000000000000' for option 'ULL'
-Warning 1653 Incorrect value 'ttt' for option 'one_or_two'
-Warning 1653 Incorrect value 'SSS' for option 'YESNO'
+Warning 1912 Incorrect value '10000000000000000000' for option 'ULL'
+Warning 1912 Incorrect value 'ttt' for option 'one_or_two'
+Warning 1912 Incorrect value 'SSS' for option 'YESNO'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index e13790f8eaf..5197aea9e87 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -156,7 +156,6 @@ prepare stmt1 from @stmt ;
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@@ -164,7 +163,6 @@ id select_type table type possible_keys key key_len ref rows Extra
execute stmt1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@@ -172,7 +170,6 @@ id select_type table type possible_keys key key_len ref rows Extra
explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t1.c2 - 0e-3) = t2.c2 GROUP BY t1.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t1.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t1, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@@ -3043,3 +3040,18 @@ id select_type table type possible_keys key key_len ref rows Extra
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.1 tests.
+prepare stmt from "select date('2010-10-10') between '2010-09-09' and ?";
+set @a='2010-11-11';
+execute stmt using @a;
+date('2010-10-10') between '2010-09-09' and ?
+1
+execute stmt using @a;
+date('2010-10-10') between '2010-09-09' and ?
+1
+set @a='2010-08-08';
+execute stmt using @a;
+date('2010-10-10') between '2010-09-09' and ?
+0
+execute stmt using @a;
+date('2010-10-10') between '2010-09-09' and ?
+0
diff --git a/mysql-test/r/ps_11bugs.result b/mysql-test/r/ps_11bugs.result
index 5c11163ab9e..f9f0525646d 100644
--- a/mysql-test/r/ps_11bugs.result
+++ b/mysql-test/r/ps_11bugs.result
@@ -120,9 +120,9 @@ create table t1 (a int primary key);
insert into t1 values (1);
explain select * from t1 where 3 in (select (1+1) union select 1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
-3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
select * from t1 where 3 in (select (1+1) union select 1);
a
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index 751a545d988..e99c5b9942b 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -63,8 +63,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
-def test t9 t9 c15 c15 7 19 19 N 9441 0 63
-def test t9 t9 c16 c16 11 8 8 Y 128 0 63
+def test t9 t9 c15 c15 7 19 19 N 9377 0 63
+def test t9 t9 c16 c16 11 10 8 Y 128 0 63
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
@@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL DEFAULT '0',
- `param10` bigint(20) DEFAULT NULL,
+ `const10` decimal(22,6) NOT NULL DEFAULT '0.000000',
+ `param10` decimal(65,30) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
-def test t5 t5 const10 const10 3 10 9 N 32769 0 63
-def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
+def test t5 t5 const10 const10 246 24 16 N 1 6 63
+def test t5 t5 param10 param10 246 67 40 Y 0 30 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861
-param10 662680861
+const10 662680861.000000
+param10 662680861.000000000000000000000000000000
const11 1991
param11 1991
const12 NULL
@@ -2762,46 +2762,212 @@ c12 -9999.9999
execute my_delete ;
test_sequence
-- insert into string columns --
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '21' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '23';
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary) ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '31' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary) )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= CAST('33' as binary);
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 41 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 43;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 51.0 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 53.0;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
+5.4e+1, 5.4e+1, 5.4e+1 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.5e+1 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
+ 5.6e+1, 5.6e+1, 5.6e+1 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.7e+1;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 2 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
order by c1 ;
@@ -2960,70 +3126,208 @@ true
delete from t9 ;
test_sequence
-- insert into date/time columns --
+set @arg00= '1991-01-01 01:01:01' ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+ '1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 23, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 30, CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime)) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 32, CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime))" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 33, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= 2000000000 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
+execute stmt1 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 43, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 1.0e+10 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 53, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 60, NULL, NULL, '1991-01-01 01:01:01',
+NULL, NULL) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 62, NULL, NULL, '1991-01-01 01:01:01',
+ NULL, NULL)" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8.0 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
c1 c13 c14 c15 c16 c17
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
@@ -3034,14 +3338,14 @@ c1 c13 c14 c15 c16 c17
31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
-40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
61 NULL NULL 1991-01-01 01:01:01 NULL NULL
62 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -3055,25 +3359,25 @@ test_sequence
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
-c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
@@ -3081,12 +3385,11 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
-c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
@@ -3094,14 +3397,43 @@ prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+found
+true
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+found
+true
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
found
true
set @arg00= 1991 ;
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 9ba5e607b5d..6b7434390af 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -63,8 +63,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
-def test t9 t9 c15 c15 7 19 19 N 9441 0 63
-def test t9 t9 c16 c16 11 8 8 Y 128 0 63
+def test t9 t9 c15 c15 7 19 19 N 9377 0 63
+def test t9 t9 c16 c16 11 10 8 Y 128 0 63
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
@@ -1776,8 +1776,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL DEFAULT '0',
- `param10` bigint(20) DEFAULT NULL,
+ `const10` decimal(22,6) NOT NULL DEFAULT '0.000000',
+ `param10` decimal(65,30) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1806,8 +1806,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
-def test t5 t5 const10 const10 3 10 9 N 32769 0 63
-def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
+def test t5 t5 const10 const10 246 24 16 N 1 6 63
+def test t5 t5 param10 param10 246 67 40 Y 0 30 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1833,8 +1833,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861
-param10 662680861
+const10 662680861.000000
+param10 662680861.000000000000000000000000000000
const11 1991
param11 1991
const12 NULL
@@ -2745,46 +2745,212 @@ c12 -9999.9999
execute my_delete ;
test_sequence
-- insert into string columns --
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '21' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '23';
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary) ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '31' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary) )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= CAST('33' as binary);
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 41 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 43;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 51.0 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 53.0;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
+5.4e+1, 5.4e+1, 5.4e+1 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.5e+1 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
+ 5.6e+1, 5.6e+1, 5.6e+1 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.7e+1;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 2 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
order by c1 ;
@@ -2943,70 +3109,208 @@ true
delete from t9 ;
test_sequence
-- insert into date/time columns --
+set @arg00= '1991-01-01 01:01:01' ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+ '1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 23, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 30, CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime)) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 32, CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime))" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 33, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= 2000000000 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
+execute stmt1 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 43, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 1.0e+10 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 53, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 60, NULL, NULL, '1991-01-01 01:01:01',
+NULL, NULL) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 62, NULL, NULL, '1991-01-01 01:01:01',
+ NULL, NULL)" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8.0 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
c1 c13 c14 c15 c16 c17
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
@@ -3017,14 +3321,14 @@ c1 c13 c14 c15 c16 c17
31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
-40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
61 NULL NULL 1991-01-01 01:01:01 NULL NULL
62 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -3038,25 +3342,25 @@ test_sequence
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
-c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
@@ -3064,12 +3368,11 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
-c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
@@ -3077,14 +3380,43 @@ prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+found
+true
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+found
+true
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
found
true
set @arg00= 1991 ;
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index e7252473c49..58acc19124a 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -64,8 +64,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
-def test t9 t9 c15 c15 7 19 19 N 9441 0 63
-def test t9 t9 c16 c16 11 8 8 Y 128 0 63
+def test t9 t9 c15 c15 7 19 19 N 9377 0 63
+def test t9 t9 c16 c16 11 10 8 Y 128 0 63
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
@@ -1777,8 +1777,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL DEFAULT '0',
- `param10` bigint(20) DEFAULT NULL,
+ `const10` decimal(22,6) NOT NULL DEFAULT '0.000000',
+ `param10` decimal(65,30) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1807,8 +1807,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
-def test t5 t5 const10 const10 3 10 9 N 32769 0 63
-def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
+def test t5 t5 const10 const10 246 24 16 N 1 6 63
+def test t5 t5 param10 param10 246 67 40 Y 0 30 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1834,8 +1834,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861
-param10 662680861
+const10 662680861.000000
+param10 662680861.000000000000000000000000000000
const11 1991
param11 1991
const12 NULL
@@ -2746,46 +2746,212 @@ c12 -9999.9999
execute my_delete ;
test_sequence
-- insert into string columns --
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '21' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '23';
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary) ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '31' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary) )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= CAST('33' as binary);
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 41 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 43;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 51.0 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 53.0;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
+5.4e+1, 5.4e+1, 5.4e+1 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.5e+1 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
+ 5.6e+1, 5.6e+1, 5.6e+1 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.7e+1;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 2 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
order by c1 ;
@@ -2944,70 +3110,208 @@ true
delete from t9 ;
test_sequence
-- insert into date/time columns --
+set @arg00= '1991-01-01 01:01:01' ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+ '1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 23, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 30, CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime)) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 32, CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime))" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 33, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= 2000000000 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
+execute stmt1 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 43, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 1.0e+10 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 53, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 60, NULL, NULL, '1991-01-01 01:01:01',
+NULL, NULL) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 62, NULL, NULL, '1991-01-01 01:01:01',
+ NULL, NULL)" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8.0 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
c1 c13 c14 c15 c16 c17
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
@@ -3018,14 +3322,14 @@ c1 c13 c14 c15 c16 c17
31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
-40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
61 NULL NULL 1991-01-01 01:01:01 NULL NULL
62 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -3039,25 +3343,25 @@ test_sequence
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
-c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
@@ -3065,12 +3369,11 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
-c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
@@ -3078,14 +3381,43 @@ prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+found
+true
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+found
+true
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
found
true
set @arg00= 1991 ;
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 7530b3ebe0b..654e641deeb 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -106,8 +106,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
-def test t9 t9 c15 c15 7 19 19 N 9441 0 63
-def test t9 t9 c16 c16 11 8 8 Y 128 0 63
+def test t9 t9 c15 c15 7 19 19 N 9377 0 63
+def test t9 t9 c16 c16 11 10 8 Y 128 0 63
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
@@ -1713,8 +1713,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL DEFAULT '0',
- `param10` bigint(20) DEFAULT NULL,
+ `const10` decimal(22,6) NOT NULL DEFAULT '0.000000',
+ `param10` decimal(65,30) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1743,8 +1743,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
-def test t5 t5 const10 const10 3 10 9 N 32769 0 63
-def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
+def test t5 t5 const10 const10 246 24 16 N 1 6 63
+def test t5 t5 param10 param10 246 67 40 Y 0 30 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1770,8 +1770,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861
-param10 662680861
+const10 662680861.000000
+param10 662680861.000000000000000000000000000000
const11 1991
param11 1991
const12 NULL
@@ -2682,46 +2682,212 @@ c12 -9999.9999
execute my_delete ;
test_sequence
-- insert into string columns --
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '21' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '23';
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary) ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '31' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary) )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= CAST('33' as binary);
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 41 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 43;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 51.0 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 53.0;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
+5.4e+1, 5.4e+1, 5.4e+1 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.5e+1 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
+ 5.6e+1, 5.6e+1, 5.6e+1 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.7e+1;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 2 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
order by c1 ;
@@ -2880,70 +3046,208 @@ true
delete from t9 ;
test_sequence
-- insert into date/time columns --
+set @arg00= '1991-01-01 01:01:01' ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+ '1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 23, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 30, CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime)) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 32, CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime))" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 33, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= 2000000000 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
+execute stmt1 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 43, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 1.0e+10 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 53, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 60, NULL, NULL, '1991-01-01 01:01:01',
+NULL, NULL) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 62, NULL, NULL, '1991-01-01 01:01:01',
+ NULL, NULL)" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8.0 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
c1 c13 c14 c15 c16 c17
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
@@ -2954,14 +3258,14 @@ c1 c13 c14 c15 c16 c17
31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
-40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
61 NULL NULL 1991-01-01 01:01:01 NULL NULL
62 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -2975,25 +3279,25 @@ test_sequence
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
-c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
@@ -3001,12 +3305,11 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
-c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
@@ -3014,14 +3317,43 @@ prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+found
+true
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+found
+true
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
found
true
set @arg00= 1991 ;
@@ -3128,8 +3460,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
-def test t9 t9 c15 c15 7 19 19 N 9441 0 63
-def test t9 t9 c16 c16 11 8 8 Y 128 0 63
+def test t9 t9 c15 c15 7 19 19 N 9377 0 63
+def test t9 t9 c16 c16 11 10 8 Y 128 0 63
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
@@ -4735,8 +5067,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL DEFAULT '0',
- `param10` bigint(20) DEFAULT NULL,
+ `const10` decimal(22,6) NOT NULL DEFAULT '0.000000',
+ `param10` decimal(65,30) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -4765,8 +5097,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
-def test t5 t5 const10 const10 3 10 9 N 32769 0 63
-def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
+def test t5 t5 const10 const10 246 24 16 N 1 6 63
+def test t5 t5 param10 param10 246 67 40 Y 0 30 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -4792,8 +5124,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861
-param10 662680861
+const10 662680861.000000
+param10 662680861.000000000000000000000000000000
const11 1991
param11 1991
const12 NULL
@@ -5704,46 +6036,212 @@ c12 -9999.9999
execute my_delete ;
test_sequence
-- insert into string columns --
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '21' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '23';
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary) ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '31' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary) )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= CAST('33' as binary);
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 41 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 43;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 51.0 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 53.0;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
+5.4e+1, 5.4e+1, 5.4e+1 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.5e+1 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
+ 5.6e+1, 5.6e+1, 5.6e+1 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.7e+1;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 2 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
order by c1 ;
@@ -5902,70 +6400,208 @@ true
delete from t9 ;
test_sequence
-- insert into date/time columns --
+set @arg00= '1991-01-01 01:01:01' ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+ '1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 23, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 30, CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime)) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 32, CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime))" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 33, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= 2000000000 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
+execute stmt1 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 43, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 1.0e+10 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 53, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 60, NULL, NULL, '1991-01-01 01:01:01',
+NULL, NULL) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 62, NULL, NULL, '1991-01-01 01:01:01',
+ NULL, NULL)" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8.0 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
c1 c13 c14 c15 c16 c17
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
@@ -5976,14 +6612,14 @@ c1 c13 c14 c15 c16 c17
31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
-40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
61 NULL NULL 1991-01-01 01:01:01 NULL NULL
62 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -5997,25 +6633,25 @@ test_sequence
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
-c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
@@ -6023,12 +6659,11 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
-c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
@@ -6036,14 +6671,43 @@ prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+found
+true
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+found
+true
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
found
true
set @arg00= 1991 ;
diff --git a/mysql-test/r/ps_ddl.result b/mysql-test/r/ps_ddl.result
index a5e71e114ca..7431ac6899e 100644
--- a/mysql-test/r/ps_ddl.result
+++ b/mysql-test/r/ps_ddl.result
@@ -1508,12 +1508,12 @@ create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B;
execute stmt;
a b a b
1 1 1 1
-2 2 1 1
-1 1 1 1
-2 2 1 1
1 1 2 2
+2 2 1 1
2 2 2 2
+1 1 1 1
1 1 2 2
+2 2 1 1
2 2 2 2
call p_verify_reprepare_count(1);
SUCCESS
@@ -1521,12 +1521,12 @@ SUCCESS
execute stmt;
a b a b
1 1 1 1
-2 2 1 1
-1 1 1 1
-2 2 1 1
1 1 2 2
+2 2 1 1
2 2 2 2
+1 1 1 1
1 1 2 2
+2 2 1 1
2 2 2 2
call p_verify_reprepare_count(0);
SUCCESS
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 2380ecc5969..f934c5cd732 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -991,20 +991,17 @@ SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
0
Warnings:
-Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
-Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 0
+Warning 1292 Incorrect datetime value: '20050327 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid';
COUNT(*)
0
Warnings:
-Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
-Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 0
+Warning 1292 Incorrect datetime value: '20050328 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
0
Warnings:
-Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
-Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 0
+Warning 1292 Incorrect datetime value: '20050327 invalid'
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
@@ -1639,6 +1636,7 @@ set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size=default;
+set local query_cache_type=default;
FLUSH STATUS;
SET GLOBAL query_cache_size=10*1024*1024;
SET @save_concurrent_insert= @@concurrent_insert;
@@ -1823,3 +1821,33 @@ SELECT 1 FROM t1 GROUP BY
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
End of 5.1 tests
+New query cache switching OFF mechanism test
+set global query_cache_size=1024*1024*20;
+set global query_cache_type=on;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+@@query_cache_size @@global.query_cache_type @@local.query_cache_type
+20971520 ON ON
+set global query_cache_size=0;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+@@query_cache_size @@global.query_cache_type @@local.query_cache_type
+0 ON ON
+set global query_cache_size=1024*1024*20;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+@@query_cache_size @@global.query_cache_type @@local.query_cache_type
+20971520 ON ON
+set global query_cache_type=off;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+@@query_cache_size @@global.query_cache_type @@local.query_cache_type
+20971520 OFF OFF
+set global query_cache_type=on;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+@@query_cache_size @@global.query_cache_type @@local.query_cache_type
+20971520 ON OFF
+set local query_cache_type= on;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+@@query_cache_size @@global.query_cache_type @@local.query_cache_type
+20971520 ON ON
+restore defaults
+SET GLOBAL query_cache_type= default;
+SET GLOBAL query_cache_size= default;
+SET LOCAL query_cache_type= default;
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 347960d98ad..8f9e8dd48c3 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -1104,16 +1104,10 @@ INSERT INTO t1 VALUES
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using index condition
-Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
-A1 2005-11-01 08:00:00 1000.000
-A1 2005-11-15 00:00:00 2000.000
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -1122,14 +1116,10 @@ DROP INDEX `PRIMARY` ON t1;
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
-Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
-A1 2005-11-01 08:00:00 1000.000
-A1 2005-11-15 00:00:00 2000.000
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -1579,21 +1569,20 @@ str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND
str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'
1
Warnings:
-Warning 1292 Truncated incorrect date value: ''
+Warning 1292 Incorrect datetime value: ''
SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
str_to_date('2007-20-00', '%Y-%m-%d') <= '';
str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
str_to_date('2007-20-00', '%Y-%m-%d') <= ''
NULL
Warnings:
-Warning 1292 Truncated incorrect date value: ''
Error 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Error 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '';
str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''
NULL
@@ -1666,4 +1655,111 @@ c_key c_notkey
1 1
3 3
DROP TABLE t1;
+#
+# Bug #57030: 'BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
+CREATE UNIQUE INDEX i4_uq ON t1(i4);
+INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const i4_uq i4_uq 5 const 1
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
+pk i4
+1 10
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const i4_uq i4_uq 5 const 1
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
+pk i4
+1 10
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range i4_uq i4_uq 5 NULL 3 Using index condition; Rowid-ordered scan
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
+pk i4
+1 10
+2 20
+3 30
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range i4_uq i4_uq 5 NULL 1 Using index condition; Rowid-ordered scan
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
+pk i4
+1 10
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
+pk i4
+1 10
+2 20
+3 30
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
+pk i4
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0;
+pk i4
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
+pk i4
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range i4_uq i4_uq 5 NULL 2 Using index condition; Rowid-ordered scan
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
+pk i4
+1 10
+2 20
+3 30
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
+pk i4
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range i4_uq i4_uq 5 NULL 1 Using index condition; Rowid-ordered scan
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
+pk i4
+1 10
+2 20
+EXPLAIN
+SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL i4_uq NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 Using index condition
+SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
+pk i4 pk i4
+EXPLAIN
+SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL i4_uq NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 Using index condition
+SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
+pk i4 pk i4
+DROP TABLE t1;
End of 5.1 tests
+create table t1 (f1 datetime, key (f1));
+insert into t1 values ('2000-03-09 15:56:59'),('2000-05-05 23:24:28'),('2000-06-13 13:12:06');
+select min(f1) from t1 where f1 >= '2006-05-25 07:00:20' and f1 between '2003-11-23 10:00:09' and '2010-01-01 01:01:01' and f1 > '2001-01-01 01:01:01';
+min(f1)
+NULL
+drop table t1;
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index f9d6c80018b..9a4d521293a 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2115,8 +2115,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -3265,7 +3265,7 @@ f1 f2
4 2005-10-01
5 2005-12-30
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
select * from t1 where f2 <= '2005-09-31' order by f2;
f1 f2
1 2005-01-01
@@ -3276,7 +3276,7 @@ f1 f2
1 2005-01-01
2 2005-09-01
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (1, 30), (2, 20), (3, 10);
@@ -3753,15 +3753,11 @@ AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t1 range ts ts 4 NULL 1 Using index condition; Using where; Rowid-ordered scan
-Warnings:
-Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
AND t1.ts BETWEEN t2.dt1 AND t2.dt2
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
a ts a dt1 dt2
30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00
-Warnings:
-Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
DROP TABLE t1,t2;
create table t1 (a bigint unsigned);
insert into t1 values
@@ -4098,17 +4094,22 @@ select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT-6'
+select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6';
+str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6'
+1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT-6'
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
-1
+0
Warnings:
-Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6'
+Warning 1292 Incorrect datetime value: '2007/10/2000:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007-10-1 00:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'
1
@@ -4128,7 +4129,7 @@ select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT
str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6'
+Warning 1292 Truncated incorrect date value: '2007-10-01 x12:34:56 GMT-6'
select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'
1
@@ -4167,33 +4168,24 @@ str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
set SQL_MODE=TRADITIONAL;
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
+1
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00'
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20'
-0
-Warnings:
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+1
set SQL_MODE=DEFAULT;
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
0
@@ -4207,31 +4199,40 @@ select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
0
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Truncated incorrect date value: '1'
+Warning 1292 Incorrect datetime value: '1'
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Truncated incorrect date value: '1'
+Warning 1292 Incorrect datetime value: '1'
select str_to_date('','%Y-%m-%d') = '';
str_to_date('','%Y-%m-%d') = ''
-0
+1
Warnings:
-Warning 1292 Truncated incorrect date value: ''
-select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
-str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL
-0
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
-str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'
+Warning 1292 Incorrect datetime value: ''
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01'
+1
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL
+NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01'
+NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL
0
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
-str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01'
0
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL
+NULL
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
c22 INT DEFAULT NULL,
@@ -4606,8 +4607,8 @@ a
4
5
DROP TABLE t1;
-CREATE TABLE A (date_key date);
-CREATE TABLE C (
+CREATE TABLE t1 (date_key date);
+CREATE TABLE t2 (
pk int,
int_nokey int,
int_key int,
@@ -4615,29 +4616,27 @@ date_key date NOT NULL,
date_nokey date,
varchar_key varchar(1)
);
-INSERT INTO C VALUES
+INSERT INTO t2 VALUES
(1,1,1,'0000-00-00',NULL,NULL),
(1,1,1,'0000-00-00',NULL,NULL);
-SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);
+SELECT 1 FROM t2 WHERE pk > ANY (SELECT 1 FROM t2);
1
-SELECT COUNT(DISTINCT 1) FROM C
-WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;
+SELECT COUNT(DISTINCT 1) FROM t2
+WHERE date_key = (SELECT 1 FROM t1 WHERE t2.date_key IS NULL) GROUP BY pk;
COUNT(DISTINCT 1)
-SELECT date_nokey FROM C
-WHERE int_key IN (SELECT 1 FROM A)
+SELECT date_nokey FROM t2
+WHERE int_key IN (SELECT 1 FROM t1)
HAVING date_nokey = '10:41:7'
ORDER BY date_key;
date_nokey
-Warnings:
-Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
-DROP TABLE A,C;
+DROP TABLE t1,t2;
CREATE TABLE t1 (a INT NOT NULL, b INT);
INSERT INTO t1 VALUES (1, 1);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1
+Note 1003 select 1 AS `a`,1 AS `b` from `test`.`t1` where 1
SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
a b
1 1
diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result
index ca7241d8f87..0f591570a99 100644
--- a/mysql-test/r/select_jcl6.result
+++ b/mysql-test/r/select_jcl6.result
@@ -2122,8 +2122,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -3272,7 +3272,7 @@ f1 f2
4 2005-10-01
5 2005-12-30
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
select * from t1 where f2 <= '2005-09-31' order by f2;
f1 f2
1 2005-01-01
@@ -3283,7 +3283,7 @@ f1 f2
1 2005-01-01
2 2005-09-01
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (1, 30), (2, 20), (3, 10);
@@ -3760,15 +3760,11 @@ AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t1 range ts ts 4 NULL 1 Using index condition; Using where; Rowid-ordered scan
-Warnings:
-Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
AND t1.ts BETWEEN t2.dt1 AND t2.dt2
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
a ts a dt1 dt2
30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00
-Warnings:
-Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
DROP TABLE t1,t2;
create table t1 (a bigint unsigned);
insert into t1 values
@@ -4105,17 +4101,22 @@ select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT-6'
+select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6';
+str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6'
+1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT-6'
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
-1
+0
Warnings:
-Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6'
+Warning 1292 Incorrect datetime value: '2007/10/2000:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007-10-1 00:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'
1
@@ -4135,7 +4136,7 @@ select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT
str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6'
+Warning 1292 Truncated incorrect date value: '2007-10-01 x12:34:56 GMT-6'
select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'
1
@@ -4174,33 +4175,24 @@ str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
set SQL_MODE=TRADITIONAL;
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
+1
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00'
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20'
-0
-Warnings:
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+1
set SQL_MODE=DEFAULT;
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
0
@@ -4214,31 +4206,40 @@ select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
0
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Truncated incorrect date value: '1'
+Warning 1292 Incorrect datetime value: '1'
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Truncated incorrect date value: '1'
+Warning 1292 Incorrect datetime value: '1'
select str_to_date('','%Y-%m-%d') = '';
str_to_date('','%Y-%m-%d') = ''
-0
+1
Warnings:
-Warning 1292 Truncated incorrect date value: ''
-select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
-str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL
-0
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
-str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'
+Warning 1292 Incorrect datetime value: ''
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01'
+1
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL
+NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01'
+NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL
0
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
-str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01'
0
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL
+NULL
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
c22 INT DEFAULT NULL,
@@ -4613,8 +4614,8 @@ a
4
5
DROP TABLE t1;
-CREATE TABLE A (date_key date);
-CREATE TABLE C (
+CREATE TABLE t1 (date_key date);
+CREATE TABLE t2 (
pk int,
int_nokey int,
int_key int,
@@ -4622,29 +4623,27 @@ date_key date NOT NULL,
date_nokey date,
varchar_key varchar(1)
);
-INSERT INTO C VALUES
+INSERT INTO t2 VALUES
(1,1,1,'0000-00-00',NULL,NULL),
(1,1,1,'0000-00-00',NULL,NULL);
-SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);
+SELECT 1 FROM t2 WHERE pk > ANY (SELECT 1 FROM t2);
1
-SELECT COUNT(DISTINCT 1) FROM C
-WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;
+SELECT COUNT(DISTINCT 1) FROM t2
+WHERE date_key = (SELECT 1 FROM t1 WHERE t2.date_key IS NULL) GROUP BY pk;
COUNT(DISTINCT 1)
-SELECT date_nokey FROM C
-WHERE int_key IN (SELECT 1 FROM A)
+SELECT date_nokey FROM t2
+WHERE int_key IN (SELECT 1 FROM t1)
HAVING date_nokey = '10:41:7'
ORDER BY date_key;
date_nokey
-Warnings:
-Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
-DROP TABLE A,C;
+DROP TABLE t1,t2;
CREATE TABLE t1 (a INT NOT NULL, b INT);
INSERT INTO t1 VALUES (1, 1);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1
+Note 1003 select 1 AS `a`,1 AS `b` from `test`.`t1` where 1
SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
a b
1 1
diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result
index f9d6c80018b..9a4d521293a 100644
--- a/mysql-test/r/select_pkeycache.result
+++ b/mysql-test/r/select_pkeycache.result
@@ -2115,8 +2115,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -3265,7 +3265,7 @@ f1 f2
4 2005-10-01
5 2005-12-30
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
select * from t1 where f2 <= '2005-09-31' order by f2;
f1 f2
1 2005-01-01
@@ -3276,7 +3276,7 @@ f1 f2
1 2005-01-01
2 2005-09-01
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (1, 30), (2, 20), (3, 10);
@@ -3753,15 +3753,11 @@ AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t1 range ts ts 4 NULL 1 Using index condition; Using where; Rowid-ordered scan
-Warnings:
-Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
AND t1.ts BETWEEN t2.dt1 AND t2.dt2
AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
a ts a dt1 dt2
30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00
-Warnings:
-Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
DROP TABLE t1,t2;
create table t1 (a bigint unsigned);
insert into t1 values
@@ -4098,17 +4094,22 @@ select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT-6'
+select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6';
+str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6'
+1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT-6'
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
-1
+0
Warnings:
-Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6'
+Warning 1292 Incorrect datetime value: '2007/10/2000:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007-10-1 00:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'
1
@@ -4128,7 +4129,7 @@ select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT
str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6'
+Warning 1292 Truncated incorrect date value: '2007-10-01 x12:34:56 GMT-6'
select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';
str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'
1
@@ -4167,33 +4168,24 @@ str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00'
set SQL_MODE=TRADITIONAL;
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
+1
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
0
-Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00'
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20'
-0
-Warnings:
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+1
set SQL_MODE=DEFAULT;
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
1
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
0
@@ -4207,31 +4199,40 @@ select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
0
Warnings:
-Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Incorrect datetime value: ''
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Truncated incorrect date value: '1'
+Warning 1292 Incorrect datetime value: '1'
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Truncated incorrect date value: '1'
+Warning 1292 Incorrect datetime value: '1'
select str_to_date('','%Y-%m-%d') = '';
str_to_date('','%Y-%m-%d') = ''
-0
+1
Warnings:
-Warning 1292 Truncated incorrect date value: ''
-select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
-str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL
-0
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
-str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'
+Warning 1292 Incorrect datetime value: ''
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01'
+1
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL
+NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01'
+NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL
0
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
-str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01';
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01'
0
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL;
+str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL
+NULL
CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
c22 INT DEFAULT NULL,
@@ -4606,8 +4607,8 @@ a
4
5
DROP TABLE t1;
-CREATE TABLE A (date_key date);
-CREATE TABLE C (
+CREATE TABLE t1 (date_key date);
+CREATE TABLE t2 (
pk int,
int_nokey int,
int_key int,
@@ -4615,29 +4616,27 @@ date_key date NOT NULL,
date_nokey date,
varchar_key varchar(1)
);
-INSERT INTO C VALUES
+INSERT INTO t2 VALUES
(1,1,1,'0000-00-00',NULL,NULL),
(1,1,1,'0000-00-00',NULL,NULL);
-SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);
+SELECT 1 FROM t2 WHERE pk > ANY (SELECT 1 FROM t2);
1
-SELECT COUNT(DISTINCT 1) FROM C
-WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;
+SELECT COUNT(DISTINCT 1) FROM t2
+WHERE date_key = (SELECT 1 FROM t1 WHERE t2.date_key IS NULL) GROUP BY pk;
COUNT(DISTINCT 1)
-SELECT date_nokey FROM C
-WHERE int_key IN (SELECT 1 FROM A)
+SELECT date_nokey FROM t2
+WHERE int_key IN (SELECT 1 FROM t1)
HAVING date_nokey = '10:41:7'
ORDER BY date_key;
date_nokey
-Warnings:
-Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
-DROP TABLE A,C;
+DROP TABLE t1,t2;
CREATE TABLE t1 (a INT NOT NULL, b INT);
INSERT INTO t1 VALUES (1, 1);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1
+Note 1003 select 1 AS `a`,1 AS `b` from `test`.`t1` where 1
SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
a b
1 1
diff --git a/mysql-test/r/shm.result b/mysql-test/r/shm.result
index 5c9eac07bb0..4dfb88771aa 100644
--- a/mysql-test/r/shm.result
+++ b/mysql-test/r/shm.result
@@ -2155,6 +2155,8 @@ mysqld is alive
SET @max_allowed_packet= @@global.max_allowed_packet;
SET @net_buffer_length= @@global.net_buffer_length;
SET GLOBAL max_allowed_packet= 1024;
+Warnings:
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SET GLOBAL net_buffer_length= 1024;
ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes
SET GLOBAL max_allowed_packet= @max_allowed_packet;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index b7697eb6563..61f0cec4a5d 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -1337,6 +1337,7 @@ drop table `été`;
set names latin1;
show columns from `#mysql50#????????`;
Got one of the listed errors
+call mtr.add_suppression("Can.t find file: '.\\\\test\\\\\\?{8}.frm'");
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS p1;
CREATE TABLE t1(c1 INT);
diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result
index 576f531af2d..e16434fdbff 100644
--- a/mysql-test/r/sp-destruct.result
+++ b/mysql-test/r/sp-destruct.result
@@ -1,4 +1,5 @@
call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted");
+call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value in column mysql.proc");
flush table mysql.proc;
use test;
drop procedure if exists bug14233;
diff --git a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result
index f5420a62f63..15ddc2b44f5 100644
--- a/mysql-test/r/sp-vars.result
+++ b/mysql-test/r/sp-vars.result
@@ -380,7 +380,7 @@ ERROR 22003: Out of range value for column 'sp_vars_check_ret1()' at row 1
SELECT sp_vars_check_ret2();
ERROR 22003: Out of range value for column 'sp_vars_check_ret2()' at row 1
SELECT sp_vars_check_ret3();
-ERROR HY000: Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1
+ERROR 22007: Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1
SELECT sp_vars_check_ret4();
sp_vars_check_ret4()
154.12
@@ -698,7 +698,7 @@ t1 CREATE TABLE "t1" (
"x" datetime DEFAULT NULL
)
Warnings:
-Warning 1264 Out of range value for column 'x' at row 1
+Warning 1265 Data truncated for column 'x' at row 1
DROP PROCEDURE p1;
---------------------------------------------------------------
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 9370b63e847..50dd2ae7047 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -3051,8 +3051,7 @@ begin
set @x = @x + 1;
return @x;
end|
-set @qcs1 = @@query_cache_size|
-set global query_cache_size = 100000|
+# Set query cache size, if we have query cache
set @x = 1|
insert into t1 values ("qc", 42)|
select bug9902() from t1|
@@ -3064,7 +3063,7 @@ bug9902()
select @x|
@x
3
-set global query_cache_size = @qcs1|
+# Restore the old query cache size
delete from t1|
drop function bug9902|
drop function if exists bug9102|
@@ -6484,7 +6483,7 @@ DROP TABLE t1;
CALL p1('text');
Warnings:
-Warning 1264 Out of range value for column 'v' at row 1
+Warning 1265 Data truncated for column 'v' at row 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
diff --git a/mysql-test/r/ssl_cipher.result b/mysql-test/r/ssl_cipher.result
new file mode 100644
index 00000000000..78081300b5b
--- /dev/null
+++ b/mysql-test/r/ssl_cipher.result
@@ -0,0 +1,9 @@
+#
+# BUG#11760210 - SSL_CIPHER_LIST NOT SET OR RETURNED FOR "SHOW STATUS LIKE 'SSL_CIPHER_LIST'"
+#
+SHOW STATUS LIKE 'Ssl_cipher';
+Variable_name Value
+Ssl_cipher AES128-SHA
+SHOW STATUS LIKE 'Ssl_cipher_list';
+Variable_name Value
+Ssl_cipher_list AES128-SHA
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 241f4198bf7..31159051749 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -41,7 +41,7 @@ INSERT INTO t1 VALUES('0000-00-00');
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
INSERT IGNORE INTO t1 VALUES('0000-00-00');
Warnings:
-Warning 1265 Data truncated for column 'col1' at row 1
+Warning 1264 Out of range value for column 'col1' at row 1
INSERT INTO t1 VALUES ('2004-0-30');
INSERT INTO t1 VALUES ('2004-2-30');
ERROR 22007: Incorrect date value: '2004-2-30' for column 'col1' at row 1
@@ -51,7 +51,7 @@ set @@sql_mode='ansi,traditional';
INSERT IGNORE INTO t1 VALUES('2004-02-29'),('2004-13-15'),('0000-00-00');
Warnings:
Warning 1265 Data truncated for column 'col1' at row 2
-Warning 1265 Data truncated for column 'col1' at row 3
+Warning 1264 Out of range value for column 'col1' at row 3
select * from t1;
col1
2004-01-01
@@ -264,14 +264,14 @@ ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col2' at row 1
INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
@@ -279,7 +279,7 @@ ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' a
INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col3' at row 1
drop table t1;
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE));
@@ -290,15 +290,17 @@ INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1
+INSERT INTO t1 (col1) VALUES('2004-0-10');
+ERROR 22007: Incorrect date value: '2004-0-10' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col2' at row 1
INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
@@ -306,7 +308,7 @@ ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' a
INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col3' at row 1
drop table t1;
CREATE TABLE t1(col1 TINYINT, col2 TINYINT UNSIGNED);
INSERT INTO t1 VALUES(-128,0),(0,0),(127,255),('-128','0'),('0','0'),('127','255'),(-128.0,0.0),(0.0,0.0),(127.0,255.0);
@@ -364,9 +366,9 @@ Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
INSERT INTO t1 (col1) VALUES ('');
-ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
-ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@@ -447,9 +449,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
-ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
-ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@@ -531,9 +533,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
-ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
-ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@@ -615,9 +617,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
-ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
-ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@@ -697,9 +699,9 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
-ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
-ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
@@ -776,7 +778,7 @@ ERROR 22003: Out of range value for column 'col1' at row 1
INSERT INTO t1 VALUES ('-100E+1');
ERROR 22003: Out of range value for column 'col1' at row 1
INSERT INTO t1 VALUES ('-100E');
-ERROR HY000: Incorrect decimal value: '-100E' for column 'col1' at row 1
+ERROR 22007: Incorrect decimal value: '-100E' for column 'col1' at row 1
UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
ERROR 22003: Out of range value for column 'col1' at row 6
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
@@ -784,11 +786,11 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
-ERROR HY000: Incorrect decimal value: '' for column 'col1' at row 1
+ERROR 22007: Incorrect decimal value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
-ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect decimal value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
-ERROR HY000: Incorrect decimal value: '1a' for column 'col1' at row 1
+ERROR 22007: Incorrect decimal value: '1a' for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
Warnings:
Note 1265 Data truncated for column 'col1' at row 1
@@ -1105,8 +1107,6 @@ count(*)
7
Warnings:
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
-Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
-Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
drop table t1;
create table t1 (col1 char(3), col2 integer);
insert into t1 (col1) values (cast(1000 as char(3)));
@@ -1136,9 +1136,9 @@ ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1
insert into t1 values (0.0,0.0,0.0);
ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1
insert into t1 (col1) values (convert('0000-00-00',date));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
insert into t1 (col1) values (cast('0000-00-00' as date));
-ERROR 22007: Incorrect datetime value: '0000-00-00'
+ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
set sql_mode='no_zero_date';
insert into t1 values (0,0,0);
Warnings:
@@ -1155,15 +1155,15 @@ set sql_mode='traditional';
create table t1 (col1 date);
insert ignore into t1 values ('0000-00-00');
Warnings:
-Warning 1265 Data truncated for column 'col1' at row 1
+Warning 1264 Out of range value for column 'col1' at row 1
insert into t1 select * from t1;
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
insert ignore into t1 values ('0000-00-00');
Warnings:
-Warning 1265 Data truncated for column 'col1' at row 1
+Warning 1264 Out of range value for column 'col1' at row 1
insert ignore into t1 (col1) values (cast('0000-00-00' as date));
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1264 Out of range value for column 'col1' at row 1
insert into t1 select * from t1;
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
alter table t1 modify col1 datetime;
@@ -1172,13 +1172,14 @@ alter ignore table t1 modify col1 datetime;
Warnings:
Warning 1264 Out of range value for column 'col1' at row 1
Warning 1264 Out of range value for column 'col1' at row 2
+Warning 1264 Out of range value for column 'col1' at row 3
insert into t1 select * from t1;
ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col1' at row 1
select * from t1;
col1
0000-00-00 00:00:00
0000-00-00 00:00:00
-NULL
+0000-00-00 00:00:00
drop table t1;
create table t1 (col1 tinyint);
drop procedure if exists t1;
@@ -1361,34 +1362,34 @@ col5 mediumint, col6 mediumint unsigned,
col7 int, col8 int unsigned,
col9 bigint, col10 bigint unsigned);
insert into t1(col1) values('-');
-ERROR HY000: Incorrect integer value: '-' for column 'col1' at row 1
+ERROR 22007: Incorrect integer value: '-' for column 'col1' at row 1
insert into t1(col2) values('+');
-ERROR HY000: Incorrect integer value: '+' for column 'col2' at row 1
+ERROR 22007: Incorrect integer value: '+' for column 'col2' at row 1
insert into t1(col3) values('-');
-ERROR HY000: Incorrect integer value: '-' for column 'col3' at row 1
+ERROR 22007: Incorrect integer value: '-' for column 'col3' at row 1
insert into t1(col4) values('+');
-ERROR HY000: Incorrect integer value: '+' for column 'col4' at row 1
+ERROR 22007: Incorrect integer value: '+' for column 'col4' at row 1
insert into t1(col5) values('-');
-ERROR HY000: Incorrect integer value: '-' for column 'col5' at row 1
+ERROR 22007: Incorrect integer value: '-' for column 'col5' at row 1
insert into t1(col6) values('+');
-ERROR HY000: Incorrect integer value: '+' for column 'col6' at row 1
+ERROR 22007: Incorrect integer value: '+' for column 'col6' at row 1
insert into t1(col7) values('-');
-ERROR HY000: Incorrect integer value: '-' for column 'col7' at row 1
+ERROR 22007: Incorrect integer value: '-' for column 'col7' at row 1
insert into t1(col8) values('+');
-ERROR HY000: Incorrect integer value: '+' for column 'col8' at row 1
+ERROR 22007: Incorrect integer value: '+' for column 'col8' at row 1
insert into t1(col9) values('-');
-ERROR HY000: Incorrect integer value: '-' for column 'col9' at row 1
+ERROR 22007: Incorrect integer value: '-' for column 'col9' at row 1
insert into t1(col10) values('+');
-ERROR HY000: Incorrect integer value: '+' for column 'col10' at row 1
+ERROR 22007: Incorrect integer value: '+' for column 'col10' at row 1
drop table t1;
set sql_mode='traditional';
create table t1(a year);
insert into t1 values ('-');
-ERROR HY000: Incorrect integer value: '-' for column 'a' at row 1
+ERROR 22007: Incorrect integer value: '-' for column 'a' at row 1
insert into t1 values ('+');
-ERROR HY000: Incorrect integer value: '+' for column 'a' at row 1
+ERROR 22007: Incorrect integer value: '+' for column 'a' at row 1
insert into t1 values ('');
-ERROR HY000: Incorrect integer value: '' for column 'a' at row 1
+ERROR 22007: Incorrect integer value: '' for column 'a' at row 1
insert into t1 values ('2000a');
ERROR 01000: Data truncated for column 'a' at row 1
insert into t1 values ('2E3x');
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 53f38141f66..c84d4538a88 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -53,7 +53,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><'1'>((select '1')) = 1)
+Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><1>((select 1)) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
@@ -202,11 +202,10 @@ select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> system NULL NULL NULL NULL 1 100.00
-3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
Warnings:
-Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
+Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,`test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1)
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
a
2
@@ -273,7 +272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2);
a
7
@@ -317,7 +316,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select <expr_cache><`test`.`t2`.`a`>((select '2' from `test`.`t1` where ('2' = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
+Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from `test`.`t1` where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
@@ -366,11 +365,11 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
-4 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
-3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings:
-Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
+Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
@@ -423,7 +422,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where 1
+Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
drop table t1;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
@@ -508,6 +507,9 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
+show warnings;
+Level Code Message
+Error 1242 Subquery returns more than 1 row
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
@@ -543,13 +545,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
+Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
+Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = 3))
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
@@ -589,7 +591,7 @@ a b
select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
-delete from t1 where b = (select b from t1);
+delete from t1 where b in (select b from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
@@ -909,7 +911,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3;
create table t1 (a float);
select 10.5 IN (SELECT * from t1 LIMIT 1);
@@ -1180,9 +1182,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
@@ -1190,9 +1192,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1;
CREATE TABLE `t1` (
`i` int(11) NOT NULL default '0',
@@ -1340,7 +1342,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 100 100.00 Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`)
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
@@ -1350,7 +1352,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 100 100.00 Using where; Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
@@ -1361,7 +1363,7 @@ explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.61 Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 11 100.00 Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`))
insert into t1 values (3,31);
@@ -1377,7 +1379,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 100 100.00 Using where; Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
drop table t0, t1, t2, t3;
@@ -1503,7 +1505,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`))))
select * from t3 where a >= some (select b from t2);
a
explain extended select * from t3 where a >= some (select b from t2);
@@ -1511,7 +1513,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2 group by 1);
a
6
@@ -1522,7 +1524,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1))))
select * from t3 where a >= some (select b from t2 group by 1);
a
explain extended select * from t3 where a >= some (select b from t2 group by 1);
@@ -1530,39 +1532,39 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= any (select b from t2);
a
explain extended select * from t3 where NULL >= any (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= any (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= some (select b from t2);
a
explain extended select * from t3 where NULL >= some (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= some (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
insert into t2 values (2,2), (2,1), (3,3), (3,1);
select * from t3 where a > all (select max(b) from t2 group by a);
a
@@ -1571,9 +1573,9 @@ a
explain extended select * from t3 where a > all (select max(b) from t2 group by a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))))
drop table t2, t3;
CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
@@ -1624,7 +1626,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 system NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
+Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(<in_optimizer>('f',('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`))))
drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
@@ -2831,14 +2833,13 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cac
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1 1.00
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1)
Warnings:
-Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`flag` = 'N'))
+Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1`
DROP TABLE t1,t2;
@@ -3110,10 +3111,10 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
-4
1
+2
3
+4
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
@@ -3122,8 +3123,8 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
1
+2
3
4
SELECT a FROM t1
@@ -3420,7 +3421,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary
ALTER TABLE t1 ADD INDEX(a);
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
a b
@@ -3431,7 +3432,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
DROP TABLE t1;
create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
@@ -4320,16 +4321,16 @@ CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a);
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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
DROP TABLE t1;
#
# Bug#45061: Incorrectly market field caused wrong result.
@@ -5012,11 +5013,10 @@ explain SELECT * FROM ot1,ot4
WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
FROM it2,it3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY ot1 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 24
-1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
-2 SUBQUERY it2 ALL NULL NULL NULL NULL 4
-2 SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
+1 PRIMARY ot1 ALL NULL NULL NULL NULL 2 Start temporary
+1 PRIMARY it2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
+1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (flat, BNL join)
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
#
# Bug#729039: NULL keys used to evaluate subquery
@@ -5068,3 +5068,62 @@ pk i
12 5
15 0
DROP table t1,t2;
+#
+# Bug#751350: crash with pushed condition for outer references when
+# there should be none of such conditions
+#
+CREATE TABLE t1 (a int, b int) ;
+INSERT INTO t1 VALUES (0,0),(0,0);
+EXPLAIN
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+b
+0
+DROP TABLE t1;
+#
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
+# BUG#779885: Crash in eliminate_item_equal with materialization=on in
+# maria-5.3
+#
+CREATE TABLE t1 ( f1 int );
+INSERT INTO t1 VALUES (19), (20);
+CREATE TABLE t2 ( f10 varchar(32) );
+INSERT INTO t2 VALUES ('c'),('d');
+CREATE TABLE t3 ( f10 varchar(32) );
+INSERT INTO t3 VALUES ('a'),('b');
+SELECT *
+FROM t1
+WHERE
+( 't' ) IN (
+SELECT t3.f10
+FROM t3
+JOIN t2
+ON t2.f10 = t3.f10
+);
+f1
+DROP TABLE t1,t2,t3;
+End of 5.3 tests
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index 3d7cbdd9ff7..e88461173df 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -28,7 +28,7 @@ select a, oref, a in (select max(ie)
from t1 where oref=t2.oref group by grp) Z from t2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary
Warnings:
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `Z` from `test`.`t2`
@@ -37,7 +37,7 @@ select a, oref from t2
where a in (select max(ie) from t1 where oref=t2.oref group by grp);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary
Warnings:
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))
@@ -69,7 +69,7 @@ set @@optimizer_switch="partial_match_rowid_merge=off,partial_match_table_scan=o
explain extended select a in (select max(ie) from t1 where oref=4 group by grp) from t3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary
Warnings:
Note 1003 select <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3`
set @@optimizer_switch=@save_optimizer_switch;
@@ -121,7 +121,7 @@ Handler_read_key 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
-Handler_read_rnd_next 29
+Handler_read_rnd_next 35
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
Z
No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.
@@ -163,7 +163,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
drop table t1, t2, t3;
create table t1 (a int NOT NULL, b int NOT NULL, key(a));
insert into t1 values
@@ -191,7 +191,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)))))) AS `Z` from `test`.`t3`
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)) and (`test`.`t2`.`a` = `test`.`t1`.`b`))))) AS `Z` from `test`.`t3`
drop table t1,t2,t3;
create table t1 (oref int, grp int);
insert into t1 (oref, grp) values
@@ -212,7 +212,7 @@ select a, oref,
a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select count(0) from `test`.`t1` group by `test`.`t1`.`grp` having ((`test`.`t1`.`grp` = `test`.`t2`.`oref`) and trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(count(0)))))))) AS `Z` from `test`.`t2`
@@ -463,7 +463,7 @@ group by grp having min(ie) > 1) Z
from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
-2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary
select oref, a,
a in (select min(ie) from t1 where oref=t2.oref
group by grp having min(ie) > 1) Z
@@ -624,7 +624,7 @@ explain
select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary
select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;
oref a Z
ee NULL 0
@@ -711,7 +711,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t1` where ((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)) having <is_not_null_test>(`test`.`t1`.`a`)))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))))))
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
a
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
@@ -732,7 +732,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index; Full scan on NULL key
-2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 Using index condition; Using where; Full scan on NULL key
+2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
@@ -841,11 +841,16 @@ x ROW(11, 12) = (SELECT MAX(x), 22) ROW(11, 12) IN (SELECT MAX(x), 22)
1 0 0
2 0 0
11 0 0
-# 2nd and 3rd columns should be same for x == 11 only
+# 2nd and 3rd columns should be same
+EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
x ROW(11, 12) = (SELECT MAX(x), 12) ROW(11, 12) IN (SELECT MAX(x), 12)
-1 0 1
-2 0 1
+1 0 0
+2 0 0
11 1 1
DROP TABLE t1;
# both columns should be same
@@ -882,7 +887,7 @@ Level Code Message
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2
Note 1276 Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2
Error 1054 Unknown column 'c' in 'field list'
-Note 1003 select `c` AS `c` from (select <expr_cache><count(`test`.`t1`.`a`),`test`.`t1`.`c`>((select count(`test`.`t1`.`a`) from (select count(`test`.`t1`.`b`) AS `COUNT(b)` from `test`.`t1`) `x` group by `t1`.`c`)) AS `(SELECT COUNT(a) FROM
+Note 1003 select `c` AS `c` from (select (select count(`test`.`t1`.`a`) from (select count(`test`.`t1`.`b`) AS `COUNT(b)` from `test`.`t1`) `x` group by `test`.`t1`.`c`) AS `(SELECT COUNT(a) FROM
(SELECT COUNT(b) FROM t1) AS x GROUP BY c
)` from `test`.`t1` group by `test`.`t1`.`b`) `y`
DROP TABLE t1;
@@ -971,7 +976,7 @@ i1 i2
# Baseline:
SHOW STATUS LIKE '%Handler_read_rnd_next';
Variable_name Value
-Handler_read_rnd_next 18
+Handler_read_rnd_next 17
INSERT INTO t1 VALUES (NULL, NULL);
FLUSH STATUS;
@@ -988,7 +993,7 @@ i1 i2
# (read record from t1, but do not read from t2)
SHOW STATUS LIKE '%Handler_read_rnd_next';
Variable_name Value
-Handler_read_rnd_next 19
+Handler_read_rnd_next 18
set @@optimizer_switch=@save_optimizer_switch2;
DROP TABLE t1,t2;
End of 5.1 tests
@@ -1023,11 +1028,10 @@ update t22 set c = '2005-12-08 15:58:27' where a = 255;
explain select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
+1 PRIMARY t11 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort; Start temporary
+1 PRIMARY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; End temporary; Using join buffer (flat, BNL join)
1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (flat, BNL join)
-1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (flat, BNL join)
-2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
-2 SUBQUERY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
a b c
@@ -1040,9 +1044,8 @@ explain
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 2
-2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
-2 DEPENDENT SUBQUERY subselect3 eq_ref unique_key unique_key 5 func 1
-3 SUBQUERY Z ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where; Start temporary
+2 DEPENDENT SUBQUERY Z ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
subq
NULL
@@ -1111,10 +1114,8 @@ a
set @@optimizer_switch=@save_optimizer_switch;
explain select * from (select a from t0) X where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11
-1 PRIMARY subselect3 eq_ref unique_key unique_key 5 func 1
-3 SUBQUERY t1 ALL NULL NULL NULL NULL 20
-2 DERIVED t0 ALL NULL NULL NULL NULL 11
+1 PRIMARY t0 ALL NULL NULL NULL NULL 11
+1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(t0)
drop table t0, t1;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -1125,18 +1126,16 @@ create table t3 (a int);
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 100
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where; Using index
+1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
+1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
create table t4 (pk int primary key);
insert into t4 select a from t3;
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
and t4.pk=t1.c);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 100
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Rowid-ordered scan
-2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index
+1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
+1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using where
+1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t3)
drop table t1, t3, t4;
create table t1 (a int) as select * from t0 where a < 5;
set @save_max_heap_table_size=@@max_heap_table_size;
@@ -1167,9 +1166,8 @@ create table t3 ( a int , filler char(100), key(a));
insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B;
explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2
-1 PRIMARY t3 ref a a 5 test.t2.a 1
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
+1 PRIMARY t3 ref a a 5 test.t2.a 1 End temporary
select * from t3 where a in (select a from t2);
a filler
1 filler
@@ -1215,47 +1213,44 @@ create table t3 (a int, b int, filler char(100), key(a));
insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C;
explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref a a 5 test.t2.a 10
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 10
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
-2 SUBQUERY A ALL NULL NULL NULL NULL 10
-2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
+2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
-2 SUBQUERY A ALL NULL NULL NULL NULL 10
-2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
+2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
explain select straight_join * from t2 X, t2 Y
where X.a in (select straight_join A.a from t1 A, t1 B);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 10 Using where
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
-2 SUBQUERY A ALL NULL NULL NULL NULL 10
-2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
+2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
create table t0 (a int, b int);
insert into t0 values(1,1);
explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref a a 5 test.t2.a 10
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary
create table t4 as select a as x, a as y from t1;
explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where
-2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t4 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; End temporary
drop table t0,t1,t2,t3,t4;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -1264,14 +1259,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
create table t2 as select * from t1;
explain select * from t2 where a in (select b from t1 where a=3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
+1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
+1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
-2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
+1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
+1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
drop table t1,t2;
create table t1 (a int, b int);
insert into t1 select a,a from t0;
@@ -1280,16 +1273,14 @@ insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B;
set @@optimizer_switch='firstmatch=off';
explain select * from t1 where (a,b) in (select a,b from t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; End temporary; Using join buffer (flat, BNL join)
set @save_optimizer_search_depth=@@optimizer_search_depth;
set @@optimizer_search_depth=63;
explain select * from t1 where (a,b) in (select a,b from t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; End temporary; Using join buffer (flat, BNL join)
set @@optimizer_search_depth=@save_optimizer_search_depth;
set @@optimizer_switch=@save_optimizer_switch;
drop table t0, t1, t2;
@@ -1299,9 +1290,8 @@ create table t1 as select * from t0;
insert into t1 select * from t0;
explain select * from t0 where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t0 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
+1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
select * from t0 where a in (select a from t1);
a
10.24
@@ -1313,9 +1303,8 @@ create table t1 as select * from t0;
insert into t1 select * from t0;
explain select * from t0 where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t0 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
+1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
select * from t0 where a in (select a from t1);
a
2008-01-01
@@ -1328,11 +1317,10 @@ create table t2 as select a as a, a as b from t0 where a < 3;
insert into t2 select * from t2;
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY subselect2 eq_ref unique_key unique_key 15 func 1
-2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where
-2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
-2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Start temporary
+1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join)
drop table t0,t1,t2;
BUG#37842: Assertion in DsMrr_impl::dsmrr_init, at handler.cc:4307
@@ -1402,10 +1390,9 @@ INNER JOIN t2 c ON c.idContact=cona.idContact
WHERE cona.postalStripped='T2H3B2'
);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2 1.00
-1 PRIMARY a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (flat, BNL join)
-2 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where
-2 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00
+1 PRIMARY cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
+1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where
+1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary
Warnings:
Note 1003 select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2'))
drop table t1,t2,t3;
diff --git a/mysql-test/r/subselect3_jcl6.result b/mysql-test/r/subselect3_jcl6.result
index b8a30ce1722..e254fad2300 100644
--- a/mysql-test/r/subselect3_jcl6.result
+++ b/mysql-test/r/subselect3_jcl6.result
@@ -35,7 +35,7 @@ select a, oref, a in (select max(ie)
from t1 where oref=t2.oref group by grp) Z from t2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary
Warnings:
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `Z` from `test`.`t2`
@@ -44,7 +44,7 @@ select a, oref from t2
where a in (select max(ie) from t1 where oref=t2.oref group by grp);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary
Warnings:
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))
@@ -76,7 +76,7 @@ set @@optimizer_switch="partial_match_rowid_merge=off,partial_match_table_scan=o
explain extended select a in (select max(ie) from t1 where oref=4 group by grp) from t3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary
Warnings:
Note 1003 select <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3`
set @@optimizer_switch=@save_optimizer_switch;
@@ -128,7 +128,7 @@ Handler_read_key 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
-Handler_read_rnd_next 29
+Handler_read_rnd_next 35
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
Z
No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.
@@ -170,7 +170,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
Warnings:
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3`
drop table t1, t2, t3;
create table t1 (a int NOT NULL, b int NOT NULL, key(a));
insert into t1 values
@@ -198,7 +198,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
Warnings:
Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)))))) AS `Z` from `test`.`t3`
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)) and (`test`.`t2`.`a` = `test`.`t1`.`b`))))) AS `Z` from `test`.`t3`
drop table t1,t2,t3;
create table t1 (oref int, grp int);
insert into t1 (oref, grp) values
@@ -219,7 +219,7 @@ select a, oref,
a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
Warnings:
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select count(0) from `test`.`t1` group by `test`.`t1`.`grp` having ((`test`.`t1`.`grp` = `test`.`t2`.`oref`) and trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(count(0)))))))) AS `Z` from `test`.`t2`
@@ -470,7 +470,7 @@ group by grp having min(ie) > 1) Z
from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
-2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary
select oref, a,
a in (select min(ie) from t1 where oref=t2.oref
group by grp having min(ie) > 1) Z
@@ -631,7 +631,7 @@ explain
select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary
select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2;
oref a Z
ee NULL 0
@@ -718,7 +718,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t1` where ((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)) having <is_not_null_test>(`test`.`t1`.`a`)))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))))))
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
a
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
@@ -739,7 +739,7 @@ WHERE t3.name='xxx' AND t2.id=t3.id);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 func 1 Using where; Using index; Full scan on NULL key
-2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 Using index condition(BKA); Using where; Full scan on NULL key; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
SELECT * FROM t1
WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3
WHERE t3.name='xxx' AND t2.id=t3.id);
@@ -848,11 +848,16 @@ x ROW(11, 12) = (SELECT MAX(x), 22) ROW(11, 12) IN (SELECT MAX(x), 22)
1 0 0
2 0 0
11 0 0
-# 2nd and 3rd columns should be same for x == 11 only
+# 2nd and 3rd columns should be same
+EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
x ROW(11, 12) = (SELECT MAX(x), 12) ROW(11, 12) IN (SELECT MAX(x), 12)
-1 0 1
-2 0 1
+1 0 0
+2 0 0
11 1 1
DROP TABLE t1;
# both columns should be same
@@ -889,7 +894,7 @@ Level Code Message
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2
Note 1276 Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2
Error 1054 Unknown column 'c' in 'field list'
-Note 1003 select `c` AS `c` from (select <expr_cache><count(`test`.`t1`.`a`),`test`.`t1`.`c`>((select count(`test`.`t1`.`a`) from (select count(`test`.`t1`.`b`) AS `COUNT(b)` from `test`.`t1`) `x` group by `t1`.`c`)) AS `(SELECT COUNT(a) FROM
+Note 1003 select `c` AS `c` from (select (select count(`test`.`t1`.`a`) from (select count(`test`.`t1`.`b`) AS `COUNT(b)` from `test`.`t1`) `x` group by `test`.`t1`.`c`) AS `(SELECT COUNT(a) FROM
(SELECT COUNT(b) FROM t1) AS x GROUP BY c
)` from `test`.`t1` group by `test`.`t1`.`b`) `y`
DROP TABLE t1;
@@ -978,7 +983,7 @@ i1 i2
# Baseline:
SHOW STATUS LIKE '%Handler_read_rnd_next';
Variable_name Value
-Handler_read_rnd_next 18
+Handler_read_rnd_next 17
INSERT INTO t1 VALUES (NULL, NULL);
FLUSH STATUS;
@@ -995,7 +1000,7 @@ i1 i2
# (read record from t1, but do not read from t2)
SHOW STATUS LIKE '%Handler_read_rnd_next';
Variable_name Value
-Handler_read_rnd_next 19
+Handler_read_rnd_next 18
set @@optimizer_switch=@save_optimizer_switch2;
DROP TABLE t1,t2;
End of 5.1 tests
@@ -1030,11 +1035,10 @@ update t22 set c = '2005-12-08 15:58:27' where a = 255;
explain select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
-1 PRIMARY t21 hash_ALL NULL #hash#$hj 4 test.t11.a 26 Using where; Using join buffer (flat, BNLH join)
-1 PRIMARY t22 hash_ALL NULL #hash#$hj 4 test.t11.a 26 Using where; Using join buffer (incremental, BNLH join)
-2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
-2 SUBQUERY t12 hash_ALL NULL #hash#$hj 4 test.t11.a 8 Using where; Using join buffer (flat, BNLH join)
+1 PRIMARY t11 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort; Start temporary
+1 PRIMARY t12 hash_ALL NULL #hash#$hj 4 test.t11.a 8 Using where; Using join buffer (flat, BNLH join)
+1 PRIMARY t22 hash_ALL NULL #hash#$hj 4 test.t11.a 26 Using where; End temporary; Using join buffer (incremental, BNLH join)
+1 PRIMARY t21 hash_ALL NULL #hash#$hj 4 test.t11.a 26 Using where; Using join buffer (incremental, BNLH join)
select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
a b c
@@ -1047,9 +1051,8 @@ explain
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 2
-2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where
-2 DEPENDENT SUBQUERY subselect3 eq_ref unique_key unique_key 5 func 1
-3 SUBQUERY Z ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where; Start temporary
+2 DEPENDENT SUBQUERY Z hash_ALL NULL #hash#$hj 5 test.Y.a 2 Using where; End temporary; Using join buffer (flat, BNLH join)
select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X;
subq
NULL
@@ -1118,10 +1121,8 @@ a
set @@optimizer_switch=@save_optimizer_switch;
explain select * from (select a from t0) X where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11
-1 PRIMARY subselect3 eq_ref unique_key unique_key 5 func 1
-3 SUBQUERY t1 ALL NULL NULL NULL NULL 20
-2 DERIVED t0 ALL NULL NULL NULL NULL 11
+1 PRIMARY t0 ALL NULL NULL NULL NULL 11
+1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(t0); Using join buffer (flat, BNL join)
drop table t0, t1;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -1132,18 +1133,16 @@ create table t3 (a int);
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 100
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where; Using index
+1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
+1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
create table t4 (pk int primary key);
insert into t4 select a from t3;
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
and t4.pk=t1.c);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 100
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Rowid-ordered scan
-2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index
+1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
+1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using where
+1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t3)
drop table t1, t3, t4;
create table t1 (a int) as select * from t0 where a < 5;
set @save_max_heap_table_size=@@max_heap_table_size;
@@ -1174,9 +1173,8 @@ create table t3 ( a int , filler char(100), key(a));
insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B;
explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2
-1 PRIMARY t3 ref a a 5 test.t2.a 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Start temporary
+1 PRIMARY t3 ref a a 5 test.t2.a 1 End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
select * from t3 where a in (select a from t2);
a filler
1 filler
@@ -1222,47 +1220,44 @@ create table t3 (a int, b int, filler char(100), key(a));
insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C;
explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
explain select straight_join * from t1 A, t1 B where A.a in (select a from t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 10
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
-2 SUBQUERY A ALL NULL NULL NULL NULL 10
-2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
+2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where
-2 SUBQUERY A ALL NULL NULL NULL NULL 10
-2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
+2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
explain select straight_join * from t2 X, t2 Y
where X.a in (select straight_join A.a from t1 A, t1 B);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY X ALL NULL NULL NULL NULL 10 Using where
1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
-2 SUBQUERY A ALL NULL NULL NULL NULL 10
-2 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 10 Using where
+2 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
create table t0 (a int, b int);
insert into t0 values(1,1);
explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref a a 5 test.t2.a 10 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t3 ref a a 5 test.t2.a 10 End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
create table t4 as select a as x, a as y from t1;
explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 system NULL NULL NULL NULL 1
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2 SUBQUERY t4 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t4 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t3 ref a a 5 test.t4.x 10 Using where; End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
drop table t0,t1,t2,t3,t4;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -1271,14 +1266,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
create table t2 as select * from t1;
explain select * from t2 where a in (select b from t1 where a=3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
+1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
+1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
-2 SUBQUERY t1 ref a a 10 const,test.t2.a 8 Using index
+1 PRIMARY t1 range a a 5 NULL 8 Using where; Using index; LooseScan
+1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
drop table t1,t2;
create table t1 (a int, b int);
insert into t1 select a,a from t0;
@@ -1287,16 +1280,14 @@ insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B;
set @@optimizer_switch='firstmatch=off';
explain select * from t1 where (a,b) in (select a,b from t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t2 hash_ALL NULL #hash#$hj 10 test.t1.a,test.t1.b 100 Using where; End temporary; Using join buffer (flat, BNLH join)
set @save_optimizer_search_depth=@@optimizer_search_depth;
set @@optimizer_search_depth=63;
explain select * from t1 where (a,b) in (select a,b from t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 100
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t2 hash_ALL NULL #hash#$hj 10 test.t1.a,test.t1.b 100 Using where; End temporary; Using join buffer (flat, BNLH join)
set @@optimizer_search_depth=@save_optimizer_search_depth;
set @@optimizer_switch=@save_optimizer_switch;
drop table t0, t1, t2;
@@ -1306,9 +1297,8 @@ create table t1 as select * from t0;
insert into t1 select * from t0;
explain select * from t0 where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t0 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
+1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Using where; Start temporary
+1 PRIMARY t1 hash_ALL NULL #hash#$hj 3 test.t0.a 4 Using where; End temporary; Using join buffer (flat, BNLH join)
select * from t0 where a in (select a from t1);
a
10.24
@@ -1320,9 +1310,8 @@ create table t1 as select * from t0;
insert into t1 select * from t0;
explain select * from t0 where a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t0 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 4
+1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Using where; Start temporary
+1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t0.a 4 Using where; End temporary; Using join buffer (flat, BNLH join)
select * from t0 where a in (select a from t1);
a
2008-01-01
@@ -1335,11 +1324,10 @@ create table t2 as select a as a, a as b from t0 where a < 3;
insert into t2 select * from t2;
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY subselect2 eq_ref unique_key unique_key 15 func 1
-2 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where
-2 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
-2 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer (incremental, BNL join)
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
+1 PRIMARY X hash_ALL NULL #hash#$hj 5 test.t1.a 6 Using where; Using join buffer (flat, BNLH join)
+1 PRIMARY Y hash_ALL NULL #hash#$hj 5 test.t1.b 6 Using where; Using join buffer (incremental, BNLH join)
+1 PRIMARY Z hash_ALL NULL #hash#$hj 5 test.t1.c 6 Using where; End temporary; Using join buffer (incremental, BNLH join)
drop table t0,t1,t2;
BUG#37842: Assertion in DsMrr_impl::dsmrr_init, at handler.cc:4307
@@ -1409,10 +1397,9 @@ INNER JOIN t2 c ON c.idContact=cona.idContact
WHERE cona.postalStripped='T2H3B2'
);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2 1.00
-1 PRIMARY a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (flat, BNL join)
-2 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where
-2 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 PRIMARY cona ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
+1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 PRIMARY a eq_ref PRIMARY PRIMARY 4 test.c.idObj 1 100.00 Using index; End temporary
Warnings:
Note 1003 select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `test`.`c`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2'))
drop table t1,t2,t3;
diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result
index 686840630f1..5a382730a99 100644
--- a/mysql-test/r/subselect4.result
+++ b/mysql-test/r/subselect4.result
@@ -1,3 +1,4 @@
+drop table if exists t1,t2,t3,t4,t5,t6;
#
# Bug #46791: Assertion failed:(table->key_read==0),function unknown
# function,file sql_base.cc
@@ -117,14 +118,14 @@ EXPLAIN
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x
-x SUBQUERY x x x x x x x x
+x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
a b
EXPLAIN
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
a b
1 NULL
@@ -147,28 +148,28 @@ EXPLAIN
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x
-x SUBQUERY x x x x x x x x
+x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
a b
EXPLAIN
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x
-x SUBQUERY x x x x x x x x
+x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
c d
EXPLAIN
SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x
-x SUBQUERY x x x x x x x x
+x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
e f
EXPLAIN
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x
-x SUBQUERY x x x x x x x x
+x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
c d
SELECT * FROM t1 WHERE ( a, b ) NOT IN
@@ -258,17 +259,14 @@ KEY `varchar_key` (`varchar_key`)
) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','','');
set @old_optimizer_switch = @@session.optimizer_switch,
-@old_optimizer_use_mrr = @@session.optimizer_use_mrr,
@old_engine_condition_pushdown = @@session.engine_condition_pushdown;
-SET SESSION OPTIMIZER_SWITCH = 'materialization=off,semijoin=off,loosescan=off,firstmatch=off';
-SET SESSION optimizer_use_mrr = 'force';
+SET SESSION OPTIMIZER_SWITCH = 'materialization=off,semijoin=off,loosescan=off,firstmatch=off,mrr=on';
SET SESSION engine_condition_pushdown = 1;
SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN (
SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER
BY `pk` ;
G1
set @@session.optimizer_switch = @old_optimizer_switch,
-@@session.optimizer_use_mrr = @old_optimizer_use_mrr,
@@session.engine_condition_pushdown = @old_engine_condition_pushdown;
DROP TABLE t1;
#
@@ -342,7 +340,7 @@ INSERT INTO t3 VALUES ('E4','P4',40);
INSERT INTO t3 VALUES ('E4','P5',80);
SET @old_optimizer_switch = @@session.optimizer_switch;
SET @old_join_cache_level = @@session.join_cache_level;
-SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,semijoin=on';
+SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,in_to_exists=off,semijoin=on';
SET SESSION join_cache_level = 1;
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
EXPLAIN SELECT EMPNAME
@@ -356,7 +354,7 @@ FROM t2
WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
@@ -371,13 +369,13 @@ WHERE EMPNUM IN
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5
-1 SIMPLE subselect2 eq_ref unique_key unique_key 3 func 1
+1 SIMPLE <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
DEALLOCATE PREPARE stmt;
@@ -394,7 +392,7 @@ FROM t2
WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
@@ -409,13 +407,13 @@ WHERE EMPNUM IN
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5
-1 SIMPLE subselect2 eq_ref unique_key unique_key 3 func 1
+1 SIMPLE <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
DEALLOCATE PREPARE stmt;
@@ -431,7 +429,7 @@ FROM t2
WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
@@ -446,13 +444,13 @@ WHERE EMPNUM IN
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
-1 SIMPLE subselect2 eq_ref unique_key unique_key 3 func 1
+1 SIMPLE <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
DEALLOCATE PREPARE stmt;
@@ -565,7 +563,7 @@ INSERT INTO t3 VALUES ('E4','P4',40);
INSERT INTO t3 VALUES ('E4','P5',80);
SET @old_optimizer_switch = @@session.optimizer_switch;
SET @old_join_cache_level = @@session.join_cache_level;
-SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,semijoin=on';
+SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,in_to_exists=off,semijoin=on';
SET SESSION join_cache_level = 1;
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
EXPLAIN SELECT EMPNAME
@@ -579,7 +577,7 @@ FROM t2
WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
@@ -594,13 +592,13 @@ WHERE EMPNUM IN
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5
-1 SIMPLE subselect2 eq_ref unique_key unique_key 3 func 1
+1 SIMPLE <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
DEALLOCATE PREPARE stmt;
@@ -617,7 +615,7 @@ FROM t2
WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
@@ -632,13 +630,13 @@ WHERE EMPNUM IN
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL t1_IDX NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5
-1 SIMPLE subselect2 eq_ref unique_key unique_key 3 func 1
+1 SIMPLE <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
DEALLOCATE PREPARE stmt;
@@ -654,7 +652,7 @@ FROM t2
WHERE PTYPE = 'Design'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
@@ -669,13 +667,13 @@ WHERE EMPNUM IN
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
-1 SIMPLE subselect2 eq_ref unique_key unique_key 3 func 1
+1 SIMPLE <subquery2> eq_ref distinct_key distinct_key 3 func 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
DEALLOCATE PREPARE stmt;
@@ -726,7 +724,7 @@ INSERT INTO t1 VALUES ('28','6','m'),('29','4','c');
CREATE TABLE t2 (f11 varchar(1)) ;
INSERT INTO t2 VALUES ('f'),('d');
SET @old_optimizer_switch = @@session.optimizer_switch;
-SET SESSION optimizer_switch = 'materialization=on';
+SET SESSION optimizer_switch = 'materialization=on,in_to_exists=off,';
EXPLAIN
SELECT * FROM t1
WHERE f3 = (
@@ -735,7 +733,8 @@ WHERE ( t1.f10 ) IN ( SELECT f11 FROM t2 GROUP BY f11 ));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
-3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 5 test.t1.f10 1
+3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary
SELECT * FROM t1
WHERE f3 = (
SELECT t1.f3 FROM t1
@@ -749,7 +748,8 @@ WHERE ( f10, f10 ) IN ( SELECT f11, f11 FROM t2 GROUP BY f11 ));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
-3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 10 test.t1.f10,test.t1.f10 1
+3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary
SELECT * FROM t1
WHERE f3 = (
SELECT f3 FROM t1
@@ -763,7 +763,7 @@ drop table t1,t2;
CREATE TABLE t1 (f1 int, f2 int);
CREATE TABLE t2 (f3 int, f4 int not null, PRIMARY KEY (f3));
set @save_optimizer_switch=@@optimizer_switch;
-SET @@optimizer_switch = 'materialization=on,semijoin=off';
+SET @@optimizer_switch = 'materialization=on,in_to_exists=off,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
@@ -851,10 +851,10 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
f1 f2
-SET @@optimizer_switch = 'materialization=off,semijoin=off';
+SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
@@ -949,25 +949,25 @@ INSERT INTO t1 VALUES (1, 2);
INSERT INTO t1 VALUES (3, 4);
INSERT INTO t2 VALUES (5, 6);
INSERT INTO t2 VALUES (7, 8);
-SET @@optimizer_switch = 'materialization=on,semijoin=off';
+SET @@optimizer_switch = 'materialization=on,in_to_exists=off,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
f1 f2
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
f1 f2
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
f1 f2
@@ -982,14 +982,14 @@ NULL
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
f1 f2
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
f1 f2
@@ -1036,29 +1036,29 @@ NULL
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
f1 f2
-SET @@optimizer_switch = 'materialization=off,semijoin=off';
+SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
f1 f2
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
f1 f2
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
f1 f2
@@ -1073,14 +1073,14 @@ NULL
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
f1 f2
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
f1 f2
@@ -1127,7 +1127,7 @@ NULL
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
f1 f2
@@ -1154,20 +1154,21 @@ PRIMARY KEY (pk),
KEY f2 (f2));
INSERT INTO t2 VALUES (1,7,'p');
set @save_optimizer_switch=@@optimizer_switch;
-set @@optimizer_switch='materialization=off,semijoin=off';
+set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
EXPLAIN
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t2 system PRIMARY NULL NULL NULL 1
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
2 DEPENDENT SUBQUERY t1 index_subquery f2 f2 4 func 2 Using index
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
f3 MAX(t1.f2)
NULL NULL
-set @@optimizer_switch='materialization=on,semijoin=off';
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
EXPLAIN
SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
@@ -1185,3 +1186,553 @@ TODO: add a test case for semijoin when the wrong result is fixed
set @@optimizer_switch='materialization=off,semijoin=on';
set @@optimizer_switch=@save_optimizer_switch;
drop table t1, t2;
+#
+# LP BUG#641203 Query returns rows where no result is expected (impossible WHERE)
+#
+CREATE TABLE t1 (c1 varchar(1) DEFAULT NULL);
+CREATE TABLE t2 (c1 varchar(1) DEFAULT NULL);
+INSERT INTO t2 VALUES ('k'), ('d');
+CREATE TABLE t3 (c1 varchar(1) DEFAULT NULL);
+INSERT INTO t3 VALUES ('a'), ('b'), ('c');
+CREATE TABLE t4 (c1 varchar(1) primary key);
+INSERT INTO t4 VALUES ('k'), ('d');
+EXPLAIN
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+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
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+c1 c1
+EXPLAIN
+SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+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
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+c1 c1
+EXPLAIN
+SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
+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
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
+c1 c1 c1
+EXPLAIN
+SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t4 index NULL PRIMARY 3 NULL 2 Using index
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
+c1 c1
+drop table t1, t2, t3, t4;
+#
+# LP BUG#675981 Assertion `cache != __null' failed in sub_select_cache()
+# on EXPLAIN
+#
+CREATE TABLE t1 (f1 int,f2 int) ;
+INSERT IGNORE INTO t1 VALUES ('2','5'),('2',NULL);
+CREATE TABLE t2 (f1 int, f5 int) ;
+INSERT IGNORE INTO t2 VALUES (1,0);
+CREATE TABLE t3 (f4 int) ;
+INSERT IGNORE INTO t3 VALUES (0),(0);
+set @@optimizer_switch='in_to_exists=on,materialization=off,semijoin=off';
+EXPLAIN
+SELECT * FROM t2
+WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+drop table t1, t2, t3;
+#
+# LP BUG#680005 Second assertion `cache != __null' failed in
+# sub_select_cache() on EXPLAIN
+#
+CREATE TABLE t1 (f1 int,f2 int,f4 int,f6 int,KEY (f4)) ;
+INSERT IGNORE INTO t1 VALUES
+('1','5','1','0'),('2','1','1','0'),('2','2','2','0'),('0',NULL,'0','0'),
+('2','1','2','0'),('2','0','0','0'),('2','2','2','0'),('2','8','2','0'),
+('2','7','2','0'),('2','5','2','0'),('2',NULL,'1','0');
+CREATE TABLE t2 (f3 int) ;
+INSERT IGNORE INTO t2 VALUES ('7');
+CREATE TABLE t3 (f3 int) ;
+INSERT IGNORE INTO t3 VALUES ('2');
+EXPLAIN
+SELECT t1.f4
+FROM t2 JOIN t1 ON t1.f6
+WHERE
+( t1.f2 ) IN (SELECT SUBQUERY2_t1.f3
+FROM t3 AS SUBQUERY2_t1
+JOIN
+(t1 AS SUBQUERY2_t2
+JOIN
+t1 AS SUBQUERY2_t3 ON SUBQUERY2_t3.f1)
+ON SUBQUERY2_t3.f2)
+GROUP BY t1.f4 ORDER BY t1.f1 LIMIT 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1 Using temporary; Using filesort
+1 PRIMARY t1 index NULL f4 5 NULL 11 Using where
+2 DEPENDENT SUBQUERY SUBQUERY2_t1 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY SUBQUERY2_t2 index NULL f4 5 NULL 11 Using index
+2 DEPENDENT SUBQUERY SUBQUERY2_t3 ALL NULL NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join)
+drop table t1, t2, t3;
+#
+# LP BUG#680038 bool close_thread_table(THD*, TABLE**):
+# Assertion `table->key_read == 0' failed in EXPLAIN
+#
+CREATE TABLE t1 (f1 int,f3 int,f4 int) ;
+INSERT IGNORE INTO t1 VALUES (NULL,1,0);
+CREATE TABLE t2 (f2 int,f4 int,f5 int) ;
+INSERT IGNORE INTO t2 VALUES (8,0,0),(5,0,0);
+CREATE TABLE t3 (f4 int,KEY (f4)) ;
+INSERT IGNORE INTO t3 VALUES (0),(0);
+set @@optimizer_switch='semijoin=off';
+EXPLAIN
+SELECT * FROM t1 WHERE
+(SELECT f2 FROM t2
+WHERE f4 <= ALL
+(SELECT SQ1_t1.f4
+FROM t3 AS SQ1_t1 JOIN t3 AS SQ1_t3 ON SQ1_t3.f4
+GROUP BY SQ1_t1.f4));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary
+3 SUBQUERY SQ1_t3 index NULL f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+drop table t1, t2, t3;
+#
+# BUG#52317: Assertion failing in Field_varstring::store()
+# at field.cc:6833
+#
+CREATE TABLE t1 (i INTEGER);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i INTEGER, KEY k(i));
+INSERT INTO t2 VALUES (1), (2);
+EXPLAIN
+SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t2 index_subquery k k 5 const 2 Using index
+DROP TABLE t2;
+DROP TABLE t1;
+#
+# LP BUG#680846: Crash in clear_tables() with subqueries
+#
+CREATE TABLE t1 (f3 int) ;
+INSERT IGNORE INTO t1 VALUES (0),(0);
+CREATE TABLE t2 (f1 int,f3 int,f4 varchar(32)) ;
+INSERT IGNORE INTO t2 VALUES (1,0,'f');
+EXPLAIN
+SELECT COUNT(t2.f3),
+(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT COUNT(t2.f3),
+(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+COUNT(t2.f3) f9
+EXPLAIN
+SELECT COUNT(t2.f3),
+(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT COUNT(t2.f3),
+(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+COUNT(t2.f3) f9
+0 2
+EXPLAIN
+SELECT COUNT(t2.f3),
+(SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT COUNT(t2.f3),
+(SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+COUNT(t2.f3) f9
+EXPLAIN
+SELECT COUNT(t2.f3),
+(SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT COUNT(t2.f3),
+(SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+COUNT(t2.f3) f9
+0 NULL
+drop table t1,t2;
+#
+# LP BUG#682683 Crash in create_tmp_table called from
+# JOIN::init_execution
+#
+CREATE TABLE t2 (f1 int) ;
+INSERT INTO t2 VALUES (1),(2);
+CREATE TABLE t1 (f1 int) ;
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+field1
+NULL
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+field1
+NULL
+NULL
+INSERT INTO t1 VALUES (1),(2);
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+ERROR 21000: Subquery returns more than 1 row
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+ERROR 21000: Subquery returns more than 1 row
+drop table t1,t2;
+#
+# LP BUG#680943 Assertion `!table || (!table->read_set ||
+# bitmap_is_set(table->read_set, field_index))' failed with subquery
+#
+CREATE TABLE t1 (f1 int,f3 int) ;
+INSERT IGNORE INTO t1 VALUES ('6','0'),('4','0');
+CREATE TABLE t2 (f1 int,f2 int,f3 int) ;
+INSERT IGNORE INTO t2 VALUES ('6','0','0'),('2','0','0');
+SELECT f2
+FROM (SELECT * FROM t2) AS alias1
+WHERE (SELECT SQ2_t2.f1
+FROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3
+WHERE SQ2_t2.f3 AND alias1.f1)
+ORDER BY f3 ;
+f2
+drop table t1,t2;
+#
+# LP BUG#715062: Wrong result with VIEW + UNION + subquery in maria-5.3-mwl89
+#
+create table t1 (f1 int);
+create table t2 (f2 int);
+create table t3 (f3 int);
+insert into t1 values (2);
+insert into t2 values (2);
+insert into t3 values (7);
+CREATE VIEW v1 AS SELECT 2 UNION SELECT 2 ;
+CREATE VIEW v2 AS SELECT * from t1 UNION SELECT * from t2 ;
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch = 'in_to_exists=off,semijoin=off,materialization=on';
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+bug
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+( 5 ) IN ( SELECT * FROM v1 )
+0
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED t1 system NULL NULL NULL NULL 1
+4 UNION t2 system NULL NULL NULL NULL 1
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+bug
+EXPLAIN
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 system NULL NULL NULL NULL 1
+2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2
+3 DERIVED t1 system NULL NULL NULL NULL 1
+4 UNION t2 system NULL NULL NULL NULL 1
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+bug
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED t1 system NULL NULL NULL NULL 1
+4 UNION t2 system NULL NULL NULL NULL 1
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+( 5 ) IN ( SELECT * FROM v2 )
+0
+SET @@optimizer_switch = 'in_to_exists=on,semijoin=off,materialization=off';
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+bug
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+( 5 ) IN ( SELECT * FROM v1 )
+0
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED t1 system NULL NULL NULL NULL 1
+4 UNION t2 system NULL NULL NULL NULL 1
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+bug
+EXPLAIN
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED t1 system NULL NULL NULL NULL 1
+4 UNION t2 system NULL NULL NULL NULL 1
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+bug
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
+3 DERIVED t1 system NULL NULL NULL NULL 1
+4 UNION t2 system NULL NULL NULL NULL 1
+NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+( 5 ) IN ( SELECT * FROM v2 )
+0
+set @@optimizer_switch=@save_optimizer_switch;
+drop table t1,t2,t3;
+drop view v1,v2;
+#
+# LP BUG#715069 Wrong result with GROUP BY inside subquery and materialization=off
+#
+CREATE TABLE t0 ( f1 int(11), f2 int(11), f10 varchar(1), PRIMARY KEY (f1)) ;
+INSERT INTO t0 VALUES (8,8,'u'),(10,5,'o');
+CREATE TABLE t1 (f1a int, f2a int not null, f3a varchar(3) not null, PRIMARY KEY (f1a)) ;
+INSERT INTO t1 VALUES
+(8,8,'a1a'),
+(10,5,'b1b');
+CREATE TABLE t2 (f1b int, f2b int not null, f3b varchar(3) not null, PRIMARY KEY (f1b)) ;
+INSERT INTO t2 VALUES
+(10,5,'d1d');
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off';
+EXPLAIN
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY alias1 index NULL PRIMARY 4 NULL 2 Using where; Using index
+2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 2
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+f1 f2
+8 8
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+f1b f2b f3b
+10 5 d1d
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+f1b f2b f3b
+10 5 d1d
+SET @@optimizer_switch = 'materialization=on';
+EXPLAIN
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY alias1 index NULL PRIMARY 4 NULL 2 Using where; Using index
+2 SUBQUERY t0 ALL NULL NULL NULL NULL 2
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+f1 f2
+8 8
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+f1b f2b f3b
+10 5 d1d
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+f1b f2b f3b
+10 5 d1d
+set @@optimizer_switch=@save_optimizer_switch;
+drop table t0,t1,t2;
+#
+# LP BUG#715759 Wrong result with in_to_exists=on in maria-5.3-mwl89
+#
+set @save_optimizer_switch=@@optimizer_switch;
+CREATE TABLE t1 (a1 int, a2 int) ;
+INSERT INTO t1 VALUES (1, 2);
+INSERT INTO t1 VALUES (3, 4);
+CREATE TABLE t2 (b1 int, b2 int) ;
+INSERT INTO t2 VALUES (1, 2);
+SET @@optimizer_switch = 'in_to_exists=on,materialization=off,semijoin=off';
+EXPLAIN SELECT * FROM t1 WHERE a1 IN (SELECT b1 FROM t2 WHERE b1 = b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+SELECT * FROM t1 WHERE a1 IN (SELECT b1 FROM t2 WHERE b1 = b2);
+a1 a2
+set @@optimizer_switch=@save_optimizer_switch;
+drop table t1, t2;
+#
+# LP BUG#772309 join_tab_cmp_straight(): Assertion `!jt2->emb_sj_nest' failed in maria-5.3-mwl89 with semijoin
+#
+CREATE TABLE t1 ( f2 int) ;
+INSERT INTO t1 VALUES (0),(0);
+CREATE TABLE t2 ( f1 int NOT NULL ) ;
+INSERT INTO t2 VALUES (0),(0);
+CREATE TABLE t3 ( f1 int NOT NULL , f2 int) ;
+INSERT INTO t3 VALUES (0,0), (0,0);
+EXPLAIN SELECT STRAIGHT_JOIN (
+SELECT f2 FROM t1 WHERE ( f2 ) IN ( SELECT t3.f2 FROM t3 JOIN t2 ON t2.f1 = 1 )
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where
+3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+SELECT STRAIGHT_JOIN (
+SELECT f2 FROM t1 WHERE ( f2 ) IN ( SELECT t3.f2 FROM t3 JOIN t2 ON t2.f1 = 1 )
+);
+(
+SELECT f2 FROM t1 WHERE ( f2 ) IN ( SELECT t3.f2 FROM t3 JOIN t2 ON t2.f1 = 1 )
+)
+NULL
+drop table t1, t2, t3;
+#
+# LP BUG#777597 Wrong result with multipart keys, in_to_exists=on, NOT IN in MWL#89
+#
+CREATE TABLE t1 ( f4 int);
+INSERT IGNORE INTO t1 VALUES (2),(2);
+CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3) );
+INSERT IGNORE INTO t2 VALUES (6, 1), (6, 1);
+CREATE TABLE t3 ( f10 int );
+INSERT IGNORE INTO t3 VALUES (1);
+SET SESSION optimizer_switch='in_to_exists=on,materialization=off';
+EXPLAIN
+SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1
+2 DEPENDENT SUBQUERY t2 ref_or_null f10 f10 10 const,const 2 Using where; Using index
+SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
+f4
+drop table t1,t2,t3;
+#
+# LP BUG#778413 Third crash in select_describe() in maria-5.3-mwl89
+#
+CREATE TABLE t1 ( f11 int) ;
+INSERT INTO t1 VALUES (1),(1);
+CREATE TABLE t2 ( f1 int NOT NULL) ;
+INSERT INTO t2 VALUES (20);
+CREATE TABLE t3 (f3 int) ;
+INSERT INTO t3 VALUES (2),(2);
+EXPLAIN SELECT * FROM t2
+WHERE t2.f1 = (
+SELECT MAX( f3 ) FROM t3
+WHERE EXISTS (
+SELECT DISTINCT f11
+FROM t1));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+2 SUBQUERY t3 ALL NULL NULL NULL NULL 2
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary
+drop table t1, t2, t3;
diff --git a/mysql-test/r/subselect_cache.result b/mysql-test/r/subselect_cache.result
index 7b9dc3c943f..f80b9882c60 100644
--- a/mysql-test/r/subselect_cache.result
+++ b/mysql-test/r/subselect_cache.result
@@ -456,8 +456,8 @@ Handler_read_first 0
Handler_read_key 7
Handler_read_next 0
Handler_read_prev 0
-Handler_read_rnd 0
-Handler_read_rnd_next 31
+Handler_read_rnd 10
+Handler_read_rnd_next 42
set optimizer_switch='subquery_cache=off';
flush status;
select a from t1 ORDER BY (select d from t2 where b=c);
@@ -482,8 +482,8 @@ Handler_read_first 0
Handler_read_key 0
Handler_read_next 0
Handler_read_prev 0
-Handler_read_rnd 0
-Handler_read_rnd_next 61
+Handler_read_rnd 10
+Handler_read_rnd_next 72
set optimizer_switch='subquery_cache=on';
#single value subquery test (distinct ORDER BY)
flush status;
@@ -1336,11 +1336,11 @@ Subquery_cache_miss 0
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 11
+Handler_read_key 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
-Handler_read_rnd_next 145
+Handler_read_rnd_next 188
set optimizer_switch='subquery_cache=on';
flush status;
select a, b , exists (select * from t2 where b=d) as SUBSE, b in (select d from t2) as SUBSI, (select d from t2 where b=c) SUBSR from t1;
@@ -1364,11 +1364,11 @@ Subquery_cache_miss 18
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 32
+Handler_read_key 27
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
-Handler_read_rnd_next 84
+Handler_read_rnd_next 102
#several subqueries (several levels)
set optimizer_switch='subquery_cache=off';
flush status;
@@ -3195,7 +3195,7 @@ 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
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`b`))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`t2` where (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`b`))))
drop table t1,t2;
set @@optimizer_switch= default;
# LP BUG#615760 (part 2: incorrect heap table index flags)
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result
index 7b7c2fe3a59..889293d2908 100644
--- a/mysql-test/r/subselect_mat.result
+++ b/mysql-test/r/subselect_mat.result
@@ -1,4 +1,7 @@
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
drop table if exists t1, t2, t3, t1i, t2i, t3i;
+drop table if exists columns;
+drop table if exists t1_16, t2_16, t3_16;
drop view if exists v1, v2, v1m, v2m;
create table t1 (a1 char(8), a2 char(8));
create table t2 (b1 char(8), b2 char(8));
@@ -30,7 +33,7 @@ create index it3i3 on t3i (c1, c2);
insert into t1i select * from t1;
insert into t2i select * from t2;
insert into t3i select * from t3;
-set @@optimizer_switch='semijoin=off';
+set @@optimizer_switch='materialization=on,in_to_exists=off,firstmatch=off';
/******************************************************************************
* Simple tests.
******************************************************************************/
@@ -41,7 +44,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`))))))
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
a1 a2
1 - 01 2 - 01
@@ -50,9 +53,9 @@ explain extended
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`))))))
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
a1 a2
1 - 01 2 - 01
@@ -61,9 +64,9 @@ explain extended
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`b2`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))))
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
a1 a2
1 - 01 2 - 01
@@ -72,9 +75,9 @@ explain extended
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`min(b2)`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`min(b2)`))))))
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
a1 a2
1 - 01 2 - 01
@@ -82,10 +85,10 @@ a1 a2
explain extended
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-2 SUBQUERY t2i index it2i1,it2i3 it2i1 9 NULL 5 100.00 Using where; Using index
+1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where;
+2 SUBQUERY t2i index it2i1,it2i3 it2i1 # NULL 5 100.00 Using where;
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`))))))
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
a1 a2
1 - 01 2 - 01
@@ -93,10 +96,10 @@ a1 a2
explain extended
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-2 SUBQUERY t2i range it2i1,it2i3 it2i1 9 NULL 3 100.00 Using where; Using index for group-by
+1 PRIMARY t1i index NULL # 18 # 3 100.00 #
+2 SUBQUERY t2i range it2i1,it2i3 # 9 # 3 100.00 #
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`))))))
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
a1 a2
1 - 01 2 - 01
@@ -104,10 +107,10 @@ a1 a2
explain extended
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-2 SUBQUERY t2i index it2i1,it2i3 it2i3 18 NULL 5 100.00 Using where; Using index
+1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where;
+2 SUBQUERY t2i index it2i1,it2i3 it2i3 # NULL 5 100.00 Using where;
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`b2`))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))))
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
a1 a2
1 - 01 2 - 01
@@ -115,10 +118,10 @@ a1 a2
explain extended
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-2 SUBQUERY t2i range it2i1,it2i3 it2i3 18 NULL 3 100.00 Using where; Using index for group-by
+1 PRIMARY t1i index NULL # # # 3 100.00 #
+2 SUBQUERY t2i range it2i1,it2i3 # # # 3 100.00 #
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`b2`))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))))
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
a1 a2
1 - 01 2 - 01
@@ -126,10 +129,10 @@ a1 a2
explain extended
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-2 SUBQUERY t2i range it2i1,it2i3 it2i3 18 NULL 3 100.00 Using where; Using index for group-by
+1 PRIMARY t1i index NULL # # # 3 100.00 #
+2 SUBQUERY t2i range it2i1,it2i3 # # # 3 100.00 #
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`min(b2)`))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`min(b2)`))))))
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
a1 a2
1 - 01 2 - 01
@@ -140,7 +143,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2i range NULL it2i3 9 NULL 3 100.00 Using index for group-by
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`max(b2)`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`max(b2)`))))))
select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
a1 a2
1 - 01 2 - 01
@@ -169,13 +172,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2i range it2i1,it2i3 it2i3 18 NULL 3 100.00 Using where; Using index for group-by
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`min(b2)`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`min(b2)`))))))
select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
a1 a2
1 - 01 2 - 01
1 - 02 2 - 02
select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1);
ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
+set @save_optimizer_switch=@@optimizer_switch;
set @@optimizer_switch='default,semijoin=off';
prepare st1 from
"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
@@ -202,14 +206,14 @@ execute st1;
a1 a2
1 - 01 2 - 01
1 - 02 2 - 02
-set @@optimizer_switch='default,semijoin=off';
+set @@optimizer_switch=@save_optimizer_switch;
explain extended
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` order by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`b2`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` order by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))))
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
a1 a2
1 - 01 2 - 01
@@ -220,7 +224,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
2 SUBQUERY t2i index NULL it2i3 18 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` order by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`b2`))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` order by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))))
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
a1 a2
1 - 01 2 - 01
@@ -275,7 +279,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
4 SUBQUERY t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`b2`)))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery4>`.`b1`) and (`test`.`t3`.`c2` = `<subquery4>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery3>`.`c1`) and (`test`.`t1`.`a2` = `<subquery3>`.`c2`)))))))
select * from t1
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
(a1, a2) in (select c1, c2 from t3
@@ -289,12 +293,12 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-3 SUBQUERY t3i index NULL it3i3 18 NULL 4 100.00 Using where; Using index
-4 SUBQUERY t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
-2 SUBQUERY t2i index it2i1,it2i3 it2i3 18 NULL 5 100.00 Using where; Using index
+1 PRIMARY t1i index NULL # # # 3 100.00 #
+3 SUBQUERY t3i index NULL # # # 4 100.00 #
+4 SUBQUERY t2i index it2i2 # # # 5 100.00 #
+2 SUBQUERY t2i index it2i1,it2i3 # # # 5 100.00 #
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`b2`)))))) and <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c2`,`test`.`t3i`.`c1`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3i`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`c2`)))))))
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c2`,`test`.`t3i`.`c1`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `<subquery4>`.`b1`) and (`test`.`t3i`.`c2` = `<subquery4>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery3>`.`c1`) and (`test`.`t1i`.`a2` = `<subquery3>`.`c2`)))))))
select * from t1i
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
@@ -317,7 +321,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`b2`)))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3`.`c2` = `<subquery6>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`)))))))
select * from t1
where (a1, a2) in (select b1, b2 from t2
where b2 in (select c2 from t3 where c2 LIKE '%02') or
@@ -342,7 +346,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select 1 from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where <expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key where ((`test`.`t3c`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3c`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where <expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key where ((`test`.`t3c`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3c`.`c2` = `<subquery6>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`)))))))
select * from t1
where (a1, a2) in (select b1, b2 from t2
where b2 in (select c2 from t3 t3a where c1 = a1) or
@@ -366,19 +370,19 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-5 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
-6 SUBQUERY t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary; Using filesort
-4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
-3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
-7 UNION t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index
-9 SUBQUERY t3i index NULL it3i3 18 NULL 4 100.00 Using where; Using index
-10 SUBQUERY t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index
-8 SUBQUERY t2i index it2i1,it2i3 it2i3 18 NULL 5 100.00 Using where; Using index
-NULL UNION RESULT <union1,7> ALL NULL NULL NULL NULL NULL NULL
+1 PRIMARY t1 ALL NULL # # # 3 100.00 #
+5 SUBQUERY t3 ALL NULL # # # 4 100.00 #
+6 SUBQUERY t2i index it2i2 # # # 5 100.00 #
+2 SUBQUERY t2 ALL NULL # # # 5 100.00 #
+4 SUBQUERY t3 ALL NULL # # # 4 100.00 #
+3 SUBQUERY t3 ALL NULL # # # 4 100.00 #
+7 UNION t1i index NULL # # # 3 100.00 #
+9 SUBQUERY t3i index NULL # # # 4 100.00 #
+10 SUBQUERY t2i index it2i2 # # # 5 100.00 #
+8 SUBQUERY t2i index it2i1,it2i3 # # # 5 100.00 #
+NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL #
Warnings:
-Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1`.`a2` = `materialized subselect`.`b2`)))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`b2`)))))) and <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c2`,`test`.`t3i`.`c1`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3i`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1i`.`a2` = `materialized subselect`.`c2`))))))))
+Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3`.`c2` = `<subquery6>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`)))))))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery8>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery8>`.`b2`)))))) and <expr_cache><`test`.`t1i`.`a2`,`test`.`t1i`.`a1`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c2`,`test`.`t3i`.`c1`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `<subquery10>`.`b1`) and (`test`.`t3i`.`c2` = `<subquery10>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery9>`.`c1`) and (`test`.`t1i`.`a2` = `<subquery9>`.`c2`))))))))
(select * from t1
where (a1, a2) in (select b1, b2 from t2
where b2 in (select c2 from t3 where c2 LIKE '%02') or
@@ -407,7 +411,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `materialized subselect`.`c1`) and (`test`.`t1`.`a2` = `materialized subselect`.`c2`)))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery5>`.`b1`) and (`test`.`t3`.`c2` = `<subquery5>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery4>`.`c1`) and (`test`.`t1`.`a2` = `<subquery4>`.`c2`)))))))
select * from t1
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
(a1, a2) in (select c1, c2 from t3
@@ -430,7 +434,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `materialized subselect`.`b1`) and (`test`.`t3`.`c2` = `materialized subselect`.`b2`)))))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `materialized subselect`.`c1`) and (`test`.`t3`.`c2` = `materialized subselect`.`c2`)))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c2`,`test`.`t3`.`c1`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery5>`.`b1`) and (`test`.`t3`.`c2` = `<subquery5>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery4>`.`c1`) and (`test`.`t3`.`c2` = `<subquery4>`.`c2`)))))))
select * from t1, t3
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
(c1, c2) in (select c1, c2 from t3
@@ -452,7 +456,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select 1 from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))))
+Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))))
select * from t3
where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
c1 c2
@@ -476,14 +480,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select 1 from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `materialized subselect`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where (<expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i3 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where (<expr_cache><`test`.`t3c`.`c2`,`test`.`t3c`.`c1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i3 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`))))))
explain extended
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having ((<cache>(`test`.`t1`.`a1`) = '1 - 01') and (<cache>(`test`.`t1`.`a2`) = '2 - 01')))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))))
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
a1 a2
1 - 01 2 - 01
@@ -493,7 +497,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having ((<cache>(`test`.`t1`.`a1`) = '1 - 01') and (<cache>(`test`.`t1`.`a2`) = '2 - 01')))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))))
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
a1 a2
1 - 01 2 - 01
@@ -549,7 +553,6 @@ a1 a2
Test that BLOBs are not materialized (except when arguments of some functions).
*/
# force materialization to be always considered
-set @@optimizer_switch='semijoin=off';
set @prefix_len = 6;
set @blob_len = 16;
set @suffix_len = @blob_len - @prefix_len;
@@ -583,7 +586,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select 1 from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`)))))
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select `test`.`t2_16`.`b1` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`)))))
select left(a1,7), left(a2,7)
from t1_16
where a1 in (select b1 from t2_16 where b1 > '0');
@@ -611,7 +614,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select substr(`test`.`t2_16`.`b1`,1,16) from `test`.`t2_16` where (`test`.`t2_16`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `materialized subselect`.`substring(b1,1,16)`))))))
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select substr(`test`.`t2_16`.`b1`,1,16) from `test`.`t2_16` where (`test`.`t2_16`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `<subquery2>`.`substring(b1,1,16)`))))))
select left(a1,7), left(a2,7)
from t1_16
where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
@@ -640,7 +643,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_16
where a1 in (select group_concat(b1) from t2_16 group by b2);
@@ -662,7 +665,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select 1 from `test`.`t1_16` where (<expr_cache><`test`.`t1_16`.`a2`,`test`.`t1_16`.`a1`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where ((`test`.`t2`.`b1` = `materialized subselect`.`c1`)))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))))
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where (<expr_cache><`test`.`t1_16`.`a2`,`test`.`t1_16`.`a1`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where ((`test`.`t2`.`b1` = `<subquery4>`.`c1`)))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))))
drop table t1_16, t2_16, t3_16;
set @blob_len = 512;
set @suffix_len = @blob_len - @prefix_len;
@@ -696,7 +699,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,<exists>(select 1 from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`)))))
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,<exists>(select `test`.`t2_512`.`b1` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`)))))
select left(a1,7), left(a2,7)
from t1_512
where a1 in (select b1 from t2_512 where b1 > '0');
@@ -724,7 +727,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select substr(`test`.`t2_512`.`b1`,1,512) from `test`.`t2_512` where (`test`.`t2_512`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `materialized subselect`.`substring(b1,1,512)`))))))
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select substr(`test`.`t2_512`.`b1`,1,512) from `test`.`t2_512` where (`test`.`t2_512`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`substring(b1,1,512)`))))))
select left(a1,7), left(a2,7)
from t1_512
where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
@@ -738,7 +741,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_512
where a1 in (select group_concat(b1) from t2_512 group by b2);
@@ -751,7 +754,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_512
where a1 in (select group_concat(b1) from t2_512 group by b2);
@@ -789,7 +792,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select 1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`)))))
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select `test`.`t2_1024`.`b1` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`)))))
select left(a1,7), left(a2,7)
from t1_1024
where a1 in (select b1 from t2_1024 where b1 > '0');
@@ -817,7 +820,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in (select 1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024))))))
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select substr(`test`.`t2_1024`.`b1`,1,1024) from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024))))))
select left(a1,7), left(a2,7)
from t1_1024
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
@@ -831,7 +834,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_1024
where a1 in (select group_concat(b1) from t2_1024 group by b2);
@@ -844,7 +847,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_1024
where a1 in (select group_concat(b1) from t2_1024 group by b2);
@@ -882,7 +885,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select 1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`)))))
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select `test`.`t2_1025`.`b1` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`)))))
select left(a1,7), left(a2,7)
from t1_1025
where a1 in (select b1 from t2_1025 where b1 > '0');
@@ -910,7 +913,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
-Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in (select 1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025))))))
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select substr(`test`.`t2_1025`.`b1`,1,1025) from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025))))))
select left(a1,7), left(a2,7)
from t1_1025
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
@@ -924,7 +927,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_1025
where a1 in (select group_concat(b1) from t2_1025 group by b2);
@@ -937,7 +940,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `materialized subselect`.`group_concat(b1)`))))))
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`))))))
select left(a1,7), left(a2,7)
from t1_1025
where a1 in (select group_concat(b1) from t2_1025 group by b2);
@@ -951,7 +954,6 @@ insert into t1bit values (b'010', b'110');
insert into t2bit values (b'001', b'101');
insert into t2bit values (b'010', b'110');
insert into t2bit values (b'110', b'111');
-set @@optimizer_switch='semijoin=off';
explain extended select bin(a1), bin(a2)
from t1bit
where (a1, a2) in (select b1, b2 from t2bit);
@@ -959,7 +961,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1bit ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2bit ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` where <expr_cache><`test`.`t1bit`.`a2`,`test`.`t1bit`.`a1`>(<in_optimizer>((`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`),(`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`) in ( <materialize> (select `test`.`t2bit`.`b1`,`test`.`t2bit`.`b2` from `test`.`t2bit` ), <primary_index_lookup>(`test`.`t1bit`.`a1` in <temporary table> on distinct_key where ((`test`.`t1bit`.`a1` = `materialized subselect`.`b1`) and (`test`.`t1bit`.`a2` = `materialized subselect`.`b2`))))))
+Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` where <expr_cache><`test`.`t1bit`.`a2`,`test`.`t1bit`.`a1`>(<in_optimizer>((`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`),(`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`) in ( <materialize> (select `test`.`t2bit`.`b1`,`test`.`t2bit`.`b2` from `test`.`t2bit` ), <primary_index_lookup>(`test`.`t1bit`.`a1` in <temporary table> on distinct_key where ((`test`.`t1bit`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1bit`.`a2` = `<subquery2>`.`b2`))))))
select bin(a1), bin(a2)
from t1bit
where (a1, a2) in (select b1, b2 from t2bit);
@@ -994,7 +996,7 @@ drop table t1, t2, t3, t1i, t2i, t3i, columns;
/******************************************************************************
* Test the cache of the left operand of IN.
******************************************************************************/
-set @@optimizer_switch='semijoin=off';
+# Test that default values of Cached_item are not used for comparison
create table t1 (s1 int);
create table t2 (s2 int);
insert into t1 values (5),(1),(0);
@@ -1030,7 +1032,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `materialized subselect`.`c`))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
select a from t1 where a in (select c from t2 where d >= 20);
a
2
@@ -1044,7 +1046,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using where; Using index
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `materialized subselect`.`c`))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
select a from t1 where a in (select c from t2 where d >= 20);
a
2
@@ -1058,7 +1060,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using where; Using index
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `materialized subselect`.`c`))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
select a from t1 where a in (select c from t2 where d >= 20);
a
2
@@ -1071,7 +1073,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `materialized subselect`.`c`))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
select a from t1 group by a having a in (select c from t2 where d >= 20);
a
2
@@ -1083,7 +1085,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `materialized subselect`.`c`))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
select a from t1 group by a having a in (select c from t2 where d >= 20);
a
2
@@ -1097,7 +1099,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
select a from t1 group by a
having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
a
@@ -1112,7 +1114,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
select a from t1
where a in (select c from t2 where d >= some(select e from t3 where b=e));
a
@@ -1142,6 +1144,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
min(a1)
+set @save_optimizer_switch=@@optimizer_switch;
set @@optimizer_switch='default,materialization=off';
explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
id select_type table type possible_keys key key_len ref rows Extra
@@ -1153,21 +1156,29 @@ set @@optimizer_switch='default,semijoin=off';
explain select min(a1) from t1 where 7 in (select b1 from t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
-2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
select min(a1) from t1 where 7 in (select b1 from t2);
min(a1)
set @@optimizer_switch='default,materialization=off';
+# with MariaDB and MWL#90, this particular case is solved:
explain select min(a1) from t1 where 7 in (select b1 from t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
select min(a1) from t1 where 7 in (select b1 from t2);
min(a1)
NULL
+# but when we go around MWL#90 code, the problem still shows up:
+explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
+min(a1)
+set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2;
create table t1 (a char(2), b varchar(10));
insert into t1 values ('a', 'aaa');
insert into t1 values ('aa', 'aaaa');
-set @@optimizer_switch='default,semijoin=off';
explain select a,b from t1 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
@@ -1187,15 +1198,17 @@ INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
CREATE TABLE t2 LIKE t1;
INSERT INTO t2 VALUES (1, 1.789);
INSERT INTO t2 VALUES (13, 1.454);
+set @save_optimizer_switch=@@optimizer_switch;
SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 2
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2
SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
COUNT(*)
2
+set @@optimizer_switch= @save_optimizer_switch;
DROP TABLE t1, t2;
CREATE TABLE t1 (
pk int,
@@ -1208,11 +1221,12 @@ PRIMARY KEY (pk)
INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
CREATE TABLE t2 LIKE t1;
INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
+set @save_optimizer_switch=@@optimizer_switch;
SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan
SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
pk
@@ -1221,6 +1235,7 @@ SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
pk
2
DROP TABLE t1, t2;
+set optimizer_switch=@save_optimizer_switch;
#
# BUG#50019: Wrong result for IN-subquery with materialization
#
@@ -1237,7 +1252,7 @@ i
3
4
set @save_optimizer_switch=@@optimizer_switch;
-set session optimizer_switch='materialization=off';
+set session optimizer_switch='materialization=off,in_to_exists=on';
select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
i
1
@@ -1272,6 +1287,66 @@ a a in (select a from t1)
1 0
2 0
drop table t0, t1;
+set optimizer_switch='firstmatch=on';
+#
+# MWL#90, review feedback: check what happens when the subquery
+# looks like candidate for MWL#90 checking at the first glance
+# but then subselect_hash_sj_engine::init_permanent() discovers
+# that it's not possible to perform duplicate removal for the
+# selected datatypes, and so materialization isn't applicable after
+# all.
+#
+set @blob_len = 1024;
+set @suffix_len = @blob_len - @prefix_len;
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+insert into t1_1024 values
+(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+explain select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1,1,1024), count(*) from t2_1024 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1,1,1024), count(*) from t2_1024 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+drop table t1_1024, t2_1024;
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
+create table t0 (a int);
+insert into t0 values (0),(1),(2);
+create table t1 (a int);
+insert into t1 values (0),(1),(2);
+explain select a, a in (select a from t1) from t0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t0 ALL NULL NULL NULL NULL 3
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+select a, a in (select a from t1) from t0;
+a a in (select a from t1)
+0 1
+1 1
+2 1
+prepare s from 'select a, a in (select a from t1) from t0';
+execute s;
+a a in (select a from t1)
+0 1
+1 1
+2 1
+update t1 set a=123;
+execute s;
+a a in (select a from t1)
+0 0
+1 0
+2 0
+drop table t0, t1;
#
# LPBUG#609121: RQG: wrong result on aggregate + NOT IN + HAVING and
# partial_match_table_scan=on
@@ -1327,8 +1402,8 @@ i
10
DROP TABLE t1, t2, t3;
#
-# LPBUG#609121: RQG: wrong result on aggregate + NOT IN + HAVING and
-# partial_match_table_scan=on
+# LPBUG#611622/BUG#52344: Subquery materialization: Assertion
+# if subquery in on-clause of outer join
#
CREATE TABLE t1 (c1 int);
INSERT INTO t1 VALUES (1),(2);
@@ -1336,7 +1411,7 @@ CREATE TABLE t2 (c2 int);
INSERT INTO t2 VALUES (10);
PREPARE st1 FROM "
SELECT *
-FROM t2 LEFT JOIN (SELECT * FROM t2) t3 ON (8, 4) IN (SELECT c1, c1 FROM t1)";
+FROM t2 LEFT JOIN t2 t3 ON (8, 4) IN (SELECT c1, c1 FROM t1)";
EXECUTE st1;
c2 c2
10 10
@@ -1362,7 +1437,7 @@ SET @@optimizer_switch='default,semijoin=on,materialization=on';
EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan
SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
pk
@@ -1372,6 +1447,29 @@ pk
2
DROP TABLE t1, t2;
#
+# BUG#724228: Wrong result with materialization=on and three aggregates in maria-5.3-mwl90
+#
+CREATE TABLE t1 ( f2 int(11)) ;
+INSERT IGNORE INTO t1 VALUES ('7'),('9'),('7'),('4'),('2'),('6'),('8'),('5'),('6'),('188'),('2'),('1'),('1'),('0'),('9'),('4');
+CREATE TABLE t2 ( f1 int(11), f2 int(11)) ENGINE=MyISAM;
+INSERT IGNORE INTO t2 VALUES ('1','1');
+CREATE TABLE t3 ( f1 int(11), f2 int(11), f3 int(11), PRIMARY KEY (f1)) ;
+INSERT IGNORE INTO t3 VALUES ('16','6','1'),('18','3','4'),('19',NULL,'9'),('20','0','6'),('41','2','0'),('42','2','5'),('43','9','6'),('44','7','4'),('45','1','4'),('46','222','238'),('47','3','6'),('48','6','6'),('49',NULL,'1'),('50','5','1');
+SET @_save_join_cache_level = @@join_cache_level;
+SET @_save_optimizer_switch = @@optimizer_switch;
+SET join_cache_level = 1;
+SET optimizer_switch='materialization=on';
+SELECT f1 FROM t3
+WHERE
+f1 NOT IN (SELECT MAX(f2) FROM t1) AND
+f3 IN (SELECT MIN(f1) FROM t2) AND
+f1 IN (SELECT COUNT(f2) FROM t1);
+f1
+16
+SET @@join_cache_level = @_save_join_cache_level;
+SET @@optimizer_switch = @_save_optimizer_switch;
+drop table t1, t2, t3;
+#
# LPBUG#719198 Ordered_key::cmp_key_with_search_key(rownum_t): Assertion `!compare_pred[i]->null_value'
# failed with subquery on both sides of NOT IN and materialization
#
@@ -1380,34 +1478,41 @@ INSERT IGNORE INTO t1 VALUES (1,1),(2,2);
CREATE TABLE t2 ( f2 int);
INSERT IGNORE INTO t2 VALUES (3),(4);
CREATE TABLE t3 (f3a int, f3b int);
-set session optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off';
+set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,in_to_exists=off';
EXPLAIN
SELECT * FROM t2 WHERE (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
-2 SUBQUERY t3 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
SELECT * FROM t2 WHERE (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
f2
EXPLAIN
+SELECT (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+SELECT (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
+(SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1)
+NULL
+EXPLAIN
SELECT * FROM t2 WHERE (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
-2 SUBQUERY t3 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
SELECT * FROM t2 WHERE (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
f2
-insert into t3 values (1,1),(2,2);
EXPLAIN
-SELECT * FROM t2 WHERE (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1);
+SELECT (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
-3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
-2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where
-SELECT * FROM t2 WHERE (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1);
-f2
-3
-4
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+SELECT (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
+(SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1)
+NULL
drop table t1, t2, t3;
#
# LPBUG#730604 Assertion `bit < (map)->n_bits' failed in maria-5.3 with
@@ -1417,7 +1522,7 @@ CREATE TABLE t1 (f1 int NOT NULL, f2 int, f3 int) ;
CREATE TABLE t2 (f1 int NOT NULL, f2 int, f3 int) ;
INSERT INTO t1 VALUES (60, 3, null), (61, null, 77);
INSERT INTO t2 VALUES (1000,6,2);
-set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off';
+set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,in_to_exists=off';
EXPLAIN
SELECT (f1, f2, f3) NOT IN
(SELECT COUNT(DISTINCT f2), f1, f3 FROM t1 GROUP BY f1, f3)
diff --git a/mysql-test/r/subselect_mat_cost.result b/mysql-test/r/subselect_mat_cost.result
new file mode 100644
index 00000000000..9d6986cf092
--- /dev/null
+++ b/mysql-test/r/subselect_mat_cost.result
@@ -0,0 +1,3771 @@
+drop table if exists t1, t2, t1_1024, t2_1024;
+drop procedure if exists make_t1_indexes;
+drop procedure if exists make_t2_indexes;
+drop procedure if exists remove_t1_indexes;
+drop procedure if exists remove_t2_indexes;
+drop procedure if exists add_materialization_data;
+drop procedure if exists delete_materialization_data;
+drop procedure if exists set_all_columns_not_null;
+drop procedure if exists set_all_columns_nullable;
+create table t1 (a1 char(8), a2 char(8), a3 char(8), a4 int);
+insert into t1 values ('1 - 00', '2 - 00', '3 - 00', 0);
+insert into t1 values ('1 - 01', '2 - 01', '3 - 01', 1);
+insert into t1 values ('1 - 02', '2 - 02', '3 - 02', 2);
+create table t2 (b1 char(8), b2 char(8), b3 char(8), b4 int);
+insert into t2 values ('1 - 01', '2 - 01', '3 - 01', 1);
+insert into t2 values ('1 - 01', '2 - 01', '3 - 02', 2);
+insert into t2 values ('1 - 02', '2 - 02', '3 - 03', 3);
+insert into t2 values ('1 - 02', '2 - 02', '3 - 04', 4);
+insert into t2 values ('1 - 03', '2 - 03', '3 - 05', 5);
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+insert into t1_1024 values (concat('1 - 00', repeat('x', 1018)), concat('2 - 00', repeat('x', 1018)));
+insert into t1_1024 values (concat('1 - 01', repeat('x', 1018)), concat('2 - 01', repeat('x', 1018)));
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+insert into t2_1024 values (concat('1 - 01', repeat('x', 1018)), concat('2 - 01', repeat('x', 1018)));
+insert into t2_1024 values (concat('1 - 02', repeat('x', 1018)), concat('2 - 02', repeat('x', 1018)));
+insert into t2_1024 values (concat('1 - 03', repeat('x', 1018)), concat('2 - 03', repeat('x', 1018)));
+insert into t2_1024 values (concat('1 - 04', repeat('x', 1018)), concat('2 - 04', repeat('x', 1018)));
+create procedure make_t1_indexes()
+begin
+create index it1i1 on t1 (a1);
+create index it1i2 on t1 (a2);
+create index it1i3 on t1 (a1, a2);
+create index it1_1024i1 on t1_1024 (a1(6));
+create index it1_1024i2 on t1_1024 (a2(6));
+create index it1_1024i3 on t1_1024 (a1(6), a2(6));
+end|
+create procedure make_t2_indexes()
+begin
+create index it2i1 on t2 (b1);
+create index it2i2 on t2 (b2);
+create index it2i3 on t2 (b1, b2);
+create unique index it2i4 on t2 (b1, b2, b3);
+create index it2_1024i1 on t2_1024 (b1(6));
+create index it2_1024i2 on t2_1024 (b2(6));
+create index it2_1024i3 on t2_1024 (b1(6), b2(6));
+end|
+create procedure remove_t1_indexes()
+begin
+drop index it1i1 on t1;
+drop index it1i2 on t1;
+drop index it1i3 on t1;
+drop index it1_1024i1 on t1_1024;
+drop index it1_1024i2 on t1_1024;
+drop index it1_1024i3 on t1_1024;
+end|
+create procedure remove_t2_indexes()
+begin
+drop index it2i1 on t2;
+drop index it2i2 on t2;
+drop index it2i3 on t2;
+drop index it2i4 on t2;
+drop index it2_1024i1 on t2_1024;
+drop index it2_1024i2 on t2_1024;
+drop index it2_1024i3 on t2_1024;
+end|
+create procedure add_materialization_data()
+begin
+insert into t1 values ('1 - 03', '2 - 03', '3 - 03', 3);
+insert into t1 values ('1 - 04', '2 - 04', '3 - 04', 4);
+insert into t1 values ('1 - 05', '2 - 05', '3 - 05', 5);
+insert into t1 values ('1 - 06', '2 - 06', '3 - 06', 6);
+insert into t1 values ('1 - 07', '2 - 07', '3 - 07', 7);
+insert into t1_1024 values (concat('1 - 03', repeat('x', 1018)), concat('2 - 03', repeat('x', 1018)));
+end|
+create procedure delete_materialization_data()
+begin
+delete from t1 where a1 >= '1 - 03';
+delete from t1_1024 where a1 >= '1 - 03';
+end|
+create procedure set_all_columns_not_null()
+begin
+alter table t1 modify a1 char(8) not null, modify a2 char(8) not null, modify a3 char(8) not null;
+alter table t2 modify b1 char(8) not null, modify b2 char(8) not null, modify b3 char(8) not null;
+end|
+create procedure set_all_columns_nullable()
+begin
+alter table t1 modify a1 char(8) null, modify a2 char(8) null, modify a3 char(8) null;
+alter table t2 modify b1 char(8) null, modify b2 char(8) null, modify b3 char(8) null;
+end|
+
+/******************************************************************************
+1. Both materialization and in-to-exists are ON, make a cost-based choice.
+******************************************************************************/
+set @@optimizer_switch='materialization=on,in_to_exists=on';
+
+/* 1.1 In-to-exists is cheaper */
+call make_t1_indexes();
+/* 1.1.1 non-indexed table access */
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i2 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+3 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 5 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref it1i1,it1i3 it1i1 9 const 1 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i1,it1i2,it1i3 it1i3 18 NULL 3 Using where; Using index
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 1.1.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 9 func 2 Using index; Using where; Full scan on NULL key
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i3 9 func 2 Using index; Using where; Full scan on NULL key
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i3 9 func 2 Using index; Using where; Full scan on NULL key
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i2 it2i2 9 func 2 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 18 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i2 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 9 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 27 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref it1i1,it1i3 it1i1 9 const 1 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 9 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 18 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 9 NULL 1 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 27 NULL 1 Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 27 NULL 1 Using where; Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 27 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 9 const 2 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i1,it1i2,it1i3 it1i3 18 NULL 3 Using where; Using index
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 1.1.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i4 8 func 1 Using index; Using where
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 16 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 ref it2i4,it2i1,it2i2,it2i3 it2i4 8 func 2 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 16 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 ref it2i4,it2i1,it2i2,it2i3 it2i4 8 func 2 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 16 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i2 it2i2 8 func 2 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 16 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 16 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i2 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 8 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 24 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref it1i1,it1i3 it1i1 8 const 1 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 8 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 16 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 16 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 8 NULL 1 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 24 NULL 1 Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 24 NULL 1 Using where; Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 24 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 8 const 5 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i1,it1i2,it1i3 it1i3 16 NULL 3 Using where; Using index
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 16 NULL 3 Using where; Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+call set_all_columns_nullable();
+
+/* 1.2 Materialization is cheaper */
+call add_materialization_data();
+call remove_t1_indexes();
+/* 1.2.1 non-indexed table access */
+call remove_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+1 - 03 1
+1 - 04 0
+1 - 05 0
+1 - 06 0
+1 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+1 - 04 2 - 04
+1 - 05 2 - 05
+1 - 06 2 - 06
+1 - 07 2 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+3 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 5 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+2 - 03
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+1 - 03
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+1 - 03
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 1.2.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 9 NULL 5 Using where; Using index
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+1 - 03 1
+1 - 04 0
+1 - 05 0
+1 - 06 0
+1 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 index it2i4,it2i1,it2i2,it2i3 it2i3 18 NULL 5 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 range it2i4,it2i1,it2i2,it2i3 it2i3 9 NULL 4 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i2 it2i2 9 NULL 5 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i2,it2i3 it2i3 18 NULL 5 Using where; Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+1 - 04 2 - 04
+1 - 05 2 - 05
+1 - 06 2 - 06
+1 - 07 2 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 9 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 27 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+2 - 03
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ref it2i2 it2i2 9 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i2,it2i3 it2i4 27 NULL 5 Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 9 NULL 5 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 range NULL it2i4 27 NULL 6 Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 range NULL it2i4 27 NULL 6 Using where; Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 27 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 9 const 2 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+1 - 03
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+1 - 03
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 1.2.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 8 NULL 5 Using where; Using index
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+1 - 03 1
+1 - 04 0
+1 - 05 0
+1 - 06 0
+1 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 index it2i4,it2i1,it2i2,it2i3 it2i3 16 NULL 5 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 SUBQUERY t2 range it2i4,it2i1,it2i2,it2i3 it2i3 8 NULL 4 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i2 it2i2 8 NULL 5 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i2,it2i3 it2i3 16 NULL 5 Using where; Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+1 - 04 2 - 04
+1 - 05 2 - 05
+1 - 06 2 - 06
+1 - 07 2 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 8 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 24 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+2 - 03
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 ref it2i2 it2i2 8 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i2,it2i3 it2i4 24 NULL 5 Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 8 NULL 5 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 range NULL it2i4 24 NULL 6 Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 range NULL it2i4 24 NULL 6 Using where; Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 24 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 8 const 5 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+1 - 03
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+1 - 03
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+call set_all_columns_nullable();
+/******************************************************************************
+2. Materialization is OFF, in-to-exists is ON, materialization is cheaper.
+******************************************************************************/
+set @@optimizer_switch='materialization=off,in_to_exists=on';
+/* 2.1 non-indexed table access */
+call remove_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+1 - 03 1
+1 - 04 0
+1 - 05 0
+1 - 06 0
+1 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+1 - 04 2 - 04
+1 - 05 2 - 05
+1 - 06 2 - 06
+1 - 07 2 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+3 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 5 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+2 - 03
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+1 - 03
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+1 - 03
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 2.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 9 func 2 Using index; Using where; Full scan on NULL key
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+1 - 03 1
+1 - 04 0
+1 - 05 0
+1 - 06 0
+1 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i3 9 func 2 Using index; Using where; Full scan on NULL key
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i3 9 func 2 Using index; Using where; Full scan on NULL key
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery it2i2 it2i2 9 func 2 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 18 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+1 - 04 2 - 04
+1 - 05 2 - 05
+1 - 06 2 - 06
+1 - 07 2 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 9 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 27 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+2 - 03
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 9 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 18 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 9 NULL 1 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 27 NULL 1 Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 27 NULL 1 Using where; Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 27 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 9 const 2 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+1 - 03
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+1 - 03
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 2.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i4 8 func 1 Using index; Using where
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+1 - 03 1
+1 - 04 0
+1 - 05 0
+1 - 06 0
+1 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 ref it2i4,it2i1,it2i2,it2i3 it2i4 8 func 2 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8
+2 DEPENDENT SUBQUERY t2 ref it2i4,it2i1,it2i2,it2i3 it2i4 8 func 2 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+1 - 03 2 - 03 1
+1 - 04 2 - 04 0
+1 - 05 2 - 05 0
+1 - 06 2 - 06 0
+1 - 07 2 - 07 0
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery it2i2 it2i2 8 func 2 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 16 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+1 - 04 2 - 04
+1 - 05 2 - 05
+1 - 06 2 - 06
+1 - 07 2 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 8 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 24 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+2 - 03
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 8 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i2,it2i3 it2i4 16 func,func 1 Using index; Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 8 NULL 1 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 1 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+1 - 03 2 - 03 3 - 03 3
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 24 NULL 1 Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 index NULL it2i4 24 NULL 1 Using where; Using index
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 24 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+1 - 03x 2 - 03x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 8 const 5 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+1 - 03
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+1 - 03
+1 - 04
+1 - 05
+1 - 06
+1 - 07
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+1 - 03
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+call set_all_columns_nullable();
+/******************************************************************************
+3. Materialization is ON, in-to-exists is OFF, in-to-exists is cheaper.
+******************************************************************************/
+set @@optimizer_switch='materialization=on,in_to_exists=off';
+call delete_materialization_data();
+call make_t1_indexes();
+/* 3.1 non-indexed table access */
+call remove_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i2 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+3 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 5 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref it1i1,it1i3 it1i1 9 const 1 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i1,it1i2,it1i3 it1i3 18 NULL 3 Using where; Using index
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 3.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using index
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 9 NULL 5 Using where; Using index
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 5 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using index
+2 SUBQUERY t2 range it2i4,it2i1,it2i3 it2i3 9 NULL 4 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY t2 index NULL it2i2 9 NULL 5 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 5 Using where; Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i2 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 9 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 27 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref it1i1,it1i3 it1i1 9 const 1 Using where; Using index
+2 SUBQUERY t2 ref it2i2 it2i2 9 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY t2 index NULL it2i4 27 NULL 5 Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 9 NULL 5 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 18 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 range NULL it2i4 27 NULL 6 Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 range NULL it2i4 27 NULL 6 Using where; Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 27 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 9 const 2 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i1,it1i2,it1i3 it1i3 18 NULL 3 Using where; Using index
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 18 NULL 3 Using where; Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 9 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+/* 3.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+
+/* A. Subqueries in the SELECT clause. */
+explain
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using index
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 8 NULL 5 Using where; Using index
+select a1, a1 in (select b1 from t2 where b1 > '0') from t1;
+a1 a1 in (select b1 from t2 where b1 > '0')
+1 - 00 0
+1 - 01 1
+1 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 16 NULL 3 Using index
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 5 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+explain
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 16 NULL 3 Using index
+2 SUBQUERY t2 range it2i4,it2i1,it2i3 it2i3 8 NULL 4 Using where; Using index
+select a1, a2, (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9') from t1;
+a1 a2 (a1, a2) in (select b1, b2 from t2 where b1 > '0' and b1 < '9')
+1 - 00 2 - 00 0
+1 - 01 2 - 01 1
+1 - 02 2 - 02 1
+
+/*
+B. "Natural" examples of subqueries without grouping that
+cannot be flattened into semijoin.
+*/
+explain
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 16 NULL 3 Using where; Using index
+2 SUBQUERY t2 index NULL it2i2 8 NULL 5 Using index
+select a1 from t1 where a1 in (select b2 from t2) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 16 NULL 3 Using where; Using index
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 5 Using where; Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') or a2 < '9';
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i2 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY t2 ref it2i2 it2i2 8 func 2 Using index
+3 DEPENDENT UNION t3 index NULL it2i4 24 NULL 5 Using where; Using index
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a2 from t1 where a2 in (select b2 from t2 UNION select b3 from t2 as t3);
+a2
+2 - 01
+2 - 02
+
+explain
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref it1i1,it1i3 it1i1 8 const 1 Using where; Using index
+2 SUBQUERY t2 ref it2i2 it2i2 8 const 1 Using index condition
+select a1 from t1 where a1 = '1 - 02' and a1 in (select max(b1) from t2 where b2 = '2 - 02');
+a1
+1 - 02
+
+explain
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i3 16 NULL 3 Using where; Using index
+2 SUBQUERY t2 index NULL it2i4 24 NULL 5 Using index
+select a1, a2 from t1 where (a1, a2) in (select b1, b2 from t2 order by b3);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+
+/* C. Subqueries in the WHERE clause with GROUP BY. */
+explain
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i1 8 NULL 5 Using where; Using index
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 index it2i4,it2i1,it2i3 it2i3 16 NULL 5 Using where; Using index
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2 having b2 < '2 - 04');
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+1 - 02 2 - 02 3 - 02 2
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 range NULL it2i4 24 NULL 6 Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 group by b1, b2, b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+explain
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 range NULL it2i4 24 NULL 6 Using where; Using index for group-by
+select * from t1 where (a1, a2, a3) in (select b1, b2, b3 from t2 where b3 = '3 - 02' group by b1, b2);
+a1 a2 a3 a4
+
+explain
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 range it2i4,it2i1,it2i3 it2i4 24 NULL 2 Using where; Using index for group-by
+select * from t1 where (a1,a2,a3) in (select b1,b2,b3 from t2 where b1 = '1 - 01' group by b1,b2,b3);
+a1 a2 a3 a4
+1 - 01 2 - 01 3 - 01 1
+
+/*
+D. Subqueries for which materialization is not possible, and the
+optimizer reverts to in-to-exists.
+*/
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i3 it2_1024i3 9 func 1 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 index_subquery it2_1024i1,it2_1024i2,it2_1024i3 it2_1024i1 9 func 2 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+explain
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+explain
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL it1_1024i2 NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2_1024 range it2_1024i1,it2_1024i3 it2_1024i1 9 NULL 4 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select substring(b1,1,1024), substring(b2,1,1024) from t2_1024 where b1 > '0') or a2 < '9';
+left(a1,7) left(a2,7)
+1 - 00x 2 - 00x
+1 - 01x 2 - 01x
+
+
+/* E. Edge cases. */
+
+/* E.1 Both materialization and in_to_exists cannot be off. */
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off,in_to_exists=off';
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+ERROR HY000: At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'.
+set @@optimizer_switch = @save_optimizer_switch;
+/* E.2 Outer query without tables, always uses IN-TO-EXISTS. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY t2 index_subquery it2i4,it2i1,it2i3 it2i1 8 const 5 Using index; Using where
+select '1 - 03' in (select b1 from t2 where b1 > '0');
+'1 - 03' in (select b1 from t2 where b1 > '0')
+1
+/* E.3 Subqueries without tables. */
+explain
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i1,it1i2,it1i3 it1i3 16 NULL 3 Using where; Using index
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+select a1 from t1 where a1 in (select '1 - 03') or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+UNION subqueries are currently limited to only use IN-TO-EXISTS.
+explain
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select a1 from t1 where a1 in (select '1 - 03' UNION select '1 - 02');
+a1
+1 - 02
+/* E.4 optimize_cond detects FALSE where/having clause. */
+explain
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index it1i2 it1i3 16 NULL 3 Using where; Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select a1 from t1 where a1 in (select b1 from t2 where b1 = b2 and b2 = '1 - 03' and b1 = '1 - 02' ) or a2 < '9';
+a1
+1 - 00
+1 - 01
+1 - 02
+/* E.5 opt_sum_query detects no matching min/max row or substitutes MIN/MAX with a const. */
+TODO this test produces wrong result due to missing logic to handle the case
+when JOIN::optimize detects an empty subquery result.
+explain
+select a1 from t1 where a1 in (select max(b1) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select a1 from t1 where a1 in (select max(b1) from t2);
+a1
+
+explain
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL it1i1 8 NULL 3 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select a1 from t1 where a1 in (select max(b1) from t2 where b1 = '7 - 02');
+a1
+/* E.6 make_join_select detects impossible WHERE. *
+TODO
+/* E.7 constant optimization detects "no matching row in const table". */
+TODO
+/* E.8 Impossible WHERE noticed after reading const tables. */
+explain
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select '1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0');
+'1 - 03' in (select b1 from t2 where b1 > '0' and b1 < '0')
+0
+
+/* F. UPDATE/DELETE with subqueries. */
+
+TODO
+
+call set_all_columns_nullable();
+drop procedure make_t1_indexes;
+drop procedure make_t2_indexes;
+drop procedure remove_t1_indexes;
+drop procedure remove_t2_indexes;
+drop procedure add_materialization_data;
+drop procedure delete_materialization_data;
+drop procedure set_all_columns_not_null;
+drop procedure set_all_columns_nullable;
+drop table t1, t2, t1_1024, t2_1024;
diff --git a/mysql-test/r/subselect_mat_cost_bugs.result b/mysql-test/r/subselect_mat_cost_bugs.result
new file mode 100644
index 00000000000..919a6c6d38d
--- /dev/null
+++ b/mysql-test/r/subselect_mat_cost_bugs.result
@@ -0,0 +1,297 @@
+#
+# LP BUG#643424 valgrind warning in choose_subquery_plan()
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+c1 int(11) DEFAULT NULL,
+c2 int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY c2 (c2));
+INSERT INTO t1 VALUES (1,NULL,2);
+INSERT INTO t1 VALUES (2,7,9);
+INSERT INTO t1 VALUES (9,NULL,8);
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+c1 int(11) DEFAULT NULL,
+c2 int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY c2 (c2));
+INSERT INTO t2 VALUES (1,1,7);
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
+SELECT pk FROM t1 WHERE (c2, c1) IN (SELECT c2, c2 FROM t2);
+pk
+set session optimizer_switch=@save_optimizer_switch;
+drop table t1, t2;
+#
+# LP BUG#652727 Crash in create_ref_for_key()
+#
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+c1 int(11) DEFAULT NULL,
+PRIMARY KEY (pk));
+INSERT INTO t2 VALUES (10,7);
+INSERT INTO t2 VALUES (11,1);
+INSERT INTO t2 VALUES (17,NULL);
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+c1 int(11) DEFAULT NULL,
+PRIMARY KEY (pk));
+INSERT INTO t1 VALUES (15,1);
+INSERT INTO t1 VALUES (19,NULL);
+CREATE TABLE t3 (c2 int(11) DEFAULT NULL, KEY c2 (c2));
+INSERT INTO t3 VALUES (1);
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
+SELECT c2
+FROM t3
+WHERE (2, 6) IN (SELECT t1.c1, t1.c1 FROM t1 STRAIGHT_JOIN t2 ON t2.pk = t1.pk);
+c2
+set session optimizer_switch=@save_optimizer_switch;
+drop table t1, t2, t3;
+#
+# LP BUG#641245 Crash in Item_equal::contains
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+c1 int(11) DEFAULT NULL,
+c2 int(11) DEFAULT NULL,
+c3 varchar(1) DEFAULT NULL,
+c4 varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY c2 (c2),
+KEY c3 (c3,c2));
+INSERT INTO t1 VALUES (10,7,8,'v','v');
+INSERT INTO t1 VALUES (11,1,9,'r','r');
+INSERT INTO t1 VALUES (12,5,9,'a','a');
+create table t1a like t1;
+insert into t1a select * from t1;
+create table t1b like t1;
+insert into t1b select * from t1;
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+c1 int(11) DEFAULT NULL,
+c2 int(11) DEFAULT NULL,
+c3 varchar(1) DEFAULT NULL,
+c4 varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY c2 (c2),
+KEY c3 (c3,c2));
+INSERT INTO t2 VALUES (1,NULL,2,'w','w');
+INSERT INTO t2 VALUES (2,7,9,'m','m');
+set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
+EXPLAIN EXTENDED SELECT pk
+FROM t1
+WHERE c1 IN
+(SELECT t1a.c1
+FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN
+t1a ON (t1a.c2 = t1b.pk AND 2)
+WHERE t1.pk) ;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+2 DEPENDENT SUBQUERY t2 index c3 c3 9 NULL 2 100.00 Using index
+2 DEPENDENT SUBQUERY t1b ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t1a ref c2 c2 5 test.t1b.pk 2 100.00 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <expr_cache><`test`.`t1`.`c1`,`test`.`t1`.`pk`>(<in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t1a`.`c1` from `test`.`t1b` join `test`.`t2` left join `test`.`t1a` on((2 and (`test`.`t1a`.`c2` = `test`.`t1b`.`pk`))) where (`test`.`t1`.`pk` and (<cache>(`test`.`t1`.`c1`) = `test`.`t1a`.`c1`) and (`test`.`t1b`.`c4` = `test`.`t2`.`c3`)))))
+SELECT pk
+FROM t1
+WHERE c1 IN
+(SELECT t1a.c1
+FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN
+t1a ON (t1a.c2 = t1b.pk AND 2)
+WHERE t1.pk) ;
+pk
+DROP TABLE t1, t1a, t1b, t2;
+#
+# LP BUG#714808 Assertion `outer_lookup_keys <= outer_record_count'
+# failed with materialization
+CREATE TABLE t1 ( pk int(11), PRIMARY KEY (pk)) ;
+CREATE TABLE t2 ( f2 int(11)) ;
+CREATE TABLE t3 ( f1 int(11), f3 varchar(1), KEY (f1)) ;
+INSERT INTO t3 VALUES (7,'f');
+set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
+EXPLAIN
+SELECT t1.*
+FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
+WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+SELECT t1.*
+FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
+WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
+pk
+drop table t1,t2,t3;
+#
+# LP BUG#714999 Second crash in select_describe() with nested subqueries
+#
+CREATE TABLE t1 ( pk int(11)) ;
+INSERT INTO t1 VALUES (29);
+CREATE TABLE t2 ( f1 varchar(1)) ;
+INSERT INTO t2 VALUES ('f'),('d');
+CREATE TABLE t3 ( f2 varchar(1)) ;
+EXPLAIN SELECT f2 FROM t3 WHERE (
+SELECT MAX( pk ) FROM t1
+WHERE EXISTS (
+SELECT DISTINCT f1
+FROM t2
+)
+) IS NULL ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 SUBQUERY t1 system NULL NULL NULL NULL 1
+3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary
+drop table t1, t2, t3;
+#
+# LP BUG#715034 Item_sum_distinct::clear(): Assertion `tree != 0' failed
+#
+CREATE TABLE t2 ( f2 int(11)) ;
+CREATE TABLE t1 ( f3 int(11), KEY (f3)) ;
+INSERT INTO t1 VALUES (6),(4);
+EXPLAIN
+SELECT * FROM (SELECT * FROM t2) AS a2
+WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+3 SUBQUERY t1 index NULL f3 5 NULL 2 Using index
+insert into t2 values (1),(2);
+EXPLAIN
+SELECT * FROM (SELECT * FROM t2) AS a2
+WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+3 SUBQUERY t1 index NULL f3 5 NULL 2 Using index
+drop table t1,t2;
+#
+# LP BUG#715027 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
+#
+CREATE TABLE t1 ( f1 int(11), PRIMARY KEY (f1)) ;
+INSERT INTO t1 VALUES (28),(29);
+CREATE TABLE t2 ( f2 int(11), f3 int(11), f10 varchar(1)) ;
+INSERT INTO t2 VALUES (NULL,6,'f'),(4,2,'d');
+EXPLAIN
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+SELECT t2.f2
+FROM t2 JOIN t1 ON t1.f1
+WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using filesort
+1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 test.t2.f3 1 Using index
+3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
+3 DEPENDENT SUBQUERY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+SELECT t2.f2
+FROM t2 JOIN t1 ON t1.f1
+WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+field1
+drop table t1,t2;
+#
+# LP BUG#718578 Yet another Assertion `!table ||
+# (!table->read_set || bitmap_is_set(table->read_set, field_index))'
+CREATE TABLE t1 ( f1 int(11), f2 int(11), f3 int(11)) ;
+INSERT IGNORE INTO t1 VALUES (28,5,6),(29,NULL,4);
+CREATE TABLE t2 ( f10 varchar(1) );
+INSERT IGNORE INTO t2 VALUES (NULL);
+SELECT f1 AS field1
+FROM ( SELECT * FROM t1 ) AS alias1
+WHERE (SELECT t1.f1
+FROM t2 JOIN t1 ON t1.f2
+WHERE alias1.f3 AND t1.f3) AND f2
+ORDER BY field1;
+field1
+28
+drop table t1,t2;
+#
+# LP BUG#601124 Bug in eliminate_item_equal
+# leads to crash in Item_func::Item_func
+CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ;
+INSERT INTO t1 VALUES (5,'m'),(NULL,'c');
+CREATE TABLE t2 ( f2 int(11), f3 varchar(1)) ;
+INSERT INTO t2 VALUES (6,'f'),(2,'d');
+CREATE TABLE t3 ( f2 int(11), f3 varchar(1)) ;
+INSERT INTO t3 VALUES (6,'f'),(2,'d');
+SELECT * FROM t3
+WHERE ( f2 ) IN (SELECT t1.f1
+FROM t1 STRAIGHT_JOIN t2 ON t2.f3 = t1.f3
+WHERE t2.f3 = 'c');
+f2 f3
+drop table t1,t2,t3;
+#
+# LP BUG#718593 Crash in substitute_for_best_equal_field -> eliminate_item_equal ->
+# Item_field::find_item_equal -> Item_equal::contains
+#
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch = 'semijoin=off';
+CREATE TABLE t1 ( f3 int(11), f10 varchar(1), f11 varchar(1)) ;
+INSERT IGNORE INTO t1 VALUES (6,'f','f'),(2,'d','d');
+CREATE TABLE t2 ( f12 int(11), f13 int(11)) ;
+insert into t2 values (1,2), (3,4);
+EXPLAIN
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+SELECT alias2.f3
+FROM t1 AS alias1 JOIN t1 AS alias2 ON alias2.f10 = alias1.f11
+WHERE alias1.f11 OR alias1.f3 = 50 AND alias1.f10
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY alias1 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY alias2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+SELECT alias2.f3
+FROM t1 AS alias1 JOIN t1 AS alias2 ON alias2.f10 = alias1.f11
+WHERE alias1.f11 OR alias1.f3 = 50 AND alias1.f10
+);
+f12 f13
+EXPLAIN
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+SELECT alias2.f3
+FROM t1 AS alias1, t1 AS alias2
+WHERE (alias2.f10 = alias1.f11) AND (alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY alias1 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY alias2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+SELECT alias2.f3
+FROM t1 AS alias1, t1 AS alias2
+WHERE (alias2.f10 = alias1.f11) AND (alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
+f12 f13
+set @@optimizer_switch=@save_optimizer_switch;
+drop table t1, t2;
+#
+# MWL#89: test introduced after Sergey Petrunia's review - test that
+# keyparts wihtout index prefix are used with the IN-EXISTS strategy.
+#
+create table t1 (c1 int);
+insert into t1 values (1), (2), (3);
+create table t2 (kp1 int, kp2 int, c2 int, filler char(100));
+insert into t2 values (0,0,0,'filler'),(0,1,1,'filler'),(0,2,2,'filler'),(0,3,3,'filler');
+create index key1 on t2 (kp1, kp2);
+create index key2 on t2 (kp1);
+create index key3 on t2 (kp2);
+set session optimizer_switch='default';
+analyze table t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status OK
+explain
+select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery key1,key2,key3 key1 10 func,const 1 Using where
+select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
+c1
+drop table t1, t2;
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index 7ab96bad552..f9a4a4373c2 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -1,6 +1,6 @@
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
-1
+0
set optimizer_switch='materialization=off';
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12;
drop view if exists v2;
@@ -57,7 +57,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><'1'>((select '1')) = 1)
+Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><1>((select 1)) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
@@ -206,11 +206,10 @@ select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> system NULL NULL NULL NULL 1 100.00
-3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
Warnings:
-Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
+Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,`test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1)
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
a
2
@@ -277,7 +276,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2);
a
7
@@ -321,7 +320,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select <expr_cache><`test`.`t2`.`a`>((select '2' from `test`.`t1` where ('2' = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
+Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from `test`.`t1` where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
@@ -370,11 +369,11 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
-4 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
-3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings:
-Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
+Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
@@ -427,7 +426,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where 1
+Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
drop table t1;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
@@ -512,6 +511,9 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
+show warnings;
+Level Code Message
+Error 1242 Subquery returns more than 1 row
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
@@ -547,13 +549,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
+Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
+Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = 3))
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
@@ -593,7 +595,7 @@ a b
select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
-delete from t1 where b = (select b from t1);
+delete from t1 where b in (select b from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
@@ -913,7 +915,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3;
create table t1 (a float);
select 10.5 IN (SELECT * from t1 LIMIT 1);
@@ -1184,9 +1186,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
@@ -1194,9 +1196,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1;
CREATE TABLE `t1` (
`i` int(11) NOT NULL default '0',
@@ -1344,7 +1346,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 100 100.00 Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`)
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
@@ -1354,7 +1356,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 100 100.00 Using where; Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
@@ -1365,7 +1367,7 @@ explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.61 Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 11 100.00 Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`))
insert into t1 values (3,31);
@@ -1381,7 +1383,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 100 100.00 Using where; Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30))
drop table t0, t1, t2, t3;
@@ -1507,7 +1509,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`))))
select * from t3 where a >= some (select b from t2);
a
explain extended select * from t3 where a >= some (select b from t2);
@@ -1515,7 +1517,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2 group by 1);
a
6
@@ -1526,7 +1528,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1))))
select * from t3 where a >= some (select b from t2 group by 1);
a
explain extended select * from t3 where a >= some (select b from t2 group by 1);
@@ -1534,39 +1536,39 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= any (select b from t2);
a
explain extended select * from t3 where NULL >= any (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= any (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= some (select b from t2);
a
explain extended select * from t3 where NULL >= some (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= some (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
insert into t2 values (2,2), (2,1), (3,3), (3,1);
select * from t3 where a > all (select max(b) from t2 group by a);
a
@@ -1575,9 +1577,9 @@ a
explain extended select * from t3 where a > all (select max(b) from t2 group by a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))))
drop table t2, t3;
CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
@@ -1628,7 +1630,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 system NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
+Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(<in_optimizer>('f',('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`))))
drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
@@ -2841,7 +2843,7 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `tes
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1`
DROP TABLE t1,t2;
@@ -3113,10 +3115,10 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
-4
1
+2
3
+4
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
@@ -3125,8 +3127,8 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
1
+2
3
4
SELECT a FROM t1
@@ -3423,7 +3425,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary
ALTER TABLE t1 ADD INDEX(a);
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
a b
@@ -3434,7 +3436,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort
+2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
DROP TABLE t1;
create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
@@ -4324,15 +4326,15 @@ INSERT INTO t1 VALUES (1),(2);
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a);
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
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having 1)))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having 1))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
DROP TABLE t1;
#
# Bug#45061: Incorrectly market field caused wrong result.
@@ -5070,7 +5072,66 @@ pk i
12 5
15 0
DROP table t1,t2;
+#
+# Bug#751350: crash with pushed condition for outer references when
+# there should be none of such conditions
+#
+CREATE TABLE t1 (a int, b int) ;
+INSERT INTO t1 VALUES (0,0),(0,0);
+EXPLAIN
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+b
+0
+DROP TABLE t1;
+#
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
+# BUG#779885: Crash in eliminate_item_equal with materialization=on in
+# maria-5.3
+#
+CREATE TABLE t1 ( f1 int );
+INSERT INTO t1 VALUES (19), (20);
+CREATE TABLE t2 ( f10 varchar(32) );
+INSERT INTO t2 VALUES ('c'),('d');
+CREATE TABLE t3 ( f10 varchar(32) );
+INSERT INTO t3 VALUES ('a'),('b');
+SELECT *
+FROM t1
+WHERE
+( 't' ) IN (
+SELECT t3.f10
+FROM t3
+JOIN t2
+ON t2.f10 = t3.f10
+);
+f1
+DROP TABLE t1,t2,t3;
+End of 5.3 tests
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
-1
+0
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 6f923c0e626..493ab9dba59 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -54,7 +54,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><'1'>((select '1')) = 1)
+Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><1>((select 1)) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
@@ -203,11 +203,10 @@ select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> system NULL NULL NULL NULL 1 100.00
-3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
Warnings:
-Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
+Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,`test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1)
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
a
2
@@ -274,7 +273,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2);
a
7
@@ -318,7 +317,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select <expr_cache><`test`.`t2`.`a`>((select '2' from `test`.`t1` where ('2' = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
+Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from `test`.`t1` where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
@@ -367,11 +366,11 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
-4 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
-3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings:
-Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
+Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
@@ -424,7 +423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where 1
+Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
drop table t1;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
@@ -509,6 +508,9 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
+show warnings;
+Level Code Message
+Error 1242 Subquery returns more than 1 row
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
@@ -544,13 +546,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
+Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
+Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = 3))
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
@@ -590,7 +592,7 @@ a b
select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
-delete from t1 where b = (select b from t1);
+delete from t1 where b in (select b from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
@@ -910,7 +912,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3;
create table t1 (a float);
select 10.5 IN (SELECT * from t1 LIMIT 1);
@@ -1181,9 +1183,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
@@ -1191,9 +1193,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1;
CREATE TABLE `t1` (
`i` int(11) NOT NULL default '0',
@@ -1321,7 +1323,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
drop table t1, t2, t3;
create table t1 (a int, b int, index a (a,b));
create table t2 (a int, index a (a));
@@ -1364,7 +1366,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index
2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
insert into t1 values (3,31);
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
@@ -1504,7 +1506,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`))))
select * from t3 where a >= some (select b from t2);
a
explain extended select * from t3 where a >= some (select b from t2);
@@ -1512,7 +1514,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2 group by 1);
a
6
@@ -1523,7 +1525,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1))))
select * from t3 where a >= some (select b from t2 group by 1);
a
explain extended select * from t3 where a >= some (select b from t2 group by 1);
@@ -1531,39 +1533,39 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= any (select b from t2);
a
explain extended select * from t3 where NULL >= any (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= any (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= some (select b from t2);
a
explain extended select * from t3 where NULL >= some (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= some (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
insert into t2 values (2,2), (2,1), (3,3), (3,1);
select * from t3 where a > all (select max(b) from t2 group by a);
a
@@ -1572,9 +1574,9 @@ a
explain extended select * from t3 where a > all (select max(b) from t2 group by a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))))
drop table t2, t3;
CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
@@ -1625,7 +1627,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 system NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
+Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(<in_optimizer>('f',('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`))))
drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
@@ -2838,7 +2840,7 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `tes
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1`
DROP TABLE t1,t2;
@@ -3110,10 +3112,10 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
-4
1
+2
3
+4
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
@@ -3122,8 +3124,8 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
1
+2
3
4
SELECT a FROM t1
@@ -3420,7 +3422,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary
ALTER TABLE t1 ADD INDEX(a);
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
a b
@@ -3431,7 +3433,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort
+2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
DROP TABLE t1;
create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
@@ -4321,15 +4323,15 @@ INSERT INTO t1 VALUES (1),(2);
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a);
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
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having 1)))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having 1))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
DROP TABLE t1;
#
# Bug#45061: Incorrectly market field caused wrong result.
@@ -5067,4 +5069,63 @@ pk i
12 5
15 0
DROP table t1,t2;
+#
+# Bug#751350: crash with pushed condition for outer references when
+# there should be none of such conditions
+#
+CREATE TABLE t1 (a int, b int) ;
+INSERT INTO t1 VALUES (0,0),(0,0);
+EXPLAIN
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+b
+0
+DROP TABLE t1;
+#
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
+# BUG#779885: Crash in eliminate_item_equal with materialization=on in
+# maria-5.3
+#
+CREATE TABLE t1 ( f1 int );
+INSERT INTO t1 VALUES (19), (20);
+CREATE TABLE t2 ( f10 varchar(32) );
+INSERT INTO t2 VALUES ('c'),('d');
+CREATE TABLE t3 ( f10 varchar(32) );
+INSERT INTO t3 VALUES ('a'),('b');
+SELECT *
+FROM t1
+WHERE
+( 't' ) IN (
+SELECT t3.f10
+FROM t3
+JOIN t2
+ON t2.f10 = t3.f10
+);
+f1
+DROP TABLE t1,t2,t3;
+End of 5.3 tests
set optimizer_switch=default;
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index 889735b1dc2..434bcd33a21 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -54,7 +54,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><'1'>((select '1')) = 1)
+Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><1>((select 1)) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
@@ -203,11 +203,10 @@ select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> system NULL NULL NULL NULL 1 100.00
-3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
Warnings:
-Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
+Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,`test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1)
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
a
2
@@ -274,7 +273,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2);
a
7
@@ -318,7 +317,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select <expr_cache><`test`.`t2`.`a`>((select '2' from `test`.`t1` where ('2' = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
+Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from `test`.`t1` where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2`
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
ERROR 21000: Subquery returns more than 1 row
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
@@ -367,11 +366,11 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
-4 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
-3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings:
-Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
+Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
@@ -424,7 +423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where 1
+Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
drop table t1;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
@@ -509,6 +508,9 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
ERROR 21000: Subquery returns more than 1 row
+show warnings;
+Level Code Message
+Error 1242 Subquery returns more than 1 row
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
@@ -544,13 +546,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
+Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
+Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = 3))
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
@@ -590,7 +592,7 @@ a b
select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
-delete from t1 where b = (select b from t1);
+delete from t1 where b in (select b from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
@@ -910,7 +912,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3;
create table t1 (a float);
select 10.5 IN (SELECT * from t1 LIMIT 1);
@@ -1181,9 +1183,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
@@ -1191,9 +1193,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1;
CREATE TABLE `t1` (
`i` int(11) NOT NULL default '0',
@@ -1298,9 +1300,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
2
@@ -1308,9 +1310,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
@@ -1318,10 +1320,10 @@ a
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 3 100.00 Using index
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where
+2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`b` = `test`.`t3`.`a`) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
drop table t1, t2, t3;
create table t1 (a int, b int, index a (a,b));
create table t2 (a int, index a (a));
@@ -1341,9 +1343,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a))))
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
2
@@ -1351,9 +1353,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
@@ -1361,10 +1363,10 @@ a
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t3 index a a 5 NULL 3 100.00 Using index
-2 SUBQUERY t1 index NULL a 10 NULL 10004 100.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index
+2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`b` = `test`.`t3`.`a`) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
insert into t1 values (3,31);
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
@@ -1378,9 +1380,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
-2 SUBQUERY t1 index NULL a 10 NULL 10005 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where ((`test`.`t2`.`a` = `materialized subselect`.`a`))))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))))
drop table t0, t1, t2, t3;
create table t1 (a int, b int);
create table t2 (a int, b int);
@@ -1504,7 +1506,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < (select max(NULL) from `test`.`t2`))))
select * from t3 where a >= some (select b from t2);
a
explain extended select * from t3 where a >= some (select b from t2);
@@ -1512,7 +1514,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(NULL) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2 group by 1);
a
6
@@ -1523,7 +1525,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < <max>(select NULL from `test`.`t2` group by 1))))
select * from t3 where a >= some (select b from t2 group by 1);
a
explain extended select * from t3 where a >= some (select b from t2 group by 1);
@@ -1531,39 +1533,39 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= any (select b from t2);
a
explain extended select * from t3 where NULL >= any (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= any (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
select * from t3 where NULL >= some (select b from t2);
a
explain extended select * from t3 where NULL >= some (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(NULL) from `test`.`t2`))))
select * from t3 where NULL >= some (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select NULL from `test`.`t2` group by 1))))
insert into t2 values (2,2), (2,1), (3,3), (3,1);
select * from t3 where a > all (select max(b) from t2 group by a);
a
@@ -1572,9 +1574,9 @@ a
explain extended select * from t3 where a > all (select max(b) from t2 group by a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))))
drop table t2, t3;
CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
@@ -1625,7 +1627,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 system NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 'e' AS `s1` from `test`.`t1` where 1
+Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(<in_optimizer>('f',('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`))))
drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
@@ -2832,13 +2834,13 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cac
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),(`test`.`t1`.`one`,`test`.`t1`.`two`) in ( <materialize> (select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = 'N') ), <primary_index_lookup>(`test`.`t1`.`one` in <temporary table> on distinct_key where ((`test`.`t1`.`one` = `materialized subselect`.`one`) and (`test`.`t1`.`two` = `materialized subselect`.`two`))))))
+Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`)))))
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1`
DROP TABLE t1,t2;
@@ -3110,10 +3112,10 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
-4
1
+2
3
+4
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
@@ -3122,8 +3124,8 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
1
+2
3
4
SELECT a FROM t1
@@ -3420,7 +3422,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary
ALTER TABLE t1 ADD INDEX(a);
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
a b
@@ -3431,7 +3433,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
DROP TABLE t1;
create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
@@ -4201,7 +4203,7 @@ CREATE INDEX I2 ON t1 (b);
EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY t1 index NULL I1 2 NULL 2 Using index
+2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
a b
CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
@@ -4211,14 +4213,14 @@ CREATE INDEX I2 ON t2 (b);
EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY t2 index NULL I1 4 NULL 2 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 2 Using index; Using where
SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
a b
EXPLAIN
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY t1 index NULL I1 2 NULL 2 Using where; Using index
+2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
a b
DROP TABLE t1,t2;
@@ -4320,16 +4322,16 @@ CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a);
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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,1 in ( <materialize> (select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `materialized subselect`.`1`))))))
+Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))))
DROP TABLE t1;
#
# Bug#45061: Incorrectly market field caused wrong result.
@@ -5014,8 +5016,8 @@ FROM it2,it3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot1 ALL NULL NULL NULL NULL 2
1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
-2 SUBQUERY it2 ALL NULL NULL NULL NULL 4
-2 SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY it2 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
#
# Bug#729039: NULL keys used to evaluate subquery
@@ -5059,12 +5061,71 @@ INSERT INTO t2 VALUES (15,4);
EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index
-2 SUBQUERY it index NULL PRIMARY 4 NULL 3 Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index
+2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using index
SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1);
pk i
11 0
12 5
15 0
DROP table t1,t2;
+#
+# Bug#751350: crash with pushed condition for outer references when
+# there should be none of such conditions
+#
+CREATE TABLE t1 (a int, b int) ;
+INSERT INTO t1 VALUES (0,0),(0,0);
+EXPLAIN
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary
+SELECT b FROM t1
+WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+GROUP BY b;
+b
+0
+DROP TABLE t1;
+#
+# Bug #11765713 58705:
+# OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+# CREATED BY OPT_SUM_QUERY
+#
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1)
+);
+ERROR 21000: Subquery returns more than 1 row
+SELECT 1 as foo FROM t1 WHERE a < SOME
+(SELECT a FROM t1 WHERE a <=>
+(SELECT a FROM t1 where a is null)
+);
+foo
+DROP TABLE t1;
+#
+# BUG#779885: Crash in eliminate_item_equal with materialization=on in
+# maria-5.3
+#
+CREATE TABLE t1 ( f1 int );
+INSERT INTO t1 VALUES (19), (20);
+CREATE TABLE t2 ( f10 varchar(32) );
+INSERT INTO t2 VALUES ('c'),('d');
+CREATE TABLE t3 ( f10 varchar(32) );
+INSERT INTO t3 VALUES ('a'),('b');
+SELECT *
+FROM t1
+WHERE
+( 't' ) IN (
+SELECT t3.f10
+FROM t3
+JOIN t2
+ON t2.f10 = t3.f10
+);
+f1
+DROP TABLE t1,t2,t3;
+End of 5.3 tests
set optimizer_switch=default;
diff --git a/mysql-test/r/subselect_partial_match.result b/mysql-test/r/subselect_partial_match.result
index 13f002235da..9d604cc1507 100644
--- a/mysql-test/r/subselect_partial_match.result
+++ b/mysql-test/r/subselect_partial_match.result
@@ -26,11 +26,10 @@ set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merg
EXPLAIN EXTENDED
SELECT * FROM (SELECT * FROM t1 WHERE a1 NOT IN (SELECT b2 FROM t2)) table1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 const row not found
-2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select NULL AS `a1`,NULL AS `a2` from (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ()))))) `table1`
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b2` from `test`.`t2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery3>`.`b2`)))))))
DROP TABLE t1, t2;
set @@optimizer_switch=@save_optimizer_switch;
#
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result
index 1fc5955f493..364813030b2 100644
--- a/mysql-test/r/subselect_sj.result
+++ b/mysql-test/r/subselect_sj.result
@@ -406,24 +406,6 @@ SELECT t1 .varchar_key from t1
int_key
9
7
-SELECT t0.int_key
-FROM t0
-WHERE t0.varchar_nokey IN (
-SELECT t1_1 .varchar_key
-FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
-);
-int_key
-9
-7
-SELECT t0.int_key
-FROM t0, t2
-WHERE t0.varchar_nokey IN (
-SELECT t1_1 .varchar_key
-FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
-);
-int_key
-9
-7
DROP TABLE t0, t1, t2;
# End of bug#46550
#
@@ -774,11 +756,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
show warnings;
Level Code Message
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
select a from t1
where a in (select c from t2 where d >= some(select e from t3 where b=e));
a
@@ -811,10 +793,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
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
-1 PRIMARY subselect2 eq_ref unique_key unique_key 13 func 1 1.00
-2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Rowid-ordered scan
+1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Rowid-ordered scan; FirstMatch(t1)
Warnings:
-Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`pk` > 0))
+Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
pk
2
@@ -980,10 +961,9 @@ FROM t1
WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
-1 PRIMARY subselect2 eq_ref unique_key unique_key 8 func 1 1.00
-2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
+1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 100.00 Using where; FirstMatch(t2)
Warnings:
-Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_key` < 'n') xor `test`.`t1`.`pk`))
+Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey`) and (`test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
SELECT varchar_nokey
FROM t2
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
@@ -1061,11 +1041,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%')
AND t1.val IN (SELECT t3.val FROM t3
WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%');
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY subselect3 eq_ref unique_key unique_key 14 func 1
-1 PRIMARY subselect2 eq_ref unique_key unique_key 14 func 1
-3 SUBQUERY t3 ALL NULL NULL NULL NULL 5 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary
+1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join)
SELECT *
FROM t1
WHERE t1.val IN (SELECT t2.val FROM t2
@@ -1240,4 +1218,112 @@ IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
AND pk = 9;
datetime_key
DROP TABLE t1, t2, t3;
+#
+# BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
+#
+CREATE TABLE t1 ( t1field integer, primary key (t1field));
+CREATE TABLE t2 ( t2field integer, primary key (t2field));
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t2 VALUES (2),(3),(4);
+explain
+SELECT * FROM t1 A
+WHERE
+A.t1field IN (SELECT A.t1field FROM t2 B) AND
+A.t1field IN (SELECT C.t2field FROM t2 C
+WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index; Start temporary
+1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; End temporary; Using join buffer (flat, BNL join)
+1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
+1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
+SELECT * FROM t1 A
+WHERE
+A.t1field IN (SELECT A.t1field FROM t2 B) AND
+A.t1field IN (SELECT C.t2field FROM t2 C
+WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
+t1field
+2
+3
+drop table t1,t2;
+#
+# BUG#787299: Valgrind complains on a join query with two IN subqueries
+#
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+create table t2 as select * from t1;
+select * from t1 A, t1 B
+where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
+a a
+1 1
+2 2
+3 3
+explain
+select * from t1 A, t1 B
+where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY A ALL NULL NULL NULL NULL 3 Start temporary
+1 PRIMARY B ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY C ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY D ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (flat, BNL join)
+drop table t1, t2;
+#
+# BUG#784441: Abort on semijoin with a view as the inner table
+#
+CREATE TABLE t1 (a int) ;
+INSERT INTO t1 VALUES (1), (1);
+CREATE TABLE t2 (a int) ;
+INSERT INTO t2 VALUES (1), (1);
+CREATE VIEW v1 AS SELECT 1;
+EXPLAIN
+SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived3> system NULL NULL NULL NULL 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
+a a
+1 1
+1 1
+1 1
+1 1
+DROP VIEW v1;
+DROP TABLE t1,t2;
+#
+# BUG#751439 Assertion `!table->file || table->file->inited == handler::NONE' failed with subquery
+#
+CREATE TABLE t1 ( f10 int, f11 int) ;
+INSERT IGNORE INTO t1 VALUES (0,0),(0,0);
+CREATE TABLE t2 ( f11 int);
+INSERT IGNORE INTO t2 VALUES (0),(0);
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+SELECT alias1.f11 AS field2
+FROM ( t3 AS alias2 JOIN t1 AS alias3 ON alias3.f10 = 1)
+LEFT JOIN ( t2 AS alias1 ) ON alias3.f11 = 1
+WHERE alias2.f11 IN ( SELECT f11 FROM t2 )
+GROUP BY field2 ;
+field2
+drop table t1, t2, t3;
+#
+# BUG#778406 Crash in hp_movelink with Aria engine and subqueries
+#
+CREATE TABLE t4 (f10 varchar(32) , KEY (f10)) ENGINE=Aria;
+INSERT INTO t4 VALUES ('x'),('m'),('c');
+CREATE TABLE t1 (f11 int) ENGINE=Aria;
+INSERT INTO t1 VALUES (0),(0),(0);
+CREATE TABLE t2 ( f10 int) ENGINE=Aria;
+INSERT INTO t2 VALUES (0),(0),(0);
+CREATE TABLE t3 ( f10 int, f11 int) ENGINE=Aria;
+SELECT *
+FROM t4
+WHERE f10 IN
+( SELECT t1.f11
+FROM t1
+LEFT JOIN t2 JOIN t3 ON t3.f10 = t2.f10 ON t3.f11 != 0 );
+f10
+x
+m
+c
+drop table t1,t2,t3,t4;
set @@optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/r/subselect_sj2.result b/mysql-test/r/subselect_sj2.result
index 56c0f45ea1d..45dd12a6b77 100644
--- a/mysql-test/r/subselect_sj2.result
+++ b/mysql-test/r/subselect_sj2.result
@@ -32,9 +32,8 @@ a b
9 5
explain select * from t2 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3
-1 PRIMARY t2 ref b b 5 test.t1.a 2
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
+1 PRIMARY t2 ref b b 5 test.t1.a 2 End temporary
select * from t2 where b in (select a from t1);
a b
1 1
@@ -51,9 +50,8 @@ primary key(pk1, pk2, pk3)
insert into t3 select a,a, a,a,a from t0;
explain select * from t3 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL b NULL NULL NULL 10
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
+1 PRIMARY t3 ref b b 5 test.t1.a 1 End temporary
select * from t3 where b in (select a from t1);
a b pk1 pk2 pk3
1 1 1 1 1
@@ -75,9 +73,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
from t0 A, t0 B where B.a <5;
explain select * from t3 where b in (select a from t0);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref b b 5 test.t0.a 1
-2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t3 ref b b 5 test.t0.a 1 End temporary
set @save_ecp= @@engine_condition_pushdown;
set engine_condition_pushdown=0;
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
@@ -101,9 +98,8 @@ set join_buffer_size= @save_join_buffer_size;
set max_heap_table_size= @save_max_heap_table_size;
explain select * from t1 where a in (select b from t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t2 index b b 5 NULL 10 Using index
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1)
select * from t1;
a b
1 1
@@ -130,9 +126,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
-1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join)
-2 SUBQUERY it ALL NULL NULL NULL NULL 22
+1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
+1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; End temporary; Using join buffer (flat, BNL join)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
@@ -164,8 +159,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY it ALL NULL NULL NULL NULL 32
+1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
@@ -198,9 +192,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
-1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join)
-2 SUBQUERY it ALL NULL NULL NULL NULL 22
+1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
+1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; End temporary; Using join buffer (flat, BNL join)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
@@ -232,8 +225,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY it ALL NULL NULL NULL NULL 52
+1 PRIMARY it ALL NULL NULL NULL NULL 52 Using where; FirstMatch(ot)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
@@ -303,6 +295,8 @@ Percentage float(3,1) NOT NULL default '0.0',
PRIMARY KEY (Country, Language),
INDEX (Percentage)
);
+set @bug35674_save_optimizer_switch=@@optimizer_switch;
+set optimizer_switch='materialization=off';
EXPLAIN
SELECT Name FROM t2
WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
@@ -311,9 +305,10 @@ t2.Code IN (SELECT Country FROM t3
WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan
-1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where
+1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where
+1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; End temporary
+set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (
Code char(3) NOT NULL DEFAULT '',
@@ -349,8 +344,7 @@ WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
-2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
+1 PRIMARY t2 ref CountryCode CountryCode 3 test.t1.Code 18 Using where; FirstMatch(t1)
SELECT Name FROM t1
WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
@@ -360,6 +354,10 @@ Canada
China
Czech Republic
drop table t1, t2;
+drop procedure if exists p1;
+drop procedure if exists p2;
+drop procedure if exists p3;
+drop procedure if exists p4;
CREATE TABLE t1(a INT);
CREATE TABLE t2(c INT);
CREATE PROCEDURE p1(v1 int)
@@ -692,9 +690,8 @@ alter table t3 add primary key(id), add key(a);
The following must use loose index scan over t3, key a:
explain select count(a) from t2 where a in ( SELECT a FROM t3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 index a a 5 NULL 1000 Using index
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t3 index a a 5 NULL 30000 Using index
+1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
+1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
select count(a) from t2 where a in ( SELECT a FROM t3);
count(a)
1000
@@ -724,3 +721,26 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch(t2)
drop table t2, t3;
+#
+# BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
+#
+CREATE TABLE t1 ( f1 int NOT NULL , f10 int) ;
+INSERT IGNORE INTO t1 VALUES (25,0),(29,0);
+CREATE TABLE t2 ( f10 int) ENGINE=InnoDB;
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+SELECT alias1.f10 AS field2
+FROM t2 AS alias1
+JOIN (
+t3 AS alias2
+JOIN t1 AS alias3
+ON alias3.f10
+) ON alias3.f1
+WHERE alias2.f11 IN (
+SELECT SQ4_alias1.f10
+FROM t1 AS SQ4_alias1
+LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10
+)
+GROUP BY field2;
+field2
+drop table t1, t2, t3;
diff --git a/mysql-test/r/subselect_sj2_jcl6.result b/mysql-test/r/subselect_sj2_jcl6.result
index 31da487158e..45cce630a22 100644
--- a/mysql-test/r/subselect_sj2_jcl6.result
+++ b/mysql-test/r/subselect_sj2_jcl6.result
@@ -39,9 +39,8 @@ a b
9 5
explain select * from t2 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3
-1 PRIMARY t2 ref b b 5 test.t1.a 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
+1 PRIMARY t2 ref b b 5 test.t1.a 2 End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
select * from t2 where b in (select a from t1);
a b
1 1
@@ -58,9 +57,8 @@ primary key(pk1, pk2, pk3)
insert into t3 select a,a, a,a,a from t0;
explain select * from t3 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL b NULL NULL NULL 10
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
+1 PRIMARY t3 ref b b 5 test.t1.a 1 End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
select * from t3 where b in (select a from t1);
a b pk1 pk2 pk3
1 1 1 1 1
@@ -82,9 +80,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
from t0 A, t0 B where B.a <5;
explain select * from t3 where b in (select a from t0);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10
-1 PRIMARY t3 ref b b 5 test.t0.a 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Start temporary
+1 PRIMARY t3 ref b b 5 test.t0.a 1 End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
set @save_ecp= @@engine_condition_pushdown;
set engine_condition_pushdown=0;
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
@@ -108,9 +105,8 @@ set join_buffer_size= @save_join_buffer_size;
set max_heap_table_size= @save_max_heap_table_size;
explain select * from t1 where a in (select b from t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t2 index b b 5 NULL 10 Using index
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1)
select * from t1;
a b
1 1
@@ -137,9 +133,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
-1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 32 Using where; Using join buffer (flat, BNLH join)
-2 SUBQUERY it ALL NULL NULL NULL NULL 22 Using where
+1 PRIMARY it ALL NULL NULL NULL NULL 22 Using where; Start temporary
+1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 32 Using where; End temporary; Using join buffer (flat, BNLH join)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
@@ -171,8 +166,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY it ALL NULL NULL NULL NULL 32
+1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot); Using join buffer (flat, BNL join)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
@@ -196,8 +190,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2)
16 filler1234 1
17 filler1234 1
18 filler1234 1
-19 filler1234 1
3 duplicate 1
+19 filler1234 1
19 duplicate 1
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
@@ -205,9 +199,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22
-1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 52 Using where; Using join buffer (flat, BNLH join)
-2 SUBQUERY it ALL NULL NULL NULL NULL 22 Using where
+1 PRIMARY it ALL NULL NULL NULL NULL 22 Using where; Start temporary
+1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 52 Using where; End temporary; Using join buffer (flat, BNLH join)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it);
@@ -239,8 +232,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY it ALL NULL NULL NULL NULL 52
+1 PRIMARY it ALL NULL NULL NULL NULL 52 Using where; FirstMatch(ot); Using join buffer (flat, BNL join)
select
a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it);
@@ -264,8 +256,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2)
16 filler1234 1
17 filler1234 1
18 filler1234 1
-19 filler1234 1
3 duplicate 1
+19 filler1234 1
19 duplicate 1
drop table t1, t2;
create table t1 (a int, b int, key(a));
@@ -310,6 +302,8 @@ Percentage float(3,1) NOT NULL default '0.0',
PRIMARY KEY (Country, Language),
INDEX (Percentage)
);
+set @bug35674_save_optimizer_switch=@@optimizer_switch;
+set optimizer_switch='materialization=off';
EXPLAIN
SELECT Name FROM t2
WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
@@ -318,9 +312,10 @@ t2.Code IN (SELECT Country FROM t3
WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan
-1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
+1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary
+1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; End temporary; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
+set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (
Code char(3) NOT NULL DEFAULT '',
@@ -356,8 +351,7 @@ WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
-1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1
-2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
+1 PRIMARY t2 ref CountryCode CountryCode 3 test.t1.Code 18 Using where; FirstMatch(t1); Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
SELECT Name FROM t1
WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
@@ -367,6 +361,10 @@ Canada
China
Czech Republic
drop table t1, t2;
+drop procedure if exists p1;
+drop procedure if exists p2;
+drop procedure if exists p3;
+drop procedure if exists p4;
CREATE TABLE t1(a INT);
CREATE TABLE t2(c INT);
CREATE PROCEDURE p1(v1 int)
@@ -701,9 +699,8 @@ alter table t3 add primary key(id), add key(a);
The following must use loose index scan over t3, key a:
explain select count(a) from t2 where a in ( SELECT a FROM t3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 index a a 5 NULL 1000 Using index
-1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1
-2 SUBQUERY t3 index a a 5 NULL 30000 Using index
+1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
+1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
select count(a) from t2 where a in ( SELECT a FROM t3);
count(a)
1000
@@ -733,6 +730,29 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch(t2); Using join buffer (incremental, BNL join)
drop table t2, t3;
+#
+# BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
+#
+CREATE TABLE t1 ( f1 int NOT NULL , f10 int) ;
+INSERT IGNORE INTO t1 VALUES (25,0),(29,0);
+CREATE TABLE t2 ( f10 int) ENGINE=InnoDB;
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+SELECT alias1.f10 AS field2
+FROM t2 AS alias1
+JOIN (
+t3 AS alias2
+JOIN t1 AS alias3
+ON alias3.f10
+) ON alias3.f1
+WHERE alias2.f11 IN (
+SELECT SQ4_alias1.f10
+FROM t1 AS SQ4_alias1
+LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10
+)
+GROUP BY field2;
+field2
+drop table t1, t2, t3;
set join_cache_level=default;
show variables like 'join_cache_level';
Variable_name Value
diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result
new file mode 100644
index 00000000000..0919e8701e2
--- /dev/null
+++ b/mysql-test/r/subselect_sj2_mat.result
@@ -0,0 +1,761 @@
+set optimizer_switch='materialization=on';
+drop table if exists t0, t1, t2, t3;
+drop view if exists v1;
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+a int,
+b int
+);
+insert into t1 values (1,1),(1,1),(2,2);
+create table t2 (
+a int,
+b int,
+key(b)
+);
+insert into t2 select a, a/2 from t0;
+select * from t1;
+a b
+1 1
+1 1
+2 2
+select * from t2;
+a b
+0 0
+1 1
+2 1
+3 2
+4 2
+5 3
+6 3
+7 4
+8 4
+9 5
+explain select * from t2 where b in (select a from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t2 ref b b 5 test.t1.a 2
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
+select * from t2 where b in (select a from t1);
+a b
+1 1
+2 1
+3 2
+4 2
+create table t3 (
+a int,
+b int,
+key(b),
+pk1 char(200), pk2 char(200), pk3 char(200),
+primary key(pk1, pk2, pk3)
+) engine=innodb;
+insert into t3 select a,a, a,a,a from t0;
+explain select * from t3 where b in (select a from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL b NULL NULL NULL 10
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+select * from t3 where b in (select a from t1);
+a b pk1 pk2 pk3
+1 1 1 1 1
+2 2 2 2 2
+set @save_max_heap_table_size= @@max_heap_table_size;
+set max_heap_table_size=16384;
+set @save_join_buffer_size = @@join_buffer_size;
+set join_buffer_size= 8000;
+drop table t3;
+create table t3 (
+a int,
+b int,
+key(b),
+pk1 char(200), pk2 char(200),
+primary key(pk1, pk2)
+) engine=innodb;
+insert into t3 select
+A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
+from t0 A, t0 B where B.a <5;
+explain select * from t3 where b in (select a from t0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 10
+1 PRIMARY t3 ref b b 5 test.t0.a 1
+2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
+set @save_ecp= @@engine_condition_pushdown;
+set engine_condition_pushdown=0;
+select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
+a b pk1 pk2
+0 0 0 0
+1 1 1 1
+2 2 2 2
+3 3 3 3
+4 4 4 4
+5 5 5 5
+6 6 6 6
+7 7 7 7
+8 8 8 8
+9 9 9 9
+10 10 10 10
+11 11 11 11
+12 12 12 12
+13 13 13 13
+set engine_condition_pushdown=@save_ecp;
+set join_buffer_size= @save_join_buffer_size;
+set max_heap_table_size= @save_max_heap_table_size;
+explain select * from t1 where a in (select b from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
+2 SUBQUERY t2 index b b 5 NULL 10 Using index
+select * from t1;
+a b
+1 1
+1 1
+2 2
+select * from t1 where a in (select b from t2);
+a b
+1 1
+1 1
+2 2
+drop table t1, t2, t3;
+set @save_join_buffer_size = @@join_buffer_size;
+set join_buffer_size= 8000;
+create table t1 (a int, filler1 binary(200), filler2 binary(200));
+insert into t1 select a, 'filler123456', 'filler123456' from t0;
+insert into t1 select a+10, 'filler123456', 'filler123456' from t0;
+create table t2 as select * from t1;
+insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
+insert into t1 values (2, 'duplicate ok', 'duplicate ok');
+insert into t1 values (18, 'duplicate ok', 'duplicate ok');
+insert into t2 values (3, 'duplicate ok', 'duplicate ok');
+insert into t2 values (19, 'duplicate ok', 'duplicate ok');
+explain select
+a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
+from t1 ot where a in (select a from t2 it);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
+1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join)
+2 SUBQUERY it ALL NULL NULL NULL NULL 22
+select
+a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
+from t1 ot where a in (select a from t2 it);
+a mid(filler1, 1,10) Z
+0 filler1234 1
+1 filler1234 1
+2 filler1234 1
+3 filler1234 1
+4 filler1234 1
+5 filler1234 1
+6 filler1234 1
+7 filler1234 1
+8 filler1234 1
+9 filler1234 1
+10 filler1234 1
+11 filler1234 1
+12 filler1234 1
+13 filler1234 1
+14 filler1234 1
+15 filler1234 1
+16 filler1234 1
+17 filler1234 1
+18 filler1234 1
+19 filler1234 1
+2 duplicate 1
+18 duplicate 1
+explain select
+a, mid(filler1, 1,10), length(filler1)=length(filler2)
+from t2 ot where a in (select a from t1 it);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY ot ALL NULL NULL NULL NULL 22
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
+2 SUBQUERY it ALL NULL NULL NULL NULL 32
+select
+a, mid(filler1, 1,10), length(filler1)=length(filler2)
+from t2 ot where a in (select a from t1 it);
+a mid(filler1, 1,10) length(filler1)=length(filler2)
+0 filler1234 1
+1 filler1234 1
+2 filler1234 1
+3 filler1234 1
+4 filler1234 1
+5 filler1234 1
+6 filler1234 1
+7 filler1234 1
+8 filler1234 1
+9 filler1234 1
+10 filler1234 1
+11 filler1234 1
+12 filler1234 1
+13 filler1234 1
+14 filler1234 1
+15 filler1234 1
+16 filler1234 1
+17 filler1234 1
+18 filler1234 1
+19 filler1234 1
+3 duplicate 1
+19 duplicate 1
+insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
+insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
+explain select
+a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
+from t1 ot where a in (select a from t2 it);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
+1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join)
+2 SUBQUERY it ALL NULL NULL NULL NULL 22
+select
+a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
+from t1 ot where a in (select a from t2 it);
+a mid(filler1, 1,10) Z
+0 filler1234 1
+1 filler1234 1
+2 filler1234 1
+3 filler1234 1
+4 filler1234 1
+5 filler1234 1
+6 filler1234 1
+7 filler1234 1
+8 filler1234 1
+9 filler1234 1
+10 filler1234 1
+11 filler1234 1
+12 filler1234 1
+13 filler1234 1
+14 filler1234 1
+15 filler1234 1
+16 filler1234 1
+17 filler1234 1
+18 filler1234 1
+19 filler1234 1
+2 duplicate 1
+18 duplicate 1
+explain select
+a, mid(filler1, 1,10), length(filler1)=length(filler2)
+from t2 ot where a in (select a from t1 it);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY ot ALL NULL NULL NULL NULL 22
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
+2 SUBQUERY it ALL NULL NULL NULL NULL 52
+select
+a, mid(filler1, 1,10), length(filler1)=length(filler2)
+from t2 ot where a in (select a from t1 it);
+a mid(filler1, 1,10) length(filler1)=length(filler2)
+0 filler1234 1
+1 filler1234 1
+2 filler1234 1
+3 filler1234 1
+4 filler1234 1
+5 filler1234 1
+6 filler1234 1
+7 filler1234 1
+8 filler1234 1
+9 filler1234 1
+10 filler1234 1
+11 filler1234 1
+12 filler1234 1
+13 filler1234 1
+14 filler1234 1
+15 filler1234 1
+16 filler1234 1
+17 filler1234 1
+18 filler1234 1
+19 filler1234 1
+3 duplicate 1
+19 duplicate 1
+drop table t1, t2;
+create table t1 (a int, b int, key(a));
+create table t2 (a int, b int, key(a));
+create table t3 (a int, b int, key(a));
+insert into t1 select a,a from t0;
+insert into t2 select a,a from t0;
+insert into t3 select a,a from t0;
+t2 and t3 must be use 'ref', not 'ALL':
+explain select *
+from t0 where a in
+(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Start temporary
+1 PRIMARY t1 index NULL a 5 NULL 10 Using index; Using join buffer (flat, BNL join)
+1 PRIMARY t2 ref a a 5 test.t1.a 1 Using where; Using index
+1 PRIMARY t3 ref a a 5 test.t1.a 1 Using where; Using index; End temporary
+drop table t0, t1,t2,t3;
+CREATE TABLE t1 (
+ID int(11) NOT NULL auto_increment,
+Name char(35) NOT NULL default '',
+Country char(3) NOT NULL default '',
+Population int(11) NOT NULL default '0',
+PRIMARY KEY (ID),
+INDEX (Population),
+INDEX (Country)
+);
+CREATE TABLE t2 (
+Code char(3) NOT NULL default '',
+Name char(52) NOT NULL default '',
+SurfaceArea float(10,2) NOT NULL default '0.00',
+Population int(11) NOT NULL default '0',
+Capital int(11) default NULL,
+PRIMARY KEY (Code),
+UNIQUE INDEX (Name),
+INDEX (Population)
+);
+CREATE TABLE t3 (
+Country char(3) NOT NULL default '',
+Language char(30) NOT NULL default '',
+Percentage float(3,1) NOT NULL default '0.0',
+PRIMARY KEY (Country, Language),
+INDEX (Percentage)
+);
+set @bug35674_save_optimizer_switch=@@optimizer_switch;
+set optimizer_switch='materialization=off';
+EXPLAIN
+SELECT Name FROM t2
+WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
+AND
+t2.Code IN (SELECT Country FROM t3
+WHERE Language='English' AND Percentage > 10 AND
+t2.Population > 100000);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary
+1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where
+1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; End temporary
+set optimizer_switch=@bug35674_save_optimizer_switch;
+DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (
+Code char(3) NOT NULL DEFAULT '',
+Name char(52) NOT NULL DEFAULT '',
+Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia',
+Region char(26) NOT NULL DEFAULT '',
+SurfaceArea float(10,2) NOT NULL DEFAULT '0.00',
+IndepYear smallint(6) DEFAULT NULL,
+Population int(11) NOT NULL DEFAULT '0',
+LifeExpectancy float(3,1) DEFAULT NULL,
+GNP float(10,2) DEFAULT NULL,
+GNPOld float(10,2) DEFAULT NULL,
+LocalName char(45) NOT NULL DEFAULT '',
+GovernmentForm char(45) NOT NULL DEFAULT '',
+HeadOfState char(60) DEFAULT NULL,
+Capital int(11) DEFAULT NULL,
+Code2 char(2) NOT NULL DEFAULT '',
+PRIMARY KEY (Code)
+);
+CREATE TABLE t2 (
+ID int(11) NOT NULL AUTO_INCREMENT,
+Name char(35) NOT NULL DEFAULT '',
+CountryCode char(3) NOT NULL DEFAULT '',
+District char(20) NOT NULL DEFAULT '',
+Population int(11) NOT NULL DEFAULT '0',
+PRIMARY KEY (ID),
+KEY CountryCode (CountryCode)
+);
+Fill the table with test data
+This must not use LooseScan:
+EXPLAIN SELECT Name FROM t1
+WHERE t1.Code IN (
+SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1
+2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
+SELECT Name FROM t1
+WHERE t1.Code IN (
+SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
+Name
+Austria
+Canada
+China
+Czech Republic
+drop table t1, t2;
+drop procedure if exists p1;
+drop procedure if exists p2;
+drop procedure if exists p3;
+drop procedure if exists p4;
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(c INT);
+CREATE PROCEDURE p1(v1 int)
+BEGIN
+SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2);
+END
+//
+CREATE PROCEDURE p2(v1 int)
+BEGIN
+SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2);
+END
+//
+CREATE PROCEDURE p3(v1 int)
+BEGIN
+SELECT 1
+FROM
+t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
+t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
+t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
+t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
+t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
+t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
+t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
+t1 t57,t1 t58,t1 t59,t1 t60
+WHERE t01.a IN (SELECT c FROM t2);
+END
+//
+CREATE PROCEDURE p4(v1 int)
+BEGIN
+SELECT 1
+FROM
+t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
+t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
+t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
+t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
+t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
+t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
+t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
+t1 t57,t1 t58,t1 t59,t1 t60
+WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2);
+END
+//
+CALL p1(1);
+1
+CALL p2(1);
+1
+CALL p3(1);
+1
+CALL p4(1);
+1
+DROP TABLE t1, t2;
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4);
+create table t1 (a int, b int, key(a));
+insert into t1 select a,a from t0;
+create table t2 (a int, b int, primary key(a));
+insert into t2 select * from t1;
+Table t2, unlike table t1, should be displayed as pulled out
+explain extended select * from t0
+where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and
+t1.b=t2.b);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where
+1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary
+1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary
+Warnings:
+Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1
+Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`))
+update t1 set a=3, b=11 where a=4;
+update t2 set b=11 where a=3;
+select * from t0 where t0.a in
+(select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b);
+a
+0
+1
+2
+3
+drop table t0, t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL,
+PRIMARY KEY (id));
+CREATE TABLE t2 (
+id int(11) NOT NULL,
+fid int(11) NOT NULL,
+PRIMARY KEY (id));
+insert into t1 values(1);
+insert into t2 values(1,7503),(2,1);
+explain select count(*)
+from t1
+where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid );
+ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery'
+drop table t1, t2;
+create table t1 (a int, b int, key (a), key (b));
+insert into t1 values (2,4),(2,4),(2,4);
+select t1.a from t1
+where
+t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a);
+a
+drop table t1;
+create table t1(a int,b int,key(a),key(b));
+insert into t1 values (1,1),(2,2),(3,3);
+select 1 from t1
+where t1.a not in (select 1 from t1
+where t1.a in (select 1 from t1)
+group by t1.b);
+1
+1
+1
+drop table t1;
+CREATE TABLE t1
+(EMPNUM CHAR(3) NOT NULL,
+EMPNAME CHAR(20),
+GRADE DECIMAL(4),
+CITY CHAR(15));
+CREATE TABLE t2
+(PNUM CHAR(3) NOT NULL,
+PNAME CHAR(20),
+PTYPE CHAR(6),
+BUDGET DECIMAL(9),
+CITY CHAR(15));
+CREATE TABLE t3
+(EMPNUM CHAR(3) NOT NULL,
+PNUM CHAR(3) NOT NULL,
+HOURS DECIMAL(5));
+INSERT INTO t1 VALUES ('E1','Alice',12,'Deale');
+INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna');
+INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna');
+INSERT INTO t1 VALUES ('E4','Don',12,'Deale');
+INSERT INTO t1 VALUES ('E5','Ed',13,'Akron');
+INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale');
+INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna');
+INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa');
+INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale');
+INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna');
+INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale');
+INSERT INTO t3 VALUES ('E1','P1',40);
+INSERT INTO t3 VALUES ('E1','P2',20);
+INSERT INTO t3 VALUES ('E1','P3',80);
+INSERT INTO t3 VALUES ('E1','P4',20);
+INSERT INTO t3 VALUES ('E1','P5',12);
+INSERT INTO t3 VALUES ('E1','P6',12);
+INSERT INTO t3 VALUES ('E2','P1',40);
+INSERT INTO t3 VALUES ('E2','P2',80);
+INSERT INTO t3 VALUES ('E3','P2',20);
+INSERT INTO t3 VALUES ('E4','P2',20);
+INSERT INTO t3 VALUES ('E4','P4',40);
+INSERT INTO t3 VALUES ('E4','P5',80);
+SELECT * FROM t1;
+EMPNUM EMPNAME GRADE CITY
+E1 Alice 12 Deale
+E2 Betty 10 Vienna
+E3 Carmen 13 Vienna
+E4 Don 12 Deale
+E5 Ed 13 Akron
+CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
+SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+(SELECT EMPNUM
+FROM t3
+WHERE PNUM IN
+(SELECT PNUM
+FROM t2
+WHERE PTYPE = 'Design'));
+EMPNAME
+Alice
+Betty
+Don
+DROP INDEX t1_IDX ON t1;
+CREATE INDEX t1_IDX ON t1(EMPNUM);
+SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+(SELECT EMPNUM
+FROM t3
+WHERE PNUM IN
+(SELECT PNUM
+FROM t2
+WHERE PTYPE = 'Design'));
+EMPNAME
+Alice
+Betty
+Don
+DROP INDEX t1_IDX ON t1;
+SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+(SELECT EMPNUM
+FROM t3
+WHERE PNUM IN
+(SELECT PNUM
+FROM t2
+WHERE PTYPE = 'Design'));
+EMPNAME
+Alice
+Betty
+Don
+DROP TABLE t1, t2, t3;
+CREATE TABLE t1 (f1 INT NOT NULL);
+CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1;
+SELECT * FROM v1;
+a
+drop view v1;
+drop table t1;
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int, b int);
+insert into t1 values (0,0),(1,1),(2,2);
+create table t2 as select * from t1;
+create table t3 (pk int, a int, primary key(pk));
+insert into t3 select a,a from t0;
+explain
+select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
+drop table t0, t1, t2, t3;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a char(200), b char(200), c char(200), primary key (a,b,c)) engine=innodb;
+insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1;
+insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1;
+alter table t2 add filler1 int;
+insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
+set @save_join_buffer_size=@@join_buffer_size;
+set join_buffer_size=1;
+select * from t2 where filler1 in ( select a from t1);
+a b c filler1
+set join_buffer_size=default;
+drop table t1, t2;
+create table t1 (a int not null);
+drop procedure if exists p1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE EXIT HANDLER FOR SQLEXCEPTION select a from t1;
+prepare s1 from '
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in (
+ select a from t1 where a in ( select a from t1)
+ )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))';
+execute s1;
+END;
+|
+call p1();
+a
+drop procedure p1;
+drop table t1;
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C;
+create table t2 (id int, a int, primary key(id), key(a)) as select a as id, a as a from t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL DEFAULT '0',
+ `a` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `a` (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+set @a=0;
+create table t3 as select * from t2 limit 0;
+insert into t3 select @a:=@a+1, t2.a from t2, t0;
+insert into t3 select @a:=@a+1, t2.a from t2, t0;
+insert into t3 select @a:=@a+1, t2.a from t2, t0;
+alter table t3 add primary key(id), add key(a);
+The following must use loose index scan over t3, key a:
+explain select count(a) from t2 where a in ( SELECT a FROM t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index a a 5 NULL 1000 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
+2 SUBQUERY t3 index a a 5 NULL 30000 Using index
+select count(a) from t2 where a in ( SELECT a FROM t3);
+count(a)
+1000
+drop table t0,t1,t2,t3;
+
+BUG#42740: crash in optimize_semijoin_nests
+
+create table t1 (c6 timestamp,key (c6)) engine=innodb;
+create table t2 (c2 double) engine=innodb;
+explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 <null) ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+drop table t1, t2;
+#
+# BUG#42742: crash in setup_sj_materialization, Copy_field::set
+#
+create table t3 ( c1 year) engine=innodb;
+insert into t3 values (2135),(2142);
+create table t2 (c1 tinytext,c2 text,c6 timestamp) engine=innodb;
+# The following must not crash, EXPLAIN should show one SJ strategy, not a mix:
+explain select 1 from t2 where
+c2 in (select 1 from t3, t2) and
+c1 in (select convert(c6,char(1)) from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 1
+1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
+1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch(t2)
+drop table t2, t3;
+#
+# BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
+#
+CREATE TABLE t1 ( f1 int NOT NULL , f10 int) ;
+INSERT IGNORE INTO t1 VALUES (25,0),(29,0);
+CREATE TABLE t2 ( f10 int) ENGINE=InnoDB;
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+SELECT alias1.f10 AS field2
+FROM t2 AS alias1
+JOIN (
+t3 AS alias2
+JOIN t1 AS alias3
+ON alias3.f10
+) ON alias3.f1
+WHERE alias2.f11 IN (
+SELECT SQ4_alias1.f10
+FROM t1 AS SQ4_alias1
+LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10
+)
+GROUP BY field2;
+field2
+drop table t1, t2, t3;
+set optimizer_switch=default;
+select @@optimizer_switch like '%materialization=on%';
+@@optimizer_switch like '%materialization=on%'
+0
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result
index 46ca02cd71a..a3eca278db4 100644
--- a/mysql-test/r/subselect_sj_jcl6.result
+++ b/mysql-test/r/subselect_sj_jcl6.result
@@ -414,24 +414,6 @@ SELECT t1 .varchar_key from t1
int_key
9
7
-SELECT t0.int_key
-FROM t0
-WHERE t0.varchar_nokey IN (
-SELECT t1_1 .varchar_key
-FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
-);
-int_key
-9
-7
-SELECT t0.int_key
-FROM t0, t2
-WHERE t0.varchar_nokey IN (
-SELECT t1_1 .varchar_key
-FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
-);
-int_key
-9
-7
DROP TABLE t0, t1, t2;
# End of bug#46550
#
@@ -782,11 +764,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
show warnings;
Level Code Message
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
select a from t1
where a in (select c from t2 where d >= some(select e from t3 where b=e));
a
@@ -819,10 +801,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
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
-1 PRIMARY subselect2 eq_ref unique_key unique_key 13 func 1 1.00
-2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Rowid-ordered scan
+1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Rowid-ordered scan; FirstMatch(t1); Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`pk` > 0))
+Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
pk
2
@@ -988,10 +969,9 @@ FROM t1
WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
-1 PRIMARY subselect2 eq_ref unique_key unique_key 8 func 1 1.00
-2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
+1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 100.00 Using where; FirstMatch(t2); Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
Warnings:
-Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_key` < 'n') xor `test`.`t1`.`pk`))
+Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey`) and (`test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
SELECT varchar_nokey
FROM t2
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
@@ -1069,11 +1049,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%')
AND t1.val IN (SELECT t3.val FROM t3
WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%');
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY subselect3 eq_ref unique_key unique_key 14 func 1
-1 PRIMARY subselect2 eq_ref unique_key unique_key 14 func 1
-3 SUBQUERY t3 ALL NULL NULL NULL NULL 5 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary
+1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (incremental, BNL join)
SELECT *
FROM t1
WHERE t1.val IN (SELECT t2.val FROM t2
@@ -1248,6 +1226,114 @@ IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
AND pk = 9;
datetime_key
DROP TABLE t1, t2, t3;
+#
+# BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
+#
+CREATE TABLE t1 ( t1field integer, primary key (t1field));
+CREATE TABLE t2 ( t2field integer, primary key (t2field));
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t2 VALUES (2),(3),(4);
+explain
+SELECT * FROM t1 A
+WHERE
+A.t1field IN (SELECT A.t1field FROM t2 B) AND
+A.t1field IN (SELECT C.t2field FROM t2 C
+WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index; Start temporary
+1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; End temporary; Using join buffer (flat, BNL join)
+1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
+1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
+SELECT * FROM t1 A
+WHERE
+A.t1field IN (SELECT A.t1field FROM t2 B) AND
+A.t1field IN (SELECT C.t2field FROM t2 C
+WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
+t1field
+2
+3
+drop table t1,t2;
+#
+# BUG#787299: Valgrind complains on a join query with two IN subqueries
+#
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+create table t2 as select * from t1;
+select * from t1 A, t1 B
+where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
+a a
+1 1
+2 2
+3 3
+explain
+select * from t1 A, t1 B
+where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY A ALL NULL NULL NULL NULL 3 Start temporary
+1 PRIMARY B ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY C ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 PRIMARY D ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (incremental, BNL join)
+drop table t1, t2;
+#
+# BUG#784441: Abort on semijoin with a view as the inner table
+#
+CREATE TABLE t1 (a int) ;
+INSERT INTO t1 VALUES (1), (1);
+CREATE TABLE t2 (a int) ;
+INSERT INTO t2 VALUES (1), (1);
+CREATE VIEW v1 AS SELECT 1;
+EXPLAIN
+SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived3> system NULL NULL NULL NULL 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
+a a
+1 1
+1 1
+1 1
+1 1
+DROP VIEW v1;
+DROP TABLE t1,t2;
+#
+# BUG#751439 Assertion `!table->file || table->file->inited == handler::NONE' failed with subquery
+#
+CREATE TABLE t1 ( f10 int, f11 int) ;
+INSERT IGNORE INTO t1 VALUES (0,0),(0,0);
+CREATE TABLE t2 ( f11 int);
+INSERT IGNORE INTO t2 VALUES (0),(0);
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+SELECT alias1.f11 AS field2
+FROM ( t3 AS alias2 JOIN t1 AS alias3 ON alias3.f10 = 1)
+LEFT JOIN ( t2 AS alias1 ) ON alias3.f11 = 1
+WHERE alias2.f11 IN ( SELECT f11 FROM t2 )
+GROUP BY field2 ;
+field2
+drop table t1, t2, t3;
+#
+# BUG#778406 Crash in hp_movelink with Aria engine and subqueries
+#
+CREATE TABLE t4 (f10 varchar(32) , KEY (f10)) ENGINE=Aria;
+INSERT INTO t4 VALUES ('x'),('m'),('c');
+CREATE TABLE t1 (f11 int) ENGINE=Aria;
+INSERT INTO t1 VALUES (0),(0),(0);
+CREATE TABLE t2 ( f10 int) ENGINE=Aria;
+INSERT INTO t2 VALUES (0),(0),(0);
+CREATE TABLE t3 ( f10 int, f11 int) ENGINE=Aria;
+SELECT *
+FROM t4
+WHERE f10 IN
+( SELECT t1.f11
+FROM t1
+LEFT JOIN t2 JOIN t3 ON t3.f10 = t2.f10 ON t3.f11 != 0 );
+f10
+x
+m
+c
+drop table t1,t2,t3,t4;
set @@optimizer_switch=@save_optimizer_switch;
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result
new file mode 100644
index 00000000000..f1e26561f4c
--- /dev/null
+++ b/mysql-test/r/subselect_sj_mat.result
@@ -0,0 +1,1360 @@
+drop table if exists t1, t2, t3, t1i, t2i, t3i;
+drop table if exists columns;
+drop table if exists t1_16, t2_16, t3_16;
+drop view if exists v1, v2, v1m, v2m;
+create table t1 (a1 char(8), a2 char(8));
+create table t2 (b1 char(8), b2 char(8));
+create table t3 (c1 char(8), c2 char(8));
+insert into t1 values ('1 - 00', '2 - 00');
+insert into t1 values ('1 - 01', '2 - 01');
+insert into t1 values ('1 - 02', '2 - 02');
+insert into t2 values ('1 - 01', '2 - 01');
+insert into t2 values ('1 - 01', '2 - 01');
+insert into t2 values ('1 - 02', '2 - 02');
+insert into t2 values ('1 - 02', '2 - 02');
+insert into t2 values ('1 - 03', '2 - 03');
+insert into t3 values ('1 - 01', '2 - 01');
+insert into t3 values ('1 - 02', '2 - 02');
+insert into t3 values ('1 - 03', '2 - 03');
+insert into t3 values ('1 - 04', '2 - 04');
+create table t1i (a1 char(8), a2 char(8));
+create table t2i (b1 char(8), b2 char(8));
+create table t3i (c1 char(8), c2 char(8));
+create index it1i1 on t1i (a1);
+create index it1i2 on t1i (a2);
+create index it1i3 on t1i (a1, a2);
+create index it2i1 on t2i (b1);
+create index it2i2 on t2i (b2);
+create index it2i3 on t2i (b1, b2);
+create index it3i1 on t3i (c1);
+create index it3i2 on t3i (c2);
+create index it3i3 on t3i (c1, c2);
+insert into t1i select * from t1;
+insert into t2i select * from t2;
+insert into t3i select * from t3;
+set @@optimizer_switch='materialization=on,in_to_exists=off,firstmatch=off';
+/******************************************************************************
+* Simple tests.
+******************************************************************************/
+# non-indexed nullable fields
+explain extended
+select * from t1 where a1 in (select b1 from t2 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 9 func 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b1` > '0'))
+select * from t1 where a1 in (select b1 from t2 where b1 > '0');
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 9 test.t1.a1 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`) join `test`.`t1` where (`<subquery2>`.`b1` = `test`.`t1`.`a1`)
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`,`test`.`t2`.`b2`) join `test`.`t1` where ((`<subquery2>`.`b2` = `test`.`t1`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1`.`a1`))
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`) join `test`.`t1` where ((`<subquery2>`.`min(b2)` = `test`.`t1`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1`.`a1`))
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i where a1 in (select b1 from t2i where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2i index it2i1,it2i3 it2i1 # NULL 5 40.00 Using where; Using index; LooseScan
+1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where ((`test`.`t1i`.`a1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0'))
+select * from t1i where a1 in (select b1 from t2i where b1 > '0');
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key # NULL # 3 100.00 #
+1 PRIMARY t1i ref it1i1,it1i3 # 9 # 1 100.00 #
+2 SUBQUERY t2i range it2i1,it2i3 # 9 # 3 100.00 #
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`) join `test`.`t1i` where (`test`.`t1i`.`a1` = `<subquery2>`.`b1`)
+select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 # NULL 5 40.00 Using where; Using index; LooseScan
+1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where ((`test`.`t1i`.`a2` = `test`.`t2i`.`b2`) and (`test`.`t1i`.`a1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0'))
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1i index it1i1,it1i2,it1i3 # # # 3 100.00 #
+1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 #
+2 SUBQUERY t2i range it2i1,it2i3 # # # 3 100.00 #
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`,`test`.`t2i`.`b2`) join `test`.`t1i` where ((`<subquery2>`.`b2` = `test`.`t1i`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1i`.`a1`))
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1i index it1i1,it1i2,it1i3 # # # 3 100.00 #
+1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 #
+2 SUBQUERY t2i range it2i1,it2i3 # # # 3 100.00 #
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`) join `test`.`t1i` where ((`<subquery2>`.`min(b2)` = `test`.`t1i`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1i`.`a1`))
+select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1 100.00
+2 SUBQUERY t2i range NULL it2i3 9 NULL 3 100.00 Using index for group-by
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` group by `test`.`t2i`.`b1`) join `test`.`t1` where ((`<subquery2>`.`max(b2)` = `test`.`t1`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1`.`a1`))
+select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+prepare st1 from "explain select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
+execute st1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1
+2 SUBQUERY t2i range NULL it2i3 9 NULL 3 Using index for group-by
+execute st1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1
+2 SUBQUERY t2i range NULL it2i3 9 NULL 3 Using index for group-by
+prepare st2 from "select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
+execute st2;
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+execute st2;
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1 100.00
+2 SUBQUERY t2i range it2i1,it2i3 it2i3 18 NULL 3 100.00 Using where; Using index for group-by
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`) join `test`.`t1` where ((`<subquery2>`.`min(b2)` = `test`.`t1`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1`.`a1`))
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1);
+ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='default,semijoin=off';
+prepare st1 from
+"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
+set @@optimizer_switch='default,materialization=off';
+execute st1;
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+set @@optimizer_switch='default,semijoin=off';
+execute st1;
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+set @@optimizer_switch='default,materialization=off';
+prepare st1 from
+"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
+set @@optimizer_switch='default,semijoin=off';
+execute st1;
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+set @@optimizer_switch='default,materialization=off';
+execute st1;
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+set @@optimizer_switch=@save_optimizer_switch;
+explain extended
+select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1.a1,test.t1.a2 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` order by `test`.`t2`.`b1`,`test`.`t2`.`b2`) join `test`.`t1` where ((`<subquery2>`.`b2` = `test`.`t1`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1`.`a1`))
+select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1i index it1i1,it1i2,it1i3 it1i3 18 NULL 3 100.00 Using where; Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 test.t1i.a1,test.t1i.a2 1 100.00
+2 SUBQUERY t2i index NULL it2i3 18 NULL 5 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` order by `test`.`t2i`.`b1`,`test`.`t2i`.`b2`) join `test`.`t1i` where ((`<subquery2>`.`b2` = `test`.`t1i`.`a2`) and (`<subquery2>`.`b1` = `test`.`t1i`.`a1`))
+select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+/******************************************************************************
+* Views, UNIONs, several levels of nesting.
+******************************************************************************/
+# materialize the result of subquery over temp-table view
+create algorithm=merge view v1 as
+select b1, c2 from t2, t3 where b2 > c2;
+create algorithm=merge view v2 as
+select b1, c2 from t2, t3 group by b2, c2;
+Warnings:
+Warning 1354 View merge algorithm can't be used here for now (assumed undefined algorithm)
+create algorithm=temptable view v1m as
+select b1, c2 from t2, t3 where b2 > c2;
+create algorithm=temptable view v2m as
+select b1, c2 from t2, t3 group by b2, c2;
+select * from v1 where (c2, b1) in (select c2, b1 from v2 where b1 is not null);
+b1 c2
+1 - 02 2 - 01
+1 - 02 2 - 01
+1 - 03 2 - 01
+1 - 03 2 - 02
+select * from v1 where (c2, b1) in (select distinct c2, b1 from v2 where b1 is not null);
+b1 c2
+1 - 02 2 - 01
+1 - 02 2 - 01
+1 - 03 2 - 01
+1 - 03 2 - 02
+select * from v1m where (c2, b1) in (select c2, b1 from v2m where b1 is not null);
+b1 c2
+1 - 02 2 - 01
+1 - 02 2 - 01
+1 - 03 2 - 01
+1 - 03 2 - 02
+select * from v1m where (c2, b1) in (select distinct c2, b1 from v2m where b1 is not null);
+b1 c2
+1 - 02 2 - 01
+1 - 02 2 - 01
+1 - 03 2 - 01
+1 - 03 2 - 02
+drop view v1, v2, v1m, v2m;
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+3 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and (`test`.`t2`.`b1` > '0') and (`test`.`t3`.`c2` > '0'))
+select * from t1
+where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+(a1, a2) in (select c1, c2 from t3i
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1i index it1i1,it1i2,it1i3 # # # 3 100.00 #
+1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 #
+1 PRIMARY <subquery3> eq_ref distinct_key # # # 1 100.00 #
+2 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
+3 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
+3 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 #
+Warnings:
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where ((`test`.`t3i`.`c2` = `test`.`t2i`.`b2`) and (`test`.`t3i`.`c1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0') and (`test`.`t2i`.`b2` > '0'))
+select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+(a1, a2) in (select c1, c2 from t3i
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 where c2 LIKE '%02') or
+b2 in (select c2 from t3 where c2 LIKE '%03')) and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+5 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+5 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer (flat, BNL join)
+4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (`test`.`t3`.`c2` > '0'))
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 where c2 LIKE '%02') or
+b2 in (select c2 from t3 where c2 LIKE '%03')) and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+a1 a2
+1 - 02 2 - 02
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 t3a where c1 = a1) or
+b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
+(a1, a2) in (select c1, c2 from t3 t3c
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+5 SUBQUERY t3c ALL NULL NULL NULL NULL 4 100.00 Using where
+5 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer (flat, BNL join)
+4 SUBQUERY t3b ALL NULL NULL NULL NULL 4 100.00 Using where
+3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b2` = `test`.`t3c`.`c2`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t3c`.`c1`) and (<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (`test`.`t3c`.`c2` > '0'))
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 t3a where c1 = a1) or
+b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
+(a1, a2) in (select c1, c2 from t3 t3c
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+(select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 where c2 LIKE '%02') or
+b2 in (select c2 from t3 where c2 LIKE '%03')
+group by b1, b2) and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
+UNION
+(select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+(a1, a2) in (select c1, c2 from t3i
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key # # # 5 0.00 #
+1 PRIMARY t3 ALL NULL # # # 4 100.00 #
+1 PRIMARY t1 ALL NULL # # # 3 100.00 #
+1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 2 100.00 #
+2 SUBQUERY t2 ALL NULL # # # 5 100.00 #
+4 SUBQUERY t3 ALL NULL # # # 4 100.00 #
+3 SUBQUERY t3 ALL NULL # # # 4 100.00 #
+7 UNION t1i index it1i1,it1i2,it1i3 # # # 3 100.00 #
+7 UNION <subquery8> eq_ref distinct_key # # # 1 100.00 #
+7 UNION <subquery9> eq_ref distinct_key # # # 1 100.00 #
+8 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
+9 SUBQUERY t2i index it2i1,it2i2,it2i3 # # # 5 100.00 #
+9 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 #
+NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL #
+Warnings:
+Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2`) semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t1` where ((`test`.`t3`.`c2` = `<subquery2>`.`b2`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`) and (`test`.`t2i`.`b2` = `<subquery2>`.`b2`) and (`test`.`t3`.`c1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t2i`.`b1` = `<subquery2>`.`b1`) and (`<subquery2>`.`b2` > '0'))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where ((`test`.`t3i`.`c2` = `test`.`t2i`.`b2`) and (`test`.`t3i`.`c1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0') and (`test`.`t2i`.`b2` > '0')))
+(select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 where c2 LIKE '%02') or
+b2 in (select c2 from t3 where c2 LIKE '%03')
+group by b1, b2) and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
+UNION
+(select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+(a1, a2) in (select c1, c2 from t3i
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
+a1 a2
+1 - 02 2 - 02
+1 - 01 2 - 01
+explain extended
+select * from t1
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+4 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and (`test`.`t3`.`c2` > '0'))
+select * from t1
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+(a1, a2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+a1 a2
+1 - 01 2 - 01
+1 - 02 2 - 02
+explain extended
+select * from t1, t3
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+(c1, c2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
+a1 = c1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 18 func,func 1 100.00
+4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+4 SUBQUERY t2i index it2i1,it2i2,it2i3 it2i3 18 NULL 5 80.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and (`test`.`t3`.`c2` > '0'))
+select * from t1, t3
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+(c1, c2) in (select c1, c2 from t3
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
+a1 = c1;
+a1 a2 c1 c2
+1 - 01 2 - 01 1 - 01 2 - 01
+1 - 02 2 - 02 1 - 02 2 - 02
+/******************************************************************************
+* Negative tests, where materialization should not be applied.
+******************************************************************************/
+# UNION in a subquery
+explain extended
+select * from t3
+where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))))
+select * from t3
+where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
+c1 c2
+1 - 01 2 - 01
+1 - 02 2 - 02
+1 - 03 2 - 03
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+where b2 in (select c2 from t3 t3a where c1 = a1) or
+b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
+(a1, a2) in (select c1, c2 from t3 t3c
+where (c1, c2) in (select b1, b2 from t2i where b2 > '0' or b2 = a2));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t1.a1,test.t1.a2 2 100.00 Using index
+1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3c ALL NULL NULL NULL NULL 4 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+4 SUBQUERY t3b ALL NULL NULL NULL NULL 4 100.00 Using where
+3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2i`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t3c`.`c2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t3c`.`c1` = `test`.`t1`.`a1`) and (<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))))
+explain extended
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))))
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
+a1 a2
+1 - 01 2 - 01
+explain extended
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a2`,`test`.`t1`.`a1`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))))
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
+a1 a2
+1 - 01 2 - 01
+/******************************************************************************
+* Subqueries in other uncovered clauses.
+******************************************************************************/
+/* SELECT clause */
+select ((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL from t1;
+((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL
+0
+0
+0
+/* GROUP BY clause */
+create table columns (col int key);
+insert into columns values (1), (2);
+explain extended
+select * from t1 group by (select col from columns limit 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
+2 SUBQUERY columns index NULL PRIMARY 4 NULL 2 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by (select `test`.`columns`.`col` from `test`.`columns` limit 1)
+select * from t1 group by (select col from columns limit 1);
+a1 a2
+1 - 00 2 - 00
+explain extended
+select * from t1 group by (a1 in (select col from columns));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY columns unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where; Full scan on NULL key
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a1`) in columns on PRIMARY where trigcond((<cache>(`test`.`t1`.`a1`) = `test`.`columns`.`col`))))))
+select * from t1 group by (a1 in (select col from columns));
+a1 a2
+1 - 00 2 - 00
+/* ORDER BY clause */
+explain extended
+select * from t1 order by (select col from columns limit 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
+2 SUBQUERY columns index NULL PRIMARY 4 NULL 2 100.00 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` order by (select `test`.`columns`.`col` from `test`.`columns` limit 1)
+select * from t1 order by (select col from columns limit 1);
+a1 a2
+1 - 00 2 - 00
+1 - 01 2 - 01
+1 - 02 2 - 02
+/******************************************************************************
+* Column types/sizes that affect materialization.
+******************************************************************************/
+/*
+Test that BLOBs are not materialized (except when arguments of some functions).
+*/
+# force materialization to be always considered
+set @prefix_len = 6;
+set @blob_len = 16;
+set @suffix_len = @blob_len - @prefix_len;
+create table t1_16 (a1 blob(16), a2 blob(16));
+create table t2_16 (b1 blob(16), b2 blob(16));
+create table t3_16 (c1 blob(16), c2 blob(16));
+insert into t1_16 values
+(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_16 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_16 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_16 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_16 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_16 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_16 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_16 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_16 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_16 values
+(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select b1 from t2_16 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select b1 from t2_16 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_16
+where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 20 func 1 100.00 Using where
+2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
+Warnings:
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16)))
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
+2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ','))))))
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+set @@group_concat_max_len = 256;
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_16.a1 1 100.00 Using where
+2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2`) join `test`.`t1_16` where (`test`.`t1_16`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended
+select * from t1
+where concat(a1,'x') IN
+(select left(a1,8) from t1_16
+where (a1, a2) IN
+(select t2_16.b1, t2_16.b2 from t2_16, t2
+where t2.b2 = substring(t2_16.b2,1,6) and
+t2.b1 IN (select c1 from t3 where c2 > '0')));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Start temporary
+1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t2`.`b1` = `test`.`t3`.`c1`) and (`test`.`t2`.`b2` = substr(`test`.`t1_16`.`a2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8)))
+drop table t1_16, t2_16, t3_16;
+set @blob_len = 512;
+set @suffix_len = @blob_len - @prefix_len;
+create table t1_512 (a1 blob(512), a2 blob(512));
+create table t2_512 (b1 blob(512), b2 blob(512));
+create table t3_512 (c1 blob(512), c2 blob(512));
+insert into t1_512 values
+(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_512 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_512 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_512 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_512 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_512 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_512 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_512 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_512 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_512 values
+(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select b1 from t2_512 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select b1 from t2_512 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_512
+where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 517 func 1 100.00 Using where
+2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
+Warnings:
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512)))
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_512.a1 1 100.00 Using where
+2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2`) join `test`.`t1_512` where (`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+left(a1,7) left(a2,7)
+set @@group_concat_max_len = 256;
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_512.a1 1 100.00 Using where
+2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2`) join `test`.`t1_512` where (`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+left(a1,7) left(a2,7)
+drop table t1_512, t2_512, t3_512;
+set @blob_len = 1024;
+set @suffix_len = @blob_len - @prefix_len;
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+create table t3_1024 (c1 blob(1024), c2 blob(1024));
+insert into t1_1024 values
+(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_1024 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_1024 values
+(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select b1 from t2_1024 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select b1 from t2_1024 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_1024
+where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref NULL distinct_key 15 func,func 1 100.00 Using where
+2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
+Warnings:
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024)))
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
+left(a1,7) left(a2,7)
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_1024.a1 1 100.00 Using where
+2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2`) join `test`.`t1_1024` where (`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+left(a1,7) left(a2,7)
+set @@group_concat_max_len = 256;
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_1024.a1 1 100.00 Using where
+2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2`) join `test`.`t1_1024` where (`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+left(a1,7) left(a2,7)
+drop table t1_1024, t2_1024, t3_1024;
+set @blob_len = 1025;
+set @suffix_len = @blob_len - @prefix_len;
+create table t1_1025 (a1 blob(1025), a2 blob(1025));
+create table t2_1025 (b1 blob(1025), b2 blob(1025));
+create table t3_1025 (c1 blob(1025), c2 blob(1025));
+insert into t1_1025 values
+(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1025 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1025 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1025 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1025 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1025 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_1025 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_1025 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_1025 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_1025 values
+(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select b1 from t2_1025 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select b1 from t2_1025 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; Start temporary
+1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0'))
+select left(a1,7), left(a2,7)
+from t1_1025
+where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+1 - 02x 2 - 02x
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref NULL distinct_key 15 func,func 1 100.00 Using where
+2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
+Warnings:
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025)))
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
+left(a1,7) left(a2,7)
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_1025.a1 1 100.00 Using where
+2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2`) join `test`.`t1_1025` where (`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+left(a1,7) left(a2,7)
+set @@group_concat_max_len = 256;
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 261 test.t1_1025.a1 1 100.00 Using where
+2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
+Warnings:
+Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2`) join `test`.`t1_1025` where (`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`)
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+left(a1,7) left(a2,7)
+drop table t1_1025, t2_1025, t3_1025;
+create table t1bit (a1 bit(3), a2 bit(3));
+create table t2bit (b1 bit(3), b2 bit(3));
+insert into t1bit values (b'000', b'100');
+insert into t1bit values (b'001', b'101');
+insert into t1bit values (b'010', b'110');
+insert into t2bit values (b'001', b'101');
+insert into t2bit values (b'010', b'110');
+insert into t2bit values (b'110', b'111');
+explain extended select bin(a1), bin(a2)
+from t1bit
+where (a1, a2) in (select b1, b2 from t2bit);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1bit ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func,func 1 100.00
+2 SUBQUERY t2bit ALL NULL NULL NULL NULL 3 100.00
+Warnings:
+Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` semi join (`test`.`t2bit`) where 1
+select bin(a1), bin(a2)
+from t1bit
+where (a1, a2) in (select b1, b2 from t2bit);
+bin(a1) bin(a2)
+1 101
+10 110
+drop table t1bit, t2bit;
+create table t1bb (a1 bit(3), a2 blob(3));
+create table t2bb (b1 bit(3), b2 blob(3));
+insert into t1bb values (b'000', '100');
+insert into t1bb values (b'001', '101');
+insert into t1bb values (b'010', '110');
+insert into t2bb values (b'001', '101');
+insert into t2bb values (b'010', '110');
+insert into t2bb values (b'110', '111');
+explain extended select bin(a1), a2
+from t1bb
+where (a1, a2) in (select b1, b2 from t2bb);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1bb ALL NULL NULL NULL NULL 3 100.00 Start temporary
+1 PRIMARY t2bb ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select conv(`test`.`t1bb`.`a1`,10,2) AS `bin(a1)`,`test`.`t1bb`.`a2` AS `a2` from `test`.`t1bb` semi join (`test`.`t2bb`) where ((`test`.`t2bb`.`b2` = `test`.`t1bb`.`a2`) and (`test`.`t2bb`.`b1` = `test`.`t1bb`.`a1`))
+select bin(a1), a2
+from t1bb
+where (a1, a2) in (select b1, b2 from t2bb);
+bin(a1) a2
+1 101
+10 110
+drop table t1bb, t2bb;
+drop table t1, t2, t3, t1i, t2i, t3i, columns;
+/******************************************************************************
+* Test the cache of the left operand of IN.
+******************************************************************************/
+# Test that default values of Cached_item are not used for comparison
+create table t1 (s1 int);
+create table t2 (s2 int);
+insert into t1 values (5),(1),(0);
+insert into t2 values (0), (1);
+select s2 from t2 where s2 in (select s1 from t1);
+s2
+0
+1
+drop table t1, t2;
+create table t1 (a int not null, b int not null);
+create table t2 (c int not null, d int not null);
+create table t3 (e int not null);
+insert into t1 values (1,10);
+insert into t1 values (1,20);
+insert into t1 values (2,10);
+insert into t1 values (2,20);
+insert into t1 values (2,30);
+insert into t1 values (3,20);
+insert into t1 values (4,40);
+insert into t2 values (2,10);
+insert into t2 values (2,20);
+insert into t2 values (2,40);
+insert into t2 values (3,20);
+insert into t2 values (4,10);
+insert into t2 values (5,10);
+insert into t3 values (10);
+insert into t3 values (10);
+insert into t3 values (20);
+insert into t3 values (30);
+explain extended
+select a from t1 where a in (select c from t2 where d >= 20);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6 100.00
+1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using join buffer (flat, BNL join)
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` >= 20))
+select a from t1 where a in (select c from t2 where d >= 20);
+a
+2
+2
+2
+3
+create index it1a on t1(a);
+explain extended
+select a from t1 where a in (select c from t2 where d >= 20);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6 100.00
+1 PRIMARY t1 ref it1a it1a 4 test.t2.c 2 100.00 Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and (`test`.`t2`.`d` >= 20))
+select a from t1 where a in (select c from t2 where d >= 20);
+a
+2
+2
+2
+3
+insert into t2 values (1,10);
+explain extended
+select a from t1 where a in (select c from t2 where d >= 20);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 index it1a it1a 4 NULL 7 100.00 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` >= 20))
+select a from t1 where a in (select c from t2 where d >= 20);
+a
+2
+2
+2
+3
+explain extended
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+a
+2
+3
+create index iab on t1(a, b);
+explain extended
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))))
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+a
+2
+3
+explain extended
+select a from t1 group by a
+having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))))
+select a from t1 group by a
+having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
+a
+2
+3
+explain extended
+select a from t1
+where a in (select c from t2 where d >= some(select e from t3 where b=e));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 7 100.00 Start temporary
+1 PRIMARY t1 ref it1a,iab iab 4 test.t2.c 1 100.00 Using where; Using index; End temporary
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
+select a from t1
+where a in (select c from t2 where d >= some(select e from t3 where b=e));
+a
+2
+2
+2
+3
+1
+drop table t1, t2, t3;
+create table t2 (a int, b int, key(a), key(b));
+insert into t2 values (3,3),(3,3),(3,3);
+select 1 from t2 where
+t2.a > 1
+or
+t2.a = 3 and not t2.a not in (select t2.b from t2);
+1
+1
+1
+1
+drop table t2;
+create table t1 (a1 int key);
+create table t2 (b1 int);
+insert into t1 values (5);
+explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+1 PRIMARY <subquery2> const distinct_key distinct_key 5 const 1
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+min(a1)
+NULL
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='default,materialization=off';
+explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
+select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+min(a1)
+set @@optimizer_switch='default,semijoin=off';
+explain select min(a1) from t1 where 7 in (select b1 from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select min(a1) from t1 where 7 in (select b1 from t2);
+min(a1)
+set @@optimizer_switch='default,materialization=off';
+# with MariaDB and MWL#90, this particular case is solved:
+explain select min(a1) from t1 where 7 in (select b1 from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select min(a1) from t1 where 7 in (select b1 from t2);
+min(a1)
+NULL
+# but when we go around MWL#90 code, the problem still shows up:
+explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
+min(a1)
+set @@optimizer_switch= @save_optimizer_switch;
+drop table t1,t2;
+create table t1 (a char(2), b varchar(10));
+insert into t1 values ('a', 'aaa');
+insert into t1 values ('aa', 'aaaa');
+explain select a,b from t1 where b in (select a from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
+select a,b from t1 where b in (select a from t1);
+a b
+prepare st1 from "select a,b from t1 where b in (select a from t1)";
+execute st1;
+a b
+execute st1;
+a b
+drop table t1;
+CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM;
+INSERT INTO t1 (f1, f2) VALUES (1, 1.789);
+INSERT INTO t1 (f1, f2) VALUES (13, 1.454);
+INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1, 1.789);
+INSERT INTO t2 VALUES (13, 1.454);
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2
+SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+COUNT(*)
+2
+set @@optimizer_switch= @save_optimizer_switch;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+pk int,
+a varchar(1),
+b varchar(4),
+c varchar(4),
+d varchar(4),
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
+2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan
+SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+pk
+2
+SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
+pk
+2
+DROP TABLE t1, t2;
+set optimizer_switch=@save_optimizer_switch;
+#
+# BUG#50019: Wrong result for IN-subquery with materialization
+#
+create table t1(i int);
+insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+create table t2(i int);
+insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+create table t3(i int);
+insert into t3 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
+i
+1
+2
+3
+4
+set @save_optimizer_switch=@@optimizer_switch;
+set session optimizer_switch='materialization=off,in_to_exists=on';
+select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
+i
+4
+3
+2
+1
+set session optimizer_switch=@save_optimizer_switch;
+drop table t1, t2, t3;
+create table t0 (a int);
+insert into t0 values (0),(1),(2);
+create table t1 (a int);
+insert into t1 values (0),(1),(2);
+explain select a, a in (select a from t1) from t0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t0 ALL NULL NULL NULL NULL 3
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+select a, a in (select a from t1) from t0;
+a a in (select a from t1)
+0 1
+1 1
+2 1
+prepare s from 'select a, a in (select a from t1) from t0';
+execute s;
+a a in (select a from t1)
+0 1
+1 1
+2 1
+update t1 set a=123;
+execute s;
+a a in (select a from t1)
+0 0
+1 0
+2 0
+drop table t0, t1;
+set optimizer_switch='firstmatch=on';
+#
+# MWL#90, review feedback: check what happens when the subquery
+# looks like candidate for MWL#90 checking at the first glance
+# but then subselect_hash_sj_engine::init_permanent() discovers
+# that it's not possible to perform duplicate removal for the
+# selected datatypes, and so materialization isn't applicable after
+# all.
+#
+set @blob_len = 1024;
+set @suffix_len = @blob_len - @prefix_len;
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+insert into t1_1024 values
+(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+explain select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1,1,1024), count(*) from t2_1024 where b1 > '0');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 Using where
+select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1,1,1024), count(*) from t2_1024 where b1 > '0');
+left(a1,7) left(a2,7)
+1 - 01x 2 - 01x
+drop table t1_1024, t2_1024;
diff --git a/mysql-test/r/subselect_sj_nonmerged.result b/mysql-test/r/subselect_sj_nonmerged.result
new file mode 100644
index 00000000000..9304c26ece6
--- /dev/null
+++ b/mysql-test/r/subselect_sj_nonmerged.result
@@ -0,0 +1,118 @@
+drop table if exists t0, t1, t2, t3, t4;
+set @save_optimizer_switch=@@optimizer_switch;
+set optimizer_switch='materialization=on';
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 as select * from t0;
+# The following should use full scan on <subquery2> and it must scan 1 row:
+explain select * from t0 where a in (select max(a) from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
+1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 10
+select * from t0 where a in (select max(a) from t1);
+a
+9
+insert into t1 values (11);
+select * from t0 where a in (select max(a) from t1);
+a
+delete from t1 where a=11;
+insert into t0 values (NULL);
+select * from t0 where a in (select max(a) from t1);
+a
+9
+delete from t0 where a is NULL;
+delete from t1;
+select * from t0 where a in (select max(a) from t1);
+a
+insert into t0 values (NULL);
+select * from t0 where a in (select max(a) from t1);
+a
+delete from t0 where a is NULL;
+drop table t1;
+create table t1 (a int, b int);
+insert into t1 select a,a from t0;
+create table t2 as select * from t1 where a<5;
+create table t3 as select (A.a + 10*B.a) as a from t0 A, t0 B;
+alter table t3 add primary key(a);
+# The following should have do a full scan on <subquery2> and scan 5 rows
+# (despite that subquery's join output estimate is 50 rows)
+explain select * from t3 where a in (select max(t2.a) from t1, t2 group by t2.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 5 Using where
+1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+# Compare to this which really will have 50 record combinations:
+explain select * from t3 where a in (select max(t2.a) from t1, t2 group by t2.b, t1.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 50 Using where
+1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+# Outer joins also work:
+explain select * from t3
+where a in (select max(t2.a) from t1 left join t2 on t1.a=t2.a group by t2.b, t1.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 50 Using where
+1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using temporary
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
+create table t4 (a int, b int, filler char(20), unique key(a,b));
+insert into t4 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t0 A, t0 B;
+explain select * from t0, t4 where
+t4.b=t0.a and t4.a in (select max(t2.a) from t1, t2 group by t2.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t0 ALL NULL NULL NULL NULL 10
+1 PRIMARY t4 ALL a NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.t4.a 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+insert into t4 select 100 + (B.a *100 + A.a), 100 + (B.a*100 + A.a), 'filler' from t4 A, t0 B;
+explain select * from t4 where
+t4.a in (select max(t2.a) from t1, t2 group by t2.b) and
+t4.b in (select max(t2.a) from t1, t2 group by t2.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 5 Using where
+1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t4 ref a a 10 <subquery2>.max(t2.a),<subquery3>.max(t2.a) 11
+3 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using temporary
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
+drop table t1,t2,t3,t4;
+drop table t0;
+#
+# BUG#780359: Crash with get_fanout_with_deps in maria-5.3-mwl90
+#
+CREATE TABLE t1 (f1 int);
+INSERT INTO t1 VALUES (2),(2);
+CREATE TABLE t2 (f3 int);
+INSERT INTO t2 VALUES (2),(2);
+SELECT *
+FROM t1
+WHERE ( f1 ) IN (
+SELECT t2.f3
+FROM t2
+WHERE t2.f3 = 97
+AND t2.f3 = 50
+GROUP BY 1
+);
+f1
+DROP TABLE t1, t2;
+#
+# BUG#727183: WL#90 does not trigger with non-comma joins
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1(a int, key(a));
+insert into t1 select A.a + 10*B.a + 100*C.a from t0 A, t0 B, t0 C;
+# The following must use non-merged SJ-Materialization:
+explain select * from t1 X join t0 Y on X.a < Y.a where X.a in (select max(a) from t0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1 Using where
+1 PRIMARY X ref a a 5 <subquery2>.max(a) 1 Using index
+1 PRIMARY Y ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
+2 SUBQUERY t0 ALL NULL NULL NULL NULL 10
+drop table t0, t1;
+set optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/r/sysdate_is_now.result b/mysql-test/r/sysdate_is_now.result
index 1ebbb8c1588..82861436ff6 100644
--- a/mysql-test/r/sysdate_is_now.result
+++ b/mysql-test/r/sysdate_is_now.result
@@ -1,4 +1,4 @@
set timestamp=1;
SELECT sleep(1),NOW()-SYSDATE() as zero;
sleep(1) zero
-0 0.000000
+0 0
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index aa407b25401..d3cbc134de9 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -240,7 +240,7 @@ event CREATE TABLE `event` (
show create table general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
- `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
@@ -250,10 +250,10 @@ general_log CREATE TABLE `general_log` (
show create table slow_log;
Table Create Table
slow_log CREATE TABLE `slow_log` (
- `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
- `query_time` time NOT NULL,
- `lock_time` time NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result
index 5c39abfc483..bb29cd7679d 100644
--- a/mysql-test/r/table_elim.result
+++ b/mysql-test/r/table_elim.result
@@ -117,58 +117,58 @@ t2 where id=f.id);
This should use one table:
explain select id from v1 where id=2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY f const PRIMARY PRIMARY 4 const 1 Using index
+1 SIMPLE f const PRIMARY PRIMARY 4 const 1 Using index
This should use one table:
explain extended select id from v1 where id in (1,2,3,4);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY f range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index
+1 SIMPLE f range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index
Warnings:
-Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #2
Note 1003 select `f`.`id` AS `id` from `test`.`t0` `f` where (`f`.`id` in (1,2,3,4))
This should use facts and a1 tables:
explain extended select id from v1 where attr1 between 12 and 14;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY a1 range PRIMARY,attr1 attr1 5 NULL 2 100.00 Using index condition; Rowid-ordered scan
-1 PRIMARY f eq_ref PRIMARY PRIMARY 4 test.a1.id 1 100.00 Using index
+1 SIMPLE a1 range PRIMARY,attr1 attr1 5 NULL 2 100.00 Using index condition; Rowid-ordered scan
+1 SIMPLE f eq_ref PRIMARY PRIMARY 4 test.a1.id 1 100.00 Using index
Warnings:
-Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #2
Note 1003 select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t1` `a1` where ((`f`.`id` = `a1`.`id`) and (`a1`.`attr1` between 12 and 14))
This should use facts, a2 and its subquery:
explain extended select id from v1 where attr2 between 12 and 14;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY a2 range PRIMARY,attr2 attr2 5 NULL 5 100.00 Using index condition; Using where; Rowid-ordered scan
-1 PRIMARY f eq_ref PRIMARY PRIMARY 4 test.a2.id 1 100.00 Using index
+1 SIMPLE a2 range PRIMARY,attr2 attr2 5 NULL 5 100.00 Using index condition; Using where; Rowid-ordered scan
+1 SIMPLE f eq_ref PRIMARY PRIMARY 4 test.a2.id 1 100.00 Using index
3 DEPENDENT SUBQUERY t2 ref PRIMARY PRIMARY 4 test.a2.id 2 100.00 Using index
Warnings:
-Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.a2.id' of SELECT #3 was resolved in SELECT #2
Note 1003 select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t2` `a2` where ((`f`.`id` = `a2`.`id`) and (`a2`.`attr2` between 12 and 14) and (`a2`.`fromdate` = (select max(`test`.`t2`.`fromdate`) from `test`.`t2` where (`test`.`t2`.`id` = `a2`.`id`))))
This should use one table:
explain select id from v2 where id=2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY f const PRIMARY PRIMARY 4 const 1 Using index
+1 SIMPLE f const PRIMARY PRIMARY 4 const 1 Using index
This should use one table:
explain extended select id from v2 where id in (1,2,3,4);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY f range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index
+1 SIMPLE f range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index
Warnings:
-Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #2
Note 1003 select `f`.`id` AS `id` from `test`.`t0` `f` where (`f`.`id` in (1,2,3,4))
This should use facts and a1 tables:
explain extended select id from v2 where attr1 between 12 and 14;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY a1 range PRIMARY,attr1 attr1 5 NULL 2 100.00 Using index condition; Rowid-ordered scan
-1 PRIMARY f eq_ref PRIMARY PRIMARY 4 test.a1.id 1 100.00 Using index
+1 SIMPLE a1 range PRIMARY,attr1 attr1 5 NULL 2 100.00 Using index condition; Rowid-ordered scan
+1 SIMPLE f eq_ref PRIMARY PRIMARY 4 test.a1.id 1 100.00 Using index
Warnings:
-Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #2
Note 1003 select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t1` `a1` where ((`f`.`id` = `a1`.`id`) and (`a1`.`attr1` between 12 and 14))
This should use facts, a2 and its subquery:
explain extended select id from v2 where attr2 between 12 and 14;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY a2 range PRIMARY,attr2 attr2 5 NULL 5 100.00 Using index condition; Rowid-ordered scan
-1 PRIMARY f eq_ref PRIMARY PRIMARY 4 test.a2.id 1 100.00 Using where; Using index
+1 SIMPLE a2 range PRIMARY,attr2 attr2 5 NULL 5 100.00 Using index condition; Rowid-ordered scan
+1 SIMPLE f eq_ref PRIMARY PRIMARY 4 test.a2.id 1 100.00 Using where; Using index
3 DEPENDENT SUBQUERY t2 ref PRIMARY PRIMARY 4 test.f.id 2 100.00 Using index
Warnings:
-Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #1
+Note 1276 Field or reference 'test.f.id' of SELECT #3 was resolved in SELECT #2
Note 1003 select `f`.`id` AS `id` from `test`.`t0` `f` join `test`.`t2` `a2` where ((`f`.`id` = `a2`.`id`) and (`a2`.`attr2` between 12 and 14) and (`a2`.`fromdate` = (select max(`test`.`t2`.`fromdate`) from `test`.`t2` where (`test`.`t2`.`id` = `f`.`id`))))
drop view v1, v2;
drop table t0, t1, t2;
diff --git a/mysql-test/r/table_options.result b/mysql-test/r/table_options.result
index ddb7bd13c03..164fe4e30d0 100644
--- a/mysql-test/r/table_options.result
+++ b/mysql-test/r/table_options.result
@@ -3,9 +3,9 @@ SET @OLD_SQL_MODE=@@SQL_MODE;
SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1';
Warnings:
-Warning 1652 Unknown option 'fkey'
-Warning 1652 Unknown option 'dff'
-Warning 1652 Unknown option 'tkey1'
+Warning 1911 Unknown option 'fkey'
+Warning 1911 Unknown option 'dff'
+Warning 1911 Unknown option 'tkey1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -16,10 +16,10 @@ drop table t1;
#reassiginig options in the same line
create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1;
Warnings:
-Warning 1652 Unknown option 'fkey'
-Warning 1652 Unknown option 'dff'
-Warning 1652 Unknown option 'tkey1'
-Warning 1652 Unknown option 'tkey2'
+Warning 1911 Unknown option 'fkey'
+Warning 1911 Unknown option 'dff'
+Warning 1911 Unknown option 'tkey1'
+Warning 1911 Unknown option 'tkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -29,7 +29,7 @@ t1 CREATE TABLE `t1` (
#add option
alter table t1 tkey4=4v1;
Warnings:
-Warning 1652 Unknown option 'tkey4'
+Warning 1911 Unknown option 'tkey4'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -39,8 +39,8 @@ t1 CREATE TABLE `t1` (
#remove options
alter table t1 tkey3=DEFAULT tkey4=DEFAULT;
Warnings:
-Warning 1652 Unknown option 'tkey3'
-Warning 1652 Unknown option 'tkey4'
+Warning 1911 Unknown option 'tkey3'
+Warning 1911 Unknown option 'tkey4'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -50,11 +50,11 @@ t1 CREATE TABLE `t1` (
drop table t1;
create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1;
Warnings:
-Warning 1652 Unknown option 'fkey1'
-Warning 1652 Unknown option 'kkey1'
-Warning 1652 Unknown option 'TKEY1'
-Warning 1652 Unknown option 'tkey2'
-Warning 1652 Unknown option 'tkey3'
+Warning 1911 Unknown option 'fkey1'
+Warning 1911 Unknown option 'kkey1'
+Warning 1911 Unknown option 'TKEY1'
+Warning 1911 Unknown option 'tkey2'
+Warning 1911 Unknown option 'tkey3'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -64,7 +64,7 @@ t1 CREATE TABLE `t1` (
#change field with option with the same value
alter table t1 change a a int `FKEY1`='v1';
Warnings:
-Warning 1652 Unknown option 'FKEY1'
+Warning 1911 Unknown option 'FKEY1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -74,7 +74,7 @@ t1 CREATE TABLE `t1` (
#change field with option with a different value
alter table t1 change a a int fkey1=v2;
Warnings:
-Warning 1652 Unknown option 'fkey1'
+Warning 1911 Unknown option 'fkey1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -93,7 +93,7 @@ t1 CREATE TABLE `t1` (
#new key with options
alter table t1 add key bkey (b) kkey2=v1;
Warnings:
-Warning 1652 Unknown option 'kkey2'
+Warning 1911 Unknown option 'kkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -105,8 +105,8 @@ t1 CREATE TABLE `t1` (
#new column with options
alter table t1 add column c int fkey1=v1 fkey2=v2;
Warnings:
-Warning 1652 Unknown option 'fkey1'
-Warning 1652 Unknown option 'fkey2'
+Warning 1911 Unknown option 'fkey1'
+Warning 1911 Unknown option 'fkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -141,7 +141,7 @@ t1 CREATE TABLE `t1` (
#add column with options after delete
alter table t1 add column b int fkey2=v1;
Warnings:
-Warning 1652 Unknown option 'fkey2'
+Warning 1911 Unknown option 'fkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -154,7 +154,7 @@ t1 CREATE TABLE `t1` (
#add key
alter table t1 add key bkey (b) kkey2=v2;
Warnings:
-Warning 1652 Unknown option 'kkey2'
+Warning 1911 Unknown option 'kkey2'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -168,7 +168,7 @@ t1 CREATE TABLE `t1` (
drop table t1;
create table t1 (a int) tkey1=100;
Warnings:
-Warning 1652 Unknown option 'tkey1'
+Warning 1911 Unknown option 'tkey1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
diff --git a/mysql-test/r/timezone.result b/mysql-test/r/timezone.result
index 1223fff36c6..5ae7e6f8117 100644
--- a/mysql-test/r/timezone.result
+++ b/mysql-test/r/timezone.result
@@ -7,7 +7,7 @@ select @a:=FROM_UNIXTIME(1);
1970-01-01 01:00:01
select unix_timestamp(@a);
unix_timestamp(@a)
-1
+1.000000
CREATE TABLE t1 (ts int);
INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00'));
INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 02:00'));
@@ -44,4 +44,7 @@ unix_timestamp('1970-01-01 01:00:01'),
unix_timestamp('2038-01-19 04:14:07'),
unix_timestamp('2038-01-19 04:14:08');
unix_timestamp('1970-01-01 01:00:00') unix_timestamp('1970-01-01 01:00:01') unix_timestamp('2038-01-19 04:14:07') unix_timestamp('2038-01-19 04:14:08')
-0 1 2147483647 0
+0.000000 1.000000 2147483647.000000 NULL
+select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59');
+unix_timestamp('1969-12-31 23:59:59') unix_timestamp('1970-01-01 00:00:00') unix_timestamp('1970-01-01 00:59:59')
+NULL NULL NULL
diff --git a/mysql-test/r/timezone4.result b/mysql-test/r/timezone4.result
index 28028bea657..ad0672890a2 100644
--- a/mysql-test/r/timezone4.result
+++ b/mysql-test/r/timezone4.result
@@ -3,4 +3,4 @@ from_unixtime(0)
1969-12-31 14:00:00
select unix_timestamp('1969-12-31 14:00:01');
unix_timestamp('1969-12-31 14:00:01')
-1
+1.000000
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index 9f32a10a3fb..50042a428c7 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -36,7 +36,7 @@ select 0 + b'1000000000000001';
32769
drop table if exists t1,t2;
create table t1 (a bit(65));
-ERROR 42000: Display width out of range for column 'a' (max = 64)
+ERROR 42000: Display width out of range for 'a' (max = 64)
create table t1 (a bit(0));
show create table t1;
Table Create Table
diff --git a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result
index a9c3cae1770..071b1c3b97b 100644
--- a/mysql-test/r/type_bit_innodb.result
+++ b/mysql-test/r/type_bit_innodb.result
@@ -36,7 +36,7 @@ select 0 + b'1000000000000001';
32769
drop table if exists t1;
create table t1 (a bit(65)) engine=innodb;
-ERROR 42000: Display width out of range for column 'a' (max = 64)
+ERROR 42000: Display width out of range for 'a' (max = 64)
create table t1 (a bit(0)) engine=innodb;
show create table t1;
Table Create Table
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index e6fd49b4247..7736fc4350a 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -833,7 +833,7 @@ drop table b15776;
create table b15776 (data blob(4294967295));
drop table b15776;
create table b15776 (data blob(4294967296));
-ERROR 42000: Display width out of range for column 'data' (max = 4294967295)
+ERROR 42000: Display width out of range for 'data' (max = 4294967295)
CREATE TABLE b15776 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) );
show columns from b15776;
Field Type Null Key Default Extra
@@ -845,13 +845,13 @@ b1 longtext YES NULL
c1 longtext YES NULL
drop table b15776;
CREATE TABLE b15776 (a blob(4294967296));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a text(4294967296));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a int(0));
INSERT INTO b15776 values (NULL), (1), (42), (654);
SELECT * from b15776 ORDER BY a;
@@ -866,7 +866,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
CREATE TABLE b15776 (a int(255));
DROP TABLE b15776;
CREATE TABLE b15776 (a int(256));
-ERROR 42000: Display width out of range for column 'a' (max = 255)
+ERROR 42000: Display width out of range for 'a' (max = 255)
CREATE TABLE b15776 (data blob(-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 '-1))' at line 1
CREATE TABLE b15776 (a char(2147483647));
@@ -876,7 +876,7 @@ ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT
CREATE TABLE b15776 (a char(4294967295));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a char(4294967296));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(4294967295));
INSERT INTO b15776 VALUES (42);
SELECT * FROM b15776;
@@ -884,33 +884,29 @@ a
2042
DROP TABLE b15776;
CREATE TABLE b15776 (a year(4294967296));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(0));
DROP TABLE b15776;
CREATE TABLE b15776 (a year(-2));
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 '-2))' at line 1
CREATE TABLE b15776 (a timestamp(4294967294));
-Warnings:
-Warning 1287 'TIMESTAMP(4294967294)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-DROP TABLE b15776;
+ERROR 42000: Too big precision 4294967294 specified for 'a'. Maximum is 6.
CREATE TABLE b15776 (a timestamp(4294967295));
-Warnings:
-Warning 1287 'TIMESTAMP(4294967295)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-DROP TABLE b15776;
+ERROR 42000: Too big precision 4294967295 specified for 'a'. Maximum is 6.
CREATE TABLE b15776 (a timestamp(4294967296));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a timestamp(-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 '-1))' at line 1
CREATE TABLE b15776 (a timestamp(-2));
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 '-2))' at line 1
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 select cast(null as char(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
@@ -936,11 +932,11 @@ explain select cast(1 as binary(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select cast(1 as char(4294967296));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select cast(1 as nchar(4294967296));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select cast(1 as binary(4294967296));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select cast(1 as decimal(-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 '-1))' at line 1
explain select cast(1 as decimal(64, 30));
@@ -956,23 +952,23 @@ explain select convert(1, char(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select convert(1, char(4294967296));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select convert(1, nchar(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select convert(1, nchar(4294967296));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select convert(1, binary(4294967295));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
explain select convert(1, binary(4294967296));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
+ERROR 42000: Display width out of range for '1' (max = 4294967295)
End of 5.0 tests
# Bug #52160: crash and inconsistent results when grouping
# by a function and column
@@ -985,3 +981,9 @@ COUNT(*)
DROP FUNCTION f1;
DROP TABLE t1;
End of 5.1 tests
+CREATE TABLE t1 ( f1 blob, f2 blob );
+INSERT INTO t1 VALUES ('','');
+SELECT f1,f2,"found row" FROM t1 WHERE f1 = f2 ;
+f1 f2 found row
+ found row
+DROP TABLE t1;
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 8c07668cf58..d33a52c0a71 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -139,8 +139,8 @@ Warning 1292 Incorrect datetime value: '1311'
create table t1 (d date , dt datetime , ts timestamp);
insert into t1 values (9912101,9912101,9912101);
Warnings:
-Warning 1264 Out of range value for column 'd' at row 1
-Warning 1264 Out of range value for column 'dt' at row 1
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
Warning 1265 Data truncated for column 'ts' at row 1
insert into t1 values (11111,11111,11111);
select * from t1;
@@ -205,24 +205,17 @@ EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
Warnings:
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
-Warning 1265 Data truncated for column 'a' at row 1
+Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t1 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
Warnings:
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
-Warning 1265 Data truncated for column 'a' at row 1
+Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t2 WHERE a = '0000-00-00';
a
0000-00-00
0000-00-00
-Warnings:
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
INSERT INTO t1 VALUES ('0000-00-00');
ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1
SET SQL_MODE=DEFAULT;
@@ -245,24 +238,17 @@ EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
Warnings:
-Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 1
SELECT * FROM t1 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
Warnings:
-Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 1
SELECT * FROM t2 WHERE a = '1000-00-00';
a
1000-00-00
1000-00-00
-Warnings:
-Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
INSERT INTO t1 VALUES ('1000-00-00');
ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1
SET SQL_MODE=DEFAULT;
@@ -301,3 +287,8 @@ the_date the_time the_date the_time
DROP TABLE t1;
DROP VIEW v1;
End of 5.1 tests
+create table t1 (f1 date, key (f1));
+insert t1 values ('2010-10-10 15:foobar');
+Warnings:
+Warning 1265 Data truncated for column 'f1' at row 1
+drop table t1;
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 76edaea45a1..092be494302 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -52,7 +52,7 @@ t
truncate table t1;
insert into t1 values("2003-0303 12:13:14");
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 1
select * from t1;
t
0000-00-00 00:00:00
@@ -115,12 +115,12 @@ create table t1 (t datetime);
insert into t1 values (20030102030460),(20030102036301),(20030102240401),
(20030132030401),(20031302030401),(100001202030401);
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
-Warning 1264 Out of range value for column 't' at row 3
-Warning 1264 Out of range value for column 't' at row 4
-Warning 1264 Out of range value for column 't' at row 5
-Warning 1264 Out of range value for column 't' at row 6
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 3
+Warning 1265 Data truncated for column 't' at row 4
+Warning 1265 Data truncated for column 't' at row 5
+Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
0000-00-00 00:00:00
@@ -134,12 +134,12 @@ insert into t1 values
("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"),
("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00");
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
-Warning 1264 Out of range value for column 't' at row 3
-Warning 1264 Out of range value for column 't' at row 4
-Warning 1264 Out of range value for column 't' at row 5
-Warning 1264 Out of range value for column 't' at row 6
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 3
+Warning 1265 Data truncated for column 't' at row 4
+Warning 1265 Data truncated for column 't' at row 5
+Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
0000-00-00 00:00:00
@@ -151,8 +151,8 @@ t
delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 2
select * from t1 order by t;
t
0000-00-00 00:00:00
@@ -170,7 +170,7 @@ dt
drop table t1;
select cast('2006-12-05 22:10:10' as datetime) + 0;
cast('2006-12-05 22:10:10' as datetime) + 0
-20061205221010.000000
+20061205221010
CREATE TABLE t1(a DATETIME NOT NULL);
INSERT INTO t1 VALUES ('20060606155555');
SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
@@ -185,14 +185,14 @@ DROP TABLE t1;
SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6));
CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6))
20060810.000000
-SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
-CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6))
+SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME(6)) AS DECIMAL(20,6));
+CAST(CAST('2006-08-10 10:11:12' AS DATETIME(6)) AS DECIMAL(20,6))
20060810101112.000000
-SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
-CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6))
+SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME(6)) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
+CAST(CAST('2006-08-10 10:11:12' AS DATETIME(6)) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6))
20060810101112.000014
-SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
-CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
+SELECT CAST(CAST('10:11:12.098700' AS TIME(6)) AS DECIMAL(20,6));
+CAST(CAST('10:11:12.098700' AS TIME(6)) AS DECIMAL(20,6))
101112.098700
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
@@ -352,7 +352,7 @@ least(cast('01-01-01' as date), '01-01-02')
2001-01-01
select greatest(cast('01-01-01' as date), '01-01-02');
greatest(cast('01-01-01' as date), '01-01-02')
-01-01-02
+2001-01-02
select least(cast('01-01-01' as date), '01-01-02') + 0;
least(cast('01-01-01' as date), '01-01-02') + 0
20010101
@@ -361,7 +361,7 @@ greatest(cast('01-01-01' as date), '01-01-02') + 0
20010102
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
least(cast('01-01-01' as datetime), '01-01-02') + 0
-20010101000000
+20010101000000.000000
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
cast(least(cast('01-01-01' as datetime), '01-01-02') as signed)
20010101000000
@@ -399,7 +399,7 @@ if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
2002-02-02
Warnings:
-Warning 1292 Incorrect date value: '' for column 'f1' at row 1
+Warning 1292 Incorrect datetime value: ''
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
@@ -423,11 +423,11 @@ f1
2001-01-01 00:00:00
2002-02-02 00:00:00
Warnings:
-Warning 1292 Incorrect datetime value: '2002010' for column 'f1' at row 1
+Warning 1292 Incorrect datetime value: '2002010'
select * from t1 where f1 between 20020101 and 2007010100000;
f1
Warnings:
-Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1
+Warning 1292 Incorrect datetime value: '2007010100000'
drop table t1;
#
# Bug#27216: functions with parameters of different date types may
@@ -495,9 +495,10 @@ insert into t1 set f1 = '45:44:44';
insert into t1 set f1 = '15:44:44';
select * from t1 where (convert(f1,datetime)) != 1;
f1
+45:44:44
15:44:44
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 45:44:44'
+Warning 1292 Incorrect datetime value: '1'
drop table t1;
create table t1 (a tinyint);
insert into t1 values (), (), ();
@@ -516,7 +517,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
-Note 1003 select '1' AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where (('2007-04-25 18:30:22' = 0))
+Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where (('2007-04-25 18:30:22' = 0))
select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null));
id cur_date
@@ -527,7 +528,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
-Note 1003 select '1' AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where (('2007-04-25' = 0))
+Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where (('2007-04-25' = 0))
select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date
@@ -617,22 +618,33 @@ ERROR 42000: Invalid default value for 'da'
create table t1 (t time default '916:00:00 a');
ERROR 42000: Invalid default value for 't'
set @@sql_mode= @org_mode;
-SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7));
-CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7))
+SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME(6)) AS DECIMAL(30,7));
+CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME(6)) AS DECIMAL(30,7))
20060810101112.0123450
Warnings:
Warning 1292 Truncated incorrect datetime value: '2006-08-10 10:11:12.0123450'
-SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7));
-CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7))
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME(6)) AS DECIMAL(30,7));
+CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME(6)) AS DECIMAL(30,7))
20060810101112.0123450
Warnings:
Warning 1292 Truncated incorrect datetime value: '00000002006-000008-0000010 000010:0000011:00000012.0123450'
-SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7));
-CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7))
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME(6)) AS DECIMAL(30,7));
+CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME(6)) AS DECIMAL(30,7))
20060810101112.0123450
-SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7));
-CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7))
+SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime(6)) AS DECIMAL(30,7));
+CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime(6)) AS DECIMAL(30,7))
20080729104251.1234560
Warnings:
Warning 1292 Truncated incorrect datetime value: '2008-07-29T10:42:51.1234567'
+#
+# Bug#59173: Failure to handle DATE(TIME) values where Year, Month or
+# Day is ZERO
+#
+CREATE TABLE t1 (dt1 DATETIME);
+INSERT INTO t1 (dt1) VALUES ('0000-00-01 00:00:01');
+DELETE FROM t1 WHERE dt1 = '0000-00-01 00:00:01';
+# Should be empty
+SELECT * FROM t1;
+dt1
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/type_datetime_hires.result b/mysql-test/r/type_datetime_hires.result
new file mode 100644
index 00000000000..583030bf0da
--- /dev/null
+++ b/mysql-test/r/type_datetime_hires.result
@@ -0,0 +1,340 @@
+drop table if exists t1, t2, t3;
+create table t1 (a datetime(7));
+ERROR 42000: Too big precision 7 specified for 'a'. Maximum is 6.
+create table t1 (a datetime(3), key(a));
+insert t1 values ('2010-12-11 00:20:03.1234');
+insert t1 values ('2010-12-11 15:47:11.1234');
+insert t1 values (20101211010203.45678);
+insert t1 values (20101211030405.789e0);
+insert t1 values (99991231235959e1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+select * from t1;
+a
+0000-00-00 00:00:00.000
+2010-12-11 00:20:03.123
+2010-12-11 01:02:03.456
+2010-12-11 03:04:05.789
+2010-12-11 15:47:11.123
+select truncate(a, 6) from t1;
+truncate(a, 6)
+0.000000
+20101211002003.121094
+20101211010203.457031
+20101211030405.789062
+20101211154711.121094
+select a DIV 1 from t1;
+a DIV 1
+0
+20101211002003
+20101211010203
+20101211030405
+20101211154711
+select group_concat(distinct a) from t1;
+group_concat(distinct a)
+0000-00-00 00:00:00.000,2010-12-11 00:20:03.123,2010-12-11 01:02:03.456,2010-12-11 03:04:05.789,2010-12-11 15:47:11.123
+alter table t1 engine=innodb;
+select * from t1 order by a;
+a
+0000-00-00 00:00:00.000
+2010-12-11 00:20:03.123
+2010-12-11 01:02:03.456
+2010-12-11 03:04:05.789
+2010-12-11 15:47:11.123
+select * from t1 order by a+0;
+a
+0000-00-00 00:00:00.000
+2010-12-11 00:20:03.123
+2010-12-11 01:02:03.456
+2010-12-11 03:04:05.789
+2010-12-11 15:47:11.123
+drop table t1;
+create table t1 (a datetime(4)) engine=innodb;
+insert t1 values ('2010-12-11 01:02:03.456789');
+select * from t1;
+a
+2010-12-11 01:02:03.4567
+select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
+extract(microsecond from a + interval 100 microsecond)
+456800
+select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
+a
+2010-12-11 01:02:03.4567
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` datetime(4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show columns from t1;
+Field Type Null Key Default Extra
+a datetime(4) YES NULL
+select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1';
+table_name t1
+column_name a
+column_default NULL
+is_nullable YES
+data_type datetime
+character_maximum_length NULL
+character_octet_length NULL
+numeric_precision NULL
+numeric_scale NULL
+datetime_precision 4
+character_set_name NULL
+collation_name NULL
+column_type datetime(4)
+column_key
+extra
+select a, a+interval 9876543 microsecond from t1;
+a a+interval 9876543 microsecond
+2010-12-11 01:02:03.4567 2010-12-11 01:02:13.333243
+update t1 set a=a+interval 9876543 microsecond;
+select * from t1;
+a
+2010-12-11 01:02:13.3332
+select a, a + interval 2 year from t1;
+a a + interval 2 year
+2010-12-11 01:02:13.3332 2012-12-11 01:02:13.3332
+insert t1 select a + interval 2 year from t1;
+select * from t1;
+a
+2010-12-11 01:02:13.3332
+2012-12-11 01:02:13.3332
+delete from t1 where a < 20110101;
+select * from t1;
+a
+2012-12-11 01:02:13.3332
+create table t2 select * from t1;
+create table t3 like t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` datetime(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` datetime(4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2, t3;
+insert t1 values ('2010-12-13 14:15:16.222222');
+select a, a+0, a-1, a*1, a/2 from t1;
+a a+0 a-1 a*1 a/2
+2012-12-11 01:02:13.3332 20121211010213.3332 20121211010212.3332 20121211010213.3332 10060605505106.66660000
+2010-12-13 14:15:16.2222 20101213141516.2222 20101213141515.2222 20101213141516.2222 10050606570758.11110000
+select max(a), min(a), sum(a), avg(a) from t1;
+max(a) min(a) sum(a) avg(a)
+2012-12-11 01:02:13.3332 2010-12-13 14:15:16.2222 40222424151729.5554 20111212075864.77770000
+create table t2 select a, a+0, a-1, a*1, a/2 from t1;
+create table t3 select max(a), min(a), sum(a), avg(a) from t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` datetime(4) DEFAULT NULL,
+ `a+0` decimal(25,4) DEFAULT NULL,
+ `a-1` decimal(25,4) DEFAULT NULL,
+ `a*1` decimal(25,4) DEFAULT NULL,
+ `a/2` decimal(28,8) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `max(a)` datetime(4) DEFAULT NULL,
+ `min(a)` datetime(4) DEFAULT NULL,
+ `sum(a)` decimal(46,4) DEFAULT NULL,
+ `avg(a)` decimal(28,8) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2, t3;
+create table t1 (f0_datetime datetime(0), f1_datetime datetime(1), f2_datetime datetime(2), f3_datetime datetime(3), f4_datetime datetime(4), f5_datetime datetime(5), f6_datetime datetime(6));
+insert t1 values ( '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432');
+select * from t1;
+f0_datetime 2010-11-12 11:14:17
+f1_datetime 2010-11-12 11:14:17.7
+f2_datetime 2010-11-12 11:14:17.76
+f3_datetime 2010-11-12 11:14:17.765
+f4_datetime 2010-11-12 11:14:17.7654
+f5_datetime 2010-11-12 11:14:17.76543
+f6_datetime 2010-11-12 11:14:17.765432
+select cast(f0_datetime as time(4)) time4_f0_datetime, cast(f1_datetime as datetime(3)) datetime3_f1_datetime, cast(f2_datetime as date) date_f2_datetime, cast(f4_datetime as double) double_f3_datetime, cast(f4_datetime as decimal(40,5)) decimal5_f4_datetime, cast(f5_datetime as signed) bigint_f5_datetime, cast(f6_datetime as char(255)) varchar_f6_datetime from t1;
+time4_f0_datetime 11:14:17.0000
+datetime3_f1_datetime 2010-11-12 11:14:17.700
+date_f2_datetime 2010-11-12
+double_f3_datetime 20101112111417.8
+decimal5_f4_datetime 20101112111417.76540
+bigint_f5_datetime 20101112111417
+varchar_f6_datetime 2010-11-12 11:14:17.765432
+create table t2 (time4_f0_datetime time(4), datetime3_f1_datetime datetime(3), date_f2_datetime date, double_f3_datetime double, decimal5_f4_datetime decimal(40,5), bigint_f5_datetime bigint, varchar_f6_datetime varchar(255));
+insert t2 select * from t1;
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'time4_f0_datetime' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'date_f2_datetime' at row 1
+select * from t2;
+time4_f0_datetime 11:14:17.0000
+datetime3_f1_datetime 2010-11-12 11:14:17.700
+date_f2_datetime 2010-11-12
+double_f3_datetime 20101112111417.8
+decimal5_f4_datetime 20101112111417.76540
+bigint_f5_datetime 20101112111417
+varchar_f6_datetime 2010-11-12 11:14:17.765432
+alter table t1 change f0_datetime time4_f0_datetime time(4), change f1_datetime datetime3_f1_datetime datetime(3), change f2_datetime date_f2_datetime date, change f3_datetime double_f3_datetime double, change f4_datetime decimal5_f4_datetime decimal(40,5), change f5_datetime bigint_f5_datetime bigint, change f6_datetime varchar_f6_datetime varchar(255);
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'time4_f0_datetime' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'date_f2_datetime' at row 1
+select * from t1;
+time4_f0_datetime 11:14:17.0000
+datetime3_f1_datetime 2010-11-12 11:14:17.700
+date_f2_datetime 2010-11-12
+double_f3_datetime 20101112111417.8
+decimal5_f4_datetime 20101112111417.76540
+bigint_f5_datetime 20101112111417
+varchar_f6_datetime 2010-11-12 11:14:17.765432
+alter table t1 modify time4_f0_datetime datetime(0), modify datetime3_f1_datetime datetime(1), modify date_f2_datetime datetime(2), modify double_f3_datetime datetime(3), modify decimal5_f4_datetime datetime(4), modify bigint_f5_datetime datetime(5), modify varchar_f6_datetime datetime(6);
+select * from t1;
+time4_f0_datetime 0000-00-00 11:14:17
+datetime3_f1_datetime 2010-11-12 11:14:17.7
+date_f2_datetime 2010-11-12 00:00:00.00
+double_f3_datetime 2010-11-12 11:14:17.800
+decimal5_f4_datetime 2010-11-12 11:14:17.7654
+bigint_f5_datetime 2010-11-12 11:14:17.00000
+varchar_f6_datetime 2010-11-12 11:14:17.765432
+delete from t1;
+insert t1 select * from t2;
+select * from t1;
+time4_f0_datetime 0000-00-00 11:14:17
+datetime3_f1_datetime 2010-11-12 11:14:17.7
+date_f2_datetime 2010-11-12 00:00:00.00
+double_f3_datetime 2010-11-12 11:14:17.765
+decimal5_f4_datetime 2010-11-12 11:14:17.7654
+bigint_f5_datetime 2010-11-12 11:14:17.00000
+varchar_f6_datetime 2010-11-12 11:14:17.765432
+drop table t1, t2;
+create table t1 (a datetime(6), b datetime(6));
+create procedure foo(x datetime, y datetime(4)) insert into t1 values (x, y);
+call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
+select * from t1;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+create procedure bar(a int, c datetime(5))
+begin
+declare b datetime(4);
+set b = c + interval a microsecond;
+insert t1 values (b, c + interval a microsecond);
+end|
+call bar(1111111, '2011-01-02 3:4:5.123456');
+select * from t1;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
+drop procedure foo;
+drop procedure bar;
+create function xyz(s char(20)) returns datetime(4)
+return addtime('2010-10-10 10:10:10.101010', s);
+select xyz('1:1:1.010101');
+xyz('1:1:1.010101')
+2010-10-10 11:11:11.1111
+drop function xyz;
+create view v1 as select * from t1 group by a,b;
+select * from v1;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
+show columns from v1;
+Field Type Null Key Default Extra
+a datetime(6) YES NULL
+b datetime(6) YES NULL
+create table t2 select * from v1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` datetime(6) DEFAULT NULL,
+ `b` datetime(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t2;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
+drop view v1;
+drop table t1, t2;
+CREATE TABLE t1 (
+taken datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
+id int(11) NOT NULL DEFAULT '0',
+PRIMARY KEY (id,taken),
+KEY taken (taken)
+)
+PARTITION BY RANGE (to_days(taken))
+(
+PARTITION p01 VALUES LESS THAN (732920),
+PARTITION p02 VALUES LESS THAN (732950),
+PARTITION p03 VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES
+('2006-09-27 21:50:01.123456',0),
+('2006-09-27 21:50:01.123456',1),
+('2006-09-27 21:50:01.123456',2),
+('2006-09-28 21:50:01.123456',3),
+('2006-09-29 21:50:01.123456',4),
+('2006-09-29 21:50:01.123456',5),
+('2006-09-30 21:50:01.123456',6),
+('2006-10-01 21:50:01.123456',7),
+('2006-10-02 21:50:01.123456',8),
+('2006-10-02 21:50:01.123456',9);
+SELECT id,to_days(taken) FROM t1 order by 2;
+id to_days(taken)
+0 732946
+1 732946
+2 732946
+3 732947
+5 732948
+4 732948
+6 732949
+7 732950
+8 732951
+9 732951
+CREATE TABLE t2 (
+taken datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
+id int(11) NOT NULL DEFAULT '0',
+PRIMARY KEY (id,taken),
+KEY taken (taken)
+)
+PARTITION BY RANGE (extract(microsecond from taken))
+(
+PARTITION p01 VALUES LESS THAN (123000),
+PARTITION p02 VALUES LESS THAN (500000),
+PARTITION p03 VALUES LESS THAN MAXVALUE);
+INSERT INTO t2 VALUES
+('2006-09-27 21:50:01',0),
+('2006-09-27 21:50:01.1',1),
+('2006-09-27 21:50:01.12',2),
+('2006-09-28 21:50:01.123',3),
+('2006-09-29 21:50:01.1234',4),
+('2006-09-29 21:50:01.12345',5),
+('2006-09-30 21:50:01.123456',6),
+('2006-10-01 21:50:01.56',7),
+('2006-10-02 21:50:01.567',8),
+('2006-10-02 21:50:01.5678',9);
+select table_name,partition_name,partition_method,partition_expression,partition_description,table_rows from information_schema.partitions where table_name in ('t1', 't2');
+table_name partition_name partition_method partition_expression partition_description table_rows
+t1 p01 RANGE to_days(taken) 732920 0
+t1 p02 RANGE to_days(taken) 732950 7
+t1 p03 RANGE to_days(taken) MAXVALUE 3
+t2 p01 RANGE extract(microsecond from taken) 123000 3
+t2 p02 RANGE extract(microsecond from taken) 500000 4
+t2 p03 RANGE extract(microsecond from taken) MAXVALUE 3
+drop table t1, t2;
+create table t1 (a datetime, b datetime(6));
+insert t1 values ('2010-01-02 03:04:05.678912', '2010-01-02 03:04:05.678912');
+update t1 set b=a;
+select * from t1;
+a b
+2010-01-02 03:04:05 2010-01-02 03:04:05.000000
+alter table t1 modify b datetime, modify a datetime(6);
+select * from t1;
+a b
+2010-01-02 03:04:05.000000 2010-01-02 03:04:05
+drop table t1;
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index 76c5ea8f756..a0252676d65 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -721,7 +721,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (d decimal(66,0));
-ERROR 42000: Too big precision 66 specified for column 'd'. Maximum is 65.
+ERROR 42000: Too big precision 66 specified for 'd'. Maximum is 65.
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index a3a13bb0435..386bb4569d8 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -133,7 +133,7 @@ min(a)
-0.010
drop table t1;
create table t1 (a float(200,100), b double(200,100));
-ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30.
+ERROR 42000: Too big scale 100 specified for 'a'. Maximum is 30.
create table t1 (c20 char);
insert into t1 values (5000.0);
Warnings:
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 70ee3a56cf3..69b99a80b75 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -825,7 +825,7 @@ Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
INSERT INTO Sow6_2f VALUES ('a59b');
-ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f;
select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000
@@ -838,12 +838,12 @@ select 9999999999999999999999999999999999999999999999999999999999999999999999999
x
99999999999999999999999999999999999999999999999999999999999999999
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
x
100000000000000000000000000000000000000000000000000000000000000000
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
select 0.190287977636363637 + 0.040372670 * 0 - 0;
0.190287977636363637 + 0.040372670 * 0 - 0
0.190287977636363637
@@ -923,11 +923,11 @@ ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column
select cast(ln(14000) as decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
create table t1 (sl decimal(70,30));
-ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
+ERROR 42000: Too big precision 70 specified for 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
-ERROR 42000: Too big scale 31 specified for column 'sl'. Maximum is 30.
+ERROR 42000: Too big scale 31 specified for 'sl'. Maximum is 30.
create table t1 (sl decimal(0,38));
-ERROR 42000: Too big scale 38 specified for column 'sl'. Maximum is 30.
+ERROR 42000: Too big scale 38 specified for 'sl'. Maximum is 30.
create table t1 (sl decimal(0,30));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'sl').
create table t1 (sl decimal(5, 5));
@@ -1380,15 +1380,15 @@ create table t1 (c1 decimal(64));
insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(1e100);
Warnings:
@@ -1432,7 +1432,7 @@ select cast(19999999999999999999 as unsigned);
cast(19999999999999999999 as unsigned)
18446744073709551615
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '19999999999999999999' to UNSIGNED INT. Value truncated.
create table t1(a decimal(18));
insert into t1 values(123456789012345678);
alter table t1 modify column a decimal(19);
@@ -1485,12 +1485,12 @@ SELECT CAST(1 AS decimal(65,10));
CAST(1 AS decimal(65,10))
1.0000000000
SELECT CAST(1 AS decimal(66,10));
-ERROR 42000: Too big precision 66 specified for column '1'. Maximum is 65.
+ERROR 42000: Too big precision 66 specified for '1'. Maximum is 65.
SELECT CAST(1 AS decimal(65,30));
CAST(1 AS decimal(65,30))
1.000000000000000000000000000000
SELECT CAST(1 AS decimal(65,31));
-ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
+ERROR 42000: Too big scale 31 specified for '1'. Maximum is 30.
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa;
@@ -1499,7 +1499,7 @@ aa SUM(b)
3.000000000000000000000000000000 10
4.000000000000000000000000000000 30
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa;
-ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
+ERROR 42000: Too big scale 31 specified for '1'. Maximum is 30.
DROP TABLE t1;
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
@@ -1674,7 +1674,7 @@ CREATE TABLE t1 SELECT
/* 82 */ 1000000000000000000000000000000000000000000000000000000000000000000000000000000001
AS c1;
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index 86712bebfa1..f2464465d60 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -1,6 +1,8 @@
drop table if exists t1;
create table t1 (t time);
insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
+Warnings:
+Note 1265 Data truncated for column 't' at row 13
insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
select * from t1;
t
@@ -26,9 +28,9 @@ t
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
Warnings:
Warning 1265 Data truncated for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
-Warning 1264 Out of range value for column 't' at row 3
-Warning 1264 Out of range value for column 't' at row 4
+Warning 1265 Data truncated for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 3
+Warning 1265 Data truncated for column 't' at row 4
Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
@@ -53,8 +55,8 @@ t
36:30:31
00:00:10
00:00:00
-838:59:59
-838:59:59
+00:00:00
+00:00:00
262:22:00
00:00:12
drop table t1;
@@ -148,3 +150,26 @@ TIMESTAMP(f1,'1')
NULL
DROP TABLE t1;
End of 5.1 tests
+create table t1 (a time);
+insert t1 values (-131415);
+select * from t1;
+a
+-13:14:15
+drop table t1;
+create table t1 (f1 time , f2 varchar(5), key(f1));
+insert into t1 values ('00:20:01','a'),('00:20:03','b');
+select * from t1 force key (f1) where f1 < curdate();
+f1 f2
+00:20:01 a
+00:20:03 b
+select * from t1 ignore key (f1) where f1 < curdate();
+f1 f2
+00:20:01 a
+00:20:03 b
+drop table t1;
+create table t1(f1 time);
+insert into t1 values ('23:38:57');
+select f1, f1 = '2010-10-11 23:38:57' from t1;
+f1 f1 = '2010-10-11 23:38:57'
+23:38:57 0
+drop table t1;
diff --git a/mysql-test/r/type_time_hires.result b/mysql-test/r/type_time_hires.result
new file mode 100644
index 00000000000..bf54434a04c
--- /dev/null
+++ b/mysql-test/r/type_time_hires.result
@@ -0,0 +1,340 @@
+drop table if exists t1, t2, t3;
+create table t1 (a time(7));
+ERROR 42000: Too big precision 7 specified for 'a'. Maximum is 6.
+create table t1 (a time(3), key(a));
+insert t1 values ('2010-12-11 00:20:03.1234');
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+insert t1 values ('2010-12-11 15:47:11.1234');
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+insert t1 values (20101211010203.45678);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+insert t1 values (20101211030405.789e0);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+insert t1 values (99991231235959e1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+select * from t1;
+a
+00:00:00.000
+00:20:03.123
+01:02:03.456
+03:04:05.789
+15:47:11.123
+select truncate(a, 6) from t1;
+truncate(a, 6)
+0.000000
+2003.123000
+10203.456000
+30405.789062
+154711.123000
+select a DIV 1 from t1;
+a DIV 1
+0
+2003
+10203
+30405
+154711
+select group_concat(distinct a) from t1;
+group_concat(distinct a)
+00:00:00.000,00:20:03.123,01:02:03.456,03:04:05.789,15:47:11.123
+alter table t1 engine=innodb;
+select * from t1 order by a;
+a
+00:00:00.000
+00:20:03.123
+01:02:03.456
+03:04:05.789
+15:47:11.123
+select * from t1 order by a+0;
+a
+00:00:00.000
+00:20:03.123
+01:02:03.456
+03:04:05.789
+15:47:11.123
+drop table t1;
+create table t1 (a time(4)) engine=innodb;
+insert t1 values ('2010-12-11 01:02:03.456789');
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+select * from t1;
+a
+01:02:03.4567
+select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
+extract(microsecond from a + interval 100 microsecond)
+select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
+a
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` time(4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show columns from t1;
+Field Type Null Key Default Extra
+a time(4) YES NULL
+select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1';
+table_name t1
+column_name a
+column_default NULL
+is_nullable YES
+data_type time
+character_maximum_length NULL
+character_octet_length NULL
+numeric_precision NULL
+numeric_scale NULL
+datetime_precision 4
+character_set_name NULL
+collation_name NULL
+column_type time(4)
+column_key
+extra
+select a, a+interval 9876543 microsecond from t1;
+a a+interval 9876543 microsecond
+01:02:03.4567 01:02:13.333243
+update t1 set a=a+interval 9876543 microsecond;
+select * from t1;
+a
+01:02:13.3332
+select a, a + interval 2 year from t1;
+a a + interval 2 year
+01:02:13.3332 NULL
+Warnings:
+Warning 1441 Datetime function: time field overflow
+insert t1 select a + interval 2 year from t1;
+Warnings:
+Warning 1441 Datetime function: time field overflow
+select * from t1;
+a
+01:02:13.3332
+NULL
+delete from t1 where a < 20110101;
+select * from t1;
+a
+01:02:13.3332
+NULL
+create table t2 select * from t1;
+create table t3 like t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` time(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` time(4) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2, t3;
+insert t1 values ('2010-12-13 14:15:16.222222');
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+select a, a+0, a-1, a*1, a/2 from t1;
+a a+0 a-1 a*1 a/2
+01:02:13.3332 10213.3332 10212.3332 10213.3332 5106.66660000
+NULL NULL NULL NULL NULL
+14:15:16.2222 141516.2222 141515.2222 141516.2222 70758.11110000
+select max(a), min(a), sum(a), avg(a) from t1;
+max(a) min(a) sum(a) avg(a)
+14:15:16.2222 01:02:13.3332 151729.5554 75864.77770000
+create table t2 select a, a+0, a-1, a*1, a/2 from t1;
+create table t3 select max(a), min(a), sum(a), avg(a) from t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` time(4) DEFAULT NULL,
+ `a+0` decimal(16,4) DEFAULT NULL,
+ `a-1` decimal(16,4) DEFAULT NULL,
+ `a*1` decimal(16,4) DEFAULT NULL,
+ `a/2` decimal(19,8) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `max(a)` time(4) DEFAULT NULL,
+ `min(a)` time(4) DEFAULT NULL,
+ `sum(a)` decimal(37,4) DEFAULT NULL,
+ `avg(a)` decimal(19,8) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2, t3;
+create table t1 (f0_time time(0), f1_time time(1), f2_time time(2), f3_time time(3), f4_time time(4), f5_time time(5), f6_time time(6));
+insert t1 values ( '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432');
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'f0_time' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'f1_time' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'f2_time' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'f3_time' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'f4_time' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'f5_time' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'f6_time' at row 1
+select * from t1;
+f0_time 11:14:17
+f1_time 11:14:17.7
+f2_time 11:14:17.76
+f3_time 11:14:17.765
+f4_time 11:14:17.7654
+f5_time 11:14:17.76543
+f6_time 11:14:17.765432
+select cast(f0_time as time(4)) time4_f0_time, cast(f1_time as datetime(3)) datetime3_f1_time, cast(f2_time as date) date_f2_time, cast(f4_time as double) double_f3_time, cast(f4_time as decimal(40,5)) decimal5_f4_time, cast(f5_time as signed) bigint_f5_time, cast(f6_time as char(255)) varchar_f6_time from t1;
+time4_f0_time 11:14:17.0000
+datetime3_f1_time 0000-00-00 11:14:17.700
+date_f2_time 0000-00-00
+double_f3_time 111417.7654
+decimal5_f4_time 111417.76540
+bigint_f5_time 111417
+varchar_f6_time 11:14:17.765432
+create table t2 (time4_f0_time time(4), datetime3_f1_time datetime(3), date_f2_time date, double_f3_time double, decimal5_f4_time decimal(40,5), bigint_f5_time bigint, varchar_f6_time varchar(255));
+insert t2 select * from t1;
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'date_f2_time' at row 1
+select * from t2;
+time4_f0_time 11:14:17.0000
+datetime3_f1_time 0000-00-00 11:14:17.700
+date_f2_time 0000-00-00
+double_f3_time 111417.765
+decimal5_f4_time 111417.76540
+bigint_f5_time 111417
+varchar_f6_time 11:14:17.765432
+alter table t1 change f0_time time4_f0_time time(4), change f1_time datetime3_f1_time datetime(3), change f2_time date_f2_time date, change f3_time double_f3_time double, change f4_time decimal5_f4_time decimal(40,5), change f5_time bigint_f5_time bigint, change f6_time varchar_f6_time varchar(255);
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'date_f2_time' at row 1
+select * from t1;
+time4_f0_time 11:14:17.0000
+datetime3_f1_time 0000-00-00 11:14:17.700
+date_f2_time 0000-00-00
+double_f3_time 111417.765
+decimal5_f4_time 111417.76540
+bigint_f5_time 111417
+varchar_f6_time 11:14:17.765432
+alter table t1 modify time4_f0_time time(0), modify datetime3_f1_time time(1), modify date_f2_time time(2), modify double_f3_time time(3), modify decimal5_f4_time time(4), modify bigint_f5_time time(5), modify varchar_f6_time time(6);
+select * from t1;
+time4_f0_time 11:14:17
+datetime3_f1_time 11:14:17.7
+date_f2_time 00:00:00.00
+double_f3_time 11:14:17.765
+decimal5_f4_time 11:14:17.7654
+bigint_f5_time 11:14:17.00000
+varchar_f6_time 11:14:17.765432
+delete from t1;
+insert t1 select * from t2;
+select * from t1;
+time4_f0_time 11:14:17
+datetime3_f1_time 11:14:17.7
+date_f2_time 00:00:00.00
+double_f3_time 11:14:17.764
+decimal5_f4_time 11:14:17.7654
+bigint_f5_time 11:14:17.00000
+varchar_f6_time 11:14:17.765432
+drop table t1, t2;
+create table t1 (a time(6), b time(6));
+create procedure foo(x time, y time(4)) insert into t1 values (x, y);
+call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
+Warnings:
+Note 1265 Data truncated for column 'x' at row 1
+Note 1265 Data truncated for column 'y' at row 1
+select * from t1;
+a b
+04:05:06.000000 04:05:06.789100
+create procedure bar(a int, c time(5))
+begin
+declare b time(4);
+set b = c + interval a microsecond;
+insert t1 values (b, c + interval a microsecond);
+end|
+call bar(1111111, '2011-01-02 3:4:5.123456');
+Warnings:
+Note 1265 Data truncated for column 'c' at row 1
+select * from t1;
+a b
+04:05:06.000000 04:05:06.789100
+03:04:06.234500 03:04:06.234561
+drop procedure foo;
+drop procedure bar;
+create function xyz(s char(20)) returns time(4)
+return addtime('2010-10-10 10:10:10.101010', s);
+select xyz('1:1:1.010101');
+xyz('1:1:1.010101')
+11:11:11.1111
+Warnings:
+Note 1265 Data truncated for column 'xyz('1:1:1.010101')' at row 1
+drop function xyz;
+create view v1 as select * from t1 group by a,b;
+select * from v1;
+a b
+03:04:06.234500 03:04:06.234561
+04:05:06.000000 04:05:06.789100
+show columns from v1;
+Field Type Null Key Default Extra
+a time(6) YES NULL
+b time(6) YES NULL
+create table t2 select * from v1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` time(6) DEFAULT NULL,
+ `b` time(6) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t2;
+a b
+03:04:06.234500 03:04:06.234561
+04:05:06.000000 04:05:06.789100
+drop view v1;
+drop table t1, t2;
+create table t1 (a time(4) not null, key(a));
+insert into t1 values ('1:2:3.001'),('1:2:3'), ('-00:00:00.6'),('-00:00:00.7'),('-00:00:00.8'),('-00:00:00.9'),('-00:00:01.0'),('-00:00:01.1'),('-00:00:01.000000'),('-00:00:01.100001'),('-00:00:01.000002'),('-00:00:01.090000');
+select * from t1 order by a;
+a
+-00:00:01.1000
+-00:00:01.1000
+-00:00:01.0900
+-00:00:01.0000
+-00:00:01.0000
+-00:00:01.0000
+-00:00:00.9000
+-00:00:00.8000
+-00:00:00.7000
+-00:00:00.6000
+01:02:03.0000
+01:02:03.0010
+select * from t1 order by a desc;
+a
+01:02:03.0010
+01:02:03.0000
+-00:00:00.6000
+-00:00:00.7000
+-00:00:00.8000
+-00:00:00.9000
+-00:00:01.0000
+-00:00:01.0000
+-00:00:01.0000
+-00:00:01.0900
+-00:00:01.1000
+-00:00:01.1000
+select min(a - interval 1 hour), max(a - interval 1 hour) from t1 where a < 0;
+min(a - interval 1 hour) max(a - interval 1 hour)
+-01:00:01.1000 -01:00:00.6000
+drop table t1;
+select cast(1e-6 as time(6));
+cast(1e-6 as time(6))
+00:00:00.000001
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index e88d3462466..cfe229d2d15 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -97,30 +97,6 @@ date date_time time_stamp
2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00
2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
-t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
-t14 timestamp(14));
-Warnings:
-Warning 1287 'TIMESTAMP(2)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(4)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(6)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(8)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(10)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(12)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(14)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-t2 t4 t6 t8 t10 t12 t14
-0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
-1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
-select * from t1;
-t2 t4 t6 t8 t10 t12 t14
-0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
-1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
-drop table t1;
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
Warnings:
@@ -436,12 +412,12 @@ max(t)
2004-02-01 00:00:00
drop table t1;
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp(5));
show create table t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" datetime DEFAULT NULL,
- "b" datetime DEFAULT NULL
+ "b" datetime(5) DEFAULT NULL
)
set sql_mode='';
drop table t1;
@@ -547,4 +523,67 @@ a
2000-01-01 00:00:01
2000-01-01 00:00:01
DROP TABLE t1;
+#
+# Bug#50774: failed to get the correct resultset when timestamp values
+# are appended with .0
+#
+CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:01' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:02' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:03' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:04' );
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+a
+2010-02-01 09:31:02
+2010-02-01 09:31:03
+2010-02-01 09:31:04
+SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a;
+a
+2010-02-01 09:31:02
+2010-02-01 09:31:03
+2010-02-01 09:31:04
+SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0';
+a
+2010-02-01 09:31:01
+2010-02-01 09:31:02
+SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a;
+a
+2010-02-01 09:31:01
+2010-02-01 09:31:02
+EXPLAIN
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+id select_type table type possible_keys key key_len ref rows Extra
+x x x range x x x x x x
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+a
+2010-02-01 09:31:02
+2010-02-01 09:31:03
+2010-02-01 09:31:04
+CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:01' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:02' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:03' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:04' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:05' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:06' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:07' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:08' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:09' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:10' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:11' );
+# The bug would cause the range optimizer's comparison to use an open
+# interval here. This reveals itself only in the number of reads
+# performed.
+FLUSH STATUS;
+EXPLAIN
+SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
+id select_type table type possible_keys key key_len ref rows Extra
+x x x range x x x x x x
+SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
+a
+2010-02-01 09:31:01
+SHOW STATUS LIKE 'Handler_read_next';
+Variable_name Value
+Handler_read_next 1
+DROP TABLE t1, t2;
End of 5.1 tests
diff --git a/mysql-test/r/type_timestamp_hires.result b/mysql-test/r/type_timestamp_hires.result
new file mode 100644
index 00000000000..b19542f90e7
--- /dev/null
+++ b/mysql-test/r/type_timestamp_hires.result
@@ -0,0 +1,280 @@
+drop table if exists t1, t2, t3;
+create table t1 (a timestamp(7));
+ERROR 42000: Too big precision 7 specified for 'a'. Maximum is 6.
+create table t1 (a timestamp(3), key(a));
+insert t1 values ('2010-12-11 00:20:03.1234');
+insert t1 values ('2010-12-11 15:47:11.1234');
+insert t1 values (20101211010203.45678);
+insert t1 values (20101211030405.789e0);
+insert t1 values (99991231235959e1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+select * from t1;
+a
+0000-00-00 00:00:00.000
+2010-12-11 00:20:03.123
+2010-12-11 01:02:03.456
+2010-12-11 03:04:05.789
+2010-12-11 15:47:11.123
+select truncate(a, 6) from t1;
+truncate(a, 6)
+0.000000
+20101211002003.121094
+20101211010203.457031
+20101211030405.789062
+20101211154711.121094
+select a DIV 1 from t1;
+a DIV 1
+0
+20101211002003
+20101211010203
+20101211030405
+20101211154711
+select group_concat(distinct a) from t1;
+group_concat(distinct a)
+0000-00-00 00:00:00.000,2010-12-11 00:20:03.123,2010-12-11 01:02:03.456,2010-12-11 03:04:05.789,2010-12-11 15:47:11.123
+alter table t1 engine=innodb;
+select * from t1 order by a;
+a
+0000-00-00 00:00:00.000
+2010-12-11 00:20:03.123
+2010-12-11 01:02:03.456
+2010-12-11 03:04:05.789
+2010-12-11 15:47:11.123
+select * from t1 order by a+0;
+a
+0000-00-00 00:00:00.000
+2010-12-11 00:20:03.123
+2010-12-11 01:02:03.456
+2010-12-11 03:04:05.789
+2010-12-11 15:47:11.123
+drop table t1;
+create table t1 (a timestamp(4)) engine=innodb;
+insert t1 values ('2010-12-11 01:02:03.456789');
+select * from t1;
+a
+2010-12-11 01:02:03.4567
+select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456';
+extract(microsecond from a + interval 100 microsecond)
+456800
+select a from t1 where a>'2010-11-12 01:02:03.456' group by a;
+a
+2010-12-11 01:02:03.4567
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+show columns from t1;
+Field Type Null Key Default Extra
+a timestamp(4) NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
+select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1';
+table_name t1
+column_name a
+column_default CURRENT_TIMESTAMP
+is_nullable NO
+data_type timestamp
+character_maximum_length NULL
+character_octet_length NULL
+numeric_precision NULL
+numeric_scale NULL
+datetime_precision 4
+character_set_name NULL
+collation_name NULL
+column_type timestamp(4)
+column_key
+extra on update CURRENT_TIMESTAMP
+select a, a+interval 9876543 microsecond from t1;
+a a+interval 9876543 microsecond
+2010-12-11 01:02:03.4567 2010-12-11 01:02:13.333243
+update t1 set a=a+interval 9876543 microsecond;
+select * from t1;
+a
+2010-12-11 01:02:13.3332
+select a, a + interval 2 year from t1;
+a a + interval 2 year
+2010-12-11 01:02:13.3332 2012-12-11 01:02:13.3332
+insert t1 select a + interval 2 year from t1;
+select * from t1;
+a
+2010-12-11 01:02:13.3332
+2012-12-11 01:02:13.3332
+delete from t1 where a < 20110101;
+select * from t1;
+a
+2012-12-11 01:02:13.3332
+create table t2 select * from t1;
+create table t3 like t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2, t3;
+insert t1 values ('2010-12-13 14:15:16.222222');
+select a, a+0, a-1, a*1, a/2 from t1;
+a a+0 a-1 a*1 a/2
+2012-12-11 01:02:13.3332 20121211010213.3332 20121211010212.3332 20121211010213.3332 10060605505106.66660000
+2010-12-13 14:15:16.2222 20101213141516.2222 20101213141515.2222 20101213141516.2222 10050606570758.11110000
+select max(a), min(a), sum(a), avg(a) from t1;
+max(a) min(a) sum(a) avg(a)
+2012-12-11 01:02:13.3332 2010-12-13 14:15:16.2222 40222424151729.5554 20111212075864.77770000
+create table t2 select a, a+0, a-1, a*1, a/2 from t1;
+create table t3 select max(a), min(a), sum(a), avg(a) from t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` timestamp(4) NOT NULL DEFAULT '0000-00-00 00:00:00.0000',
+ `a+0` decimal(25,4) NOT NULL DEFAULT '0.0000',
+ `a-1` decimal(25,4) NOT NULL DEFAULT '0.0000',
+ `a*1` decimal(25,4) NOT NULL DEFAULT '0.0000',
+ `a/2` decimal(28,8) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `max(a)` timestamp(4) NULL DEFAULT NULL,
+ `min(a)` timestamp(4) NULL DEFAULT NULL,
+ `sum(a)` decimal(46,4) DEFAULT NULL,
+ `avg(a)` decimal(28,8) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2, t3;
+create table t1 (f0_timestamp timestamp(0), f1_timestamp timestamp(1), f2_timestamp timestamp(2), f3_timestamp timestamp(3), f4_timestamp timestamp(4), f5_timestamp timestamp(5), f6_timestamp timestamp(6));
+insert t1 values ( '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432', '2010-11-12 11:14:17.765432');
+select * from t1;
+f0_timestamp 2010-11-12 11:14:17
+f1_timestamp 2010-11-12 11:14:17.7
+f2_timestamp 2010-11-12 11:14:17.76
+f3_timestamp 2010-11-12 11:14:17.765
+f4_timestamp 2010-11-12 11:14:17.7654
+f5_timestamp 2010-11-12 11:14:17.76543
+f6_timestamp 2010-11-12 11:14:17.765432
+select cast(f0_timestamp as time(4)) time4_f0_timestamp, cast(f1_timestamp as datetime(3)) datetime3_f1_timestamp, cast(f2_timestamp as date) date_f2_timestamp, cast(f4_timestamp as double) double_f3_timestamp, cast(f4_timestamp as decimal(40,5)) decimal5_f4_timestamp, cast(f5_timestamp as signed) bigint_f5_timestamp, cast(f6_timestamp as char(255)) varchar_f6_timestamp from t1;
+time4_f0_timestamp 11:14:17.0000
+datetime3_f1_timestamp 2010-11-12 11:14:17.700
+date_f2_timestamp 2010-11-12
+double_f3_timestamp 20101112111417.8
+decimal5_f4_timestamp 20101112111417.76540
+bigint_f5_timestamp 20101112111417
+varchar_f6_timestamp 2010-11-12 11:14:17.765432
+create table t2 (time4_f0_timestamp time(4), datetime3_f1_timestamp datetime(3), date_f2_timestamp date, double_f3_timestamp double, decimal5_f4_timestamp decimal(40,5), bigint_f5_timestamp bigint, varchar_f6_timestamp varchar(255));
+insert t2 select * from t1;
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'time4_f0_timestamp' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'date_f2_timestamp' at row 1
+select * from t2;
+time4_f0_timestamp 11:14:17.0000
+datetime3_f1_timestamp 2010-11-12 11:14:17.700
+date_f2_timestamp 2010-11-12
+double_f3_timestamp 20101112111417.8
+decimal5_f4_timestamp 20101112111417.76540
+bigint_f5_timestamp 20101112111417
+varchar_f6_timestamp 2010-11-12 11:14:17.765432
+alter table t1 change f0_timestamp time4_f0_timestamp time(4), change f1_timestamp datetime3_f1_timestamp datetime(3), change f2_timestamp date_f2_timestamp date, change f3_timestamp double_f3_timestamp double, change f4_timestamp decimal5_f4_timestamp decimal(40,5), change f5_timestamp bigint_f5_timestamp bigint, change f6_timestamp varchar_f6_timestamp varchar(255);
+Warnings:
+Level Note
+Code 1265
+Message Data truncated for column 'time4_f0_timestamp' at row 1
+Level Note
+Code 1265
+Message Data truncated for column 'date_f2_timestamp' at row 1
+select * from t1;
+time4_f0_timestamp 11:14:17.0000
+datetime3_f1_timestamp 2010-11-12 11:14:17.700
+date_f2_timestamp 2010-11-12
+double_f3_timestamp 20101112111417.8
+decimal5_f4_timestamp 20101112111417.76540
+bigint_f5_timestamp 20101112111417
+varchar_f6_timestamp 2010-11-12 11:14:17.765432
+alter table t1 modify time4_f0_timestamp timestamp(0), modify datetime3_f1_timestamp timestamp(1), modify date_f2_timestamp timestamp(2), modify double_f3_timestamp timestamp(3), modify decimal5_f4_timestamp timestamp(4), modify bigint_f5_timestamp timestamp(5), modify varchar_f6_timestamp timestamp(6);
+Warnings:
+Level Warning
+Code 1265
+Message Data truncated for column 'time4_f0_timestamp' at row 1
+select * from t1;
+time4_f0_timestamp 0000-00-00 00:00:00
+datetime3_f1_timestamp 2010-11-12 11:14:17.7
+date_f2_timestamp 2010-11-12 00:00:00.00
+double_f3_timestamp 2010-11-12 11:14:17.800
+decimal5_f4_timestamp 2010-11-12 11:14:17.7654
+bigint_f5_timestamp 2010-11-12 11:14:17.00000
+varchar_f6_timestamp 2010-11-12 11:14:17.765432
+delete from t1;
+insert t1 select * from t2;
+Warnings:
+Level Warning
+Code 1265
+Message Data truncated for column 'time4_f0_timestamp' at row 1
+select * from t1;
+time4_f0_timestamp 0000-00-00 00:00:00
+datetime3_f1_timestamp 2010-11-12 11:14:17.7
+date_f2_timestamp 2010-11-12 00:00:00.00
+double_f3_timestamp 2010-11-12 11:14:17.765
+decimal5_f4_timestamp 2010-11-12 11:14:17.7654
+bigint_f5_timestamp 2010-11-12 11:14:17.00000
+varchar_f6_timestamp 2010-11-12 11:14:17.765432
+drop table t1, t2;
+create table t1 (a timestamp(6), b timestamp(6));
+create procedure foo(x timestamp, y timestamp(4)) insert into t1 values (x, y);
+call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123');
+select * from t1;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+create procedure bar(a int, c timestamp(5))
+begin
+declare b timestamp(4);
+set b = c + interval a microsecond;
+insert t1 values (b, c + interval a microsecond);
+end|
+call bar(1111111, '2011-01-02 3:4:5.123456');
+select * from t1;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
+drop procedure foo;
+drop procedure bar;
+create function xyz(s char(20)) returns timestamp(4)
+return addtime('2010-10-10 10:10:10.101010', s);
+select xyz('1:1:1.010101');
+xyz('1:1:1.010101')
+2010-10-10 11:11:11.1111
+drop function xyz;
+create view v1 as select * from t1 group by a,b;
+select * from v1;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
+show columns from v1;
+Field Type Null Key Default Extra
+a timestamp(6) NO 0000-00-00 00:00:00.000000
+b timestamp(6) NO 0000-00-00 00:00:00.000000
+create table t2 select * from v1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
+ `b` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t2;
+a b
+2010-02-03 04:05:06.000000 2010-02-03 04:05:06.789100
+2011-01-02 03:04:06.234500 2011-01-02 03:04:06.234561
+drop view v1;
+drop table t1, t2;
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
+create table t1 (a timestamp(5));
+insert t1 values ();
+select * from t1;
+a
+2011-01-01 01:01:01.12345
+drop table t1;
diff --git a/mysql-test/r/type_year.result b/mysql-test/r/type_year.result
index 2dc491c6166..5a484f3ce3c 100644
--- a/mysql-test/r/type_year.result
+++ b/mysql-test/r/type_year.result
@@ -353,6 +353,9 @@ c1
SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
total_rows min_value MAX(c1)
3 0 2155
+SELECT COUNT(*) AS total_rows, MIN(c1+0) AS min_value, MAX(c1+0) FROM t1;
+total_rows min_value MAX(c1+0)
+3 0 2155
DROP TABLE t1;
#
End of 5.1 tests
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index cd3091b072b..4495836f568 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -414,7 +414,7 @@ a
5
select found_rows();
found_rows()
-6
+5
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2;
a
1
@@ -447,7 +447,7 @@ a
4
select found_rows();
found_rows()
-6
+5
SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2;
a
3
@@ -522,7 +522,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 (select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where 1)
+Note 1003 (select 1 AS `a`,1 AS `b` from `test`.`t1` where 1) union (select 1 AS `a`,10 AS `b` from `test`.`t2` where 1)
(select * from t1 where a=5) union (select * from t2 where a=1);
a b
1 10
@@ -1208,9 +1208,12 @@ a b
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
+2 b
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
+2 b
+3 c
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
a b
1 a
@@ -1632,11 +1635,11 @@ ORDER BY (SELECT a FROM t2 WHERE b = 12);
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
2 UNION t1 ALL NULL NULL NULL NULL 2 100.00
-3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort
+3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` union select `test`.`t1`.`a` AS `a` from `test`.`t1` order by (select `test`.`t1`.`a` from `test`.`t2` where (`test`.`t2`.`b` = 12))
+Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #-1
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` union select `test`.`t1`.`a` AS `a` from `test`.`t1` order by (select `a` from `test`.`t2` where (`test`.`t2`.`b` = 12))
# Should not crash
SELECT * FROM t1 UNION SELECT * FROM t1
ORDER BY (SELECT a FROM t2 WHERE b = 12);
@@ -1647,4 +1650,17 @@ b
1
2
DROP TABLE t1,t2;
+create table t1 (a int);
+insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10);
+select a from t1 where false UNION select a from t1 limit 8;
+a
+10
+2
+3
+4
+5
+6
+7
+8
+drop table t1;
End of 5.1 tests
diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result
index f2c8886c915..ec63cc0d98c 100644
--- a/mysql-test/r/upgrade.result
+++ b/mysql-test/r/upgrade.result
@@ -48,14 +48,10 @@ insert into `txu#p#p1` values (1);
select * from `txu@0023p@0023p1`;
ERROR 42S02: Table 'test.txu@0023p@0023p1' doesn't exist
create table `txu@0023p@0023p1` (s1 int);
-insert into `txu@0023p@0023p1` values (2);
-select * from `txu@0023p@0023p1`;
-s1
-2
+ERROR 42S01: Table '#mysql50#txu@0023p@0023p1' already exists
select * from `txu#p#p1`;
s1
1
-drop table `txu@0023p@0023p1`;
drop table `txu#p#p1`;
#
# Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result
index b623ea1d86e..545044fc520 100644
--- a/mysql-test/r/varbinary.result
+++ b/mysql-test/r/varbinary.result
@@ -15,7 +15,7 @@ explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 const UNIQ UNIQ 8 const 1 100.00
Warnings:
-Note 1003 select '00000001' AS `ID`,'004084688022709641610' AS `UNIQ` from `test`.`t1` where 1
+Note 1003 select 00000001 AS `ID`,004084688022709641610 AS `UNIQ` from `test`.`t1` where 1
drop table t1;
select x'hello';
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 'x'hello'' at line 1
diff --git a/mysql-test/r/variables-notembedded.result b/mysql-test/r/variables-notembedded.result
index c9a1d64cdd0..6089d39780b 100644
--- a/mysql-test/r/variables-notembedded.result
+++ b/mysql-test/r/variables-notembedded.result
@@ -108,3 +108,27 @@ SET @@session.slave_skip_errors= 7;
ERROR HY000: Variable 'slave_skip_errors' is a read only variable
SET @@global.slave_skip_errors= 7;
ERROR HY000: Variable 'slave_skip_errors' is a read only variable
+#
+# Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET
+# ARE NOT BEING HONORED
+#
+CREATE TABLE t1 (a MEDIUMTEXT);
+SET GLOBAL max_allowed_packet=2048;
+Warnings:
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
+SET GLOBAL net_buffer_length=4096;
+Warnings:
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
+SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
+Variable_name Value
+max_allowed_packet 2048
+SHOW SESSION VARIABLES LIKE 'net_buffer_length';
+Variable_name Value
+net_buffer_length 4096
+ERROR 08S01: Got a packet bigger than 'max_allowed_packet' bytes
+SELECT LENGTH(a) FROM t1;
+LENGTH(a)
+SET GLOBAL max_allowed_packet=default;
+SET GLOBAL net_buffer_length=default;
+DROP TABLE t1;
+End of 5.1 tests
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index dce5edda6f6..890eb9fcc20 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -278,6 +278,7 @@ NET_BUFFER_LENGTH 1024
set global net_buffer_length=2000000000;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '2000000000'
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
show global variables like 'net_buffer_length';
Variable_name Value
net_buffer_length 1048576
@@ -498,6 +499,7 @@ set low_priority_updates=1;
set global max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
set global max_binlog_cache_size=100;
Warnings:
Warning 1292 Truncated incorrect max_binlog_cache_size value: '100'
@@ -1051,6 +1053,8 @@ set global max_write_lock_count =default;
set global myisam_data_pointer_size =@my_myisam_data_pointer_size;
set global myisam_max_sort_file_size =@my_myisam_max_sort_file_size;
set global net_buffer_length =@my_net_buffer_length;
+Warnings:
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
set global net_write_timeout =@my_net_write_timeout;
set global net_read_timeout =@my_net_read_timeout;
set global rpl_recovery_rank =@my_rpl_recovery_rank;
@@ -1535,4 +1539,52 @@ SET @@global.max_binlog_cache_size=DEFAULT;
SET @@global.max_join_size=DEFAULT;
SET @@global.key_buffer_size=@kbs;
SET @@global.key_cache_block_size=@kcbs;
+select @@max_long_data_size;
+@@max_long_data_size
+1048576
+#
+# Bug#11766424 59527:
+# Assert in DECIMAL_BIN_SIZE:
+# `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
+# This test also exposed a bug with sql_buffer_result
+#
+CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED);
+INSERT INTO t1 VALUES (0.2),(0.1);
+set @a=NULL;
+set sql_buffer_result=0;
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= ROUND(f1);
+one
+1
+explain SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+one
+1
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+one
+1
+set sql_buffer_result=1;
+explain SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+one
+1
+1
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+one
+1
+1
+DROP TABLE t1;
+set sql_buffer_result=0;
+CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(1) unsigned NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 2b6bd3b3706..9f720019303 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -117,7 +117,7 @@ c
12
explain extended select c from v5;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> ALL NULL NULL NULL NULL 5 100.00
+1 SIMPLE <derived3> ALL NULL NULL NULL NULL 5 100.00
3 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00
Warnings:
Note 1003 select (`v2`.`c` + 1) AS `c` from `test`.`v2`
@@ -237,7 +237,7 @@ a
3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a
@@ -302,7 +302,7 @@ a+1
4
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
@@ -1256,8 +1256,8 @@ s1
insert into t1 values (0);
execute stmt1;
s1
-0
1
+0
deallocate prepare stmt1;
drop view v2;
drop table t1, t2;
@@ -3897,6 +3897,15 @@ DROP TABLE t1;
#
CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
DROP VIEW v1;
+#
+# Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+#
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+SELECT * FROM v1;
+a
+DROP VIEW v1;
+DROP TABLE t1;
# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------
@@ -4129,3 +4138,49 @@ Warning 1292 Truncated incorrect INTEGER value: 'VV'
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'JJ')
DROP VIEW v1;
DROP TABLE t1;
+#
+# Bug#777745: crash with equality propagation
+# over view fields
+#
+CREATE TABLE t1 (a int NOT NULL ) ;
+INSERT INTO t1 VALUES (2), (1);
+CREATE TABLE t2 (a int NOT NULL , b int NOT NULL) ;
+INSERT INTO t2 VALUES (2,20),(2,30);
+CREATE VIEW v2 AS SELECT * FROM t2;
+EXPLAIN
+SELECT * FROM t1,v2
+WHERE v2.a = t1.a AND v2.a = 2 AND v2.a IS NULL AND t1.a != 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+SELECT * FROM t1,v2
+WHERE v2.a = t1.a AND v2.a = 2 AND v2.a IS NULL AND t1.a != 0;
+a a b
+EXPLAIN
+SELECT * FROM t1,v2
+WHERE v2.a = t1.a AND v2.a = 2 AND v2.a+1 > 2 AND t1.a != 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+SELECT * FROM t1,v2
+WHERE v2.a = t1.a AND v2.a = 2 AND v2.a+1 > 2 AND t1.a != 0;
+a a b
+2 2 20
+2 2 30
+DROP VIEW v2;
+DROP TABLE t1,t2;
+#
+# Bug#794038: crash with INSERT/UPDATE/DELETE
+# over a non-updatable view
+#
+CREATE TABLE t1 (a int);
+CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
+CREATE ALGORITHM = TEMPTABLE VIEW v3 AS SELECT * FROM v2;
+INSERT INTO v3 VALUES (1);
+ERROR HY000: The target table v3 of the INSERT is not insertable-into
+UPDATE v3 SET a=0;
+ERROR HY000: The target table v3 of the UPDATE is not updatable
+DELETE FROM v3;
+ERROR HY000: The target table v3 of the DELETE is not updatable
+DROP VIEW v1,v2,v3;
+DROP TABLE t1;
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 95a969d3791..4195e90c128 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -324,7 +324,7 @@ select CAST(a AS DECIMAL(13,5)) FROM (SELECT '' as a) t;
CAST(a AS DECIMAL(13,5))
0.00000
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
create table t1 (a integer unsigned);
insert into t1 values (1),(-1),(0),(-2);
diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result
index d0cdd858d4a..dc624a07f4f 100644
--- a/mysql-test/r/windows.result
+++ b/mysql-test/r/windows.result
@@ -16,7 +16,7 @@ CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1,1);
EXPLAIN SELECT * FROM t1 WHERE b = (SELECT max(2));
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
DROP TABLE t1;
CREATE DATABASE `TESTDB`;
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 92f84381415..dda77cba04c 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -1113,4 +1113,23 @@ SELECT UPDATEXML(NULL, (LPAD(0.1111E-15, '2011', 1)), 1);
ERROR 22007: Illegal double '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' value found during parsing
SELECT EXTRACTVALUE('', LPAD(0.1111E-15, '2011', 1));
ERROR 22007: Illegal double '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' value found during parsing
+#
+# Bug #44332 my_xml_scan reads behind the end of buffer
+#
+SELECT UPDATEXML(CONVERT(_latin1'<' USING utf8),'1','1');
+UPDATEXML(CONVERT(_latin1'<' USING utf8),'1','1')
+NULL
+Warnings:
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 2: END-OF-INPUT unexpected (ident or '/' wanted)'
+SELECT UPDATEXML(CONVERT(_latin1'<!--' USING utf8),'1','1');
+UPDATEXML(CONVERT(_latin1'<!--' USING utf8),'1','1')
+NULL
+#
+# Bug#11766725 (bug#59901): EXTRACTVALUE STILL BROKEN AFTER FIX FOR BUG #44332
+#
+SELECT ExtractValue(CONVERT('<\"', BINARY(10)), 1);
+ExtractValue(CONVERT('<\"', BINARY(10)), 1)
+NULL
+Warnings:
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 11: STRING unexpected (ident or '/' wanted)'
End of 5.1 tests
diff --git a/mysql-test/std_data/checkDBI_DBD-mysql.pl b/mysql-test/std_data/checkDBI_DBD-mysql.pl
new file mode 100644
index 00000000000..f001e471081
--- /dev/null
+++ b/mysql-test/std_data/checkDBI_DBD-mysql.pl
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+################################################################################
+#
+# This perl script checks for availability of the Perl modules DBI and
+# DBD::mysql using the "current" perl interpreter.
+#
+# Useful for test environment checking before testing executable perl scripts
+# in the MySQL Server distribution.
+#
+# NOTE: The "shebang" on the first line of this script should always point to
+# /usr/bin/perl, so that we can use this script to check whether or not we
+# support running perl scripts with such a shebang without specifying the
+# perl interpreter on the command line. Such a script is mysqlhotcopy.
+#
+# When run as "checkDBI_DBD-mysql.pl" the shebang line will be evaluated
+# and used. When run as "perl checkDBI_DBD-mysql.pl" the shebang line is
+# not used.
+#
+# NOTE: This script will create a temporary file in MTR's tmp dir.
+# If modules are found, a mysql-test statement which sets a special
+# variable is written to this file. If one of the modules is not found
+# (or cannot be loaded), the file will remain empty.
+# A test (or include file) which sources that file can then easily do
+# an if-check on the special variable to determine success or failure.
+#
+# Example:
+#
+# --let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl
+# --let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt
+# --chmod 0755 $perlChecker
+# --exec $perlChecker
+# --source $resultFile
+# if (!$dbidbd) {
+# --skip Test needs Perl modules DBI and DBD::mysql
+# }
+#
+# The calling script is also responsible for cleaning up after use:
+#
+# --remove_file $resultFile
+#
+# Windows notes:
+# - shebangs may work differently - call this script with "perl " in front.
+#
+# See mysql-test/include/have_dbi_dbd-mysql.inc for example use of this script.
+# This script should be executable for the user running MTR.
+#
+################################################################################
+
+BEGIN {
+ # By using eval inside BEGIN we can suppress warnings and continue after.
+ # We need to catch "Can't locate" as well as "Can't load" errors.
+ eval{
+ $FOUND_DBI=0;
+ $FOUND_DBD_MYSQL=0;
+
+ # Check for DBI module:
+ $FOUND_DBI=1 if require DBI;
+
+ # Check for DBD::mysql module
+ $FOUND_DBD_MYSQL=1 if require DBD::mysql;
+ };
+};
+
+# Open a file to be used for transfer of result back to mysql-test.
+# The file must be created whether we write to it or not, otherwise mysql-test
+# will complain if trying to source it.
+# An empty file indicates failure to load modules.
+open(FILE, ">", $ENV{'MYSQL_TMP_DIR'}.'/dbidbd-mysql.txt');
+
+if ($FOUND_DBI && $FOUND_DBD_MYSQL) {
+ # write a mysql-test command setting a variable to indicate success
+ print(FILE 'let $dbidbd= FOUND_DBI_DBD-MYSQL;'."\n");
+}
+
+# close the file.
+close(FILE);
+
+1;
+
diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result
index 7fb5e50a219..a4c610c845a 100644
--- a/mysql-test/suite/binlog/r/binlog_base64_flag.result
+++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result
@@ -91,6 +91,8 @@ iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA==
';
ERROR HY000: master may suffer from http://bugs.mysql.com/bug.php?id=37426 so slave stops; check error log on slave for more info
drop table t1, char63_utf8, char128_utf8;
+call mtr.add_suppression("Slave SQL.*master suffers from this bug: http:..bugs.mysql.com.bug.php.id=37426.* Error_code: 1105");
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 1 size mismatch.* Error_code: 1535");
#
# Bug #54393: crash and/or valgrind errors in
# mysql_client_binlog_statement
diff --git a/mysql-test/suite/binlog/r/binlog_bug23533.result b/mysql-test/suite/binlog/r/binlog_bug23533.result
new file mode 100644
index 00000000000..d5cd93284a2
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_bug23533.result
@@ -0,0 +1,15 @@
+SET AUTOCOMMIT=0;
+CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1000
+SET GLOBAL binlog_cache_size=4096;
+SET GLOBAL max_binlog_cache_size=4096;
+START TRANSACTION;
+CREATE TABLE t2 SELECT * FROM t1;
+ERROR HY000: Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again
+COMMIT;
+SHOW TABLES LIKE 't%';
+Tables_in_test (t%)
+t1
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/r/binlog_bug36391.result b/mysql-test/suite/binlog/r/binlog_bug36391.result
new file mode 100644
index 00000000000..551bfb9924d
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_bug36391.result
@@ -0,0 +1,10 @@
+CREATE TABLE t1(id INT);
+SHOW TABLES;
+Tables_in_test
+t1
+FLUSH LOGS;
+DROP TABLE t1;
+SHOW TABLES;
+Tables_in_test
+t1
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/r/binlog_checksum.result b/mysql-test/suite/binlog/r/binlog_checksum.result
new file mode 100644
index 00000000000..44024456720
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_checksum.result
@@ -0,0 +1,23 @@
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+reset master;
+must be master-bin.000001
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+create table t1 (a int);
+flush logs;
+drop table t1;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; create table t1 (a int)
+master-bin.000001 # Rotate # # master-bin.000002;pos=4
+show tables;
+Tables_in_test
+t1
+drop table t1;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+End of the tests
diff --git a/mysql-test/suite/binlog/r/binlog_killed.result b/mysql-test/suite/binlog/r/binlog_killed.result
index 72fda535b6f..8809bdca3dd 100644
--- a/mysql-test/suite/binlog/r/binlog_killed.result
+++ b/mysql-test/suite/binlog/r/binlog_killed.result
@@ -6,6 +6,11 @@ get_lock("a", 20)
1
reset master;
insert into t2 values (null, null), (null, get_lock("a", 10));
+kill query ID;
+select
+(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
+is not null;
+set @result= 2 - 1 - 1;
select @result /* must be zero either way */;
@result
0
@@ -55,7 +60,7 @@ drop table t4;
create table t4 (a int, b int) ENGINE=MyISAM /* for killing update and delete */;
create function bug27563(n int)
RETURNS int(11)
-DETERMINISTIC
+NOT DETERMINISTIC
begin
if @b > 0 then
select get_lock("a", 20) into @a;
@@ -84,18 +89,19 @@ a b
select @b /* must be 1 at the end of a stmt calling bug27563() */;
@b
1
-must have the update query event more to FD
+must have the update query event on the 3th line
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # User var # # @`b`=0
master-bin.000001 # Query # # use `test`; update t4 set b=b + bug27563(b)
+*** a proof the query is binlogged with an error ***
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null
1
-select 0 /* must return 0 to mean the killed query is in */;
+select 0 /* must return 0 to mean the killed update is in */;
0
0
select RELEASE_LOCK("a");
@@ -120,7 +126,7 @@ count(*)
select @b /* must be 1 at the end of a stmt calling bug27563() */;
@b
1
-must have the delete query event more to FD
+must have the delete query event on the 3th line
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # User var # # @`b`=0
@@ -131,7 +137,7 @@ is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null
1
-select 0 /* must return 0 to mean the killed query is in */;
+select 0 /* must return 0 to mean the killed delete is in */;
0
0
select RELEASE_LOCK("a");
diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
index 1678f8add58..a30dc69c7c0 100644
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result
@@ -260,10 +260,18 @@ master-bin.000001 # Query # # use `test`; drop table t1
set @bcs = @@binlog_cache_size;
set global binlog_cache_size=4096;
reset master;
-create table t1 (a int) engine=innodb;
+create table t1 (a int, b char(255)) engine=innodb;
+flush status;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 0
+*** the following must show the counter value = 1 ***
+Variable_name Value
+Binlog_cache_use 1
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=innodb
+master-bin.000001 # Query # # use `test`; create table t1 (a int, b char(255)) engine=innodb
+master-bin.000001 # Query # # use `test`; flush status
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
@@ -465,606 +473,6 @@ master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
-master-bin.000001 # Table_map # # table_id: # (test.t1)
-master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Rotate # # master-bin.000002;pos=4
drop table t1;
@@ -1374,6 +782,7 @@ unique_checks OFF
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
# It should not change current session's variables, even error happens
+call mtr.add_suppression("Slave SQL.*Could not execute Write_rows event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
index 92531d9fb54..5b324150d5a 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
@@ -168,411 +168,119 @@ master-bin.000001 # Query # # use `test`; drop table t1
set @bcs = @@binlog_cache_size;
set global binlog_cache_size=4096;
reset master;
-create table t1 (a int) engine=innodb;
+create table t1 (a int, b char(255)) engine=innodb;
+flush status;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 0
+*** the following must show the counter value = 1 ***
+Variable_name Value
+Binlog_cache_use 1
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=innodb
+master-bin.000001 # Query # # use `test`; create table t1 (a int, b char(255)) engine=innodb
+master-bin.000001 # Query # # use `test`; flush status
master-bin.000001 # Query # # BEGIN
-master-bin.000001 # Query # # use `test`; insert into t1 values( 400 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 399 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 398 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 397 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 396 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 395 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 394 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 393 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 392 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 391 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 390 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 389 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 388 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 387 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 386 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 385 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 384 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 383 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 382 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 381 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 380 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 379 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 378 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 377 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 376 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 375 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 374 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 373 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 372 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 371 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 370 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 369 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 368 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 367 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 366 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 365 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 364 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 363 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 362 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 361 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 360 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 359 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 358 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 357 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 356 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 355 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 354 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 353 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 352 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 351 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 350 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 349 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 348 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 347 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 346 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 345 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 344 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 343 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 342 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 341 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 340 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 339 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 338 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 337 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 336 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 335 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 334 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 333 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 332 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 331 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 330 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 329 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 328 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 327 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 326 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 325 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 324 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 323 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 322 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 321 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 320 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 319 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 318 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 317 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 316 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 315 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 314 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 313 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 312 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 311 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 310 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 309 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 308 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 307 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 306 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 305 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 304 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 303 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 302 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 301 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 300 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 299 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 298 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 297 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 296 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 295 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 294 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 293 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 292 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 291 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 290 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 289 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 288 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 287 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 286 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 285 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 284 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 283 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 282 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 281 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 280 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 279 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 278 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 277 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 276 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 275 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 274 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 273 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 272 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 271 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 270 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 269 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 268 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 267 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 266 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 265 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 264 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 263 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 262 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 261 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 260 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 259 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 258 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 257 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 256 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 255 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 254 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 253 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 252 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 251 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 250 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 249 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 248 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 247 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 246 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 245 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 244 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 243 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 242 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 241 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( <binlog_start> )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 239 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 238 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 237 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 236 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 235 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 234 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 233 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 232 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 231 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 230 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 229 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 228 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 227 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 226 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 225 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 224 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 223 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 222 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 221 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 220 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 219 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 218 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 217 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 216 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 215 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 214 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 213 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 212 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 211 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 210 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 209 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 208 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 207 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 206 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 205 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 204 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 203 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 202 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 201 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 200 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 199 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 198 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 197 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 196 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 195 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 194 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 193 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 192 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 191 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 190 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 189 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 188 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 187 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 186 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 185 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 184 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 183 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 182 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 181 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 180 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 179 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 178 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 177 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 176 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 175 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 174 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 173 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 172 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 171 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 170 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 169 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 168 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 167 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 166 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 165 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 164 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 163 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 162 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 161 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 160 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 159 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 158 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 157 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 156 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 155 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 154 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 153 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 152 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 151 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 150 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 149 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 148 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 147 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 146 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 145 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 144 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 143 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 142 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 141 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 140 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 139 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 138 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 137 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 136 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 135 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 134 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 133 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 132 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 131 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 130 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 129 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 128 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 127 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 126 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 125 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 124 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 123 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 122 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 121 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 120 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 119 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 118 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 117 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 116 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 115 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 114 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 113 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 112 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 111 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 110 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 109 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 108 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 107 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 106 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 105 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 104 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 103 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 102 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 101 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 100 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 99 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 98 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 97 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 96 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 95 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 94 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 93 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 92 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 91 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 90 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 89 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 88 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 87 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 86 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 85 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 84 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 83 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 82 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 81 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 80 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 79 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 78 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 77 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 76 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 75 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 74 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 73 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 72 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 71 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 70 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 69 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 68 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 67 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 66 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 65 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 64 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 63 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 62 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 61 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 60 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 59 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 58 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 57 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 56 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 55 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 54 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 53 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 52 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 51 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 50 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 49 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 48 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 47 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 46 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 45 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 44 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 43 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 42 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 41 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 40 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 39 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 38 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 37 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 36 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 35 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 34 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 33 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 32 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 31 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 30 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 29 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 28 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 27 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 26 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 25 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 24 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 23 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 22 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 21 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 20 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 19 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 18 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 17 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 16 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 15 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 14 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 13 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 12 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 11 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 10 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 9 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 8 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 7 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 6 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 5 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 4 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 3 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 2 )
-master-bin.000001 # Query # # use `test`; insert into t1 values( 1 )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 100, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 99, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 98, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 97, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 96, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 95, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 94, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 93, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 92, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 91, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 90, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 89, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 88, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 87, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 86, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 85, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 84, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 83, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 82, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 81, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 80, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 79, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 78, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 77, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 76, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 75, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 74, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 73, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 72, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 71, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 70, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 69, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 68, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 67, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 66, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 65, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 64, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 63, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 62, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 61, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 60, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 59, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 58, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 57, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 56, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 55, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 54, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 53, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 52, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 51, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 50, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 49, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 48, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 47, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 46, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 45, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 44, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 43, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 42, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 41, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 40, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 39, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 38, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 37, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 36, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 35, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 34, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 33, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 32, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 31, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 30, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 29, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 28, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 27, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 26, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 25, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 24, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 23, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 22, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 21, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 20, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 19, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 18, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 17, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 16, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 15, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 14, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 13, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 12, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 11, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 10, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 9, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 8, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 7, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 6, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 5, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 4, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 3, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 2, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
+master-bin.000001 # Query # # use `test`; insert into t1 values( 1, 'just to fill void to make transaction occupying at least two buffers of the trans cache' )
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Rotate # # master-bin.000002;pos=4
drop table t1;
@@ -847,6 +555,7 @@ unique_checks OFF
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
# It should not change current session's variables, even error happens
+call mtr.add_suppression("Slave SQL.*Could not execute Write_rows event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
diff --git a/mysql-test/suite/binlog/t/binlog_base64_flag.test b/mysql-test/suite/binlog/t/binlog_base64_flag.test
index 2964b493c5d..d735dd78bcb 100644
--- a/mysql-test/suite/binlog/t/binlog_base64_flag.test
+++ b/mysql-test/suite/binlog/t/binlog_base64_flag.test
@@ -152,6 +152,8 @@ iONkSBcBAAAAKwAAAMQBAAAQABAAAAAAAAEAA//4AQAAAAMAMTIzAQAAAA==
drop table t1, char63_utf8, char128_utf8;
+call mtr.add_suppression("Slave SQL.*master suffers from this bug: http:..bugs.mysql.com.bug.php.id=37426.* Error_code: 1105");
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 1 size mismatch.* Error_code: 1535");
--echo #
--echo # Bug #54393: crash and/or valgrind errors in
diff --git a/mysql-test/suite/bugs/t/rpl_bug23533.test b/mysql-test/suite/binlog/t/binlog_bug23533.test
index 337dddcef3d..c05abe788c6 100644
--- a/mysql-test/suite/bugs/t/rpl_bug23533.test
+++ b/mysql-test/suite/binlog/t/binlog_bug23533.test
@@ -4,33 +4,47 @@
#############################################################
--source include/have_innodb.inc
+--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc
---source include/master-slave.inc
SET AUTOCOMMIT=0;
-SET GLOBAL max_binlog_cache_size=4096;
-SHOW VARIABLES LIKE 'max_binlog_cache_size';
+# Create 1st table
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
-
--disable_query_log
let $i= 1000;
while ($i)
{
+ BEGIN;
eval INSERT INTO t1 VALUES($i, REPEAT('x', 4096));
+ COMMIT;
dec $i;
}
--enable_query_log
-
SELECT COUNT(*) FROM t1;
+# Set small value for max_binlog_cache_size
+let $saved_binlog_cache_size= query_get_value(SELECT @@binlog_cache_size AS Value, Value, 1);
+let $saved_max_binlog_cache_size= query_get_value(SELECT @@max_binlog_cache_size AS Value, Value, 1);
+SET GLOBAL binlog_cache_size=4096;
+SET GLOBAL max_binlog_cache_size=4096;
+
+# New value of max_binlog_cache_size will apply to new session
+disconnect default;
+connect(default,localhost,root,,test);
+
# Copied data from t1 into t2 large than max_binlog_cache_size
START TRANSACTION;
---error 1534
+--error 1197
CREATE TABLE t2 SELECT * FROM t1;
COMMIT;
SHOW TABLES LIKE 't%';
-
# 5.1 End of Test
---source include/rpl_end.inc
+--disable_query_log
+eval SET GLOBAL max_binlog_cache_size=$saved_max_binlog_cache_size;
+eval SET GLOBAL binlog_cache_size=$saved_binlog_cache_size;
+--enable_query_log
+DROP TABLE t1;
+disconnect default;
+connect(default,localhost,root,,test);
diff --git a/mysql-test/suite/bugs/t/rpl_bug36391-master.opt b/mysql-test/suite/binlog/t/binlog_bug36391-master.opt
index 56273241f14..56273241f14 100644
--- a/mysql-test/suite/bugs/t/rpl_bug36391-master.opt
+++ b/mysql-test/suite/binlog/t/binlog_bug36391-master.opt
diff --git a/mysql-test/suite/bugs/t/rpl_bug36391.test b/mysql-test/suite/binlog/t/binlog_bug36391.test
index 3961082273d..64d91dfafd9 100644
--- a/mysql-test/suite/bugs/t/rpl_bug36391.test
+++ b/mysql-test/suite/binlog/t/binlog_bug36391.test
@@ -13,17 +13,18 @@
#
#
---source include/master-slave.inc
+--source include/have_log_bin.inc
+--source include/have_binlog_format_mixed.inc
-create table t1(id int);
+CREATE TABLE t1(id INT);
+let $binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+let $binlog_path= `SELECT CONCAT(@@DATADIR, '$binlog')`;
+SHOW TABLES;
+FLUSH LOGS;
+DROP TABLE t1;
-show tables;
+--exec $MYSQL_BINLOG $binlog_path | $MYSQL test
+SHOW TABLES;
---source include/show_master_status.inc
-
-flush logs;
-
---exec $MYSQL_BINLOG $MYSQL_TEST_DIR/var/log/master-bin.000001 | $MYSQL test
-
-drop table t1;
---source include/rpl_end.inc
+# Clean up
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/binlog_checksum.test b/mysql-test/suite/binlog/t/binlog_checksum.test
new file mode 100644
index 00000000000..7ecb9308f70
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_checksum.test
@@ -0,0 +1,37 @@
+source include/have_innodb.inc;
+source include/have_log_bin.inc;
+
+#
+# WL#2540 replication event checksum
+#
+# Objectives of the test are:
+# to demo binlog events with CRC32 checksum in them and
+# to prove show binlog events and mysqlbinlog are capable to handle
+# the checksum.
+#
+
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+reset master;
+--echo must be master-bin.000001
+--source include/show_binary_logs.inc
+
+create table t1 (a int);
+flush logs;
+drop table t1;
+
+--source include/show_binlog_events.inc
+--exec $MYSQL_BINLOG -c $MYSQLD_DATADIR/master-bin.000001 | $MYSQL
+show tables;
+
+# clean-up
+
+drop table t1;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+
+--echo End of the tests
diff --git a/mysql-test/suite/binlog/t/binlog_index.test b/mysql-test/suite/binlog/t/binlog_index.test
index c2b8efce57f..86c314e9236 100644
--- a/mysql-test/suite/binlog/t/binlog_index.test
+++ b/mysql-test/suite/binlog/t/binlog_index.test
@@ -6,6 +6,8 @@ source include/not_embedded.inc;
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
source include/have_debug.inc;
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
call mtr.add_suppression('Attempting backtrace');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
diff --git a/mysql-test/suite/binlog/t/binlog_killed.test b/mysql-test/suite/binlog/t/binlog_killed.test
index a2bd7d8095a..dd40f298083 100644
--- a/mysql-test/suite/binlog/t/binlog_killed.test
+++ b/mysql-test/suite/binlog/t/binlog_killed.test
@@ -40,10 +40,15 @@ send insert into t2 values (null, null), (null, get_lock("a", 10));
connection con1;
-disable_abort_on_error;
-disable_query_log;
-disable_result_log;
+--disable_abort_on_error
+--disable_warnings
+
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where info like "%insert into t2 values%" and state like 'User lock';
+--source include/wait_condition.inc
+--replace_regex /[0-9]+/ID/
eval kill query $ID;
connection con2;
@@ -52,20 +57,23 @@ reap;
let $rows= `select count(*) from t2 /* must be 2 or 0 */`;
let $MYSQLD_DATADIR= `select @@datadir`;
-let $start_pos= `select @binlog_start_pos + 28`;
---exec $MYSQL_BINLOG --force-if-open --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
+
+--let $binlog_killed_pos=query_get_value(SHOW BINLOG EVENTS, Pos, 3)
+--let $binlog_killed_end_log_pos=query_get_value(SHOW BINLOG EVENTS, End_log_pos, 3)
+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--disable_result_log
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
is not null;
+--enable_result_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
let $error_code= `select @a like "%#%error_code=0%" /* must return 1 or 0*/`;
let $insert_binlogged= `select @a like "%insert into%" /* must return 1 or 0 */`;
-eval set @result= $rows- $error_code - $insert_binlogged;
+eval set @result= $rows - $error_code - $insert_binlogged;
-enable_abort_on_error;
-enable_query_log;
-enable_result_log;
+--enable_warnings
+--enable_abort_on_error
select @result /* must be zero either way */;
@@ -220,7 +228,7 @@ create table t4 (a int, b int) ENGINE=MyISAM /* for killing update and delete */
delimiter |;
create function bug27563(n int)
RETURNS int(11)
-DETERMINISTIC
+NOT DETERMINISTIC
begin
if @b > 0 then
select get_lock("a", 20) into @a;
@@ -259,19 +267,21 @@ connection con2;
reap;
select * from t4 order by b /* must be (1,1), (1,2) */;
select @b /* must be 1 at the end of a stmt calling bug27563() */;
---echo must have the update query event more to FD
+--echo must have the update query event on the 3th line
source include/show_binlog_events.inc;
+--let $binlog_killed_pos= query_get_value(SHOW BINLOG EVENTS, Pos, 3)
+--let $binlog_killed_end_log_pos= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 3)
-# a proof the query is binlogged with an error
+--echo *** a proof the query is binlogged with an error ***
---exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
let $error_code= `select @a like "%#%error_code=0%" /* must return 0*/`;
-eval select $error_code /* must return 0 to mean the killed query is in */;
+eval select $error_code /* must return 0 to mean the killed update is in */;
# cleanup for the sub-case
connection con1;
@@ -305,19 +315,21 @@ connection con2;
reap;
select count(*) from t4 /* must be 1 */;
select @b /* must be 1 at the end of a stmt calling bug27563() */;
---echo must have the delete query event more to FD
+--echo must have the delete query event on the 3th line
source include/show_binlog_events.inc;
+--let $binlog_killed_pos= query_get_value(SHOW BINLOG EVENTS, Pos, 3)
+--let $binlog_killed_end_log_pos= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 3)
# a proof the query is binlogged with an error
---exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
let $error_code= `select @a like "%#%error_code=0%" /* must return 0*/`;
-eval select $error_code /* must return 0 to mean the killed query is in */;
+eval select $error_code /* must return 0 to mean the killed delete is in */;
# cleanup for the sub-case
connection con1;
diff --git a/mysql-test/suite/bugs/combinations b/mysql-test/suite/bugs/combinations
deleted file mode 100644
index 07042c2cbec..00000000000
--- a/mysql-test/suite/bugs/combinations
+++ /dev/null
@@ -1,8 +0,0 @@
-[row]
-binlog-format=row
-
-[stmt]
-binlog-format=statement
-
-[mix]
-binlog-format=mixed
diff --git a/mysql-test/suite/bugs/data/rpl_bug12691.dat b/mysql-test/suite/bugs/data/rpl_bug12691.dat
deleted file mode 100644
index de980441c3a..00000000000
--- a/mysql-test/suite/bugs/data/rpl_bug12691.dat
+++ /dev/null
@@ -1,3 +0,0 @@
-a
-b
-c
diff --git a/mysql-test/suite/bugs/r/rpl_bug12691.result b/mysql-test/suite/bugs/r/rpl_bug12691.result
deleted file mode 100644
index 8feeb0effc3..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug12691.result
+++ /dev/null
@@ -1,33 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-
-**** On Master ****
-CREATE TABLE t1 (b CHAR(10));
-
-**** On Slave ****
-STOP SLAVE;
-
-**** On Master ****
-LOAD DATA INFILE FILENAME
-SELECT COUNT(*) FROM t1;
-COUNT(*)
-3
-show binlog events from <binlog_start>;
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (b CHAR(10))
-master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat' INTO TABLE `t1` FIELDS TERMINATED BY '|' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`b`) ;file_id=#
-
-**** On Slave ****
-SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
-SELECT COUNT(*) FROM t1;
-COUNT(*)
-0
-
-**** On Master ****
-DROP TABLE t1;
diff --git a/mysql-test/suite/bugs/r/rpl_bug23533.result b/mysql-test/suite/bugs/r/rpl_bug23533.result
deleted file mode 100644
index 1dda75a69b0..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug23533.result
+++ /dev/null
@@ -1,23 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-DROP TABLE IF EXISTS t1,t2;
-SET AUTOCOMMIT=0;
-SET GLOBAL max_binlog_cache_size=4096;
-SHOW VARIABLES LIKE 'max_binlog_cache_size';
-Variable_name Value
-max_binlog_cache_size 4096
-CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b TEXT, PRIMARY KEY(a)) ENGINE=InnoDB;
-SELECT COUNT(*) FROM t1;
-COUNT(*)
-1000
-START TRANSACTION;
-CREATE TABLE t2 SELECT * FROM t1;
-ERROR HY000: Writing one row to the row-based binary log failed
-COMMIT;
-SHOW TABLES LIKE 't%';
-Tables_in_test (t%)
-t1
diff --git a/mysql-test/suite/bugs/r/rpl_bug31582.result b/mysql-test/suite/bugs/r/rpl_bug31582.result
deleted file mode 100644
index 1f71fbf8fe7..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug31582.result
+++ /dev/null
@@ -1,16 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('a');
-UPDATE t1 SET a = 'MyISAM';
-SELECT * FROM t1 ORDER BY a;
-a
-MyISAM
-SELECT * FROM t1 ORDER BY a;
-a
-MyISAM
-DROP TABLE t1;
diff --git a/mysql-test/suite/bugs/r/rpl_bug31583.result b/mysql-test/suite/bugs/r/rpl_bug31583.result
deleted file mode 100644
index 74846607313..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug31583.result
+++ /dev/null
@@ -1,16 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-CREATE TABLE t1 ( a INT, b INT DEFAULT -3 );
-INSERT INTO t1 VALUES (1, DEFAULT);
-UPDATE t1 SET a = 3;
-SELECT * FROM t1 ORDER BY a;
-a b
-3 -3
-SELECT * FROM t1 ORDER BY a;
-a b
-3 -3
-DROP TABLE t1;
diff --git a/mysql-test/suite/bugs/r/rpl_bug33029.result b/mysql-test/suite/bugs/r/rpl_bug33029.result
deleted file mode 100644
index d11ae1cc0be..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug33029.result
+++ /dev/null
@@ -1,15 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-create table `t1` (`id` int not null auto_increment primary key);
-create trigger `trg` before insert on `t1` for each row begin end;
-set @@global.debug="+d,simulate_bug33029";
-stop slave;
-start slave;
-insert into `t1` values ();
-select * from t1;
-id
-1
diff --git a/mysql-test/suite/bugs/r/rpl_bug36391.result b/mysql-test/suite/bugs/r/rpl_bug36391.result
deleted file mode 100644
index 33175d89d30..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug36391.result
+++ /dev/null
@@ -1,18 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-drop table if exists t1;
-Warnings:
-Note 1051 Unknown table 't1'
-create table t1(id int);
-show tables;
-Tables_in_test
-t1
-show master status;
-File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000001 # <Binlog_Do_DB> <Binlog_Ignore_DB>
-flush logs;
-drop table t1;
diff --git a/mysql-test/suite/bugs/r/rpl_bug37426.result b/mysql-test/suite/bugs/r/rpl_bug37426.result
deleted file mode 100644
index 24dfd27ca01..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug37426.result
+++ /dev/null
@@ -1,17 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-CREATE TABLE char128_utf8 (
-i1 INT NOT NULL,
-c CHAR(128) CHARACTER SET utf8 NOT NULL,
-i2 INT NOT NULL);
-INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
-SELECT * FROM char128_utf8;
-i1 c i2
-1 123 1
-SELECT * FROM char128_utf8;
-i1 c i2
-1 123 1
diff --git a/mysql-test/suite/bugs/r/rpl_bug38205.result b/mysql-test/suite/bugs/r/rpl_bug38205.result
deleted file mode 100644
index 8f1dee344fa..00000000000
--- a/mysql-test/suite/bugs/r/rpl_bug38205.result
+++ /dev/null
@@ -1,56 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-create table t1i(n int primary key) engine=innodb;
-create table t2m(n int primary key) engine=myisam;
-begin;
-insert into t1i values (1);
-insert into t1i values (2);
-insert into t1i values (3);
-commit;
-begin;
-insert into t1i values (5);
-begin;
-insert into t1i values (4);
-insert into t2m values (1);
-update t1i set n = 5 where n = 4;
-commit;
-zero
-0
-*** kill sql thread ***
-rollback;
-*** sql thread is *not* running: No ***
-*** the prove: the killed slave has not finished the current transaction ***
-three
-3
-one
-1
-zero
-0
-delete from t2m;
-start slave sql_thread;
-delete from t1i;
-delete from t2m;
-begin;
-insert into t1i values (5);
-begin;
-insert into t1i values (4);
-update t1i set n = 5 where n = 4;
-commit;
-zero
-0
-stop slave sql_thread;
-rollback;
-*** sql thread is *not* running: No ***
-*** the prove: the stopped slave has rolled back the current transaction ***
-zero
-0
-zero
-0
-one
-1
-start slave sql_thread;
-drop table t1i, t2m;
diff --git a/mysql-test/suite/bugs/t/rpl_bug12691.test b/mysql-test/suite/bugs/t/rpl_bug12691.test
deleted file mode 100644
index 038f3e57b75..00000000000
--- a/mysql-test/suite/bugs/t/rpl_bug12691.test
+++ /dev/null
@@ -1,49 +0,0 @@
-# Bug#12691: Exec_master_log_pos corrupted with SQL_SLAVE_SKIP_COUNTER
-
---source include/master-slave.inc
---connection master
---source include/have_binlog_format_mixed_or_statement.inc
-
---echo
---echo **** On Master ****
-CREATE TABLE t1 (b CHAR(10));
---echo
---echo **** On Slave ****
---sync_slave_with_master
-STOP SLAVE;
---source include/wait_for_slave_to_stop.inc
-
---connection master
-
---echo
---echo **** On Master ****
---exec cp $MYSQL_TEST_DIR/suite/bugs/data/rpl_bug12691.dat $MYSQLTEST_VARDIR/tmp/
---echo LOAD DATA INFILE FILENAME
---disable_query_log
---eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat' INTO TABLE t1 FIELDS TERMINATED BY '|'
---enable_query_log
---remove_file $MYSQLTEST_VARDIR/tmp/rpl_bug12691.dat
-
-SELECT COUNT(*) FROM t1;
-
-source include/show_binlog_events.inc;
-
---save_master_pos
-
---connection slave
---echo
---echo **** On Slave ****
-SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
-START SLAVE;
---source include/wait_for_slave_to_start.inc
---sync_with_master
-
-SELECT COUNT(*) FROM t1;
-
-# Clean up
---connection master
---echo
---echo **** On Master ****
-DROP TABLE t1;
-
---source include/rpl_end.inc
diff --git a/mysql-test/suite/bugs/t/rpl_bug31582.test b/mysql-test/suite/bugs/t/rpl_bug31582.test
deleted file mode 100644
index 6bff8ef4172..00000000000
--- a/mysql-test/suite/bugs/t/rpl_bug31582.test
+++ /dev/null
@@ -1,25 +0,0 @@
-
-# BUG#31582: 5.1-telco-6.1 -> 5.1.22. Slave crashes when reading
-# UPDATE for VARCHAR
-
-# This is a problem for any update statement replicating from an old
-# server to a new server. The bug consisted of a new slave trying to
-# read two column bitmaps, but there is only one available in the old
-# format.
-
-# This test case should be executed replicating from an old server to
-# a new server, so make sure you have one handy.
-
-source include/master-slave.inc;
-
-CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('a');
-UPDATE t1 SET a = 'MyISAM';
-SELECT * FROM t1 ORDER BY a;
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-connection master;
-DROP TABLE t1;
-
---source include/rpl_end.inc
diff --git a/mysql-test/suite/bugs/t/rpl_bug31583.test b/mysql-test/suite/bugs/t/rpl_bug31583.test
deleted file mode 100644
index ee5b7698016..00000000000
--- a/mysql-test/suite/bugs/t/rpl_bug31583.test
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# BUG#31583: 5.1-telco-6.1 -> 5.1.22. Slave returns Error in unknown event
-
-# This is a problem for any update statement replicating from an old
-# server to a new server. The bug consisted of a new slave trying to
-# read two column bitmaps, but there is only one available in the old
-# format.
-
-# This test case should be executed replicating from an old server to
-# a new server, so make sure you have one handy.
-
-source include/master-slave.inc;
-
-CREATE TABLE t1 ( a INT, b INT DEFAULT -3 );
-
-INSERT INTO t1 VALUES (1, DEFAULT);
-UPDATE t1 SET a = 3;
-SELECT * FROM t1 ORDER BY a;
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-connection master;
-DROP TABLE t1;
-
---source include/rpl_end.inc
diff --git a/mysql-test/suite/bugs/t/rpl_bug33029.test b/mysql-test/suite/bugs/t/rpl_bug33029.test
deleted file mode 100644
index f5aad4de8df..00000000000
--- a/mysql-test/suite/bugs/t/rpl_bug33029.test
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Bug #36443 Server crashes when executing insert when insert trigger on table
-#
-# Emulating the former bug#33029 situation to see that there is no crash anymore.
-#
-
-
-source include/master-slave.inc;
-
-create table `t1` (`id` int not null auto_increment primary key);
-create trigger `trg` before insert on `t1` for each row begin end;
-
-sync_slave_with_master;
-set @@global.debug="+d,simulate_bug33029";
-
-stop slave;
-start slave;
-
-connection master;
-
-insert into `t1` values ();
-
-sync_slave_with_master;
-select * from t1;
-
---source include/rpl_end.inc
diff --git a/mysql-test/suite/bugs/t/rpl_bug38205.test b/mysql-test/suite/bugs/t/rpl_bug38205.test
deleted file mode 100644
index 550746719f4..00000000000
--- a/mysql-test/suite/bugs/t/rpl_bug38205.test
+++ /dev/null
@@ -1,166 +0,0 @@
-#
-# Bug #38205 Row-based Replication (RBR) causes inconsistencies: HA_ERR_FOUND_DUPP_KEY
-# Bug#319 if while a non-transactional slave is replicating a transaction possible problem
-#
-# Verifying the fact that STOP SLAVE in the middle of a group execution waits
-# for the end of the group before the slave sql thread will stop.
-# The patch refines STOP SLAVE to not interrupt a transaction or other type of
-# the replication events group (the part I).
-# Killing the sql thread continues to provide a "hard" stop (the part II).
-#
-# Non-deterministic tests
-#
-
-source include/master-slave.inc;
-source include/have_innodb.inc;
-
-
-#
-# Part II, killed sql slave leaves instantly
-#
-
-# A. multi-statement transaction as the replication group
-
-connection master;
-
-create table t1i(n int primary key) engine=innodb;
-create table t2m(n int primary key) engine=myisam;
-
-sync_slave_with_master;
-
-connection master;
-
-begin;
-insert into t1i values (1);
-insert into t1i values (2);
-insert into t1i values (3);
-commit;
-
-sync_slave_with_master;
-
-#
-# todo: first challenge is to find out the SQL thread id
-# the following is not fully reliable
-#
-
-let $id=`SELECT id from information_schema.processlist where user like 'system user' and state like '%Has read all relay log%' or user like 'system user' and state like '%Reading event from the relay log%'`;
-connection slave;
-begin;
-insert into t1i values (5);
-
-connection master;
-let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-begin;
-insert into t1i values (4);
-insert into t2m values (1); # non-ta update
-update t1i set n = 5 where n = 4; # to block at. can't be played with killed
-commit;
-let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-
-connection slave;
-# slave sql thread must be locked out by the conn `slave' explicit lock
-let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
---disable_query_log
-eval select $pos0_master - $pos0_slave as zero;
---enable_query_log
-
-connection slave1;
-
-let $count= 1;
-let $table= t2m;
-source include/wait_until_rows_count.inc;
-#
-# todo: may fail as said above
-#
---echo *** kill sql thread ***
---disable_query_log
-eval kill connection $id;
---enable_query_log
-
-connection slave;
-rollback; # release the sql thread
-
-connection slave1;
-
-source include/wait_for_slave_sql_to_stop.inc;
-let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
---echo *** sql thread is *not* running: $sql_status ***
-let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
-
-connection slave;
---echo *** the prove: the killed slave has not finished the current transaction ***
-
---disable_query_log
-select count(*) as three from t1i;
-eval select $pos1_master > $pos1_slave as one;
-eval select $pos1_slave - $pos0_slave as zero;
---enable_query_log
-
-delete from t2m; # remove the row to be able to replay
-start slave sql_thread;
-
-#
-# Part I: B The homogenous transaction remains interuptable in between
-#
-
-connection master;
-delete from t1i;
-delete from t2m;
-
-sync_slave_with_master;
-begin;
-insert into t1i values (5);
-
-connection master;
-let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-begin;
-insert into t1i values (4);
-update t1i set n = 5 where n = 4; # to block at. not to be played
-commit;
-let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
-
-
-connection slave1;
-# slave sql can't advance as must be locked by the conn `slave' trans
-let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
---disable_query_log
-eval select $pos0_master - $pos0_slave as zero;
---enable_query_log
-
-#
-# the replicated trans is blocked by the slave's local.
-# However, it's not easy to catch the exact moment when it happens.
-# The test issues sleep which makes the test either non-deterministic or
-# wasting too much time.
-#
---sleep 3
-
-send stop slave sql_thread;
-
-connection slave;
-rollback; # release the sql thread
-
-connection slave1;
-reap;
-source include/wait_for_slave_sql_to_stop.inc;
-let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
---echo *** sql thread is *not* running: $sql_status ***
-
-let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
-
---echo *** the prove: the stopped slave has rolled back the current transaction ***
-
---disable_query_log
-select count(*) as zero from t1i;
-eval select $pos0_master - $pos0_slave as zero;
-eval select $pos1_master > $pos0_slave as one;
---enable_query_log
-
-start slave sql_thread;
-
-# clean-up
-
-connection master;
-drop table t1i, t2m;
-
---source include/rpl_end.inc
diff --git a/mysql-test/suite/engines/funcs/r/ps_string_not_null.result b/mysql-test/suite/engines/funcs/r/ps_string_not_null.result
index 859fab8b490..5f2a630811c 100644
--- a/mysql-test/suite/engines/funcs/r/ps_string_not_null.result
+++ b/mysql-test/suite/engines/funcs/r/ps_string_not_null.result
Binary files differ
diff --git a/mysql-test/suite/engines/funcs/t/ps_string_not_null.test b/mysql-test/suite/engines/funcs/t/ps_string_not_null.test
index f9e937cb24d..662adfd7a88 100644
--- a/mysql-test/suite/engines/funcs/t/ps_string_not_null.test
+++ b/mysql-test/suite/engines/funcs/t/ps_string_not_null.test
@@ -1,5 +1,5 @@
--disable_warnings
-DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1(c1 CHAR(100) NOT NULL);
PREPARE stmt1 FROM 'INSERT INTO t1 (c1) VALUES(?)';
diff --git a/mysql-test/suite/engines/iuds/r/insert_year.result b/mysql-test/suite/engines/iuds/r/insert_year.result
index 69d1139c037..386c8090434 100644
--- a/mysql-test/suite/engines/iuds/r/insert_year.result
+++ b/mysql-test/suite/engines/iuds/r/insert_year.result
@@ -2431,7 +2431,7 @@ c1 c2 c3 c4
2155 2155 1998-12-26 1998-12-26 11:30:45
SELECT count(*) as total_rows, min(c2) as min_value, max(c2) FROM t3;
total_rows min_value max(c2)
-21 1901 2155
+21 0 2155
SELECT * FROM t3 WHERE c3 = '1998-12-11';
c1 c2 c3 c4
1990 1990 1998-12-11 1998-12-11 11:30:45
@@ -2838,7 +2838,7 @@ c1 c2 c3 c4
2155 2155 1998-12-26 1998-12-26 11:30:45
SELECT count(*) as total_rows, min(c2) as min_value, max(c2) FROM t3;
total_rows min_value max(c2)
-21 1901 2155
+21 0 2155
SELECT * FROM t3 WHERE c3 = '1998-12-11';
c1 c2 c3 c4
1990 1990 1998-12-11 1998-12-11 11:30:45
diff --git a/mysql-test/suite/funcs_1/datadict/datadict_priv.inc b/mysql-test/suite/funcs_1/datadict/datadict_priv.inc
index 8256b51949e..60c16279311 100644
--- a/mysql-test/suite/funcs_1/datadict/datadict_priv.inc
+++ b/mysql-test/suite/funcs_1/datadict/datadict_priv.inc
@@ -52,8 +52,10 @@ eval CREATE VIEW test.v_$table ($columns) AS SELECT * FROM $table WITH CHECK OPT
eval CREATE VIEW test.v_$table ($columns) AS SELECT * FROM $table;
---error ER_DBACCESS_DENIED_ERROR
-eval UPDATE test.v_$TABLE SET TIME=NOW() WHERE id = 1;
+# !!! This query returns a wrong error due to a bug in the code of mwl106
+# !!! Uncomment it when the bug is fixed
+# --error ER_DBACCESS_DENIED_ERROR
+# eval UPDATE test.v_$TABLE SET TIME=NOW() WHERE id = 1;
eval DROP VIEW test.v_$table;
diff --git a/mysql-test/suite/funcs_1/r/innodb_func_view.result b/mysql-test/suite/funcs_1/r/innodb_func_view.result
index c62c91f1d57..0d514e7b8e6 100644
--- a/mysql-test/suite/funcs_1/r/innodb_func_view.result
+++ b/mysql-test/suite/funcs_1/r/innodb_func_view.result
@@ -945,8 +945,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -960,8 +960,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1;
@@ -2450,6 +2450,8 @@ NULL NULL 1
8385959 838:59:59 3
130000 13:00:00 4
100000 10:00:00 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2462,6 +2464,8 @@ NULL NULL 1
8385959 838:59:59 3
130000 13:00:00 4
100000 10:00:00 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2556,7 +2560,9 @@ NULL NULL 1
18446744073709551615 -1 5
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2571,7 +2577,9 @@ NULL NULL 1
18446744073709551615 -1 5
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2587,9 +2595,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2603,9 +2611,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
DROP VIEW v1;
@@ -2620,6 +2628,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3
0 0 4
18446744073709551615 -1 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2632,6 +2643,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3
0 0 4
18446744073709551615 -1 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2955,8 +2969,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2970,8 +2984,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1;
@@ -3282,9 +3296,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 30
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -3300,9 +3314,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 30
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
DROP VIEW v1;
@@ -3372,9 +3386,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 29
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3389,9 +3403,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 29
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1;
@@ -3408,11 +3422,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 28
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@@ -3430,11 +3444,11 @@ NULL NULL 1
-1.00 -1
-3333.33 -3333.3333
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@@ -3454,9 +3468,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 27
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3471,9 +3485,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 27
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1;
@@ -3490,11 +3504,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 26
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' '
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -3510,11 +3524,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 26
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' '
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
DROP VIEW v1;
@@ -3526,10 +3540,10 @@ my_year, id FROM t1_values
WHERE select_id = 58 OR select_id IS NULL order by id;
CAST(my_year AS TIME) my_year id
NULL NULL 1
-00:19:01 1901 2
-00:21:55 2155 3
-00:20:00 2000 4
-00:20:05 2005 5
+00:00:00 1901 2
+00:00:00 2155 3
+00:00:00 2000 4
+00:00:00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as time) AS `CAST(my_year AS TIME)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3538,10 +3552,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 58 OR select_id IS NULL) order by id;
CAST(my_year AS TIME) my_year id
NULL NULL 1
-00:19:01 1901 2
-00:21:55 2155 3
-00:20:00 2000 4
-00:20:05 2005 5
+00:00:00 1901 2
+00:00:00 2155 3
+00:00:00 2000 4
+00:00:00 2005 5
DROP VIEW v1;
@@ -3662,8 +3676,8 @@ NULL 1.7976931348623e+308 3
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3678,8 +3692,8 @@ NULL 1.7976931348623e+308 3
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
DROP VIEW v1;
@@ -3872,15 +3886,10 @@ my_year, id FROM t1_values
WHERE select_id = 47 OR select_id IS NULL order by id;
CAST(my_year AS DATETIME) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 00:00:00 1901 2
+2155-00-00 00:00:00 2155 3
+2000-00-00 00:00:00 2000 4
+2005-00-00 00:00:00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as datetime) AS `CAST(my_year AS DATETIME)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3889,15 +3898,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 47 OR select_id IS NULL) order by id;
CAST(my_year AS DATETIME) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 00:00:00 1901 2
+2155-00-00 00:00:00 2155 3
+2000-00-00 00:00:00 2000 4
+2005-00-00 00:00:00 2005 5
DROP VIEW v1;
@@ -3908,13 +3912,12 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
-0000-00-00 00:00:00 -838:59:59 2
-0000-00-00 00:00:00 838:59:59 3
+NULL -838:59:59 2
+0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
+Warning 1292 Truncated incorrect datetime value: '-838:59:59'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3923,13 +3926,12 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
-0000-00-00 00:00:00 -838:59:59 2
-0000-00-00 00:00:00 838:59:59 3
+NULL -838:59:59 2
+0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
+Warning 1292 Truncated incorrect datetime value: '-838:59:59'
DROP VIEW v1;
@@ -4020,15 +4022,14 @@ CAST(my_double AS DATETIME) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 00:00:00 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
-Warning 1292 Incorrect datetime value: '200506271758'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
+Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 19
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as datetime) AS `CAST(my_double AS DATETIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4039,15 +4040,14 @@ CAST(my_double AS DATETIME) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 00:00:00 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
-Warning 1292 Incorrect datetime value: '200506271758'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1
DROP VIEW v1;
@@ -4252,15 +4252,10 @@ my_year, id FROM t1_values
WHERE select_id = 36 OR select_id IS NULL order by id;
CAST(my_year AS DATE) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 1901 2
+2155-00-00 2155 3
+2000-00-00 2000 4
+2005-00-00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as date) AS `CAST(my_year AS DATE)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4269,15 +4264,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 36 OR select_id IS NULL) order by id;
CAST(my_year AS DATE) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 1901 2
+2155-00-00 2155 3
+2000-00-00 2000 4
+2005-00-00 2005 5
DROP VIEW v1;
@@ -4394,14 +4384,13 @@ CAST(my_double AS DATE) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as date) AS `CAST(my_double AS DATE)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4412,14 +4401,13 @@ CAST(my_double AS DATE) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/innodb_storedproc_06.result b/mysql-test/suite/funcs_1/r/innodb_storedproc_06.result
index ee1548fe012..5219f057593 100644
--- a/mysql-test/suite/funcs_1/r/innodb_storedproc_06.result
+++ b/mysql-test/suite/funcs_1/r/innodb_storedproc_06.result
@@ -128,8 +128,6 @@ root@localhost db_storedproc_1
drop user 'user_1'@'localhost';
DROP PROCEDURE sp3;
DROP FUNCTION fn1;
-Warnings:
-Warning 1403 There is no such grant defined for user 'user_1' on host 'localhost' on routine 'fn1'
Testcase 3.1.6.4:
-----------------
diff --git a/mysql-test/suite/funcs_1/r/is_cml_innodb.result b/mysql-test/suite/funcs_1/r/is_cml_innodb.result
index 7c214cb770f..65e76575818 100644
--- a/mysql-test/suite/funcs_1/r/is_cml_innodb.result
+++ b/mysql-test/suite/funcs_1/r/is_cml_innodb.result
@@ -16,17 +16,17 @@ f11 LONGTEXT UNICODE
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 1 2 NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references
-NULL test t1 f10 9 NULL YES mediumtext 8388607 16777215 NULL NULL ucs2 ucs2_general_ci mediumtext select,insert,update,references
-NULL test t1 f11 10 NULL YES longtext 2147483647 4294967295 NULL NULL ucs2 ucs2_general_ci longtext select,insert,update,references
-NULL test t1 f2 2 NULL YES char 0 0 NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references
-NULL test t1 f3 3 NULL YES char 10 20 NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references
-NULL test t1 f5 4 NULL YES varchar 0 0 NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references
-NULL test t1 f6 5 NULL YES varchar 255 510 NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references
-NULL test t1 f7 6 NULL YES varchar 260 520 NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references
-NULL test t1 f8 7 NULL YES text 32767 65535 NULL NULL ucs2 ucs2_general_ci text select,insert,update,references
-NULL test t1 f9 8 NULL YES tinytext 127 255 NULL NULL ucs2 ucs2_general_ci tinytext select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 1 2 NULL NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references
+NULL test t1 f10 9 NULL YES mediumtext 8388607 16777215 NULL NULL NULL ucs2 ucs2_general_ci mediumtext select,insert,update,references
+NULL test t1 f11 10 NULL YES longtext 2147483647 4294967295 NULL NULL NULL ucs2 ucs2_general_ci longtext select,insert,update,references
+NULL test t1 f2 2 NULL YES char 0 0 NULL NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references
+NULL test t1 f3 3 NULL YES char 10 20 NULL NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references
+NULL test t1 f5 4 NULL YES varchar 0 0 NULL NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references
+NULL test t1 f6 5 NULL YES varchar 255 510 NULL NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references
+NULL test t1 f7 6 NULL YES varchar 260 520 NULL NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references
+NULL test t1 f8 7 NULL YES text 32767 65535 NULL NULL NULL ucs2 ucs2_general_ci text select,insert,update,references
+NULL test t1 f9 8 NULL YES tinytext 127 255 NULL NULL NULL ucs2 ucs2_general_ci tinytext select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_cml_memory.result b/mysql-test/suite/funcs_1/r/is_cml_memory.result
index fe4b018cec3..2c6b3263a7e 100644
--- a/mysql-test/suite/funcs_1/r/is_cml_memory.result
+++ b/mysql-test/suite/funcs_1/r/is_cml_memory.result
@@ -13,13 +13,13 @@ f7 VARCHAR(260) UNICODE
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 1 2 NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references
-NULL test t1 f2 2 NULL YES char 0 0 NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references
-NULL test t1 f3 3 NULL YES char 10 20 NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references
-NULL test t1 f5 4 NULL YES varchar 0 0 NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references
-NULL test t1 f6 5 NULL YES varchar 255 510 NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references
-NULL test t1 f7 6 NULL YES varchar 260 520 NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 1 2 NULL NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references
+NULL test t1 f2 2 NULL YES char 0 0 NULL NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references
+NULL test t1 f3 3 NULL YES char 10 20 NULL NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references
+NULL test t1 f5 4 NULL YES varchar 0 0 NULL NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references
+NULL test t1 f6 5 NULL YES varchar 255 510 NULL NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references
+NULL test t1 f7 6 NULL YES varchar 260 520 NULL NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_cml_myisam.result b/mysql-test/suite/funcs_1/r/is_cml_myisam.result
index 9808b1c1793..e8dc694d954 100644
--- a/mysql-test/suite/funcs_1/r/is_cml_myisam.result
+++ b/mysql-test/suite/funcs_1/r/is_cml_myisam.result
@@ -17,17 +17,17 @@ f11 LONGTEXT UNICODE
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 1 2 NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references
-NULL test t1 f10 9 NULL YES mediumtext 8388607 16777215 NULL NULL ucs2 ucs2_general_ci mediumtext select,insert,update,references
-NULL test t1 f11 10 NULL YES longtext 2147483647 4294967295 NULL NULL ucs2 ucs2_general_ci longtext select,insert,update,references
-NULL test t1 f2 2 NULL YES char 0 0 NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references
-NULL test t1 f3 3 NULL YES char 10 20 NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references
-NULL test t1 f5 4 NULL YES varchar 0 0 NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references
-NULL test t1 f6 5 NULL YES varchar 255 510 NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references
-NULL test t1 f7 6 NULL YES varchar 260 520 NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references
-NULL test t1 f8 7 NULL YES text 32767 65535 NULL NULL ucs2 ucs2_general_ci text select,insert,update,references
-NULL test t1 f9 8 NULL YES tinytext 127 255 NULL NULL ucs2 ucs2_general_ci tinytext select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 1 2 NULL NULL NULL ucs2 ucs2_general_ci char(1) select,insert,update,references
+NULL test t1 f10 9 NULL YES mediumtext 8388607 16777215 NULL NULL NULL ucs2 ucs2_general_ci mediumtext select,insert,update,references
+NULL test t1 f11 10 NULL YES longtext 2147483647 4294967295 NULL NULL NULL ucs2 ucs2_general_ci longtext select,insert,update,references
+NULL test t1 f2 2 NULL YES char 0 0 NULL NULL NULL ucs2 ucs2_general_ci char(0) select,insert,update,references
+NULL test t1 f3 3 NULL YES char 10 20 NULL NULL NULL ucs2 ucs2_general_ci char(10) select,insert,update,references
+NULL test t1 f5 4 NULL YES varchar 0 0 NULL NULL NULL ucs2 ucs2_general_ci varchar(0) select,insert,update,references
+NULL test t1 f6 5 NULL YES varchar 255 510 NULL NULL NULL ucs2 ucs2_general_ci varchar(255) select,insert,update,references
+NULL test t1 f7 6 NULL YES varchar 260 520 NULL NULL NULL ucs2 ucs2_general_ci varchar(260) select,insert,update,references
+NULL test t1 f8 7 NULL YES text 32767 65535 NULL NULL NULL ucs2 ucs2_general_ci text select,insert,update,references
+NULL test t1 f9 8 NULL YES tinytext 127 255 NULL NULL NULL ucs2 ucs2_general_ci tinytext select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_columns.result b/mysql-test/suite/funcs_1/r/is_columns.result
index 7901902e729..bf77e5c4148 100644
--- a/mysql-test/suite/funcs_1/r/is_columns.result
+++ b/mysql-test/suite/funcs_1/r/is_columns.result
@@ -40,6 +40,7 @@ CHARACTER_MAXIMUM_LENGTH bigint(21) unsigned YES NULL
CHARACTER_OCTET_LENGTH bigint(21) unsigned YES NULL
NUMERIC_PRECISION bigint(21) unsigned YES NULL
NUMERIC_SCALE bigint(21) unsigned YES NULL
+DATETIME_PRECISION bigint(21) unsigned YES NULL
CHARACTER_SET_NAME varchar(32) YES NULL
COLLATION_NAME varchar(32) YES NULL
COLUMN_TYPE longtext NO NULL
@@ -62,6 +63,7 @@ COLUMNS CREATE TEMPORARY TABLE `COLUMNS` (
`CHARACTER_OCTET_LENGTH` bigint(21) unsigned DEFAULT NULL,
`NUMERIC_PRECISION` bigint(21) unsigned DEFAULT NULL,
`NUMERIC_SCALE` bigint(21) unsigned DEFAULT NULL,
+ `DATETIME_PRECISION` bigint(21) unsigned DEFAULT NULL,
`CHARACTER_SET_NAME` varchar(32) DEFAULT NULL,
`COLLATION_NAME` varchar(32) DEFAULT NULL,
`COLUMN_TYPE` longtext NOT NULL,
@@ -84,6 +86,7 @@ CHARACTER_MAXIMUM_LENGTH bigint(21) unsigned YES NULL
CHARACTER_OCTET_LENGTH bigint(21) unsigned YES NULL
NUMERIC_PRECISION bigint(21) unsigned YES NULL
NUMERIC_SCALE bigint(21) unsigned YES NULL
+DATETIME_PRECISION bigint(21) unsigned YES NULL
CHARACTER_SET_NAME varchar(32) YES NULL
COLLATION_NAME varchar(32) YES NULL
COLUMN_TYPE longtext NO NULL
@@ -117,17 +120,17 @@ GRANT INSERT(f1, f2) ON db_datadict.t2 TO 'testuser2'@'localhost';
SELECT * FROM information_schema.columns
WHERE table_schema = 'db_datadict'
ORDER BY table_schema, table_name, ordinal_position;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL db_datadict t1 f1 1 NULL YES char 10 10 NULL NULL latin1 latin1_swedish_ci char(10) MUL select,insert,update,references
-NULL db_datadict t1 f2 2 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
-NULL db_datadict t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL db_datadict t1 f4 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) PRI auto_increment select,insert,update,references
-NULL db_datadict t2 f1 1 NO char 10 10 NULL NULL latin1 latin1_swedish_ci char(10) PRI select,insert,update,references
-NULL db_datadict t2 f2 2 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
-NULL db_datadict t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL db_datadict t2 f4 4 0 NO int NULL NULL 10 0 NULL NULL int(11) PRI select,insert,update,references
-NULL db_datadict v1 f1 1 0 NO int NULL NULL 10 0 NULL NULL int(1) select,insert,update,references
-NULL db_datadict v1 f2 2 0 NO int NULL NULL 10 0 NULL NULL int(1) select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL db_datadict t1 f1 1 NULL YES char 10 10 NULL NULL NULL latin1 latin1_swedish_ci char(10) MUL select,insert,update,references
+NULL db_datadict t1 f2 2 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
+NULL db_datadict t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL db_datadict t1 f4 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) PRI auto_increment select,insert,update,references
+NULL db_datadict t2 f1 1 NO char 10 10 NULL NULL NULL latin1 latin1_swedish_ci char(10) PRI select,insert,update,references
+NULL db_datadict t2 f2 2 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
+NULL db_datadict t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL db_datadict t2 f4 4 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) PRI select,insert,update,references
+NULL db_datadict v1 f1 1 0 NO int NULL NULL 10 0 NULL NULL NULL int(1) select,insert,update,references
+NULL db_datadict v1 f2 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(1) select,insert,update,references
SHOW COLUMNS FROM db_datadict.t1;
Field Type Null Key Default Extra
f1 char(10) YES MUL NULL
@@ -148,10 +151,10 @@ f2 int(1) NO 0
SELECT * FROM information_schema.columns
WHERE table_schema = 'db_datadict'
ORDER BY table_schema, table_name, ordinal_position;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL db_datadict t1 f1 1 NULL YES char 10 10 NULL NULL latin1 latin1_swedish_ci char(10) MUL select
-NULL db_datadict t1 f2 2 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select
-NULL db_datadict v1 f2 2 0 NO int NULL NULL 10 0 NULL NULL int(1) select
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL db_datadict t1 f1 1 NULL YES char 10 10 NULL NULL NULL latin1 latin1_swedish_ci char(10) MUL select
+NULL db_datadict t1 f2 2 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select
+NULL db_datadict v1 f2 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(1) select
SHOW COLUMNS FROM db_datadict.t1;
Field Type Null Key Default Extra
f1 char(10) YES MUL NULL
@@ -165,9 +168,9 @@ f2 int(1) NO 0
SELECT * FROM information_schema.columns
WHERE table_schema = 'db_datadict'
ORDER BY table_schema, table_name, ordinal_position;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL db_datadict t2 f1 1 NO char 10 10 NULL NULL latin1 latin1_swedish_ci char(10) PRI insert
-NULL db_datadict t2 f2 2 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text insert
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL db_datadict t2 f1 1 NO char 10 10 NULL NULL NULL latin1 latin1_swedish_ci char(10) PRI insert
+NULL db_datadict t2 f2 2 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text insert
SHOW COLUMNS FROM db_datadict.t1;
ERROR 42000: SELECT command denied to user 'testuser2'@'localhost' for table 't1'
SHOW COLUMNS FROM db_datadict.t2;
@@ -206,6 +209,7 @@ CHARACTER_MAXIMUM_LENGTH 12
CHARACTER_OCTET_LENGTH 12
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
+DATETIME_PRECISION NULL
CHARACTER_SET_NAME latin1
COLLATION_NAME latin1_swedish_ci
COLUMN_TYPE char(12)
@@ -411,6 +415,7 @@ CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION 10
NUMERIC_SCALE 0
+DATETIME_PRECISION NULL
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
COLUMN_TYPE int(1)
@@ -430,6 +435,7 @@ CHARACTER_MAXIMUM_LENGTH 1
CHARACTER_OCTET_LENGTH 1
NUMERIC_PRECISION NULL
NUMERIC_SCALE NULL
+DATETIME_PRECISION NULL
CHARACTER_SET_NAME latin1
COLLATION_NAME latin1_german1_ci
COLUMN_TYPE varchar(1)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_innodb.result b/mysql-test/suite/funcs_1/r/is_columns_innodb.result
index 61079b06666..c86437474d8 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_innodb.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_innodb.result
@@ -382,333 +382,333 @@ LOAD DATA INFILE '<MYSQLTEST_VARDIR>/std_data/funcs_1/t9.txt' INTO TABLE t9;
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t1 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t1 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t10 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t10 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t10 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t11 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t11 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t11 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t2 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t2 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t2 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t3 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t3 f2 2 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t4 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t4 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t4 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t7 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t7 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t8 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t8 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t9 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb1 f1 1 NULL YES char 0 0 NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references
-NULL test tb1 f10 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL mediumblob select,insert,update,references
-NULL test tb1 f11 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL test tb1 f12 12 NULL YES binary 1 1 NULL NULL NULL NULL binary(1) select,insert,update,references
-NULL test tb1 f13 13 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(4) select,insert,update,references
-NULL test tb1 f14 14 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL test tb1 f15 15 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb1 f16 16 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb1 f17 17 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(6) select,insert,update,references
-NULL test tb1 f18 18 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL test tb1 f19 19 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb1 f2 2 NULL YES char 0 0 NULL NULL latin1 latin1_bin char(0) select,insert,update,references
-NULL test tb1 f20 20 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb1 f21 21 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(9) select,insert,update,references
-NULL test tb1 f22 22 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned select,insert,update,references
-NULL test tb1 f23 23 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb1 f24 24 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb1 f25 25 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb1 f26 26 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references
-NULL test tb1 f3 3 NULL YES char 0 0 NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references
-NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb1 f33 33 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f34 34 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f35 35 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f36 36 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f37 37 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f38 38 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb1 f39 39 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f4 4 NULL YES tinytext 255 255 NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
-NULL test tb1 f40 40 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb1 f41 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f42 42 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f43 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f44 44 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f45 45 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f46 46 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb1 f47 47 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f48 48 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb1 f49 49 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f5 5 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
-NULL test tb1 f50 50 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb1 f51 51 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f52 52 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb1 f53 53 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f54 54 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f55 55 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f56 56 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f57 57 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f58 58 99 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
-NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
-NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob select,insert,update,references
-NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
-NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb3 f121 4 NULL YES tinytext 255 255 NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
-NULL test tb3 f122 5 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
-NULL test tb3 f123 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
-NULL test tb3 f124 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
-NULL test tb3 f125 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob select,insert,update,references
-NULL test tb3 f126 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL test tb3 f127 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL mediumblob select,insert,update,references
-NULL test tb3 f128 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL test tb3 f129 12  NO binary 1 1 NULL NULL NULL NULL binary(1) select,insert,update,references
-NULL test tb3 f130 13 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(4) select,insert,update,references
-NULL test tb3 f131 14 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL test tb3 f132 15 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb3 f133 16 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb3 f134 17 999 NO smallint NULL NULL 5 0 NULL NULL smallint(6) select,insert,update,references
-NULL test tb3 f135 18 999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL test tb3 f136 19 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb3 f137 20 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb3 f138 21 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(9) select,insert,update,references
-NULL test tb3 f139 22 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned select,insert,update,references
-NULL test tb3 f140 23 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb3 f141 24 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb3 f142 25 99999 NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references
-NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f153 36 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f154 37 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f155 38 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb3 f156 39 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f157 40 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb3 f158 41 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f159 42 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f160 43 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f161 44 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f162 45 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f163 46 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb3 f164 47 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f165 48 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb3 f166 49 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f167 50 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb3 f168 51 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f169 52 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb3 f170 53 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f171 54 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f172 55 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f173 56 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f174 57 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f175 58 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test tb4 f235 52 NULL YES char 0 0 NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references
-NULL test tb4 f236 53 NULL YES char 90 90 NULL NULL latin1 latin1_swedish_ci char(90) select,insert,update,references
-NULL test tb4 f237 54 NULL YES char 255 255 NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
-NULL test tb4 f238 55 NULL YES varchar 0 0 NULL NULL latin1 latin1_swedish_ci varchar(0) select,insert,update,references
-NULL test tb4 f239 56 NULL YES varchar 20000 20000 NULL NULL latin1 latin1_bin varchar(20000) select,insert,update,references
-NULL test tb4 f240 57 NULL YES varchar 2000 2000 NULL NULL latin1 latin1_swedish_ci varchar(2000) select,insert,update,references
-NULL test tb4 f241 58 NULL YES char 100 100 NULL NULL latin1 latin1_swedish_ci char(100) select,insert,update,references
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t1 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t1 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t10 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t10 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t10 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t11 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t11 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t11 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t2 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t2 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t2 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t3 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t3 f2 2 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t4 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t4 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t4 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t7 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t7 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t8 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t8 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t9 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb1 f1 1 NULL YES char 0 0 NULL NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references
+NULL test tb1 f10 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL NULL mediumblob select,insert,update,references
+NULL test tb1 f11 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL test tb1 f12 12 NULL YES binary 1 1 NULL NULL NULL NULL NULL binary(1) select,insert,update,references
+NULL test tb1 f13 13 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4) select,insert,update,references
+NULL test tb1 f14 14 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL test tb1 f15 15 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb1 f16 16 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb1 f17 17 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(6) select,insert,update,references
+NULL test tb1 f18 18 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL test tb1 f19 19 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb1 f2 2 NULL YES char 0 0 NULL NULL NULL latin1 latin1_bin char(0) select,insert,update,references
+NULL test tb1 f20 20 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb1 f21 21 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9) select,insert,update,references
+NULL test tb1 f22 22 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned select,insert,update,references
+NULL test tb1 f23 23 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb1 f24 24 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb1 f25 25 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb1 f26 26 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(20) select,insert,update,references
+NULL test tb1 f3 3 NULL YES char 0 0 NULL NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references
+NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb1 f33 33 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f34 34 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f35 35 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f36 36 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f37 37 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f38 38 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb1 f39 39 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f4 4 NULL YES tinytext 255 255 NULL NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
+NULL test tb1 f40 40 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb1 f41 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f42 42 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f43 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f44 44 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f45 45 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f46 46 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb1 f47 47 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f48 48 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb1 f49 49 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f5 5 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
+NULL test tb1 f50 50 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb1 f51 51 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f52 52 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb1 f53 53 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f54 54 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f55 55 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f56 56 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f57 57 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f58 58 99 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
+NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
+NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL NULL tinyblob select,insert,update,references
+NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb3 f118 1 a NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb3 f119 2  NO char 1 1 NULL NULL NULL latin1 latin1_bin char(1) select,insert,update,references
+NULL test tb3 f120 3  NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb3 f121 4 NULL YES tinytext 255 255 NULL NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
+NULL test tb3 f122 5 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
+NULL test tb3 f123 6 NULL YES mediumtext 16777215 16777215 NULL NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
+NULL test tb3 f124 7 NULL YES longtext 4294967295 4294967295 NULL NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
+NULL test tb3 f125 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL NULL tinyblob select,insert,update,references
+NULL test tb3 f126 9 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL test tb3 f127 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL NULL mediumblob select,insert,update,references
+NULL test tb3 f128 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL test tb3 f129 12  NO binary 1 1 NULL NULL NULL NULL NULL binary(1) select,insert,update,references
+NULL test tb3 f130 13 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4) select,insert,update,references
+NULL test tb3 f131 14 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL test tb3 f132 15 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb3 f133 16 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb3 f134 17 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(6) select,insert,update,references
+NULL test tb3 f135 18 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL test tb3 f136 19 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb3 f137 20 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb3 f138 21 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9) select,insert,update,references
+NULL test tb3 f139 22 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned select,insert,update,references
+NULL test tb3 f140 23 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb3 f141 24 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb3 f142 25 99999 NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) select,insert,update,references
+NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f153 36 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f154 37 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f155 38 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb3 f156 39 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f157 40 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb3 f158 41 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f159 42 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f160 43 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f161 44 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f162 45 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f163 46 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb3 f164 47 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f165 48 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb3 f166 49 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f167 50 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb3 f168 51 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f169 52 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb3 f170 53 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f171 54 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f172 55 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f173 56 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f174 57 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f175 58 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test tb4 f235 52 NULL YES char 0 0 NULL NULL NULL latin1 latin1_swedish_ci char(0) select,insert,update,references
+NULL test tb4 f236 53 NULL YES char 90 90 NULL NULL NULL latin1 latin1_swedish_ci char(90) select,insert,update,references
+NULL test tb4 f237 54 NULL YES char 255 255 NULL NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
+NULL test tb4 f238 55 NULL YES varchar 0 0 NULL NULL NULL latin1 latin1_swedish_ci varchar(0) select,insert,update,references
+NULL test tb4 f239 56 NULL YES varchar 20000 20000 NULL NULL NULL latin1 latin1_bin varchar(20000) select,insert,update,references
+NULL test tb4 f240 57 NULL YES varchar 2000 2000 NULL NULL NULL latin1 latin1_swedish_ci varchar(2000) select,insert,update,references
+NULL test tb4 f241 58 NULL YES char 100 100 NULL NULL NULL latin1 latin1_swedish_ci char(100) select,insert,update,references
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result
index 0fd3c0a2810..a7b03a5c18b 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is.result
@@ -2,491 +2,493 @@ SELECT * FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema CHARACTER_SETS DESCRIPTION 3 NO varchar 60 180 NULL NULL utf8 utf8_general_ci varchar(60) select
-NULL information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3) select
-NULL information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double select
-NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS BYTES_SENT 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS CLIENT 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS 18 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS CONNECTED_TIME 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double select
-NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS 20 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES 23 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS 21 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS 17 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS ROWS_DELETED 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS ROWS_INSERTED 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS ROWS_READ 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS ROWS_SENT 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema COLLATIONS CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema COLLATIONS COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(11) select
-NULL information_schema COLLATIONS IS_COMPILED 5 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema COLLATIONS IS_DEFAULT 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema COLLATIONS SORTLEN 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3) select
-NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select
-NULL information_schema COLUMNS COLUMN_DEFAULT 6 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema COLUMNS COLUMN_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema COLUMNS DATA_TYPE 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27) select
-NULL information_schema COLUMNS IS_NULLABLE 7 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema COLUMNS NUMERIC_PRECISION 11 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema COLUMNS NUMERIC_SCALE 12 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema COLUMNS ORDINAL_POSITION 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select
-NULL information_schema COLUMNS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema COLUMNS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMNS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMN_PRIVILEGES COLUMN_NAME 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema COLUMN_PRIVILEGES IS_GRANTABLE 7 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema COLUMN_PRIVILEGES PRIVILEGE_TYPE 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMN_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema COLUMN_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema COLUMN_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ENGINES COMMENT 3 NO varchar 160 480 NULL NULL utf8 utf8_general_ci varchar(160) select
-NULL information_schema ENGINES ENGINE 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ENGINES SAVEPOINTS 6 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema ENGINES SUPPORT 2 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
-NULL information_schema ENGINES TRANSACTIONS 4 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema ENGINES XA 5 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema EVENTS CHARACTER_SET_CLIENT 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema EVENTS COLLATION_CONNECTION 23 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema EVENTS CREATED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema EVENTS DATABASE_COLLATION 24 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema EVENTS DEFINER 4 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77) select
-NULL information_schema EVENTS ENDS 14 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema EVENTS EVENT_BODY 6 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
-NULL information_schema EVENTS EVENT_CATALOG 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema EVENTS EVENT_COMMENT 20 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema EVENTS EVENT_DEFINITION 7 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema EVENTS EVENT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema EVENTS EVENT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema EVENTS EVENT_TYPE 8 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9) select
-NULL information_schema EVENTS EXECUTE_AT 9 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema EVENTS INTERVAL_FIELD 11 NULL YES varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select
-NULL information_schema EVENTS INTERVAL_VALUE 10 NULL YES varchar 256 768 NULL NULL utf8 utf8_general_ci varchar(256) select
-NULL information_schema EVENTS LAST_ALTERED 18 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema EVENTS LAST_EXECUTED 19 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema EVENTS ON_COMPLETION 16 NO varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select
-NULL information_schema EVENTS ORIGINATOR 21 0 NO bigint NULL NULL 19 0 NULL NULL bigint(10) select
-NULL information_schema EVENTS SQL_MODE 12 NO varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192) select
-NULL information_schema EVENTS STARTS 13 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema EVENTS STATUS 15 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select
-NULL information_schema EVENTS TIME_ZONE 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES AUTOEXTEND_SIZE 19 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES AVG_ROW_LENGTH 28 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES CHECKSUM 36 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES CHECK_TIME 35 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema FILES CREATE_TIME 33 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema FILES CREATION_TIME 20 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema FILES DATA_FREE 32 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES DATA_LENGTH 29 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES DELETED_ROWS 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES ENGINE 10 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES EXTENT_SIZE 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES EXTRA 38 NULL YES varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select
-NULL information_schema FILES FILE_ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES FILE_NAME 2 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES FILE_TYPE 3 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select
-NULL information_schema FILES FREE_EXTENTS 14 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES FULLTEXT_KEYS 11 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES INDEX_LENGTH 31 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES INITIAL_SIZE 17 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES LAST_ACCESS_TIME 22 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema FILES LAST_UPDATE_TIME 21 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema FILES LOGFILE_GROUP_NAME 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES LOGFILE_GROUP_NUMBER 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES MAXIMUM_SIZE 18 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES MAX_DATA_LENGTH 30 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES RECOVER_TIME 23 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES ROW_FORMAT 26 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select
-NULL information_schema FILES STATUS 37 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select
-NULL information_schema FILES TABLESPACE_NAME 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES TABLE_CATALOG 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES TABLE_NAME 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES TABLE_ROWS 27 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema FILES TABLE_SCHEMA 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema FILES TOTAL_EXTENTS 15 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES TRANSACTION_COUNTER 24 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES UPDATE_COUNT 13 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema FILES UPDATE_TIME 34 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema FILES VERSION 25 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema INDEX_STATISTICS INDEX_NAME 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema INDEX_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES page_no 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES page_type 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema INNODB_BUFFER_POOL_PAGES space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB compressed 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB fix_count 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB flush_type 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB lru_position 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB page_no 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB part_len 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB space_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX access_time 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 12 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 13 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 11 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 10 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_CMP compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP compress_time 4 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5) select
-NULL information_schema INNODB_CMP uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMPMEM pages_free 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMPMEM pages_used 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMPMEM page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5) select
-NULL information_schema INNODB_CMPMEM relocation_ops 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema INNODB_CMPMEM relocation_time 5 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMPMEM_RESET pages_free 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMPMEM_RESET pages_used 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMPMEM_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5) select
-NULL information_schema INNODB_CMPMEM_RESET relocation_ops 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema INNODB_CMPMEM_RESET relocation_time 5 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP_RESET compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP_RESET compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP_RESET compress_time 4 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5) select
-NULL information_schema INNODB_CMP_RESET uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_CMP_RESET uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema INNODB_INDEX_STATS fields 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_INDEX_STATS index_name 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_INDEX_STATS index_size 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_INDEX_STATS leaf_pages 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_INDEX_STATS row_per_keys 5 NO varchar 256 768 NULL NULL utf8 utf8_general_ci varchar(256) select
-NULL information_schema INNODB_INDEX_STATS table_name 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_INDEX_STATS table_schema 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_LOCKS lock_data 10 NULL YES varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192) select
-NULL information_schema INNODB_LOCKS lock_id 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema INNODB_LOCKS lock_index 6 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema INNODB_LOCKS lock_mode 3 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema INNODB_LOCKS lock_page 8 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_LOCKS lock_rec 9 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_LOCKS lock_space 7 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_LOCKS lock_table 5 NO varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema INNODB_LOCKS lock_trx_id 2 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select
-NULL information_schema INNODB_LOCKS lock_type 4 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema INNODB_LOCK_WAITS blocking_lock_id 4 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema INNODB_LOCK_WAITS blocking_trx_id 3 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select
-NULL information_schema INNODB_LOCK_WAITS requested_lock_id 2 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema INNODB_LOCK_WAITS requesting_trx_id 1 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select
-NULL information_schema INNODB_RSEG curr_size 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_RSEG max_size 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_RSEG page_no 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_RSEG rseg_id 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_RSEG space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_RSEG zip_size 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_INDEXES ID 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_INDEXES NAME 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_SYS_INDEXES N_FIELDS 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_INDEXES PAGE_NO 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_INDEXES SPACE 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_INDEXES TABLE_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_INDEXES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_STATS DIFF_VALS 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_STATS INDEX_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_STATS KEY_COLS 2 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_TABLES CLUSTER_NAME 8 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_SYS_TABLES ID 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_TABLES MIX_ID 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_TABLES MIX_LEN 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_TABLES NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_SYS_TABLES N_COLS 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_TABLES SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_SYS_TABLES SPACE 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_SYS_TABLES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_TABLE_STATS clust_size 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_TABLE_STATS modified 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_TABLE_STATS other_size 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_TABLE_STATS rows 3 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_TABLE_STATS table_name 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_TABLE_STATS table_schema 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema INNODB_TRX trx_id 1 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18) select
-NULL information_schema INNODB_TRX trx_mysql_thread_id 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema INNODB_TRX trx_query 8 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema INNODB_TRX trx_requested_lock_id 4 NULL YES varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema INNODB_TRX trx_started 3 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema INNODB_TRX trx_state 2 NO varchar 13 39 NULL NULL utf8 utf8_general_ci varchar(13) select
-NULL information_schema INNODB_TRX trx_wait_started 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema INNODB_TRX trx_weight 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES KEY_CACHE_NAME 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema KEY_CACHES READS 10 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES READ_REQUESTS 9 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES SEGMENTS 2 NULL YES int NULL NULL 10 0 NULL NULL int(3) unsigned select
-NULL information_schema KEY_CACHES SEGMENT_NUMBER 3 NULL YES int NULL NULL 10 0 NULL NULL int(3) unsigned select
-NULL information_schema KEY_CACHES UNUSED_BLOCKS 7 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES USED_BLOCKS 6 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES WRITES 12 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_CACHES WRITE_REQUESTS 11 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema KEY_COLUMN_USAGE COLUMN_NAME 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE ORDINAL_POSITION 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(10) select
-NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(10) select
-NULL information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME 12 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME 11 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PARTITIONS AVG_ROW_LENGTH 14 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS CHECKSUM 22 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS CHECK_TIME 21 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema PARTITIONS CREATE_TIME 19 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema PARTITIONS DATA_FREE 18 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS DATA_LENGTH 15 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS INDEX_LENGTH 17 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS MAX_DATA_LENGTH 16 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS NODEGROUP 24 NO varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select
-NULL information_schema PARTITIONS PARTITION_COMMENT 23 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select
-NULL information_schema PARTITIONS PARTITION_DESCRIPTION 12 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema PARTITIONS PARTITION_EXPRESSION 10 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema PARTITIONS PARTITION_METHOD 8 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select
-NULL information_schema PARTITIONS PARTITION_NAME 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PARTITIONS PARTITION_ORDINAL_POSITION 6 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS SUBPARTITION_EXPRESSION 11 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema PARTITIONS SUBPARTITION_METHOD 9 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select
-NULL information_schema PARTITIONS SUBPARTITION_NAME 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PARTITIONS SUBPARTITION_ORDINAL_POSITION 7 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS TABLESPACE_NAME 25 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PARTITIONS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema PARTITIONS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PARTITIONS TABLE_ROWS 13 0 NO bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema PARTITIONS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PARTITIONS UPDATE_TIME 20 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema PBXT_STATISTICS ID 1 0 NO int NULL NULL 10 0 NULL NULL int(4) select
-NULL information_schema PBXT_STATISTICS Name 2 NO varchar 40 120 NULL NULL utf8 utf8_general_ci varchar(40) select
-NULL information_schema PBXT_STATISTICS Value 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(8) select
-NULL information_schema PLUGINS PLUGIN_AUTHOR 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PLUGINS PLUGIN_AUTH_VERSION 12 NULL YES varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select
-NULL information_schema PLUGINS PLUGIN_DESCRIPTION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema PLUGINS PLUGIN_LIBRARY 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PLUGINS PLUGIN_LIBRARY_VERSION 7 NULL YES varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select
-NULL information_schema PLUGINS PLUGIN_LICENSE 10 NULL YES varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select
-NULL information_schema PLUGINS PLUGIN_MATURITY 11 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12) select
-NULL information_schema PLUGINS PLUGIN_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PLUGINS PLUGIN_STATUS 3 NO varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select
-NULL information_schema PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select
-NULL information_schema PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select
-NULL information_schema PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20) select
-NULL information_schema PROCESSLIST COMMAND 5 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) select
-NULL information_schema PROCESSLIST DB 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL int(7) select
-NULL information_schema PROCESSLIST TIME_MS 9 0.000 NO decimal NULL NULL 22 3 NULL NULL decimal(22,3) select
-NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) select
-NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS DELETE_RULE 9 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS MATCH_OPTION 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS REFERENCED_TABLE_NAME 11 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS TABLE_NAME 10 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_CATALOG 4 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_NAME 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema REFERENTIAL_CONSTRAINTS UPDATE_RULE 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES CHARACTER_SET_CLIENT 21 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema ROUTINES COLLATION_CONNECTION 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema ROUTINES CREATED 16 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema ROUTINES DATABASE_COLLATION 23 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema ROUTINES DEFINER 20 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77) select
-NULL information_schema ROUTINES DTD_IDENTIFIER 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES EXTERNAL_LANGUAGE 10 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES EXTERNAL_NAME 9 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES IS_DETERMINISTIC 12 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema ROUTINES LAST_ALTERED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema ROUTINES PARAMETER_STYLE 11 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
-NULL information_schema ROUTINES ROUTINE_BODY 7 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
-NULL information_schema ROUTINES ROUTINE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema ROUTINES ROUTINE_COMMENT 19 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES ROUTINE_DEFINITION 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema ROUTINES ROUTINE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES ROUTINE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES ROUTINE_TYPE 5 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9) select
-NULL information_schema ROUTINES SECURITY_TYPE 15 NO varchar 7 21 NULL NULL utf8 utf8_general_ci varchar(7) select
-NULL information_schema ROUTINES SPECIFIC_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES SQL_DATA_ACCESS 13 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema ROUTINES SQL_MODE 18 NO varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192) select
-NULL information_schema ROUTINES SQL_PATH 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema SCHEMATA CATALOG_NAME 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema SCHEMATA DEFAULT_CHARACTER_SET_NAME 3 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema SCHEMATA DEFAULT_COLLATION_NAME 4 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema SCHEMATA SCHEMA_NAME 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema SCHEMATA SQL_PATH 5 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema SCHEMA_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema SCHEMA_PRIVILEGES IS_GRANTABLE 5 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema SCHEMA_PRIVILEGES PRIVILEGE_TYPE 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema SCHEMA_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema SCHEMA_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema SESSION_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema SESSION_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema SESSION_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema SESSION_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL utf8 utf8_general_ci varchar(1) select
-NULL information_schema STATISTICS COLUMN_NAME 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema STATISTICS COMMENT 15 NULL YES varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) select
-NULL information_schema STATISTICS INDEX_NAME 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema STATISTICS INDEX_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema STATISTICS INDEX_TYPE 14 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) select
-NULL information_schema STATISTICS NON_UNIQUE 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(1) select
-NULL information_schema STATISTICS NULLABLE 13 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select
-NULL information_schema STATISTICS SEQ_IN_INDEX 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(2) select
-NULL information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(3) select
-NULL information_schema STATISTICS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema STATISTICS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema STATISTICS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLES AUTO_INCREMENT 14 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES AVG_ROW_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES CHECKSUM 19 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES CHECK_TIME 17 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema TABLES CREATE_OPTIONS 20 NULL YES varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select
-NULL information_schema TABLES CREATE_TIME 15 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema TABLES DATA_FREE 13 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES DATA_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES ENGINE 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLES INDEX_LENGTH 12 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES MAX_DATA_LENGTH 11 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES ROW_FORMAT 7 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10) select
-NULL information_schema TABLES TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema TABLES TABLE_COLLATION 18 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema TABLES TABLE_COMMENT 21 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80) select
-NULL information_schema TABLES TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLES TABLE_ROWS 8 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLES TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLES TABLE_TYPE 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLES UPDATE_TIME 16 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema TABLES VERSION 6 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(21) unsigned select
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_CONSTRAINTS TABLE_NAME 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_CONSTRAINTS TABLE_SCHEMA 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema TABLE_PRIVILEGES IS_GRANTABLE 6 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema TABLE_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TABLE_STATISTICS ROWS_CHANGED 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema TABLE_STATISTICS ROWS_READ 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema TABLE_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema TABLE_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192) select
-NULL information_schema TRIGGERS ACTION_CONDITION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema TRIGGERS ACTION_ORDER 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select
-NULL information_schema TRIGGERS ACTION_ORIENTATION 11 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9) select
-NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_ROW 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_TABLE 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_ROW 15 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_TABLE 13 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TRIGGERS ACTION_STATEMENT 10 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema TRIGGERS ACTION_TIMING 12 NO varchar 6 18 NULL NULL utf8 utf8_general_ci varchar(6) select
-NULL information_schema TRIGGERS CHARACTER_SET_CLIENT 20 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema TRIGGERS COLLATION_CONNECTION 21 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema TRIGGERS CREATED 17 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select
-NULL information_schema TRIGGERS DATABASE_COLLATION 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema TRIGGERS DEFINER 19 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77) select
-NULL information_schema TRIGGERS EVENT_MANIPULATION 4 NO varchar 6 18 NULL NULL utf8 utf8_general_ci varchar(6) select
-NULL information_schema TRIGGERS EVENT_OBJECT_CATALOG 5 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema TRIGGERS EVENT_OBJECT_SCHEMA 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TRIGGERS EVENT_OBJECT_TABLE 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TRIGGERS SQL_MODE 18 NO varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192) select
-NULL information_schema TRIGGERS TRIGGER_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema TRIGGERS TRIGGER_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema TRIGGERS TRIGGER_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema USER_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81) select
-NULL information_schema USER_PRIVILEGES IS_GRANTABLE 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema USER_PRIVILEGES PRIVILEGE_TYPE 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema USER_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema USER_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double select
-NULL information_schema USER_STATISTICS BYTES_RECEIVED 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS BYTES_SENT 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS 18 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema USER_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema USER_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double select
-NULL information_schema USER_STATISTICS DENIED_CONNECTIONS 20 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS EMPTY_QUERIES 23 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS LOST_CONNECTIONS 21 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS OTHER_COMMANDS 17 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS ROWS_DELETED 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS ROWS_INSERTED 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS ROWS_READ 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS ROWS_SENT 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL int(11) select
-NULL information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) select
-NULL information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL utf8 utf8_general_ci varchar(48) select
-NULL information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8) select
-NULL information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32) select
-NULL information_schema VIEWS DEFINER 7 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77) select
-NULL information_schema VIEWS IS_UPDATABLE 6 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3) select
-NULL information_schema VIEWS SECURITY_TYPE 8 NO varchar 7 21 NULL NULL utf8 utf8_general_ci varchar(7) select
-NULL information_schema VIEWS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
-NULL information_schema VIEWS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema VIEWS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema VIEWS VIEW_DEFINITION 4 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
-NULL information_schema XTRADB_ADMIN_COMMAND result_message 1 NO varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024) select
-NULL information_schema XTRADB_ENHANCEMENTS comment 3 NO varchar 100 300 NULL NULL utf8 utf8_general_ci varchar(100) select
-NULL information_schema XTRADB_ENHANCEMENTS description 2 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select
-NULL information_schema XTRADB_ENHANCEMENTS link 4 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select
-NULL information_schema XTRADB_ENHANCEMENTS name 1 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255) select
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema CHARACTER_SETS DESCRIPTION 3 NO varchar 60 180 NULL NULL NULL utf8 utf8_general_ci varchar(60) select
+NULL information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select
+NULL information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL NULL double select
+NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED 7 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS BYTES_SENT 8 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS CLIENT 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS 18 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS CONNECTED_TIME 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL NULL double select
+NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS 20 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES 23 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS 21 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS 17 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS ROWS_DELETED 12 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS ROWS_INSERTED 13 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS ROWS_READ 10 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS ROWS_SENT 11 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS 2 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema COLLATIONS CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema COLLATIONS COLLATION_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select
+NULL information_schema COLLATIONS IS_COMPILED 5 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema COLLATIONS IS_DEFAULT 4 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema COLLATIONS SORTLEN 6 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select
+NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema COLUMNS CHARACTER_SET_NAME 14 NULL YES varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema COLUMNS COLLATION_NAME 15 NULL YES varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema COLUMNS COLUMN_COMMENT 20 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255) select
+NULL information_schema COLUMNS COLUMN_DEFAULT 6 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema COLUMNS COLUMN_KEY 17 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema COLUMNS COLUMN_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMNS COLUMN_TYPE 16 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema COLUMNS DATA_TYPE 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMNS DATETIME_PRECISION 13 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema COLUMNS EXTRA 18 NO varchar 27 81 NULL NULL NULL utf8 utf8_general_ci varchar(27) select
+NULL information_schema COLUMNS IS_NULLABLE 7 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema COLUMNS NUMERIC_PRECISION 11 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema COLUMNS NUMERIC_SCALE 12 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema COLUMNS ORDINAL_POSITION 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema COLUMNS PRIVILEGES 19 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80) select
+NULL information_schema COLUMNS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema COLUMNS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMNS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMN_PRIVILEGES COLUMN_NAME 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema COLUMN_PRIVILEGES IS_GRANTABLE 7 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema COLUMN_PRIVILEGES PRIVILEGE_TYPE 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMN_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema COLUMN_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema COLUMN_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ENGINES COMMENT 3 NO varchar 160 480 NULL NULL NULL utf8 utf8_general_ci varchar(160) select
+NULL information_schema ENGINES ENGINE 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ENGINES SAVEPOINTS 6 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema ENGINES SUPPORT 2 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select
+NULL information_schema ENGINES TRANSACTIONS 4 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema ENGINES XA 5 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema EVENTS CHARACTER_SET_CLIENT 22 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema EVENTS COLLATION_CONNECTION 23 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema EVENTS CREATED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema EVENTS DATABASE_COLLATION 24 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema EVENTS DEFINER 4 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77) select
+NULL information_schema EVENTS ENDS 14 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema EVENTS EVENT_BODY 6 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select
+NULL information_schema EVENTS EVENT_CATALOG 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema EVENTS EVENT_COMMENT 20 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema EVENTS EVENT_DEFINITION 7 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema EVENTS EVENT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema EVENTS EVENT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema EVENTS EVENT_TYPE 8 NO varchar 9 27 NULL NULL NULL utf8 utf8_general_ci varchar(9) select
+NULL information_schema EVENTS EXECUTE_AT 9 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema EVENTS INTERVAL_FIELD 11 NULL YES varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18) select
+NULL information_schema EVENTS INTERVAL_VALUE 10 NULL YES varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select
+NULL information_schema EVENTS LAST_ALTERED 18 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema EVENTS LAST_EXECUTED 19 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema EVENTS ON_COMPLETION 16 NO varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12) select
+NULL information_schema EVENTS ORIGINATOR 21 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(10) select
+NULL information_schema EVENTS SQL_MODE 12 NO varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192) select
+NULL information_schema EVENTS STARTS 13 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema EVENTS STATUS 15 NO varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18) select
+NULL information_schema EVENTS TIME_ZONE 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES AUTOEXTEND_SIZE 19 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES AVG_ROW_LENGTH 28 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES CHECKSUM 36 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES CHECK_TIME 35 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema FILES CREATE_TIME 33 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema FILES CREATION_TIME 20 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema FILES DATA_FREE 32 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES DATA_LENGTH 29 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES DELETED_ROWS 12 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES ENGINE 10 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES EXTENT_SIZE 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES EXTRA 38 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255) select
+NULL information_schema FILES FILE_ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES FILE_NAME 2 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES FILE_TYPE 3 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
+NULL information_schema FILES FREE_EXTENTS 14 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES FULLTEXT_KEYS 11 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES INDEX_LENGTH 31 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES INITIAL_SIZE 17 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES LAST_ACCESS_TIME 22 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema FILES LAST_UPDATE_TIME 21 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema FILES LOGFILE_GROUP_NAME 8 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES LOGFILE_GROUP_NUMBER 9 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES MAXIMUM_SIZE 18 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES MAX_DATA_LENGTH 30 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES RECOVER_TIME 23 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES ROW_FORMAT 26 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) select
+NULL information_schema FILES STATUS 37 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
+NULL information_schema FILES TABLESPACE_NAME 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES TABLE_CATALOG 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES TABLE_NAME 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES TABLE_ROWS 27 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema FILES TABLE_SCHEMA 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema FILES TOTAL_EXTENTS 15 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES TRANSACTION_COUNTER 24 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES UPDATE_COUNT 13 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema FILES UPDATE_TIME 34 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema FILES VERSION 25 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema INDEX_STATISTICS INDEX_NAME 3 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema INDEX_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES page_no 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES page_type 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema INNODB_BUFFER_POOL_PAGES space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB compressed 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB fix_count 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB flush_type 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB lru_position 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB page_no 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB part_len 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB space_id 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX access_time 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 9 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 12 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 13 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_id 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 11 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 10 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_CMP compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP compress_time 4 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP page_size 1 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) select
+NULL information_schema INNODB_CMP uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMPMEM pages_free 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMPMEM pages_used 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMPMEM page_size 1 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) select
+NULL information_schema INNODB_CMPMEM relocation_ops 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema INNODB_CMPMEM relocation_time 5 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMPMEM_RESET pages_free 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMPMEM_RESET pages_used 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMPMEM_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) select
+NULL information_schema INNODB_CMPMEM_RESET relocation_ops 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema INNODB_CMPMEM_RESET relocation_time 5 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP_RESET compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP_RESET compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP_RESET compress_time 4 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) select
+NULL information_schema INNODB_CMP_RESET uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_CMP_RESET uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema INNODB_INDEX_STATS fields 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_INDEX_STATS index_name 3 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_INDEX_STATS index_size 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_INDEX_STATS leaf_pages 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_INDEX_STATS row_per_keys 5 NO varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select
+NULL information_schema INNODB_INDEX_STATS table_name 2 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_INDEX_STATS table_schema 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_LOCKS lock_data 10 NULL YES varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192) select
+NULL information_schema INNODB_LOCKS lock_id 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema INNODB_LOCKS lock_index 6 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema INNODB_LOCKS lock_mode 3 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema INNODB_LOCKS lock_page 8 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_LOCKS lock_rec 9 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_LOCKS lock_space 7 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_LOCKS lock_table 5 NO varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema INNODB_LOCKS lock_trx_id 2 NO varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18) select
+NULL information_schema INNODB_LOCKS lock_type 4 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema INNODB_LOCK_WAITS blocking_lock_id 4 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema INNODB_LOCK_WAITS blocking_trx_id 3 NO varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18) select
+NULL information_schema INNODB_LOCK_WAITS requested_lock_id 2 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema INNODB_LOCK_WAITS requesting_trx_id 1 NO varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18) select
+NULL information_schema INNODB_RSEG curr_size 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_RSEG max_size 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_RSEG page_no 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_RSEG rseg_id 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_RSEG space_id 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_RSEG zip_size 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_INDEXES ID 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_INDEXES NAME 3 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_SYS_INDEXES N_FIELDS 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_INDEXES PAGE_NO 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_INDEXES SPACE 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_INDEXES TABLE_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_INDEXES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_STATS DIFF_VALS 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_STATS INDEX_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_STATS KEY_COLS 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_STATS NON_NULL_VALS 4 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_TABLES CLUSTER_NAME 8 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_SYS_TABLES ID 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_TABLES MIX_ID 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_TABLES MIX_LEN 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_TABLES NAME 2 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_SYS_TABLES N_COLS 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_TABLES SCHEMA 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_SYS_TABLES SPACE 9 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_SYS_TABLES TYPE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_TABLE_STATS clust_size 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_TABLE_STATS modified 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_TABLE_STATS other_size 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_TABLE_STATS rows 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_TABLE_STATS table_name 2 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_TABLE_STATS table_schema 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema INNODB_TRX trx_id 1 NO varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18) select
+NULL information_schema INNODB_TRX trx_mysql_thread_id 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema INNODB_TRX trx_query 8 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema INNODB_TRX trx_requested_lock_id 4 NULL YES varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema INNODB_TRX trx_started 3 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema INNODB_TRX trx_state 2 NO varchar 13 39 NULL NULL NULL utf8 utf8_general_ci varchar(13) select
+NULL information_schema INNODB_TRX trx_wait_started 5 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema INNODB_TRX trx_weight 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES KEY_CACHE_NAME 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema KEY_CACHES READS 10 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES READ_REQUESTS 9 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES SEGMENTS 2 NULL YES int NULL NULL 10 0 NULL NULL NULL int(3) unsigned select
+NULL information_schema KEY_CACHES SEGMENT_NUMBER 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(3) unsigned select
+NULL information_schema KEY_CACHES UNUSED_BLOCKS 7 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES USED_BLOCKS 6 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES WRITES 12 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_CACHES WRITE_REQUESTS 11 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema KEY_COLUMN_USAGE COLUMN_NAME 7 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE ORDINAL_POSITION 8 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(10) select
+NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT 9 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(10) select
+NULL information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME 12 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME 11 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PARTITIONS AVG_ROW_LENGTH 14 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS CHECKSUM 22 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS CHECK_TIME 21 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema PARTITIONS CREATE_TIME 19 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema PARTITIONS DATA_FREE 18 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS DATA_LENGTH 15 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS INDEX_LENGTH 17 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS MAX_DATA_LENGTH 16 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS NODEGROUP 24 NO varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12) select
+NULL information_schema PARTITIONS PARTITION_COMMENT 23 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80) select
+NULL information_schema PARTITIONS PARTITION_DESCRIPTION 12 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema PARTITIONS PARTITION_EXPRESSION 10 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema PARTITIONS PARTITION_METHOD 8 NULL YES varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12) select
+NULL information_schema PARTITIONS PARTITION_NAME 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PARTITIONS PARTITION_ORDINAL_POSITION 6 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS SUBPARTITION_EXPRESSION 11 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema PARTITIONS SUBPARTITION_METHOD 9 NULL YES varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12) select
+NULL information_schema PARTITIONS SUBPARTITION_NAME 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PARTITIONS SUBPARTITION_ORDINAL_POSITION 7 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS TABLESPACE_NAME 25 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PARTITIONS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema PARTITIONS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PARTITIONS TABLE_ROWS 13 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema PARTITIONS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PARTITIONS UPDATE_TIME 20 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema PBXT_STATISTICS ID 1 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) select
+NULL information_schema PBXT_STATISTICS Name 2 NO varchar 40 120 NULL NULL NULL utf8 utf8_general_ci varchar(40) select
+NULL information_schema PBXT_STATISTICS Value 3 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(8) select
+NULL information_schema PLUGINS PLUGIN_AUTHOR 8 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PLUGINS PLUGIN_AUTH_VERSION 12 NULL YES varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80) select
+NULL information_schema PLUGINS PLUGIN_DESCRIPTION 9 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema PLUGINS PLUGIN_LIBRARY 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PLUGINS PLUGIN_LIBRARY_VERSION 7 NULL YES varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
+NULL information_schema PLUGINS PLUGIN_LICENSE 10 NULL YES varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80) select
+NULL information_schema PLUGINS PLUGIN_MATURITY 11 NULL YES varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12) select
+NULL information_schema PLUGINS PLUGIN_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PLUGINS PLUGIN_STATUS 3 NO varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) select
+NULL information_schema PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80) select
+NULL information_schema PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
+NULL information_schema PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
+NULL information_schema PROCESSLIST COMMAND 5 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select
+NULL information_schema PROCESSLIST DB 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select
+NULL information_schema PROCESSLIST TIME_MS 9 0.000 NO decimal NULL NULL 22 3 NULL NULL NULL decimal(22,3) select
+NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select
+NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS DELETE_RULE 9 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS MATCH_OPTION 7 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS REFERENCED_TABLE_NAME 11 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS TABLE_NAME 10 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_CATALOG 4 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_NAME 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema REFERENTIAL_CONSTRAINTS UPDATE_RULE 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES CHARACTER_SET_CLIENT 21 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema ROUTINES COLLATION_CONNECTION 22 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema ROUTINES CREATED 16 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema ROUTINES DATABASE_COLLATION 23 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema ROUTINES DEFINER 20 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77) select
+NULL information_schema ROUTINES DTD_IDENTIFIER 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES EXTERNAL_LANGUAGE 10 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES EXTERNAL_NAME 9 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES IS_DETERMINISTIC 12 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema ROUTINES LAST_ALTERED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema ROUTINES PARAMETER_STYLE 11 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select
+NULL information_schema ROUTINES ROUTINE_BODY 7 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select
+NULL information_schema ROUTINES ROUTINE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema ROUTINES ROUTINE_COMMENT 19 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES ROUTINE_DEFINITION 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema ROUTINES ROUTINE_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES ROUTINE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES ROUTINE_TYPE 5 NO varchar 9 27 NULL NULL NULL utf8 utf8_general_ci varchar(9) select
+NULL information_schema ROUTINES SECURITY_TYPE 15 NO varchar 7 21 NULL NULL NULL utf8 utf8_general_ci varchar(7) select
+NULL information_schema ROUTINES SPECIFIC_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES SQL_DATA_ACCESS 13 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema ROUTINES SQL_MODE 18 NO varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192) select
+NULL information_schema ROUTINES SQL_PATH 14 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema SCHEMATA CATALOG_NAME 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema SCHEMATA DEFAULT_CHARACTER_SET_NAME 3 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema SCHEMATA DEFAULT_COLLATION_NAME 4 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema SCHEMATA SCHEMA_NAME 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema SCHEMATA SQL_PATH 5 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema SCHEMA_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema SCHEMA_PRIVILEGES IS_GRANTABLE 5 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema SCHEMA_PRIVILEGES PRIVILEGE_TYPE 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema SCHEMA_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema SCHEMA_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema SESSION_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema SESSION_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema SESSION_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema SESSION_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1) select
+NULL information_schema STATISTICS COLUMN_NAME 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema STATISTICS COMMENT 15 NULL YES varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select
+NULL information_schema STATISTICS INDEX_NAME 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema STATISTICS INDEX_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema STATISTICS INDEX_TYPE 14 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select
+NULL information_schema STATISTICS NON_UNIQUE 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) select
+NULL information_schema STATISTICS NULLABLE 13 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) select
+NULL information_schema STATISTICS SEQ_IN_INDEX 7 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2) select
+NULL information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select
+NULL information_schema STATISTICS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema STATISTICS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema STATISTICS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLES AUTO_INCREMENT 14 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES AVG_ROW_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES CHECKSUM 19 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES CHECK_TIME 17 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema TABLES CREATE_OPTIONS 20 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255) select
+NULL information_schema TABLES CREATE_TIME 15 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema TABLES DATA_FREE 13 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES DATA_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES ENGINE 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLES INDEX_LENGTH 12 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES MAX_DATA_LENGTH 11 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES ROW_FORMAT 7 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) select
+NULL information_schema TABLES TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema TABLES TABLE_COLLATION 18 NULL YES varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema TABLES TABLE_COMMENT 21 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80) select
+NULL information_schema TABLES TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLES TABLE_ROWS 8 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLES TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLES TABLE_TYPE 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLES UPDATE_TIME 16 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema TABLES VERSION 6 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_CONSTRAINTS TABLE_NAME 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_CONSTRAINTS TABLE_SCHEMA 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema TABLE_PRIVILEGES IS_GRANTABLE 6 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema TABLE_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TABLE_STATISTICS ROWS_CHANGED 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES 5 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema TABLE_STATISTICS ROWS_READ 3 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema TABLE_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema TABLE_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
+NULL information_schema TRIGGERS ACTION_CONDITION 9 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema TRIGGERS ACTION_ORDER 8 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
+NULL information_schema TRIGGERS ACTION_ORIENTATION 11 NO varchar 9 27 NULL NULL NULL utf8 utf8_general_ci varchar(9) select
+NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_ROW 16 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_TABLE 14 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_ROW 15 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_TABLE 13 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TRIGGERS ACTION_STATEMENT 10 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema TRIGGERS ACTION_TIMING 12 NO varchar 6 18 NULL NULL NULL utf8 utf8_general_ci varchar(6) select
+NULL information_schema TRIGGERS CHARACTER_SET_CLIENT 20 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema TRIGGERS COLLATION_CONNECTION 21 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema TRIGGERS CREATED 17 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select
+NULL information_schema TRIGGERS DATABASE_COLLATION 22 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema TRIGGERS DEFINER 19 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77) select
+NULL information_schema TRIGGERS EVENT_MANIPULATION 4 NO varchar 6 18 NULL NULL NULL utf8 utf8_general_ci varchar(6) select
+NULL information_schema TRIGGERS EVENT_OBJECT_CATALOG 5 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema TRIGGERS EVENT_OBJECT_SCHEMA 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TRIGGERS EVENT_OBJECT_TABLE 7 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TRIGGERS SQL_MODE 18 NO varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192) select
+NULL information_schema TRIGGERS TRIGGER_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema TRIGGERS TRIGGER_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema TRIGGERS TRIGGER_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema USER_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81) select
+NULL information_schema USER_PRIVILEGES IS_GRANTABLE 4 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema USER_PRIVILEGES PRIVILEGE_TYPE 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema USER_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema USER_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL NULL double select
+NULL information_schema USER_STATISTICS BYTES_RECEIVED 7 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS BYTES_SENT 8 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS 18 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema USER_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema USER_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL NULL double select
+NULL information_schema USER_STATISTICS DENIED_CONNECTIONS 20 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS EMPTY_QUERIES 23 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS LOST_CONNECTIONS 21 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS OTHER_COMMANDS 17 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS ROWS_DELETED 12 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS ROWS_INSERTED 13 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS ROWS_READ 10 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS ROWS_SENT 11 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
+NULL information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
+NULL information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL NULL utf8 utf8_general_ci varchar(48) select
+NULL information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select
+NULL information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
+NULL information_schema VIEWS DEFINER 7 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77) select
+NULL information_schema VIEWS IS_UPDATABLE 6 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
+NULL information_schema VIEWS SECURITY_TYPE 8 NO varchar 7 21 NULL NULL NULL utf8 utf8_general_ci varchar(7) select
+NULL information_schema VIEWS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select
+NULL information_schema VIEWS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema VIEWS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
+NULL information_schema VIEWS VIEW_DEFINITION 4 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
+NULL information_schema XTRADB_ADMIN_COMMAND result_message 1 NO varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select
+NULL information_schema XTRADB_ENHANCEMENTS comment 3 NO varchar 100 300 NULL NULL NULL utf8 utf8_general_ci varchar(100) select
+NULL information_schema XTRADB_ENHANCEMENTS description 2 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255) select
+NULL information_schema XTRADB_ENHANCEMENTS link 4 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255) select
+NULL information_schema XTRADB_ENHANCEMENTS name 1 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255) select
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
@@ -594,6 +596,7 @@ NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH bigint NULL NULL NULL N
NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema COLUMNS NUMERIC_PRECISION bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema COLUMNS NUMERIC_SCALE bigint NULL NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS DATETIME_PRECISION bigint NULL NULL NULL NULL bigint(21) unsigned
3.0000 information_schema COLUMNS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema COLUMNS COLLATION_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
1.0000 information_schema COLUMNS COLUMN_TYPE longtext 4294967295 4294967295 utf8 utf8_general_ci longtext
@@ -770,6 +773,7 @@ NULL information_schema INNODB_SYS_INDEXES PAGE_NO bigint NULL NULL NULL NULL bi
NULL information_schema INNODB_SYS_STATS INDEX_ID bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema INNODB_SYS_STATS KEY_COLS bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema INNODB_SYS_STATS DIFF_VALS bigint NULL NULL NULL NULL bigint(21) unsigned
+NULL information_schema INNODB_SYS_STATS NON_NULL_VALS bigint NULL NULL NULL NULL bigint(21) unsigned
3.0000 information_schema INNODB_SYS_TABLES SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192)
3.0000 information_schema INNODB_SYS_TABLES NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema INNODB_SYS_TABLES ID bigint NULL NULL NULL NULL bigint(21) unsigned
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
index a8713293c2a..b2dffaafe10 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
@@ -2,454 +2,305 @@ SELECT * FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema CHARACTER_SETS DESCRIPTION 3 NO varchar 60 180 NULL NULL utf8 utf8_general_ci varchar(60)
-NULL information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3)
-NULL information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double
-NULL information_schema CLIENT_STATISTICS BYTES_RECEIVED 7 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS BYTES_SENT 8 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS CLIENT 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema CLIENT_STATISTICS COMMIT_TRANSACTIONS 18 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double
-NULL information_schema CLIENT_STATISTICS DENIED_CONNECTIONS 20 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS EMPTY_QUERIES 23 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS LOST_CONNECTIONS 21 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS OTHER_COMMANDS 17 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS ROWS_DELETED 12 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS ROWS_INSERTED 13 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS ROWS_READ 10 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS ROWS_SENT 11 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS ROWS_UPDATED 14 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS SELECT_COMMANDS 15 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema CLIENT_STATISTICS UPDATE_COMMANDS 16 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema COLLATIONS CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema COLLATIONS COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(11)
-NULL information_schema COLLATIONS IS_COMPILED 5 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema COLLATIONS IS_DEFAULT 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema COLLATIONS SORTLEN 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(3)
-NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME 1 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH 10 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema COLUMNS CHARACTER_SET_NAME 13 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema COLUMNS COLLATION_NAME 14 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema COLUMNS COLUMN_COMMENT 19 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255)
-NULL information_schema COLUMNS COLUMN_DEFAULT 6 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema COLUMNS COLUMN_KEY 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema COLUMNS COLUMN_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMNS COLUMN_TYPE 15 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema COLUMNS DATA_TYPE 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMNS EXTRA 17 NO varchar 27 81 NULL NULL utf8 utf8_general_ci varchar(27)
-NULL information_schema COLUMNS IS_NULLABLE 7 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema COLUMNS NUMERIC_PRECISION 11 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema COLUMNS NUMERIC_SCALE 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema COLUMNS ORDINAL_POSITION 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema COLUMNS PRIVILEGES 18 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80)
-NULL information_schema COLUMNS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema COLUMNS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMNS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMN_PRIVILEGES COLUMN_NAME 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema COLUMN_PRIVILEGES IS_GRANTABLE 7 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema COLUMN_PRIVILEGES PRIVILEGE_TYPE 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMN_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema COLUMN_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema COLUMN_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ENGINES COMMENT 3 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80)
-NULL information_schema ENGINES ENGINE 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ENGINES SAVEPOINTS 6 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema ENGINES SUPPORT 2 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8)
-NULL information_schema ENGINES TRANSACTIONS 4 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema ENGINES XA 5 NULL YES varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema EVENTS CHARACTER_SET_CLIENT 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema EVENTS COLLATION_CONNECTION 23 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema EVENTS CREATED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema EVENTS DATABASE_COLLATION 24 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema EVENTS DEFINER 4 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77)
-NULL information_schema EVENTS ENDS 14 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema EVENTS EVENT_BODY 6 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8)
-NULL information_schema EVENTS EVENT_CATALOG 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema EVENTS EVENT_COMMENT 20 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema EVENTS EVENT_DEFINITION 7 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema EVENTS EVENT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema EVENTS EVENT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema EVENTS EVENT_TYPE 8 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9)
-NULL information_schema EVENTS EXECUTE_AT 9 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema EVENTS INTERVAL_FIELD 11 NULL YES varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18)
-NULL information_schema EVENTS INTERVAL_VALUE 10 NULL YES varchar 256 768 NULL NULL utf8 utf8_general_ci varchar(256)
-NULL information_schema EVENTS LAST_ALTERED 18 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema EVENTS LAST_EXECUTED 19 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema EVENTS ON_COMPLETION 16 NO varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12)
-NULL information_schema EVENTS ORIGINATOR 21 0 NO bigint NULL NULL 19 0 NULL NULL bigint(10)
-NULL information_schema EVENTS SQL_MODE 12 NO varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192)
-NULL information_schema EVENTS STARTS 13 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema EVENTS STATUS 15 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18)
-NULL information_schema EVENTS TIME_ZONE 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES AUTOEXTEND_SIZE 19 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES AVG_ROW_LENGTH 28 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES CHECKSUM 36 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES CHECK_TIME 35 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema FILES CREATE_TIME 33 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema FILES CREATION_TIME 20 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema FILES DATA_FREE 32 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES DATA_LENGTH 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES DELETED_ROWS 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES ENGINE 10 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES EXTENT_SIZE 16 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES EXTRA 38 NULL YES varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255)
-NULL information_schema FILES FILE_ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES FILE_NAME 2 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES FILE_TYPE 3 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20)
-NULL information_schema FILES FREE_EXTENTS 14 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES FULLTEXT_KEYS 11 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES INDEX_LENGTH 31 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES INITIAL_SIZE 17 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES LAST_ACCESS_TIME 22 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema FILES LAST_UPDATE_TIME 21 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema FILES LOGFILE_GROUP_NAME 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES LOGFILE_GROUP_NUMBER 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES MAXIMUM_SIZE 18 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES MAX_DATA_LENGTH 30 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES RECOVER_TIME 23 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES ROW_FORMAT 26 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10)
-NULL information_schema FILES STATUS 37 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20)
-NULL information_schema FILES TABLESPACE_NAME 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES TABLE_CATALOG 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES TABLE_NAME 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES TABLE_ROWS 27 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema FILES TABLE_SCHEMA 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema FILES TOTAL_EXTENTS 15 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES TRANSACTION_COUNTER 24 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES UPDATE_COUNT 13 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema FILES UPDATE_TIME 34 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema FILES VERSION 25 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema INDEX_STATISTICS INDEX_NAME 3 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema INDEX_STATISTICS ROWS_READ 4 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema INDEX_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema INDEX_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema INNODB_BUFFER_POOL_PAGES fix_count 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES flush_type 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES lru_position 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES page_no 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES page_type 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema INNODB_BUFFER_POOL_PAGES space_id 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB compressed 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB fix_count 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB flush_type 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB lru_position 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB next_page_no 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB page_no 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB part_len 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_BLOB space_id 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX accessed 9 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX data_size 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX dirty 11 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX fix_count 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX flush_type 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX hashed 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX index_name 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX lru_position 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX modified 10 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX n_recs 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX old 12 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX page_no 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX schema_name 1 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX space_id 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_BUFFER_POOL_PAGES_INDEX table_name 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema INNODB_CMP compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP compress_time 4 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5)
-NULL information_schema INNODB_CMP uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMPMEM pages_free 3 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMPMEM pages_used 2 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMPMEM page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5)
-NULL information_schema INNODB_CMPMEM relocation_ops 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21)
-NULL information_schema INNODB_CMPMEM relocation_time 5 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMPMEM_RESET pages_free 3 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMPMEM_RESET pages_used 2 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMPMEM_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5)
-NULL information_schema INNODB_CMPMEM_RESET relocation_ops 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21)
-NULL information_schema INNODB_CMPMEM_RESET relocation_time 5 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP_RESET compress_ops 2 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP_RESET compress_ops_ok 3 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP_RESET compress_time 4 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP_RESET page_size 1 0 NO int NULL NULL 10 0 NULL NULL int(5)
-NULL information_schema INNODB_CMP_RESET uncompress_ops 5 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_CMP_RESET uncompress_time 6 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL information_schema INNODB_INDEX_STATS fields 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_INDEX_STATS index_name 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema INNODB_INDEX_STATS index_size 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_INDEX_STATS leaf_pages 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_INDEX_STATS row_per_keys 4 NO varchar 256 768 NULL NULL utf8 utf8_general_ci varchar(256)
-NULL information_schema INNODB_INDEX_STATS table_name 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema INNODB_LOCKS lock_data 10 NULL YES varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192)
-NULL information_schema INNODB_LOCKS lock_id 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema INNODB_LOCKS lock_index 6 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema INNODB_LOCKS lock_mode 3 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema INNODB_LOCKS lock_page 8 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_LOCKS lock_rec 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_LOCKS lock_space 7 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_LOCKS lock_table 5 NO varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema INNODB_LOCKS lock_trx_id 2 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18)
-NULL information_schema INNODB_LOCKS lock_type 4 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema INNODB_LOCK_WAITS blocking_lock_id 4 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema INNODB_LOCK_WAITS blocking_trx_id 3 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18)
-NULL information_schema INNODB_LOCK_WAITS requested_lock_id 2 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema INNODB_LOCK_WAITS requesting_trx_id 1 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18)
-NULL information_schema INNODB_RSEG curr_size 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_RSEG max_size 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_RSEG page_no 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_RSEG rseg_id 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_RSEG space_id 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_RSEG zip_size 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_TABLE_STATS clust_size 3 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_TABLE_STATS modified 5 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_TABLE_STATS other_size 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_TABLE_STATS rows 2 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_TABLE_STATS table_name 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema INNODB_TRX trx_id 1 NO varchar 18 54 NULL NULL utf8 utf8_general_ci varchar(18)
-NULL information_schema INNODB_TRX trx_mysql_thread_id 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema INNODB_TRX trx_query 8 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema INNODB_TRX trx_requested_lock_id 4 NULL YES varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema INNODB_TRX trx_started 3 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema INNODB_TRX trx_state 2 NO varchar 13 39 NULL NULL utf8 utf8_general_ci varchar(13)
-NULL information_schema INNODB_TRX trx_wait_started 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema INNODB_TRX trx_weight 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema KEY_COLUMN_USAGE COLUMN_NAME 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE ORDINAL_POSITION 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(10)
-NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(10)
-NULL information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME 12 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME 11 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PARTITIONS AVG_ROW_LENGTH 14 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS CHECKSUM 22 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS CHECK_TIME 21 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema PARTITIONS CREATE_TIME 19 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema PARTITIONS DATA_FREE 18 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS DATA_LENGTH 15 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS INDEX_LENGTH 17 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS MAX_DATA_LENGTH 16 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS NODEGROUP 24 NO varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12)
-NULL information_schema PARTITIONS PARTITION_COMMENT 23 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80)
-NULL information_schema PARTITIONS PARTITION_DESCRIPTION 12 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema PARTITIONS PARTITION_EXPRESSION 10 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema PARTITIONS PARTITION_METHOD 8 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12)
-NULL information_schema PARTITIONS PARTITION_NAME 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PARTITIONS PARTITION_ORDINAL_POSITION 6 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS SUBPARTITION_EXPRESSION 11 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema PARTITIONS SUBPARTITION_METHOD 9 NULL YES varchar 12 36 NULL NULL utf8 utf8_general_ci varchar(12)
-NULL information_schema PARTITIONS SUBPARTITION_NAME 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PARTITIONS SUBPARTITION_ORDINAL_POSITION 7 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS TABLESPACE_NAME 25 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PARTITIONS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema PARTITIONS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PARTITIONS TABLE_ROWS 13 0 NO bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema PARTITIONS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PARTITIONS UPDATE_TIME 20 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema PLUGINS PLUGIN_AUTHOR 8 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PLUGINS PLUGIN_DESCRIPTION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema PLUGINS PLUGIN_LIBRARY 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PLUGINS PLUGIN_LIBRARY_VERSION 7 NULL YES varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20)
-NULL information_schema PLUGINS PLUGIN_LICENSE 10 NULL YES varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80)
-NULL information_schema PLUGINS PLUGIN_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PLUGINS PLUGIN_STATUS 3 NO varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10)
-NULL information_schema PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80)
-NULL information_schema PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20)
-NULL information_schema PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL utf8 utf8_general_ci varchar(20)
-NULL information_schema PROCESSLIST COMMAND 5 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16)
-NULL information_schema PROCESSLIST DB 4 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL int(7)
-NULL information_schema PROCESSLIST TIME_MS 9 0.000 NO decimal NULL NULL 22 3 NULL NULL decimal(22,3)
-NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16)
-NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS DELETE_RULE 9 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS MATCH_OPTION 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS REFERENCED_TABLE_NAME 11 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS TABLE_NAME 10 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_CATALOG 4 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_NAME 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema REFERENTIAL_CONSTRAINTS UPDATE_RULE 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES CHARACTER_SET_CLIENT 21 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema ROUTINES COLLATION_CONNECTION 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema ROUTINES CREATED 16 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema ROUTINES DATABASE_COLLATION 23 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema ROUTINES DEFINER 20 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77)
-NULL information_schema ROUTINES DTD_IDENTIFIER 6 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES EXTERNAL_LANGUAGE 10 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES EXTERNAL_NAME 9 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES IS_DETERMINISTIC 12 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema ROUTINES LAST_ALTERED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema ROUTINES PARAMETER_STYLE 11 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8)
-NULL information_schema ROUTINES ROUTINE_BODY 7 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8)
-NULL information_schema ROUTINES ROUTINE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema ROUTINES ROUTINE_COMMENT 19 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES ROUTINE_DEFINITION 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema ROUTINES ROUTINE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES ROUTINE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES ROUTINE_TYPE 5 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9)
-NULL information_schema ROUTINES SECURITY_TYPE 15 NO varchar 7 21 NULL NULL utf8 utf8_general_ci varchar(7)
-NULL information_schema ROUTINES SPECIFIC_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES SQL_DATA_ACCESS 13 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema ROUTINES SQL_MODE 18 NO varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192)
-NULL information_schema ROUTINES SQL_PATH 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema SCHEMATA CATALOG_NAME 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema SCHEMATA DEFAULT_CHARACTER_SET_NAME 3 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema SCHEMATA DEFAULT_COLLATION_NAME 4 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema SCHEMATA SCHEMA_NAME 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema SCHEMATA SQL_PATH 5 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema SCHEMA_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema SCHEMA_PRIVILEGES IS_GRANTABLE 5 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema SCHEMA_PRIVILEGES PRIVILEGE_TYPE 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema SCHEMA_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema SCHEMA_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema SESSION_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema SESSION_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema SESSION_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema SESSION_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL utf8 utf8_general_ci varchar(1024)
-NULL information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21)
-NULL information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL utf8 utf8_general_ci varchar(1)
-NULL information_schema STATISTICS COLUMN_NAME 8 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema STATISTICS COMMENT 15 NULL YES varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16)
-NULL information_schema STATISTICS INDEX_NAME 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema STATISTICS INDEX_SCHEMA 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema STATISTICS INDEX_TYPE 14 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16)
-NULL information_schema STATISTICS NON_UNIQUE 4 0 NO bigint NULL NULL 19 0 NULL NULL bigint(1)
-NULL information_schema STATISTICS NULLABLE 13 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10)
-NULL information_schema STATISTICS SEQ_IN_INDEX 7 0 NO bigint NULL NULL 19 0 NULL NULL bigint(2)
-NULL information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(3)
-NULL information_schema STATISTICS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema STATISTICS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema STATISTICS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLES AUTO_INCREMENT 14 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES AVG_ROW_LENGTH 9 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES CHECKSUM 19 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES CHECK_TIME 17 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema TABLES CREATE_OPTIONS 20 NULL YES varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255)
-NULL information_schema TABLES CREATE_TIME 15 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema TABLES DATA_FREE 13 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES DATA_LENGTH 10 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES ENGINE 5 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLES INDEX_LENGTH 12 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES MAX_DATA_LENGTH 11 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES ROW_FORMAT 7 NULL YES varchar 10 30 NULL NULL utf8 utf8_general_ci varchar(10)
-NULL information_schema TABLES TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema TABLES TABLE_COLLATION 18 NULL YES varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema TABLES TABLE_COMMENT 21 NO varchar 80 240 NULL NULL utf8 utf8_general_ci varchar(80)
-NULL information_schema TABLES TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLES TABLE_ROWS 8 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLES TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLES TABLE_TYPE 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLES UPDATE_TIME 16 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema TABLES VERSION 6 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(21) unsigned
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_CONSTRAINTS TABLE_NAME 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_CONSTRAINTS TABLE_SCHEMA 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema TABLE_PRIVILEGES IS_GRANTABLE 6 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE 5 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema TABLE_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TABLE_STATISTICS ROWS_CHANGED 4 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema TABLE_STATISTICS ROWS_CHANGED_X_INDEXES 5 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema TABLE_STATISTICS ROWS_READ 3 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema TABLE_STATISTICS TABLE_NAME 2 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema TABLE_STATISTICS TABLE_SCHEMA 1 NO varchar 192 576 NULL NULL utf8 utf8_general_ci varchar(192)
-NULL information_schema TRIGGERS ACTION_CONDITION 9 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema TRIGGERS ACTION_ORDER 8 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4)
-NULL information_schema TRIGGERS ACTION_ORIENTATION 11 NO varchar 9 27 NULL NULL utf8 utf8_general_ci varchar(9)
-NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_ROW 16 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_TABLE 14 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_ROW 15 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_TABLE 13 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TRIGGERS ACTION_STATEMENT 10 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema TRIGGERS ACTION_TIMING 12 NO varchar 6 18 NULL NULL utf8 utf8_general_ci varchar(6)
-NULL information_schema TRIGGERS CHARACTER_SET_CLIENT 20 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema TRIGGERS COLLATION_CONNECTION 21 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema TRIGGERS CREATED 17 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL information_schema TRIGGERS DATABASE_COLLATION 22 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema TRIGGERS DEFINER 19 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77)
-NULL information_schema TRIGGERS EVENT_MANIPULATION 4 NO varchar 6 18 NULL NULL utf8 utf8_general_ci varchar(6)
-NULL information_schema TRIGGERS EVENT_OBJECT_CATALOG 5 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema TRIGGERS EVENT_OBJECT_SCHEMA 6 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TRIGGERS EVENT_OBJECT_TABLE 7 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TRIGGERS SQL_MODE 18 NO varchar 8192 24576 NULL NULL utf8 utf8_general_ci varchar(8192)
-NULL information_schema TRIGGERS TRIGGER_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema TRIGGERS TRIGGER_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema TRIGGERS TRIGGER_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema USER_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL utf8 utf8_general_ci varchar(81)
-NULL information_schema USER_PRIVILEGES IS_GRANTABLE 4 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema USER_PRIVILEGES PRIVILEGE_TYPE 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema USER_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema USER_STATISTICS ACCESS_DENIED 22 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL double
-NULL information_schema USER_STATISTICS BYTES_RECEIVED 7 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS BYTES_SENT 8 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS COMMIT_TRANSACTIONS 18 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS 3 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS CONNECTED_TIME 4 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS CPU_TIME 6 0 NO double NULL NULL 21 NULL NULL NULL double
-NULL information_schema USER_STATISTICS DENIED_CONNECTIONS 20 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS EMPTY_QUERIES 23 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS LOST_CONNECTIONS 21 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS OTHER_COMMANDS 17 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS ROLLBACK_TRANSACTIONS 19 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS ROWS_DELETED 12 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS ROWS_INSERTED 13 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS ROWS_READ 10 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS ROWS_SENT 11 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO int NULL NULL 10 0 NULL NULL int(21)
-NULL information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL utf8 utf8_general_ci varchar(48)
-NULL information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL utf8 utf8_general_ci varchar(8)
-NULL information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL utf8 utf8_general_ci varchar(32)
-NULL information_schema VIEWS DEFINER 7 NO varchar 77 231 NULL NULL utf8 utf8_general_ci varchar(77)
-NULL information_schema VIEWS IS_UPDATABLE 6 NO varchar 3 9 NULL NULL utf8 utf8_general_ci varchar(3)
-NULL information_schema VIEWS SECURITY_TYPE 8 NO varchar 7 21 NULL NULL utf8 utf8_general_ci varchar(7)
-NULL information_schema VIEWS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL information_schema VIEWS TABLE_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema VIEWS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL information_schema VIEWS VIEW_DEFINITION 4 NULL NO longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext
-NULL information_schema XTRADB_ENHANCEMENTS comment 3 NO varchar 100 300 NULL NULL utf8 utf8_general_ci varchar(100)
-NULL information_schema XTRADB_ENHANCEMENTS description 2 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255)
-NULL information_schema XTRADB_ENHANCEMENTS link 4 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255)
-NULL information_schema XTRADB_ENHANCEMENTS name 1 NO varchar 255 765 NULL NULL utf8 utf8_general_ci varchar(255)
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME 2 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema CHARACTER_SETS DESCRIPTION 3 NO varchar 60 180 NULL NULL NULL utf8 utf8_general_ci varchar(60)
+NULL information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3)
+NULL information_schema COLLATIONS CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema COLLATIONS COLLATION_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema COLLATIONS ID 3 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11)
+NULL information_schema COLLATIONS IS_COMPILED 5 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema COLLATIONS IS_DEFAULT 4 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema COLLATIONS SORTLEN 6 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3)
+NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY CHARACTER_SET_NAME 2 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS CHARACTER_SET_NAME 14 NULL YES varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema COLUMNS COLLATION_NAME 15 NULL YES varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema COLUMNS COLUMN_COMMENT 20 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255)
+NULL information_schema COLUMNS COLUMN_DEFAULT 6 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema COLUMNS COLUMN_KEY 17 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema COLUMNS COLUMN_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMNS COLUMN_TYPE 16 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema COLUMNS DATA_TYPE 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMNS DATETIME_PRECISION 13 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS EXTRA 18 NO varchar 27 81 NULL NULL NULL utf8 utf8_general_ci varchar(27)
+NULL information_schema COLUMNS IS_NULLABLE 7 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema COLUMNS NUMERIC_PRECISION 11 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS NUMERIC_SCALE 12 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS ORDINAL_POSITION 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS PRIVILEGES 19 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80)
+NULL information_schema COLUMNS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema COLUMNS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMNS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMN_PRIVILEGES COLUMN_NAME 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMN_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81)
+NULL information_schema COLUMN_PRIVILEGES IS_GRANTABLE 7 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema COLUMN_PRIVILEGES PRIVILEGE_TYPE 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMN_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema COLUMN_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema COLUMN_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ENGINES COMMENT 3 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80)
+NULL information_schema ENGINES ENGINE 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ENGINES SAVEPOINTS 6 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema ENGINES SUPPORT 2 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8)
+NULL information_schema ENGINES TRANSACTIONS 4 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema ENGINES XA 5 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema EVENTS CHARACTER_SET_CLIENT 22 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema EVENTS COLLATION_CONNECTION 23 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema EVENTS CREATED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema EVENTS DATABASE_COLLATION 24 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema EVENTS DEFINER 4 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77)
+NULL information_schema EVENTS ENDS 14 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema EVENTS EVENT_BODY 6 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8)
+NULL information_schema EVENTS EVENT_CATALOG 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema EVENTS EVENT_COMMENT 20 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema EVENTS EVENT_DEFINITION 7 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema EVENTS EVENT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema EVENTS EVENT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema EVENTS EVENT_TYPE 8 NO varchar 9 27 NULL NULL NULL utf8 utf8_general_ci varchar(9)
+NULL information_schema EVENTS EXECUTE_AT 9 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema EVENTS INTERVAL_FIELD 11 NULL YES varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18)
+NULL information_schema EVENTS INTERVAL_VALUE 10 NULL YES varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256)
+NULL information_schema EVENTS LAST_ALTERED 18 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema EVENTS LAST_EXECUTED 19 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema EVENTS ON_COMPLETION 16 NO varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12)
+NULL information_schema EVENTS ORIGINATOR 21 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(10)
+NULL information_schema EVENTS SQL_MODE 12 NO varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192)
+NULL information_schema EVENTS STARTS 13 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema EVENTS STATUS 15 NO varchar 18 54 NULL NULL NULL utf8 utf8_general_ci varchar(18)
+NULL information_schema EVENTS TIME_ZONE 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES AUTOEXTEND_SIZE 19 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES AVG_ROW_LENGTH 28 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES CHECKSUM 36 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES CHECK_TIME 35 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema FILES CREATE_TIME 33 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema FILES CREATION_TIME 20 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema FILES DATA_FREE 32 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES DATA_LENGTH 29 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES DELETED_ROWS 12 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES ENGINE 10 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES EXTENT_SIZE 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES EXTRA 38 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255)
+NULL information_schema FILES FILE_ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES FILE_NAME 2 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES FILE_TYPE 3 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
+NULL information_schema FILES FREE_EXTENTS 14 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES FULLTEXT_KEYS 11 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES INDEX_LENGTH 31 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES INITIAL_SIZE 17 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES LAST_ACCESS_TIME 22 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema FILES LAST_UPDATE_TIME 21 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema FILES LOGFILE_GROUP_NAME 8 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES LOGFILE_GROUP_NUMBER 9 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES MAXIMUM_SIZE 18 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES MAX_DATA_LENGTH 30 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES RECOVER_TIME 23 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES ROW_FORMAT 26 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10)
+NULL information_schema FILES STATUS 37 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
+NULL information_schema FILES TABLESPACE_NAME 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES TABLE_CATALOG 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES TABLE_NAME 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES TABLE_ROWS 27 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema FILES TABLE_SCHEMA 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema FILES TOTAL_EXTENTS 15 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES TRANSACTION_COUNTER 24 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES UPDATE_COUNT 13 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema FILES UPDATE_TIME 34 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema FILES VERSION 25 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema GLOBAL_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema GLOBAL_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024)
+NULL information_schema GLOBAL_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema GLOBAL_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024)
+NULL information_schema KEY_COLUMN_USAGE COLUMN_NAME 7 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE ORDINAL_POSITION 8 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(10)
+NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT 9 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(10)
+NULL information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME 12 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME 11 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PARTITIONS AVG_ROW_LENGTH 14 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS CHECKSUM 22 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS CHECK_TIME 21 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema PARTITIONS CREATE_TIME 19 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema PARTITIONS DATA_FREE 18 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS DATA_LENGTH 15 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS INDEX_LENGTH 17 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS MAX_DATA_LENGTH 16 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS NODEGROUP 24 NO varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12)
+NULL information_schema PARTITIONS PARTITION_COMMENT 23 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80)
+NULL information_schema PARTITIONS PARTITION_DESCRIPTION 12 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema PARTITIONS PARTITION_EXPRESSION 10 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema PARTITIONS PARTITION_METHOD 8 NULL YES varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12)
+NULL information_schema PARTITIONS PARTITION_NAME 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PARTITIONS PARTITION_ORDINAL_POSITION 6 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS SUBPARTITION_EXPRESSION 11 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema PARTITIONS SUBPARTITION_METHOD 9 NULL YES varchar 12 36 NULL NULL NULL utf8 utf8_general_ci varchar(12)
+NULL information_schema PARTITIONS SUBPARTITION_NAME 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PARTITIONS SUBPARTITION_ORDINAL_POSITION 7 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS TABLESPACE_NAME 25 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PARTITIONS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema PARTITIONS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PARTITIONS TABLE_ROWS 13 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema PARTITIONS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PARTITIONS UPDATE_TIME 20 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema PLUGINS PLUGIN_AUTHOR 8 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PLUGINS PLUGIN_DESCRIPTION 9 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema PLUGINS PLUGIN_LIBRARY 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PLUGINS PLUGIN_LIBRARY_VERSION 7 NULL YES varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
+NULL information_schema PLUGINS PLUGIN_LICENSE 10 NULL YES varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80)
+NULL information_schema PLUGINS PLUGIN_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PLUGINS PLUGIN_STATUS 3 NO varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10)
+NULL information_schema PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80)
+NULL information_schema PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
+NULL information_schema PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
+NULL information_schema PROCESSLIST COMMAND 5 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16)
+NULL information_schema PROCESSLIST DB 4 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(7)
+NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16)
+NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS DELETE_RULE 9 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS MATCH_OPTION 7 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS REFERENCED_TABLE_NAME 11 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS TABLE_NAME 10 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_CATALOG 4 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_NAME 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema REFERENTIAL_CONSTRAINTS UPDATE_RULE 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES CHARACTER_SET_CLIENT 21 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema ROUTINES COLLATION_CONNECTION 22 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema ROUTINES CREATED 16 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema ROUTINES DATABASE_COLLATION 23 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema ROUTINES DEFINER 20 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77)
+NULL information_schema ROUTINES DTD_IDENTIFIER 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES EXTERNAL_LANGUAGE 10 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES EXTERNAL_NAME 9 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES IS_DETERMINISTIC 12 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema ROUTINES LAST_ALTERED 17 0000-00-00 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema ROUTINES PARAMETER_STYLE 11 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8)
+NULL information_schema ROUTINES ROUTINE_BODY 7 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8)
+NULL information_schema ROUTINES ROUTINE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema ROUTINES ROUTINE_COMMENT 19 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES ROUTINE_DEFINITION 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema ROUTINES ROUTINE_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES ROUTINE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES ROUTINE_TYPE 5 NO varchar 9 27 NULL NULL NULL utf8 utf8_general_ci varchar(9)
+NULL information_schema ROUTINES SECURITY_TYPE 15 NO varchar 7 21 NULL NULL NULL utf8 utf8_general_ci varchar(7)
+NULL information_schema ROUTINES SPECIFIC_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES SQL_DATA_ACCESS 13 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema ROUTINES SQL_MODE 18 NO varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192)
+NULL information_schema ROUTINES SQL_PATH 14 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema SCHEMATA CATALOG_NAME 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema SCHEMATA DEFAULT_CHARACTER_SET_NAME 3 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema SCHEMATA DEFAULT_COLLATION_NAME 4 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema SCHEMATA SCHEMA_NAME 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema SCHEMATA SQL_PATH 5 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema SCHEMA_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81)
+NULL information_schema SCHEMA_PRIVILEGES IS_GRANTABLE 5 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema SCHEMA_PRIVILEGES PRIVILEGE_TYPE 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema SCHEMA_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema SCHEMA_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema SESSION_STATUS VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema SESSION_STATUS VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024)
+NULL information_schema SESSION_VARIABLES VARIABLE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema SESSION_VARIABLES VARIABLE_VALUE 2 NULL YES varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024)
+NULL information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(21)
+NULL information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1)
+NULL information_schema STATISTICS COLUMN_NAME 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema STATISTICS COMMENT 15 NULL YES varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16)
+NULL information_schema STATISTICS INDEX_NAME 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema STATISTICS INDEX_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema STATISTICS INDEX_TYPE 14 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16)
+NULL information_schema STATISTICS NON_UNIQUE 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1)
+NULL information_schema STATISTICS NULLABLE 13 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10)
+NULL information_schema STATISTICS SEQ_IN_INDEX 7 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(2)
+NULL information_schema STATISTICS SUB_PART 11 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(3)
+NULL information_schema STATISTICS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema STATISTICS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema STATISTICS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLES AUTO_INCREMENT 14 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES AVG_ROW_LENGTH 9 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES CHECKSUM 19 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES CHECK_TIME 17 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema TABLES CREATE_OPTIONS 20 NULL YES varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255)
+NULL information_schema TABLES CREATE_TIME 15 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema TABLES DATA_FREE 13 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES DATA_LENGTH 10 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES ENGINE 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLES INDEX_LENGTH 12 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES MAX_DATA_LENGTH 11 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES ROW_FORMAT 7 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10)
+NULL information_schema TABLES TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema TABLES TABLE_COLLATION 18 NULL YES varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema TABLES TABLE_COMMENT 21 NO varchar 80 240 NULL NULL NULL utf8 utf8_general_ci varchar(80)
+NULL information_schema TABLES TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLES TABLE_ROWS 8 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLES TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLES TABLE_TYPE 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLES UPDATE_TIME 16 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema TABLES VERSION 6 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_CONSTRAINTS CONSTRAINT_TYPE 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_CONSTRAINTS TABLE_NAME 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_CONSTRAINTS TABLE_SCHEMA 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81)
+NULL information_schema TABLE_PRIVILEGES IS_GRANTABLE 6 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema TABLE_PRIVILEGES PRIVILEGE_TYPE 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema TABLE_PRIVILEGES TABLE_NAME 4 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TABLE_PRIVILEGES TABLE_SCHEMA 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TRIGGERS ACTION_CONDITION 9 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema TRIGGERS ACTION_ORDER 8 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+NULL information_schema TRIGGERS ACTION_ORIENTATION 11 NO varchar 9 27 NULL NULL NULL utf8 utf8_general_ci varchar(9)
+NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_ROW 16 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema TRIGGERS ACTION_REFERENCE_NEW_TABLE 14 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_ROW 15 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema TRIGGERS ACTION_REFERENCE_OLD_TABLE 13 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TRIGGERS ACTION_STATEMENT 10 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+NULL information_schema TRIGGERS ACTION_TIMING 12 NO varchar 6 18 NULL NULL NULL utf8 utf8_general_ci varchar(6)
+NULL information_schema TRIGGERS CHARACTER_SET_CLIENT 20 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema TRIGGERS COLLATION_CONNECTION 21 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema TRIGGERS CREATED 17 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL information_schema TRIGGERS DATABASE_COLLATION 22 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema TRIGGERS DEFINER 19 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77)
+NULL information_schema TRIGGERS EVENT_MANIPULATION 4 NO varchar 6 18 NULL NULL NULL utf8 utf8_general_ci varchar(6)
+NULL information_schema TRIGGERS EVENT_OBJECT_CATALOG 5 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema TRIGGERS EVENT_OBJECT_SCHEMA 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TRIGGERS EVENT_OBJECT_TABLE 7 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TRIGGERS SQL_MODE 18 NO varchar 8192 24576 NULL NULL NULL utf8 utf8_general_ci varchar(8192)
+NULL information_schema TRIGGERS TRIGGER_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema TRIGGERS TRIGGER_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema TRIGGERS TRIGGER_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema USER_PRIVILEGES GRANTEE 1 NO varchar 81 243 NULL NULL NULL utf8 utf8_general_ci varchar(81)
+NULL information_schema USER_PRIVILEGES IS_GRANTABLE 4 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema USER_PRIVILEGES PRIVILEGE_TYPE 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema USER_PRIVILEGES TABLE_CATALOG 2 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8)
+NULL information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
+NULL information_schema VIEWS DEFINER 7 NO varchar 77 231 NULL NULL NULL utf8 utf8_general_ci varchar(77)
+NULL information_schema VIEWS IS_UPDATABLE 6 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
+NULL information_schema VIEWS SECURITY_TYPE 8 NO varchar 7 21 NULL NULL NULL utf8 utf8_general_ci varchar(7)
+NULL information_schema VIEWS TABLE_CATALOG 1 NULL YES varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL information_schema VIEWS TABLE_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema VIEWS TABLE_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL information_schema VIEWS VIEW_DEFINITION 4 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
@@ -557,6 +408,7 @@ NULL information_schema COLUMNS CHARACTER_MAXIMUM_LENGTH bigint NULL NULL NULL N
NULL information_schema COLUMNS CHARACTER_OCTET_LENGTH bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema COLUMNS NUMERIC_PRECISION bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema COLUMNS NUMERIC_SCALE bigint NULL NULL NULL NULL bigint(21) unsigned
+NULL information_schema COLUMNS DATETIME_PRECISION bigint NULL NULL NULL NULL bigint(21) unsigned
3.0000 information_schema COLUMNS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema COLUMNS COLLATION_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
1.0000 information_schema COLUMNS COLUMN_TYPE longtext 4294967295 4294967295 utf8 utf8_general_ci longtext
diff --git a/mysql-test/suite/funcs_1/r/is_columns_memory.result b/mysql-test/suite/funcs_1/r/is_columns_memory.result
index 60dea25e0e3..680210df1de 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_memory.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_memory.result
@@ -371,318 +371,318 @@ LOAD DATA INFILE '<MYSQLTEST_VARDIR>/std_data/funcs_1/t9.txt' INTO TABLE t9;
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t1 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t1 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t10 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t10 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t10 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t11 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t11 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t11 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t2 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t2 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t2 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t3 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t3 f2 2 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t4 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t4 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t4 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t7 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t7 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t8 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t8 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t9 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb1 f1 1 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb1 f12 4 NULL YES binary 1 1 NULL NULL NULL NULL binary(1) select,insert,update,references
-NULL test tb1 f13 5 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(4) select,insert,update,references
-NULL test tb1 f14 6 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL test tb1 f15 7 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb1 f16 8 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb1 f17 9 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(6) select,insert,update,references
-NULL test tb1 f18 10 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL test tb1 f19 11 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb1 f2 2 NULL YES char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
-NULL test tb1 f20 12 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb1 f21 13 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(9) select,insert,update,references
-NULL test tb1 f22 14 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned select,insert,update,references
-NULL test tb1 f23 15 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb1 f24 16 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb1 f25 17 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb1 f26 18 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL test tb1 f27 19 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb1 f28 20 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb1 f29 21 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references
-NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb1 f30 22 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL test tb1 f31 23 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb1 f32 24 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb1 f33 25 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f34 26 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f35 27 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f36 28 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f37 29 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f38 30 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb1 f39 31 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f40 32 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb1 f41 33 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f42 34 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f43 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f44 36 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f45 37 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f46 38 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb1 f47 39 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f48 40 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb1 f49 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f50 42 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb1 f51 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f52 44 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb1 f53 45 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f54 46 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f55 47 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f56 48 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f57 49 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f58 50 99 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
-NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb3 f121 4 NULL YES char 50 50 NULL NULL latin1 latin1_swedish_ci char(50) select,insert,update,references
-NULL test tb3 f122 5 NULL YES char 50 50 NULL NULL latin1 latin1_swedish_ci char(50) select,insert,update,references
-NULL test tb3 f129 6  NO binary 1 1 NULL NULL NULL NULL binary(1) select,insert,update,references
-NULL test tb3 f130 7 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(4) select,insert,update,references
-NULL test tb3 f131 8 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL test tb3 f132 9 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb3 f133 10 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb3 f134 11 999 NO smallint NULL NULL 5 0 NULL NULL smallint(6) select,insert,update,references
-NULL test tb3 f135 12 999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL test tb3 f136 13 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb3 f137 14 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb3 f138 15 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(9) select,insert,update,references
-NULL test tb3 f139 16 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned select,insert,update,references
-NULL test tb3 f140 17 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb3 f141 18 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb3 f142 19 99999 NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb3 f143 20 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL test tb3 f144 21 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb3 f145 22 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb3 f146 23 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references
-NULL test tb3 f147 24 999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL test tb3 f148 25 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb3 f149 26 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb3 f150 27 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f151 28 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f152 29 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f153 30 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f154 31 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f155 32 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb3 f156 33 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f157 34 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb3 f158 35 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f159 36 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f160 37 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f161 38 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f162 39 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f163 40 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb3 f164 41 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f165 42 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb3 f166 43 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f167 44 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb3 f168 45 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f169 46 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb3 f170 47 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f171 48 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f172 49 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f173 50 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f174 51 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f175 52 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test tb4 f236 52 NULL YES char 95 95 NULL NULL latin1 latin1_swedish_ci char(95) select,insert,update,references
-NULL test tb4 f237 54 NULL YES char 130 130 NULL NULL latin1 latin1_bin char(130) select,insert,update,references
-NULL test tb4 f238 55 NULL YES varchar 25000 25000 NULL NULL latin1 latin1_bin varchar(25000) select,insert,update,references
-NULL test tb4 f239 56 NULL YES varbinary 0 0 NULL NULL NULL NULL varbinary(0) select,insert,update,references
-NULL test tb4 f240 57 NULL YES varchar 1200 1200 NULL NULL latin1 latin1_swedish_ci varchar(1200) select,insert,update,references
-NULL test tb4 f241 53 NULL YES char 255 255 NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t1 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t1 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t10 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t10 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t10 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t11 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t11 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t11 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t2 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t2 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t2 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t3 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t3 f2 2 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t4 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t4 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t4 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t7 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t7 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t8 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t8 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t9 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb1 f1 1 NULL YES char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb1 f12 4 NULL YES binary 1 1 NULL NULL NULL NULL NULL binary(1) select,insert,update,references
+NULL test tb1 f13 5 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4) select,insert,update,references
+NULL test tb1 f14 6 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL test tb1 f15 7 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb1 f16 8 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb1 f17 9 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(6) select,insert,update,references
+NULL test tb1 f18 10 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL test tb1 f19 11 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb1 f2 2 NULL YES char 1 1 NULL NULL NULL latin1 latin1_bin char(1) select,insert,update,references
+NULL test tb1 f20 12 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb1 f21 13 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9) select,insert,update,references
+NULL test tb1 f22 14 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned select,insert,update,references
+NULL test tb1 f23 15 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb1 f24 16 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb1 f25 17 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb1 f26 18 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL test tb1 f27 19 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb1 f28 20 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb1 f29 21 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(20) select,insert,update,references
+NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb1 f30 22 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL test tb1 f31 23 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb1 f32 24 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb1 f33 25 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f34 26 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f35 27 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f36 28 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f37 29 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f38 30 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb1 f39 31 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f40 32 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb1 f41 33 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f42 34 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f43 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f44 36 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f45 37 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f46 38 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb1 f47 39 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f48 40 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb1 f49 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f50 42 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb1 f51 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f52 44 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb1 f53 45 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f54 46 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f55 47 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f56 48 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f57 49 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f58 50 99 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb3 f118 1 a NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb3 f119 2  NO char 1 1 NULL NULL NULL latin1 latin1_bin char(1) select,insert,update,references
+NULL test tb3 f120 3  NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb3 f121 4 NULL YES char 50 50 NULL NULL NULL latin1 latin1_swedish_ci char(50) select,insert,update,references
+NULL test tb3 f122 5 NULL YES char 50 50 NULL NULL NULL latin1 latin1_swedish_ci char(50) select,insert,update,references
+NULL test tb3 f129 6  NO binary 1 1 NULL NULL NULL NULL NULL binary(1) select,insert,update,references
+NULL test tb3 f130 7 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4) select,insert,update,references
+NULL test tb3 f131 8 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL test tb3 f132 9 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb3 f133 10 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb3 f134 11 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(6) select,insert,update,references
+NULL test tb3 f135 12 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL test tb3 f136 13 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb3 f137 14 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb3 f138 15 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9) select,insert,update,references
+NULL test tb3 f139 16 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned select,insert,update,references
+NULL test tb3 f140 17 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb3 f141 18 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb3 f142 19 99999 NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb3 f143 20 99999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL test tb3 f144 21 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb3 f145 22 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb3 f146 23 999999 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) select,insert,update,references
+NULL test tb3 f147 24 999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL test tb3 f148 25 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb3 f149 26 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb3 f150 27 1000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f151 28 999 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f152 29 0000001000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f153 30 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f154 31 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f155 32 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb3 f156 33 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f157 34 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb3 f158 35 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f159 36 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f160 37 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f161 38 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f162 39 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f163 40 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb3 f164 41 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f165 42 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb3 f166 43 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f167 44 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb3 f168 45 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f169 46 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb3 f170 47 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f171 48 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f172 49 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f173 50 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f174 51 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f175 52 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test tb4 f236 52 NULL YES char 95 95 NULL NULL NULL latin1 latin1_swedish_ci char(95) select,insert,update,references
+NULL test tb4 f237 54 NULL YES char 130 130 NULL NULL NULL latin1 latin1_bin char(130) select,insert,update,references
+NULL test tb4 f238 55 NULL YES varchar 25000 25000 NULL NULL NULL latin1 latin1_bin varchar(25000) select,insert,update,references
+NULL test tb4 f239 56 NULL YES varbinary 0 0 NULL NULL NULL NULL NULL varbinary(0) select,insert,update,references
+NULL test tb4 f240 57 NULL YES varchar 1200 1200 NULL NULL NULL latin1 latin1_swedish_ci varchar(1200) select,insert,update,references
+NULL test tb4 f241 53 NULL YES char 255 255 NULL NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_columns_myisam.result b/mysql-test/suite/funcs_1/r/is_columns_myisam.result
index 6d0a44d2223..3e65adbcf02 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_myisam.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_myisam.result
@@ -411,358 +411,358 @@ LOAD DATA INFILE '<MYSQLTEST_VARDIR>/std_data/funcs_1/t9.txt' INTO TABLE t9;
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t1 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t1 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t10 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t10 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t10 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t11 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t11 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t11 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t2 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t2 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t2 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t3 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t3 f2 2 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t4 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t4 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t4 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t7 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t7 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t8 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test t8 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test t9 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb1 f1 1 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb1 f10 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL mediumblob select,insert,update,references
-NULL test tb1 f11 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL test tb1 f12 12 NULL YES binary 1 1 NULL NULL NULL NULL binary(1) select,insert,update,references
-NULL test tb1 f13 13 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(4) select,insert,update,references
-NULL test tb1 f14 14 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL test tb1 f15 15 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb1 f16 16 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb1 f17 17 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(6) select,insert,update,references
-NULL test tb1 f18 18 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL test tb1 f19 19 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb1 f2 2 NULL YES char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
-NULL test tb1 f20 20 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb1 f21 21 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(9) select,insert,update,references
-NULL test tb1 f22 22 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned select,insert,update,references
-NULL test tb1 f23 23 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb1 f24 24 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb1 f25 25 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb1 f26 26 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references
-NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb1 f33 33 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f34 34 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f35 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f36 36 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f37 37 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f38 38 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb1 f39 39 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f4 4 NULL YES tinytext 255 255 NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
-NULL test tb1 f40 40 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb1 f41 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f42 42 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f43 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f44 44 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f45 45 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f46 46 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb1 f47 47 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f48 48 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb1 f49 49 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f5 5 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
-NULL test tb1 f50 50 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb1 f51 51 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f52 52 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb1 f53 53 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f54 54 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb1 f55 55 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f56 56 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb1 f57 57 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb1 f58 58 99 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
-NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
-NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob select,insert,update,references
-NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27) select,insert,update,references
-NULL test tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27) select,insert,update,references
-NULL test tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
-NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
-NULL test tb3 f121 4 NULL YES tinytext 255 255 NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
-NULL test tb3 f122 5 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
-NULL test tb3 f123 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
-NULL test tb3 f124 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
-NULL test tb3 f125 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob select,insert,update,references
-NULL test tb3 f126 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL test tb3 f127 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL mediumblob select,insert,update,references
-NULL test tb3 f128 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL test tb3 f129 12  NO binary 1 1 NULL NULL NULL NULL binary(1) select,insert,update,references
-NULL test tb3 f130 13 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(4) select,insert,update,references
-NULL test tb3 f131 14 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL test tb3 f132 15 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb3 f133 16 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
-NULL test tb3 f134 17 999 NO smallint NULL NULL 5 0 NULL NULL smallint(6) select,insert,update,references
-NULL test tb3 f135 18 999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL test tb3 f136 19 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb3 f137 20 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill select,insert,update,references
-NULL test tb3 f138 21 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(9) select,insert,update,references
-NULL test tb3 f139 22 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned select,insert,update,references
-NULL test tb3 f140 23 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb3 f141 24 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
-NULL test tb3 f142 25 99999 NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill select,insert,update,references
-NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) select,insert,update,references
-NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned zerofill select,insert,update,references
-NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f153 36 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f154 37 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f155 38 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb3 f156 39 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f157 40 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb3 f158 41 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f159 42 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f160 43 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f161 44 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f162 45 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f163 46 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb3 f164 47 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f165 48 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb3 f166 49 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f167 50 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb3 f168 51 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f169 52 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb3 f170 53 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f171 54 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb3 f172 55 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f173 56 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb3 f174 57 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb3 f175 58 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test tb4 f227 52 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test tb4 f228 53 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27) select,insert,update,references
-NULL test tb4 f229 54 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test tb4 f230 55 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test tb4 f231 56 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test tb4 f232 57 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27) select,insert,update,references
-NULL test tb4 f233 58 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test tb4 f234 59 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test tb4 f235 60 NULL YES char 255 255 NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
-NULL test tb4 f236 61 NULL YES char 60 60 NULL NULL latin1 latin1_swedish_ci char(60) select,insert,update,references
-NULL test tb4 f237 62 NULL YES char 255 255 NULL NULL latin1 latin1_bin char(255) select,insert,update,references
-NULL test tb4 f238 63 NULL YES varchar 0 0 NULL NULL latin1 latin1_bin varchar(0) select,insert,update,references
-NULL test tb4 f239 64 NULL YES varbinary 1000 1000 NULL NULL NULL NULL varbinary(1000) select,insert,update,references
-NULL test tb4 f240 65 NULL YES varchar 120 120 NULL NULL latin1 latin1_swedish_ci varchar(120) select,insert,update,references
-NULL test tb4 f241 66 NULL YES char 100 100 NULL NULL latin1 latin1_swedish_ci char(100) select,insert,update,references
-NULL test tb4 f242 67 NULL YES bit NULL NULL 30 NULL NULL NULL bit(30) select,insert,update,references
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
-NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
-NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
-NULL test1 tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test1 tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27) select,insert,update,references
-NULL test1 tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test1 tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test1 tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test1 tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27) select,insert,update,references
-NULL test1 tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64) select,insert,update,references
-NULL test1 tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192) select,insert,update,references
-NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned select,insert,update,references
-NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
-NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) select,insert,update,references
-NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned select,insert,update,references
-NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned select,insert,update,references
-NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
-NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
-NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
-NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
-NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t1 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t1 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t10 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t10 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t10 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t11 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t11 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t11 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t2 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t2 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t2 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t3 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t3 f2 2 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t4 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t4 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t4 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t7 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t7 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t8 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test t8 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test t9 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb1 f1 1 NULL YES char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb1 f10 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL NULL mediumblob select,insert,update,references
+NULL test tb1 f11 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL test tb1 f12 12 NULL YES binary 1 1 NULL NULL NULL NULL NULL binary(1) select,insert,update,references
+NULL test tb1 f13 13 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4) select,insert,update,references
+NULL test tb1 f14 14 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL test tb1 f15 15 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb1 f16 16 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb1 f17 17 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(6) select,insert,update,references
+NULL test tb1 f18 18 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL test tb1 f19 19 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb1 f2 2 NULL YES char 1 1 NULL NULL NULL latin1 latin1_bin char(1) select,insert,update,references
+NULL test tb1 f20 20 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb1 f21 21 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9) select,insert,update,references
+NULL test tb1 f22 22 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned select,insert,update,references
+NULL test tb1 f23 23 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb1 f24 24 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb1 f25 25 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb1 f26 26 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(20) select,insert,update,references
+NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb1 f33 33 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f34 34 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f35 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f36 36 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f37 37 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f38 38 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb1 f39 39 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f4 4 NULL YES tinytext 255 255 NULL NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
+NULL test tb1 f40 40 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb1 f41 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f42 42 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f43 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f44 44 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f45 45 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f46 46 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb1 f47 47 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f48 48 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb1 f49 49 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f5 5 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
+NULL test tb1 f50 50 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb1 f51 51 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f52 52 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb1 f53 53 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f54 54 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb1 f55 55 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f56 56 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb1 f57 57 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb1 f58 58 99 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
+NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
+NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL NULL tinyblob select,insert,update,references
+NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27) select,insert,update,references
+NULL test tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27) select,insert,update,references
+NULL test tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb3 f118 1 a NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb3 f119 2  NO char 1 1 NULL NULL NULL latin1 latin1_bin char(1) select,insert,update,references
+NULL test tb3 f120 3  NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
+NULL test tb3 f121 4 NULL YES tinytext 255 255 NULL NULL NULL latin1 latin1_swedish_ci tinytext select,insert,update,references
+NULL test tb3 f122 5 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text select,insert,update,references
+NULL test tb3 f123 6 NULL YES mediumtext 16777215 16777215 NULL NULL NULL latin1 latin1_swedish_ci mediumtext select,insert,update,references
+NULL test tb3 f124 7 NULL YES longtext 4294967295 4294967295 NULL NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
+NULL test tb3 f125 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL NULL tinyblob select,insert,update,references
+NULL test tb3 f126 9 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL test tb3 f127 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL NULL mediumblob select,insert,update,references
+NULL test tb3 f128 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL test tb3 f129 12  NO binary 1 1 NULL NULL NULL NULL NULL binary(1) select,insert,update,references
+NULL test tb3 f130 13 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4) select,insert,update,references
+NULL test tb3 f131 14 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL test tb3 f132 15 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb3 f133 16 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill select,insert,update,references
+NULL test tb3 f134 17 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(6) select,insert,update,references
+NULL test tb3 f135 18 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL test tb3 f136 19 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb3 f137 20 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill select,insert,update,references
+NULL test tb3 f138 21 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9) select,insert,update,references
+NULL test tb3 f139 22 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned select,insert,update,references
+NULL test tb3 f140 23 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb3 f141 24 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill select,insert,update,references
+NULL test tb3 f142 25 99999 NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill select,insert,update,references
+NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) select,insert,update,references
+NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill select,insert,update,references
+NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f153 36 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f154 37 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f155 38 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb3 f156 39 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f157 40 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb3 f158 41 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f159 42 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f160 43 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f161 44 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f162 45 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f163 46 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb3 f164 47 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f165 48 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb3 f166 49 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f167 50 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb3 f168 51 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f169 52 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb3 f170 53 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f171 54 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb3 f172 55 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f173 56 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb3 f174 57 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb3 f175 58 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) select,insert,update,references
+NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test tb4 f227 52 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test tb4 f228 53 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27) select,insert,update,references
+NULL test tb4 f229 54 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test tb4 f230 55 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test tb4 f231 56 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test tb4 f232 57 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27) select,insert,update,references
+NULL test tb4 f233 58 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test tb4 f234 59 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test tb4 f235 60 NULL YES char 255 255 NULL NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
+NULL test tb4 f236 61 NULL YES char 60 60 NULL NULL NULL latin1 latin1_swedish_ci char(60) select,insert,update,references
+NULL test tb4 f237 62 NULL YES char 255 255 NULL NULL NULL latin1 latin1_bin char(255) select,insert,update,references
+NULL test tb4 f238 63 NULL YES varchar 0 0 NULL NULL NULL latin1 latin1_bin varchar(0) select,insert,update,references
+NULL test tb4 f239 64 NULL YES varbinary 1000 1000 NULL NULL NULL NULL NULL varbinary(1000) select,insert,update,references
+NULL test tb4 f240 65 NULL YES varchar 120 120 NULL NULL NULL latin1 latin1_swedish_ci varchar(120) select,insert,update,references
+NULL test tb4 f241 66 NULL YES char 100 100 NULL NULL NULL latin1 latin1_swedish_ci char(100) select,insert,update,references
+NULL test tb4 f242 67 NULL YES bit NULL NULL 30 NULL NULL NULL NULL bit(30) select,insert,update,references
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time select,insert,update,references
+NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4) select,insert,update,references
+NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum') select,insert,update,references
+NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set') select,insert,update,references
+NULL test1 tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test1 tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27) select,insert,update,references
+NULL test1 tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test1 tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test1 tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test1 tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27) select,insert,update,references
+NULL test1 tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64) select,insert,update,references
+NULL test1 tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192) select,insert,update,references
+NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned select,insert,update,references
+NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) select,insert,update,references
+NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) select,insert,update,references
+NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned select,insert,update,references
+NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned select,insert,update,references
+NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
+NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float select,insert,update,references
+NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double select,insert,update,references
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
+NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date select,insert,update,references
+NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
+NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result
index 2721dcf3c6e..48b4bfa9d50 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result
@@ -411,358 +411,358 @@ LOAD DATA INFILE '<MYSQLTEST_VARDIR>/std_data/funcs_1/t9.txt' INTO TABLE t9;
SELECT * FROM information_schema.columns
WHERE table_schema LIKE 'test%'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL test t1 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t1 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t1 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t10 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t10 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t10 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t11 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t11 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t11 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t2 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t2 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t2 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t3 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t3 f2 2 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t4 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t4 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t4 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t7 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t7 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t8 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test t8 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test t9 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test tb1 f1 1 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1)
-NULL test tb1 f10 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL mediumblob
-NULL test tb1 f11 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL test tb1 f12 12 NULL YES binary 1 1 NULL NULL NULL NULL binary(1)
-NULL test tb1 f13 13 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(4)
-NULL test tb1 f14 14 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned
-NULL test tb1 f15 15 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill
-NULL test tb1 f16 16 NULL YES tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill
-NULL test tb1 f17 17 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(6)
-NULL test tb1 f18 18 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned
-NULL test tb1 f19 19 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill
-NULL test tb1 f2 2 NULL YES char 1 1 NULL NULL latin1 latin1_bin char(1)
-NULL test tb1 f20 20 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill
-NULL test tb1 f21 21 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(9)
-NULL test tb1 f22 22 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned
-NULL test tb1 f23 23 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill
-NULL test tb1 f24 24 NULL YES mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill
-NULL test tb1 f25 25 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test tb1 f26 26 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill
-NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill
-NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20)
-NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL latin1 latin1_swedish_ci char(1)
-NULL test tb1 f30 30 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL test tb1 f31 31 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill
-NULL test tb1 f32 32 NULL YES bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill
-NULL test tb1 f33 33 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb1 f34 34 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb1 f35 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f36 36 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f37 37 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb1 f38 38 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0)
-NULL test tb1 f39 39 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb1 f4 4 NULL YES tinytext 255 255 NULL NULL latin1 latin1_swedish_ci tinytext
-NULL test tb1 f40 40 10 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned
-NULL test tb1 f41 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f42 42 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb1 f43 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f44 44 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb1 f45 45 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb1 f46 46 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30)
-NULL test tb1 f47 47 10 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb1 f48 48 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned
-NULL test tb1 f49 49 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f5 5 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text
-NULL test tb1 f50 50 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb1 f51 51 0000000010 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f52 52 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb1 f53 53 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb1 f54 54 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb1 f55 55 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f56 56 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb1 f57 57 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb1 f58 58 99 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0)
-NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1_swedish_ci mediumtext
-NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext
-NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob
-NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob
-NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date
-NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time
-NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp
-NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4)
-NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4)
-NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4)
-NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum')
-NULL test tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set')
-NULL test tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27)
-NULL test tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27)
-NULL test tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned
-NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30)
-NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned
-NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double
-NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double
-NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double
-NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1)
-NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1)
-NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1)
-NULL test tb3 f121 4 NULL YES tinytext 255 255 NULL NULL latin1 latin1_swedish_ci tinytext
-NULL test tb3 f122 5 NULL YES text 65535 65535 NULL NULL latin1 latin1_swedish_ci text
-NULL test tb3 f123 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1_swedish_ci mediumtext
-NULL test tb3 f124 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext
-NULL test tb3 f125 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob
-NULL test tb3 f126 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob
-NULL test tb3 f127 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL mediumblob
-NULL test tb3 f128 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL test tb3 f129 12  NO binary 1 1 NULL NULL NULL NULL binary(1)
-NULL test tb3 f130 13 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(4)
-NULL test tb3 f131 14 99 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned
-NULL test tb3 f132 15 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill
-NULL test tb3 f133 16 099 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned zerofill
-NULL test tb3 f134 17 999 NO smallint NULL NULL 5 0 NULL NULL smallint(6)
-NULL test tb3 f135 18 999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned
-NULL test tb3 f136 19 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill
-NULL test tb3 f137 20 00999 NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned zerofill
-NULL test tb3 f138 21 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(9)
-NULL test tb3 f139 22 9999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned
-NULL test tb3 f140 23 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill
-NULL test tb3 f141 24 00009999 NO mediumint NULL NULL 7 0 NULL NULL mediumint(8) unsigned zerofill
-NULL test tb3 f142 25 99999 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill
-NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL int(10) unsigned zerofill
-NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20)
-NULL test tb3 f147 30 999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill
-NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned zerofill
-NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f153 36 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f154 37 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb3 f155 38 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0)
-NULL test tb3 f156 39 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb3 f157 40 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned
-NULL test tb3 f158 41 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f159 42 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb3 f160 43 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f161 44 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb3 f162 45 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb3 f163 46 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30)
-NULL test tb3 f164 47 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb3 f165 48 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned
-NULL test tb3 f166 49 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f167 50 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb3 f168 51 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f169 52 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb3 f170 53 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb3 f171 54 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb3 f172 55 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f173 56 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb3 f174 57 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb3 f175 58 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0)
-NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned
-NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30)
-NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned
-NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double
-NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double
-NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float
-NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float
-NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float
-NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float
-NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double
-NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time
-NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL year(4)
-NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL year(4)
-NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL year(4)
-NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum')
-NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set')
-NULL test tb4 f227 52 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test tb4 f228 53 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27)
-NULL test tb4 f229 54 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test tb4 f230 55 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test tb4 f231 56 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test tb4 f232 57 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27)
-NULL test tb4 f233 58 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test tb4 f234 59 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test tb4 f235 60 NULL YES char 255 255 NULL NULL latin1 latin1_swedish_ci char(255)
-NULL test tb4 f236 61 NULL YES char 60 60 NULL NULL latin1 latin1_swedish_ci char(60)
-NULL test tb4 f237 62 NULL YES char 255 255 NULL NULL latin1 latin1_bin char(255)
-NULL test tb4 f238 63 NULL YES varchar 0 0 NULL NULL latin1 latin1_bin varchar(0)
-NULL test tb4 f239 64 NULL YES varbinary 1000 1000 NULL NULL NULL NULL varbinary(1000)
-NULL test tb4 f240 65 NULL YES varchar 120 120 NULL NULL latin1 latin1_swedish_ci varchar(120)
-NULL test tb4 f241 66 NULL YES char 100 100 NULL NULL latin1 latin1_swedish_ci char(100)
-NULL test tb4 f242 67 NULL YES bit NULL NULL 30 NULL NULL NULL bit(30)
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date
-NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time
-NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime
-NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL NULL NULL timestamp
-NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL year(4)
-NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL year(4)
-NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL year(4)
-NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum')
-NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL latin1 latin1_swedish_ci set('1set','2set')
-NULL test1 tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test1 tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27)
-NULL test1 tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test1 tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test1 tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test1 tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL varbinary(27)
-NULL test1 tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL varbinary(64)
-NULL test1 tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL varbinary(192)
-NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned
-NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL decimal(64,0) unsigned zerofill
-NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0)
-NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30)
-NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned
-NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned
-NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill
-NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill
-NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double
-NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double
-NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float
-NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double
-NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned
-NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned
-NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill
-NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20)
-NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date
-NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25)
-NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL test t1 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t1 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t1 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t1 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t1 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t1 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t10 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t10 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t10 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t10 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t10 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t10 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t11 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t11 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t11 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t11 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t11 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t11 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t2 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t2 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t2 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t2 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t2 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t2 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t3 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t3 f2 2 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t3 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t4 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t4 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t4 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t4 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t4 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t4 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t7 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t7 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t7 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t7 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t8 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test t8 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t8 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test t8 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t9 f1 1 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test t9 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test t9 f3 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test tb1 f1 1 NULL YES char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1)
+NULL test tb1 f10 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL NULL mediumblob
+NULL test tb1 f11 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL test tb1 f12 12 NULL YES binary 1 1 NULL NULL NULL NULL NULL binary(1)
+NULL test tb1 f13 13 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4)
+NULL test tb1 f14 14 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned
+NULL test tb1 f15 15 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill
+NULL test tb1 f16 16 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill
+NULL test tb1 f17 17 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(6)
+NULL test tb1 f18 18 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned
+NULL test tb1 f19 19 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill
+NULL test tb1 f2 2 NULL YES char 1 1 NULL NULL NULL latin1 latin1_bin char(1)
+NULL test tb1 f20 20 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill
+NULL test tb1 f21 21 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9)
+NULL test tb1 f22 22 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned
+NULL test tb1 f23 23 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill
+NULL test tb1 f24 24 NULL YES mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill
+NULL test tb1 f25 25 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test tb1 f26 26 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL test tb1 f27 27 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill
+NULL test tb1 f28 28 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill
+NULL test tb1 f29 29 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(20)
+NULL test tb1 f3 3 NULL YES char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1)
+NULL test tb1 f30 30 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL test tb1 f31 31 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill
+NULL test tb1 f32 32 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill
+NULL test tb1 f33 33 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb1 f34 34 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb1 f35 35 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f36 36 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f37 37 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb1 f38 38 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0)
+NULL test tb1 f39 39 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb1 f4 4 NULL YES tinytext 255 255 NULL NULL NULL latin1 latin1_swedish_ci tinytext
+NULL test tb1 f40 40 10 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned
+NULL test tb1 f41 41 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f42 42 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb1 f43 43 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f44 44 0000000000000000000000000000000000000000000000000000000000000010 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb1 f45 45 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb1 f46 46 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30)
+NULL test tb1 f47 47 10 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb1 f48 48 9.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned
+NULL test tb1 f49 49 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f5 5 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text
+NULL test tb1 f50 50 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb1 f51 51 0000000010 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f52 52 000000000000000000000000000000009.900000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb1 f53 53 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb1 f54 54 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb1 f55 55 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f56 56 0000000099 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb1 f57 57 99 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb1 f58 58 99 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0)
+NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL NULL latin1 latin1_swedish_ci mediumtext
+NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL NULL latin1 latin1_swedish_ci longtext
+NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL NULL tinyblob
+NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date
+NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time
+NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL test tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp
+NULL test tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum')
+NULL test tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set')
+NULL test tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27)
+NULL test tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27)
+NULL test tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned
+NULL test tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30)
+NULL test tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned
+NULL test tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb3 f118 1 a NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1)
+NULL test tb3 f119 2  NO char 1 1 NULL NULL NULL latin1 latin1_bin char(1)
+NULL test tb3 f120 3  NO char 1 1 NULL NULL NULL latin1 latin1_swedish_ci char(1)
+NULL test tb3 f121 4 NULL YES tinytext 255 255 NULL NULL NULL latin1 latin1_swedish_ci tinytext
+NULL test tb3 f122 5 NULL YES text 65535 65535 NULL NULL NULL latin1 latin1_swedish_ci text
+NULL test tb3 f123 6 NULL YES mediumtext 16777215 16777215 NULL NULL NULL latin1 latin1_swedish_ci mediumtext
+NULL test tb3 f124 7 NULL YES longtext 4294967295 4294967295 NULL NULL NULL latin1 latin1_swedish_ci longtext
+NULL test tb3 f125 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL NULL tinyblob
+NULL test tb3 f126 9 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob
+NULL test tb3 f127 10 NULL YES mediumblob 16777215 16777215 NULL NULL NULL NULL NULL mediumblob
+NULL test tb3 f128 11 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL test tb3 f129 12  NO binary 1 1 NULL NULL NULL NULL NULL binary(1)
+NULL test tb3 f130 13 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(4)
+NULL test tb3 f131 14 99 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned
+NULL test tb3 f132 15 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill
+NULL test tb3 f133 16 099 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned zerofill
+NULL test tb3 f134 17 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(6)
+NULL test tb3 f135 18 999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned
+NULL test tb3 f136 19 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill
+NULL test tb3 f137 20 00999 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned zerofill
+NULL test tb3 f138 21 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(9)
+NULL test tb3 f139 22 9999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned
+NULL test tb3 f140 23 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill
+NULL test tb3 f141 24 00009999 NO mediumint NULL NULL 7 0 NULL NULL NULL mediumint(8) unsigned zerofill
+NULL test tb3 f142 25 99999 NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test tb3 f143 26 99999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL test tb3 f144 27 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill
+NULL test tb3 f145 28 0000099999 NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned zerofill
+NULL test tb3 f146 29 999999 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20)
+NULL test tb3 f147 30 999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL test tb3 f148 31 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill
+NULL test tb3 f149 32 00000000000000999999 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned zerofill
+NULL test tb3 f150 33 1000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb3 f151 34 999 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb3 f152 35 0000001000 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f153 36 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f154 37 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb3 f155 38 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0)
+NULL test tb3 f156 39 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb3 f157 40 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned
+NULL test tb3 f158 41 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f159 42 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb3 f160 43 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f161 44 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb3 f162 45 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb3 f163 46 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30)
+NULL test tb3 f164 47 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb3 f165 48 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned
+NULL test tb3 f166 49 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f167 50 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb3 f168 51 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f169 52 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb3 f170 53 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb3 f171 54 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb3 f172 55 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f173 56 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb3 f174 57 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb3 f175 58 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0)
+NULL test tb4 f176 1 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb4 f177 2 9 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned
+NULL test tb4 f178 3 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb4 f179 4 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb4 f180 5 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb4 f181 6 0000000000000000000000000000000000000000000000000000000000000009 NO decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test tb4 f182 7 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test tb4 f183 8 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30)
+NULL test tb4 f184 9 9 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test tb4 f185 10 9.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned
+NULL test tb4 f186 11 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL NULL float
+NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL NULL double
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL 0 NULL NULL time
+NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL test tb4 f221 46 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL test tb4 f222 47 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test tb4 f223 48 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test tb4 f224 49 NULL YES year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test tb4 f225 50 NULL YES enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum')
+NULL test tb4 f226 51 NULL YES set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set')
+NULL test tb4 f227 52 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test tb4 f228 53 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27)
+NULL test tb4 f229 54 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test tb4 f230 55 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test tb4 f231 56 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test tb4 f232 57 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27)
+NULL test tb4 f233 58 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test tb4 f234 59 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test tb4 f235 60 NULL YES char 255 255 NULL NULL NULL latin1 latin1_swedish_ci char(255)
+NULL test tb4 f236 61 NULL YES char 60 60 NULL NULL NULL latin1 latin1_swedish_ci char(60)
+NULL test tb4 f237 62 NULL YES char 255 255 NULL NULL NULL latin1 latin1_bin char(255)
+NULL test tb4 f238 63 NULL YES varchar 0 0 NULL NULL NULL latin1 latin1_bin varchar(0)
+NULL test tb4 f239 64 NULL YES varbinary 1000 1000 NULL NULL NULL NULL NULL varbinary(1000)
+NULL test tb4 f240 65 NULL YES varchar 120 120 NULL NULL NULL latin1 latin1_swedish_ci varchar(120)
+NULL test tb4 f241 66 NULL YES char 100 100 NULL NULL NULL latin1 latin1_swedish_ci char(100)
+NULL test tb4 f242 67 NULL YES bit NULL NULL 30 NULL NULL NULL NULL bit(30)
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL NULL date
+NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL 0 NULL NULL time
+NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL test1 tb2 f104 46 2000-12-31 23:59:59 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp
+NULL test1 tb2 f105 47 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test1 tb2 f106 48 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test1 tb2 f107 49 2000 NO year NULL NULL NULL NULL NULL NULL NULL year(4)
+NULL test1 tb2 f108 50 1enum NO enum 5 5 NULL NULL NULL latin1 latin1_swedish_ci enum('1enum','2enum')
+NULL test1 tb2 f109 51 1set NO set 9 9 NULL NULL NULL latin1 latin1_swedish_ci set('1set','2set')
+NULL test1 tb2 f110 52 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test1 tb2 f111 53 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27)
+NULL test1 tb2 f112 54 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test1 tb2 f113 55 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test1 tb2 f114 56 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test1 tb2 f115 57 NULL YES varbinary 27 27 NULL NULL NULL NULL NULL varbinary(27)
+NULL test1 tb2 f116 58 NULL YES varbinary 64 64 NULL NULL NULL NULL NULL varbinary(64)
+NULL test1 tb2 f117 59 NULL YES varbinary 192 192 NULL NULL NULL NULL NULL varbinary(192)
+NULL test1 tb2 f59 1 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test1 tb2 f60 2 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned
+NULL test1 tb2 f61 3 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test1 tb2 f62 4 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test1 tb2 f63 5 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test1 tb2 f64 6 NULL YES decimal NULL NULL 64 0 NULL NULL NULL decimal(64,0) unsigned zerofill
+NULL test1 tb2 f65 7 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0)
+NULL test1 tb2 f66 8 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30)
+NULL test1 tb2 f67 9 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned
+NULL test1 tb2 f68 10 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned
+NULL test1 tb2 f69 11 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL NULL decimal(10,0) unsigned zerofill
+NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL NULL decimal(63,30) unsigned zerofill
+NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL NULL double
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float
+NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL NULL float unsigned zerofill
+NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL NULL latin1 latin1_swedish_ci char(20)
+NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL NULL date
+NULL test4 t6 f4 4 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL test4 t6 f5 5 NULL YES char 25 25 NULL NULL NULL latin1 latin1_swedish_ci char(25)
+NULL test4 t6 f6 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
index 30a3d047bde..e93070952f4 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -1,222 +1,222 @@
SELECT * FROM information_schema.columns
WHERE table_schema = 'mysql'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references
-NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql columns_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
-NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
-NULL mysql db Alter_priv 13 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Alter_routine_priv 19 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Create_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Create_routine_priv 18 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Create_tmp_table_priv 14 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Create_view_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql db Delete_priv 7 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Drop_priv 9 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Event_priv 21 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Execute_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Grant_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
-NULL mysql db Index_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Insert_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Lock_tables_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db References_priv 11 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Select_priv 4 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Show_view_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Trigger_priv 22 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db Update_priv 6 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql db User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
-NULL mysql event body 3 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL mysql event body_utf8 22 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL mysql event character_set_client 19 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
-NULL mysql event collation_connection 20 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
-NULL mysql event comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references
-NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql event db 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql event db_collation 21 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
-NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references
-NULL mysql event ends 12 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references
-NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
-NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') select,insert,update,references
-NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL mysql event sql_mode 15 NO set 494 1482 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references
-NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
-NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') select,insert,update,references
-NULL mysql event time_zone 18 SYSTEM NO char 64 64 NULL NULL latin1 latin1_swedish_ci char(64) select,insert,update,references
-NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references
-NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1) select,insert,update,references
-NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references
-NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
-NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references
-NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
-NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references
-NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references
-NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL mysql help_category url 4 NULL NO char 128 384 NULL NULL utf8 utf8_general_ci char(128) select,insert,update,references
-NULL mysql help_keyword help_keyword_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql help_keyword name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references
-NULL mysql help_relation help_keyword_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql help_relation help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql help_topic description 4 NULL NO text 65535 65535 NULL NULL utf8 utf8_general_ci text select,insert,update,references
-NULL mysql help_topic example 5 NULL NO text 65535 65535 NULL NULL utf8 utf8_general_ci text select,insert,update,references
-NULL mysql help_topic help_category_id 3 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned select,insert,update,references
-NULL mysql help_topic help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql help_topic name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references
-NULL mysql help_topic url 6 NULL NO char 128 384 NULL NULL utf8 utf8_general_ci char(128) select,insert,update,references
-NULL mysql host Alter_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Alter_routine_priv 18 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Create_priv 7 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Create_routine_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Create_tmp_table_priv 13 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Create_view_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql host Delete_priv 6 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Drop_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Execute_priv 19 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Grant_priv 9 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
-NULL mysql host Index_priv 11 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Insert_priv 4 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Lock_tables_priv 14 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host References_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Select_priv 3 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql host Update_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned PRI select,insert,update,references
-NULL mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL latin1 latin1_swedish_ci varchar(255) select,insert,update,references
-NULL mysql ndb_binlog_index inserts 4 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL mysql ndb_binlog_index Position 1 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL mysql ndb_binlog_index schemaops 7 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL mysql ndb_binlog_index updates 5 NULL NO bigint NULL NULL 20 0 NULL NULL bigint(20) unsigned select,insert,update,references
-NULL mysql plugin dl 2 NO char 128 384 NULL NULL utf8 utf8_bin char(128) select,insert,update,references
-NULL mysql plugin name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL mysql proc body_utf8 20 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL mysql proc character_set_client 17 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
-NULL mysql proc collation_connection 18 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
-NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64) select,insert,update,references
-NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql proc db 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql proc db_collation 19 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32) select,insert,update,references
-NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77) select,insert,update,references
-NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references
-NULL mysql proc language 5 SQL NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('SQL') select,insert,update,references
-NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
-NULL mysql proc name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
-NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob select,insert,update,references
-NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references
-NULL mysql proc specific_name 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8_general_ci enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') select,insert,update,references
-NULL mysql proc sql_mode 15 NO set 494 1482 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references
-NULL mysql proc type 3 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('FUNCTION','PROCEDURE') PRI select,insert,update,references
-NULL mysql procs_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references
-NULL mysql procs_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
-NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references
-NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
-NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references
-NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql procs_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
-NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql servers Password 5 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4) select,insert,update,references
-NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
-NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql servers Username 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
-NULL mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select,insert,update,references
-NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
-NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
-NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
-NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references
-NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references
-NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
-NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
-NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references
-NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
-NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references
-NULL mysql time_zone Use_leap_seconds 2 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('Y','N') select,insert,update,references
-NULL mysql time_zone_leap_second Correction 2 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql time_zone_leap_second Transition_time 1 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) PRI select,insert,update,references
-NULL mysql time_zone_name Name 1 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
-NULL mysql time_zone_name Time_zone_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL mysql time_zone_transition Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql time_zone_transition Transition_time 2 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) PRI select,insert,update,references
-NULL mysql time_zone_transition Transition_type_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
-NULL mysql time_zone_transition_type Abbreviation 5 NO char 8 24 NULL NULL utf8 utf8_general_ci char(8) select,insert,update,references
-NULL mysql time_zone_transition_type Is_DST 4 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned select,insert,update,references
-NULL mysql time_zone_transition_type Offset 3 0 NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql time_zone_transition_type Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql time_zone_transition_type Transition_type_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI select,insert,update,references
-NULL mysql user Alter_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Alter_routine_priv 28 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user auth_string 41 NULL NO text 65535 65535 NULL NULL utf8 utf8_bin text select,insert,update,references
-NULL mysql user Create_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Create_routine_priv 27 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Create_tmp_table_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Create_user_priv 29 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Create_view_priv 25 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Delete_priv 7 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Drop_priv 9 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Event_priv 30 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Execute_priv 22 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user File_priv 13 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Grant_priv 14 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
-NULL mysql user Index_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Insert_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Lock_tables_priv 21 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user max_connections 38 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
-NULL mysql user max_questions 36 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
-NULL mysql user max_updates 37 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
-NULL mysql user max_user_connections 39 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
-NULL mysql user Password 3 NO char 41 41 NULL NULL latin1 latin1_bin char(41) select,insert,update,references
-NULL mysql user plugin 40 NO char 60 60 NULL NULL latin1 latin1_swedish_ci char(60) select,insert,update,references
-NULL mysql user Process_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user References_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Reload_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Repl_client_priv 24 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Repl_slave_priv 23 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Select_priv 4 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Show_db_priv 18 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Show_view_priv 26 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Shutdown_priv 11 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user ssl_cipher 33 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL mysql user ssl_type 32 NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('','ANY','X509','SPECIFIED') select,insert,update,references
-NULL mysql user Super_priv 19 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Trigger_priv 31 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user Update_priv 6 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
-NULL mysql user User 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
-NULL mysql user x509_issuer 34 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL mysql user x509_subject 35 NULL NO blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references
+NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql columns_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql columns_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
+NULL mysql db Alter_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Alter_routine_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Create_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Create_routine_priv 18 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Create_tmp_table_priv 14 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Create_view_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql db Delete_priv 7 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Drop_priv 9 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Event_priv 21 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Execute_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Grant_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+NULL mysql db Index_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Insert_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Lock_tables_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db References_priv 11 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Select_priv 4 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Show_view_priv 17 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Trigger_priv 22 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db Update_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql db User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
+NULL mysql event body 3 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL mysql event body_utf8 22 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL mysql event character_set_client 19 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32) select,insert,update,references
+NULL mysql event collation_connection 20 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32) select,insert,update,references
+NULL mysql event comment 16 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) select,insert,update,references
+NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql event db 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql event db_collation 21 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32) select,insert,update,references
+NULL mysql event definer 4 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77) select,insert,update,references
+NULL mysql event ends 12 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') select,insert,update,references
+NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL mysql event name 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
+NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') select,insert,update,references
+NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL mysql event sql_mode 15 NO set 494 1482 NULL NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references
+NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime select,insert,update,references
+NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') select,insert,update,references
+NULL mysql event time_zone 18 SYSTEM NO char 64 64 NULL NULL NULL latin1 latin1_swedish_ci char(64) select,insert,update,references
+NULL mysql func dl 3 NO char 128 384 NULL NULL NULL utf8 utf8_bin char(128) select,insert,update,references
+NULL mysql func name 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1) select,insert,update,references
+NULL mysql func type 4 NULL NO enum 9 27 NULL NULL NULL utf8 utf8_general_ci enum('function','aggregate') select,insert,update,references
+NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
+NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references
+NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 6 NULL NULL timestamp(6) on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
+NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned PRI select,insert,update,references
+NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references
+NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL mysql help_category url 4 NULL NO char 128 384 NULL NULL NULL utf8 utf8_general_ci char(128) select,insert,update,references
+NULL mysql help_keyword help_keyword_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql help_keyword name 2 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references
+NULL mysql help_relation help_keyword_id 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql help_relation help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql help_topic description 4 NULL NO text 65535 65535 NULL NULL NULL utf8 utf8_general_ci text select,insert,update,references
+NULL mysql help_topic example 5 NULL NO text 65535 65535 NULL NULL NULL utf8 utf8_general_ci text select,insert,update,references
+NULL mysql help_topic help_category_id 3 NULL NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select,insert,update,references
+NULL mysql help_topic help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql help_topic name 2 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) UNI select,insert,update,references
+NULL mysql help_topic url 6 NULL NO char 128 384 NULL NULL NULL utf8 utf8_general_ci char(128) select,insert,update,references
+NULL mysql host Alter_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Alter_routine_priv 18 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Create_priv 7 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Create_routine_priv 17 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Create_tmp_table_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Create_view_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql host Delete_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Drop_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Execute_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Grant_priv 9 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+NULL mysql host Index_priv 11 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Insert_priv 4 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Lock_tables_priv 14 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host References_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Select_priv 3 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql host Update_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned PRI select,insert,update,references
+NULL mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL NULL latin1 latin1_swedish_ci varchar(255) select,insert,update,references
+NULL mysql ndb_binlog_index inserts 4 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL mysql ndb_binlog_index Position 1 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL mysql ndb_binlog_index schemaops 7 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL mysql ndb_binlog_index updates 5 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+NULL mysql plugin dl 2 NO char 128 384 NULL NULL NULL utf8 utf8_bin char(128) select,insert,update,references
+NULL mysql plugin name 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL mysql proc body_utf8 20 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL mysql proc character_set_client 17 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32) select,insert,update,references
+NULL mysql proc collation_connection 18 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32) select,insert,update,references
+NULL mysql proc comment 16 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) select,insert,update,references
+NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql proc db 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql proc db_collation 19 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32) select,insert,update,references
+NULL mysql proc definer 12 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77) select,insert,update,references
+NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('YES','NO') select,insert,update,references
+NULL mysql proc language 5 SQL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('SQL') select,insert,update,references
+NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp select,insert,update,references
+NULL mysql proc name 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
+NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
+NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER') select,insert,update,references
+NULL mysql proc specific_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL NULL utf8 utf8_general_ci enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') select,insert,update,references
+NULL mysql proc sql_mode 15 NO set 494 1482 NULL NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references
+NULL mysql proc type 3 NULL NO enum 9 27 NULL NULL NULL utf8 utf8_general_ci enum('FUNCTION','PROCEDURE') PRI select,insert,update,references
+NULL mysql procs_priv Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references
+NULL mysql procs_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant') select,insert,update,references
+NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
+NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI select,insert,update,references
+NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql procs_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
+NULL mysql servers Db 3 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql servers Host 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql servers Owner 9 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql servers Password 5 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) select,insert,update,references
+NULL mysql servers Server_name 1 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
+NULL mysql servers Socket 7 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql servers Username 4 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references
+NULL mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select,insert,update,references
+NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL 6 NULL NULL time(6) select,insert,update,references
+NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL 6 NULL NULL time(6) select,insert,update,references
+NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
+NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 6 NULL NULL timestamp(6) on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
+NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References') select,insert,update,references
+NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77) MUL select,insert,update,references
+NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI select,insert,update,references
+NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') select,insert,update,references
+NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+NULL mysql tables_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
+NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI auto_increment select,insert,update,references
+NULL mysql time_zone Use_leap_seconds 2 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('Y','N') select,insert,update,references
+NULL mysql time_zone_leap_second Correction 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql time_zone_leap_second Transition_time 1 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) PRI select,insert,update,references
+NULL mysql time_zone_name Name 1 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
+NULL mysql time_zone_name Time_zone_id 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL mysql time_zone_transition Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql time_zone_transition Transition_time 2 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) PRI select,insert,update,references
+NULL mysql time_zone_transition Transition_type_id 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references
+NULL mysql time_zone_transition_type Abbreviation 5 NO char 8 24 NULL NULL NULL utf8 utf8_general_ci char(8) select,insert,update,references
+NULL mysql time_zone_transition_type Is_DST 4 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references
+NULL mysql time_zone_transition_type Offset 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references
+NULL mysql time_zone_transition_type Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql time_zone_transition_type Transition_type_id 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI select,insert,update,references
+NULL mysql user Alter_priv 17 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Alter_routine_priv 28 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user auth_string 41 NULL NO text 65535 65535 NULL NULL NULL utf8 utf8_bin text select,insert,update,references
+NULL mysql user Create_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Create_routine_priv 27 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Create_tmp_table_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Create_user_priv 29 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Create_view_priv 25 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Delete_priv 7 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Drop_priv 9 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Event_priv 30 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Execute_priv 22 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user File_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Grant_priv 14 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI select,insert,update,references
+NULL mysql user Index_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Insert_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Lock_tables_priv 21 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user max_connections 38 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references
+NULL mysql user max_questions 36 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references
+NULL mysql user max_updates 37 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references
+NULL mysql user max_user_connections 39 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references
+NULL mysql user Password 3 NO char 41 41 NULL NULL NULL latin1 latin1_bin char(41) select,insert,update,references
+NULL mysql user plugin 40 NO char 60 60 NULL NULL NULL latin1 latin1_swedish_ci char(60) select,insert,update,references
+NULL mysql user Process_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user References_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Reload_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Repl_client_priv 24 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Repl_slave_priv 23 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Select_priv 4 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Show_db_priv 18 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Show_view_priv 26 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Shutdown_priv 11 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user ssl_cipher 33 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL mysql user ssl_type 32 NO enum 9 27 NULL NULL NULL utf8 utf8_general_ci enum('','ANY','X509','SPECIFIED') select,insert,update,references
+NULL mysql user Super_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Trigger_priv 31 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user Update_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
+NULL mysql user User 2 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI select,insert,update,references
+NULL mysql user x509_issuer 34 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
+NULL mysql user x509_subject 35 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
@@ -342,7 +342,7 @@ NULL mysql event originator int NULL NULL NULL NULL int(10) unsigned
NULL mysql func ret tinyint NULL NULL NULL NULL tinyint(1)
3.0000 mysql func dl char 128 384 utf8 utf8_bin char(128)
3.0000 mysql func type enum 9 27 utf8 utf8_general_ci enum('function','aggregate')
-NULL mysql general_log event_time timestamp NULL NULL NULL NULL timestamp
+NULL mysql general_log event_time timestamp NULL NULL NULL NULL timestamp(6)
1.0000 mysql general_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
NULL mysql general_log thread_id int NULL NULL NULL NULL int(11)
NULL mysql general_log server_id int NULL NULL NULL NULL int(10) unsigned
@@ -428,10 +428,10 @@ NULL mysql servers Port int NULL NULL NULL NULL int(4)
3.0000 mysql servers Socket char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Wrapper char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql servers Owner char 64 192 utf8 utf8_general_ci char(64)
-NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp
+NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6)
1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
-NULL mysql slow_log query_time time NULL NULL NULL NULL time
-NULL mysql slow_log lock_time time NULL NULL NULL NULL time
+NULL mysql slow_log query_time time NULL NULL NULL NULL time(6)
+NULL mysql slow_log lock_time time NULL NULL NULL NULL time(6)
NULL mysql slow_log rows_sent int NULL NULL NULL NULL int(11)
NULL mysql slow_log rows_examined int NULL NULL NULL NULL int(11)
3.0000 mysql slow_log db varchar 512 1536 utf8 utf8_general_ci varchar(512)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
index 104960e4b79..941fb873596 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
@@ -1,220 +1,220 @@
SELECT * FROM information_schema.columns
WHERE table_schema = 'mysql'
ORDER BY table_schema, table_name, column_name;
-TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References')
-NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql columns_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
-NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql columns_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI
-NULL mysql db Alter_priv 13 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Alter_routine_priv 19 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Create_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Create_routine_priv 18 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Create_tmp_table_priv 14 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Create_view_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql db Delete_priv 7 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Drop_priv 9 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Event_priv 21 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Execute_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Grant_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
-NULL mysql db Index_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Insert_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Lock_tables_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db References_priv 11 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Select_priv 4 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Show_view_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Trigger_priv 22 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db Update_priv 6 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql db User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI
-NULL mysql event body 3 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL mysql event body_utf8 22 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL mysql event character_set_client 19 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32)
-NULL mysql event collation_connection 20 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32)
-NULL mysql event comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64)
-NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql event db 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql event db_collation 21 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32)
-NULL mysql event definer 4 NO char 77 231 NULL NULL utf8 utf8_bin char(77)
-NULL mysql event ends 12 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND')
-NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp
-NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI
-NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE')
-NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
-NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime
-NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED')
-NULL mysql event time_zone 18 SYSTEM NO char 64 64 NULL NULL latin1 latin1_swedish_ci char(64)
-NULL mysql func dl 3 NO char 128 384 NULL NULL utf8 utf8_bin char(128)
-NULL mysql func name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(1)
-NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('function','aggregate')
-NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext
-NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64)
-NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext
-NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI
-NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI
-NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned
-NULL mysql help_category url 4 NULL NO char 128 384 NULL NULL utf8 utf8_general_ci char(128)
-NULL mysql help_keyword help_keyword_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql help_keyword name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI
-NULL mysql help_relation help_keyword_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql help_relation help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql help_topic description 4 NULL NO text 65535 65535 NULL NULL utf8 utf8_general_ci text
-NULL mysql help_topic example 5 NULL NO text 65535 65535 NULL NULL utf8 utf8_general_ci text
-NULL mysql help_topic help_category_id 3 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned
-NULL mysql help_topic help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql help_topic name 2 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) UNI
-NULL mysql help_topic url 6 NULL NO char 128 384 NULL NULL utf8 utf8_general_ci char(128)
-NULL mysql host Alter_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Alter_routine_priv 18 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Create_priv 7 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Create_routine_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Create_tmp_table_priv 13 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Create_view_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql host Delete_priv 6 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Drop_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Execute_priv 19 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Grant_priv 9 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
-NULL mysql host Index_priv 11 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Insert_priv 4 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Lock_tables_priv 14 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host References_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Select_priv 3 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql host Update_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned PRI
-NULL mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL latin1 latin1_swedish_ci varchar(255)
-NULL mysql ndb_binlog_index inserts 4 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL mysql ndb_binlog_index Position 1 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL mysql ndb_binlog_index schemaops 7 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL mysql ndb_binlog_index updates 5 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) unsigned
-NULL mysql plugin dl 2 NO char 128 384 NULL NULL utf8 utf8_bin char(128)
-NULL mysql plugin name 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL mysql proc body_utf8 20 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL mysql proc character_set_client 17 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32)
-NULL mysql proc collation_connection 18 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32)
-NULL mysql proc comment 16 NO char 64 192 NULL NULL utf8 utf8_bin char(64)
-NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql proc db 1 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql proc db_collation 19 NULL YES char 32 96 NULL NULL utf8 utf8_bin char(32)
-NULL mysql proc definer 12 NO char 77 231 NULL NULL utf8 utf8_bin char(77)
-NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('YES','NO')
-NULL mysql proc language 5 SQL NO enum 3 9 NULL NULL utf8 utf8_general_ci enum('SQL')
-NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp
-NULL mysql proc name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI
-NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL blob
-NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL longblob
-NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER')
-NULL mysql proc specific_name 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL utf8 utf8_general_ci enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA')
-NULL mysql proc sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
-NULL mysql proc type 3 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('FUNCTION','PROCEDURE') PRI
-NULL mysql procs_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL
-NULL mysql procs_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
-NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant')
-NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI
-NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql procs_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI
-NULL mysql servers Db 3 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql servers Host 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql servers Owner 9 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql servers Password 5 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL int(4)
-NULL mysql servers Server_name 1 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI
-NULL mysql servers Socket 7 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql servers Username 4 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64)
-NULL mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512)
-NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time
-NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time
-NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext
-NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext
-NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References')
-NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL utf8 utf8_bin char(77) MUL
-NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
-NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL utf8 utf8_bin char(64) PRI
-NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger')
-NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP
-NULL mysql tables_priv User 3 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI
-NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI auto_increment
-NULL mysql time_zone Use_leap_seconds 2 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('Y','N')
-NULL mysql time_zone_leap_second Correction 2 NULL NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql time_zone_leap_second Transition_time 1 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) PRI
-NULL mysql time_zone_name Name 1 NULL NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI
-NULL mysql time_zone_name Time_zone_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL mysql time_zone_transition Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql time_zone_transition Transition_time 2 NULL NO bigint NULL NULL 19 0 NULL NULL bigint(20) PRI
-NULL mysql time_zone_transition Transition_type_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned
-NULL mysql time_zone_transition_type Abbreviation 5 NO char 8 24 NULL NULL utf8 utf8_general_ci char(8)
-NULL mysql time_zone_transition_type Is_DST 4 0 NO tinyint NULL NULL 3 0 NULL NULL tinyint(3) unsigned
-NULL mysql time_zone_transition_type Offset 3 0 NO int NULL NULL 10 0 NULL NULL int(11)
-NULL mysql time_zone_transition_type Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql time_zone_transition_type Transition_type_id 2 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned PRI
-NULL mysql user Alter_priv 17 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Alter_routine_priv 28 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Create_priv 8 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Create_routine_priv 27 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Create_tmp_table_priv 20 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Create_user_priv 29 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Create_view_priv 25 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Delete_priv 7 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Drop_priv 9 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Event_priv 30 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Execute_priv 22 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user File_priv 13 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Grant_priv 14 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Host 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
-NULL mysql user Index_priv 16 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Insert_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Lock_tables_priv 21 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user max_connections 38 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned
-NULL mysql user max_questions 36 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned
-NULL mysql user max_updates 37 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned
-NULL mysql user max_user_connections 39 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned
-NULL mysql user Password 3 NO char 41 41 NULL NULL latin1 latin1_bin char(41)
-NULL mysql user Process_priv 12 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user References_priv 15 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Reload_priv 10 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Repl_client_priv 24 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Repl_slave_priv 23 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Select_priv 4 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Show_db_priv 18 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Show_view_priv 26 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Shutdown_priv 11 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user ssl_cipher 33 NULL NO blob 65535 65535 NULL NULL NULL NULL blob
-NULL mysql user ssl_type 32 NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('','ANY','X509','SPECIFIED')
-NULL mysql user Super_priv 19 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Trigger_priv 31 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user Update_priv 6 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y')
-NULL mysql user User 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI
-NULL mysql user x509_issuer 34 NULL NO blob 65535 65535 NULL NULL NULL NULL blob
-NULL mysql user x509_subject 35 NULL NO blob 65535 65535 NULL NULL NULL NULL blob
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+NULL mysql columns_priv Column_name 5 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql columns_priv Column_priv 7 NO set 31 93 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References')
+NULL mysql columns_priv Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql columns_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI
+NULL mysql columns_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql columns_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql columns_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
+NULL mysql db Alter_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Alter_routine_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Create_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Create_routine_priv 18 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Create_tmp_table_priv 14 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Create_view_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql db Delete_priv 7 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Drop_priv 9 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Event_priv 21 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Execute_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Grant_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI
+NULL mysql db Index_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Insert_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Lock_tables_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db References_priv 11 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Select_priv 4 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Show_view_priv 17 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Trigger_priv 22 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db Update_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql db User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
+NULL mysql event body 3 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL mysql event body_utf8 22 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL mysql event character_set_client 19 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32)
+NULL mysql event collation_connection 20 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32)
+NULL mysql event comment 16 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64)
+NULL mysql event created 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql event db 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql event db_collation 21 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32)
+NULL mysql event definer 4 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77)
+NULL mysql event ends 12 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL mysql event execute_at 5 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL mysql event interval_field 7 NULL YES enum 18 54 NULL NULL NULL utf8 utf8_general_ci enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND')
+NULL mysql event interval_value 6 NULL YES int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp
+NULL mysql event name 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI
+NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE')
+NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
+NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL 0 NULL NULL datetime
+NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED')
+NULL mysql event time_zone 18 SYSTEM NO char 64 64 NULL NULL NULL latin1 latin1_swedish_ci char(64)
+NULL mysql func dl 3 NO char 128 384 NULL NULL NULL utf8 utf8_bin char(128)
+NULL mysql func name 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql func ret 2 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(1)
+NULL mysql func type 4 NULL NO enum 9 27 NULL NULL NULL utf8 utf8_general_ci enum('function','aggregate')
+NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext
+NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext
+NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned PRI
+NULL mysql help_category name 2 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) UNI
+NULL mysql help_category parent_category_id 3 NULL YES smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned
+NULL mysql help_category url 4 NULL NO char 128 384 NULL NULL NULL utf8 utf8_general_ci char(128)
+NULL mysql help_keyword help_keyword_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql help_keyword name 2 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) UNI
+NULL mysql help_relation help_keyword_id 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql help_relation help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql help_topic description 4 NULL NO text 65535 65535 NULL NULL NULL utf8 utf8_general_ci text
+NULL mysql help_topic example 5 NULL NO text 65535 65535 NULL NULL NULL utf8 utf8_general_ci text
+NULL mysql help_topic help_category_id 3 NULL NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned
+NULL mysql help_topic help_topic_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql help_topic name 2 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) UNI
+NULL mysql help_topic url 6 NULL NO char 128 384 NULL NULL NULL utf8 utf8_general_ci char(128)
+NULL mysql host Alter_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Alter_routine_priv 18 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Create_priv 7 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Create_routine_priv 17 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Create_tmp_table_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Create_view_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql host Delete_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Drop_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Execute_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Grant_priv 9 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI
+NULL mysql host Index_priv 11 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Insert_priv 4 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Lock_tables_priv 14 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host References_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Select_priv 3 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Show_view_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Trigger_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql host Update_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql ndb_binlog_index deletes 6 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL mysql ndb_binlog_index epoch 3 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned PRI
+NULL mysql ndb_binlog_index File 2 NULL NO varchar 255 255 NULL NULL NULL latin1 latin1_swedish_ci varchar(255)
+NULL mysql ndb_binlog_index inserts 4 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL mysql ndb_binlog_index Position 1 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL mysql ndb_binlog_index schemaops 7 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL mysql ndb_binlog_index updates 5 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
+NULL mysql plugin dl 2 NO char 128 384 NULL NULL NULL utf8 utf8_bin char(128)
+NULL mysql plugin name 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL mysql proc body_utf8 20 NULL YES longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL mysql proc character_set_client 17 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32)
+NULL mysql proc collation_connection 18 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32)
+NULL mysql proc comment 16 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64)
+NULL mysql proc created 13 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql proc db 1 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql proc db_collation 19 NULL YES char 32 96 NULL NULL NULL utf8 utf8_bin char(32)
+NULL mysql proc definer 12 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77)
+NULL mysql proc is_deterministic 7 NO NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('YES','NO')
+NULL mysql proc language 5 SQL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('SQL')
+NULL mysql proc modified 14 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp
+NULL mysql proc name 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI
+NULL mysql proc param_list 9 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob
+NULL mysql proc returns 10 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob
+NULL mysql proc security_type 8 DEFINER NO enum 7 21 NULL NULL NULL utf8 utf8_general_ci enum('INVOKER','DEFINER')
+NULL mysql proc specific_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql proc sql_data_access 6 CONTAINS_SQL NO enum 17 51 NULL NULL NULL utf8 utf8_general_ci enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA')
+NULL mysql proc sql_mode 15 NO set 478 1434 NULL NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
+NULL mysql proc type 3 NULL NO enum 9 27 NULL NULL NULL utf8 utf8_general_ci enum('FUNCTION','PROCEDURE') PRI
+NULL mysql procs_priv Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql procs_priv Grantor 6 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77) MUL
+NULL mysql procs_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI
+NULL mysql procs_priv Proc_priv 7 NO set 27 81 NULL NULL NULL utf8 utf8_general_ci set('Execute','Alter Routine','Grant')
+NULL mysql procs_priv Routine_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI
+NULL mysql procs_priv Routine_type 5 NULL NO enum 9 27 NULL NULL NULL utf8 utf8_bin enum('FUNCTION','PROCEDURE') PRI
+NULL mysql procs_priv Timestamp 8 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql procs_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
+NULL mysql servers Db 3 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql servers Host 2 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql servers Owner 9 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql servers Password 5 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4)
+NULL mysql servers Server_name 1 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI
+NULL mysql servers Socket 7 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql servers Username 4 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql servers Wrapper 8 NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64)
+NULL mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
+NULL mysql slow_log insert_id 9 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql slow_log last_insert_id 8 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL 0 NULL NULL time
+NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL 0 NULL NULL time
+NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext
+NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL NULL utf8 utf8_general_ci mediumtext
+NULL mysql tables_priv Column_priv 8 NO set 31 93 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','References')
+NULL mysql tables_priv Db 2 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql tables_priv Grantor 5 NO char 77 231 NULL NULL NULL utf8 utf8_bin char(77) MUL
+NULL mysql tables_priv Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI
+NULL mysql tables_priv Table_name 4 NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) PRI
+NULL mysql tables_priv Table_priv 7 NO set 98 294 NULL NULL NULL utf8 utf8_general_ci set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger')
+NULL mysql tables_priv Timestamp 6 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP
+NULL mysql tables_priv User 3 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
+NULL mysql time_zone Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI auto_increment
+NULL mysql time_zone Use_leap_seconds 2 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('Y','N')
+NULL mysql time_zone_leap_second Correction 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql time_zone_leap_second Transition_time 1 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) PRI
+NULL mysql time_zone_name Name 1 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) PRI
+NULL mysql time_zone_name Time_zone_id 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL mysql time_zone_transition Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql time_zone_transition Transition_time 2 NULL NO bigint NULL NULL 19 0 NULL NULL NULL bigint(20) PRI
+NULL mysql time_zone_transition Transition_type_id 3 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned
+NULL mysql time_zone_transition_type Abbreviation 5 NO char 8 24 NULL NULL NULL utf8 utf8_general_ci char(8)
+NULL mysql time_zone_transition_type Is_DST 4 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned
+NULL mysql time_zone_transition_type Offset 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11)
+NULL mysql time_zone_transition_type Time_zone_id 1 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql time_zone_transition_type Transition_type_id 2 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned PRI
+NULL mysql user Alter_priv 17 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Alter_routine_priv 28 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Create_priv 8 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Create_routine_priv 27 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Create_tmp_table_priv 20 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Create_user_priv 29 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Create_view_priv 25 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Delete_priv 7 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Drop_priv 9 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Event_priv 30 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Execute_priv 22 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user File_priv 13 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Grant_priv 14 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Host 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI
+NULL mysql user Index_priv 16 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Insert_priv 5 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Lock_tables_priv 21 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user max_connections 38 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned
+NULL mysql user max_questions 36 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned
+NULL mysql user max_updates 37 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned
+NULL mysql user max_user_connections 39 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned
+NULL mysql user Password 3 NO char 41 41 NULL NULL NULL latin1 latin1_bin char(41)
+NULL mysql user Process_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user References_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Reload_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Repl_client_priv 24 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Repl_slave_priv 23 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Select_priv 4 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Show_db_priv 18 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Show_view_priv 26 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Shutdown_priv 11 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user ssl_cipher 33 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob
+NULL mysql user ssl_type 32 NO enum 9 27 NULL NULL NULL utf8 utf8_general_ci enum('','ANY','X509','SPECIFIED')
+NULL mysql user Super_priv 19 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Trigger_priv 31 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user Update_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y')
+NULL mysql user User 2 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI
+NULL mysql user x509_issuer 34 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob
+NULL mysql user x509_subject 35 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
@@ -411,7 +411,7 @@ NULL mysql proc modified timestamp NULL NULL NULL NULL timestamp
3.0000 mysql procs_priv Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql procs_priv Db char 64 192 utf8 utf8_bin char(64)
3.0000 mysql procs_priv User char 16 48 utf8 utf8_bin char(16)
-3.0000 mysql procs_priv Routine_name char 64 192 utf8 utf8_bin char(64)
+3.0000 mysql procs_priv Routine_name char 64 192 utf8 utf8_general_ci char(64)
3.0000 mysql procs_priv Routine_type enum 9 27 utf8 utf8_bin enum('FUNCTION','PROCEDURE')
3.0000 mysql procs_priv Grantor char 77 231 utf8 utf8_bin char(77)
3.0000 mysql procs_priv Proc_priv set 27 81 utf8 utf8_general_ci set('Execute','Alter Routine','Grant')
diff --git a/mysql-test/suite/funcs_1/r/memory_func_view.result b/mysql-test/suite/funcs_1/r/memory_func_view.result
index f83a931af5c..61b375fbc1e 100644
--- a/mysql-test/suite/funcs_1/r/memory_func_view.result
+++ b/mysql-test/suite/funcs_1/r/memory_func_view.result
@@ -946,8 +946,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -961,8 +961,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1;
@@ -2451,6 +2451,8 @@ NULL NULL 1
8385959 838:59:59 3
130000 13:00:00 4
100000 10:00:00 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2463,6 +2465,8 @@ NULL NULL 1
8385959 838:59:59 3
130000 13:00:00 4
100000 10:00:00 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2557,7 +2561,9 @@ NULL NULL 1
18446744073709551615 -1 5
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2572,7 +2578,9 @@ NULL NULL 1
18446744073709551615 -1 5
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2588,9 +2596,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2604,9 +2612,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
DROP VIEW v1;
@@ -2621,6 +2629,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3
0 0 4
18446744073709551615 -1 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2633,6 +2644,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3
0 0 4
18446744073709551615 -1 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2956,8 +2970,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2971,8 +2985,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1;
@@ -3283,9 +3297,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 30
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -3301,9 +3315,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 30
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
DROP VIEW v1;
@@ -3373,9 +3387,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 29
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3390,9 +3404,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 29
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1;
@@ -3409,11 +3423,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 28
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@@ -3431,11 +3445,11 @@ NULL NULL 1
-1.00 -1
-3333.33 -3333.3333
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@@ -3455,9 +3469,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 27
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3472,9 +3486,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 27
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1;
@@ -3491,11 +3505,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 26
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' '
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -3511,11 +3525,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 26
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' '
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
DROP VIEW v1;
@@ -3527,10 +3541,10 @@ my_year, id FROM t1_values
WHERE select_id = 58 OR select_id IS NULL order by id;
CAST(my_year AS TIME) my_year id
NULL NULL 1
-00:19:01 1901 2
-00:21:55 2155 3
-00:20:00 2000 4
-00:20:05 2005 5
+00:00:00 1901 2
+00:00:00 2155 3
+00:00:00 2000 4
+00:00:00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as time) AS `CAST(my_year AS TIME)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3539,10 +3553,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 58 OR select_id IS NULL) order by id;
CAST(my_year AS TIME) my_year id
NULL NULL 1
-00:19:01 1901 2
-00:21:55 2155 3
-00:20:00 2000 4
-00:20:05 2005 5
+00:00:00 1901 2
+00:00:00 2155 3
+00:00:00 2000 4
+00:00:00 2005 5
DROP VIEW v1;
@@ -3663,8 +3677,8 @@ NULL 1.7976931348623e+308 3
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3679,8 +3693,8 @@ NULL 1.7976931348623e+308 3
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
DROP VIEW v1;
@@ -3873,15 +3887,10 @@ my_year, id FROM t1_values
WHERE select_id = 47 OR select_id IS NULL order by id;
CAST(my_year AS DATETIME) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 00:00:00 1901 2
+2155-00-00 00:00:00 2155 3
+2000-00-00 00:00:00 2000 4
+2005-00-00 00:00:00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as datetime) AS `CAST(my_year AS DATETIME)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3890,15 +3899,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 47 OR select_id IS NULL) order by id;
CAST(my_year AS DATETIME) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 00:00:00 1901 2
+2155-00-00 00:00:00 2155 3
+2000-00-00 00:00:00 2000 4
+2005-00-00 00:00:00 2005 5
DROP VIEW v1;
@@ -3909,13 +3913,12 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
-0000-00-00 00:00:00 -838:59:59 2
-0000-00-00 00:00:00 838:59:59 3
+NULL -838:59:59 2
+0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
+Warning 1292 Truncated incorrect datetime value: '-838:59:59'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3924,13 +3927,12 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
-0000-00-00 00:00:00 -838:59:59 2
-0000-00-00 00:00:00 838:59:59 3
+NULL -838:59:59 2
+0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
+Warning 1292 Truncated incorrect datetime value: '-838:59:59'
DROP VIEW v1;
@@ -4021,15 +4023,14 @@ CAST(my_double AS DATETIME) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 00:00:00 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
-Warning 1292 Incorrect datetime value: '200506271758'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
+Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 6
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as datetime) AS `CAST(my_double AS DATETIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4040,15 +4041,14 @@ CAST(my_double AS DATETIME) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 00:00:00 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
-Warning 1292 Incorrect datetime value: '200506271758'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1
DROP VIEW v1;
@@ -4253,15 +4253,10 @@ my_year, id FROM t1_values
WHERE select_id = 36 OR select_id IS NULL order by id;
CAST(my_year AS DATE) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 1901 2
+2155-00-00 2155 3
+2000-00-00 2000 4
+2005-00-00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as date) AS `CAST(my_year AS DATE)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4270,15 +4265,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 36 OR select_id IS NULL) order by id;
CAST(my_year AS DATE) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 1901 2
+2155-00-00 2155 3
+2000-00-00 2000 4
+2005-00-00 2005 5
DROP VIEW v1;
@@ -4395,14 +4385,13 @@ CAST(my_double AS DATE) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as date) AS `CAST(my_double AS DATE)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4413,14 +4402,13 @@ CAST(my_double AS DATE) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/memory_storedproc_06.result b/mysql-test/suite/funcs_1/r/memory_storedproc_06.result
index 096cbd1261e..ac66f0bb230 100644
--- a/mysql-test/suite/funcs_1/r/memory_storedproc_06.result
+++ b/mysql-test/suite/funcs_1/r/memory_storedproc_06.result
@@ -129,8 +129,6 @@ root@localhost db_storedproc_1
drop user 'user_1'@'localhost';
DROP PROCEDURE sp3;
DROP FUNCTION fn1;
-Warnings:
-Warning 1403 There is no such grant defined for user 'user_1' on host 'localhost' on routine 'fn1'
Testcase 3.1.6.4:
-----------------
diff --git a/mysql-test/suite/funcs_1/r/myisam_func_view.result b/mysql-test/suite/funcs_1/r/myisam_func_view.result
index f83a931af5c..61b375fbc1e 100644
--- a/mysql-test/suite/funcs_1/r/myisam_func_view.result
+++ b/mysql-test/suite/funcs_1/r/myisam_func_view.result
@@ -946,8 +946,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_decimal`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_decimal)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -961,8 +961,8 @@ AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 9999999999999999999999999999999999.999999999999
0.000000000000000000000000000000 4
-1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1;
@@ -2451,6 +2451,8 @@ NULL NULL 1
8385959 838:59:59 3
130000 13:00:00 4
100000 10:00:00 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as unsigned) AS `CAST(my_time AS UNSIGNED INTEGER)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2463,6 +2465,8 @@ NULL NULL 1
8385959 838:59:59 3
130000 13:00:00 4
100000 10:00:00 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2557,7 +2561,9 @@ NULL NULL 1
18446744073709551615 -1 5
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2572,7 +2578,9 @@ NULL NULL 1
18446744073709551615 -1 5
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2588,9 +2596,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as unsigned) AS `CAST(my_decimal AS UNSIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2604,9 +2612,9 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
0 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to UNSIGNED INT. Value truncated.
+Error 1916 Got overflow when converting '-1.000000000000000000000000000000' to UNSIGNED INT. Value truncated.
DROP VIEW v1;
@@ -2621,6 +2629,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3
0 0 4
18446744073709551615 -1 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_bigint` as unsigned) AS `CAST(my_bigint AS UNSIGNED INTEGER)`,`t1_values`.`my_bigint` AS `my_bigint`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2633,6 +2644,9 @@ NULL NULL 1
9223372036854775807 9223372036854775807 3
0 0 4
18446744073709551615 -1 5
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
DROP VIEW v1;
@@ -2956,8 +2970,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_decimal` as signed) AS `CAST(my_decimal AS SIGNED INTEGER)`,`t1_values`.`my_decimal` AS `my_decimal`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2971,8 +2985,8 @@ NULL NULL 1
0 0.000000000000000000000000000000 4
-1 -1.000000000000000000000000000000 5
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
+Error 1916 Got overflow when converting '9999999999999999999999999999999999.999999999999999999999999999999' to INT. Value truncated.
DROP VIEW v1;
@@ -3283,9 +3297,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 30
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -3301,9 +3315,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 30
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Error 1264 Out of range value for column 'CAST(my_double AS DECIMAL(37,2))' at row 1
DROP VIEW v1;
@@ -3373,9 +3387,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 29
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as decimal(37,2)) AS `CAST(my_varbinary_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3390,9 +3404,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 29
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1;
@@ -3409,11 +3423,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 28
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@@ -3431,11 +3445,11 @@ NULL NULL 1
-1.00 -1
-3333.33 -3333.3333
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ''
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
Warning 1292 Truncated incorrect DECIMAL value: '-1'
Warning 1292 Truncated incorrect DECIMAL value: '-3333.3333'
@@ -3455,9 +3469,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 27
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as decimal(37,2)) AS `CAST(my_varchar_1000 AS DECIMAL(37,2))`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3472,9 +3486,9 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 27
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
+Error 1918 Encountered illegal value '' when converting to DECIMAL
DROP VIEW v1;
@@ -3491,11 +3505,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 26
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' '
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -3511,11 +3525,11 @@ NULL NULL 1
-1.00 -1 5
-3333.33 -3333.3333 26
Warnings:
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' '
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: '<--------30 characters------->'
-Error 1366 Incorrect decimal value: '' for column '' at row 0
+Error 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: ' ---äÖüß@µ*$-- '
DROP VIEW v1;
@@ -3527,10 +3541,10 @@ my_year, id FROM t1_values
WHERE select_id = 58 OR select_id IS NULL order by id;
CAST(my_year AS TIME) my_year id
NULL NULL 1
-00:19:01 1901 2
-00:21:55 2155 3
-00:20:00 2000 4
-00:20:05 2005 5
+00:00:00 1901 2
+00:00:00 2155 3
+00:00:00 2000 4
+00:00:00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as time) AS `CAST(my_year AS TIME)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3539,10 +3553,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 58 OR select_id IS NULL) order by id;
CAST(my_year AS TIME) my_year id
NULL NULL 1
-00:19:01 1901 2
-00:21:55 2155 3
-00:20:00 2000 4
-00:20:05 2005 5
+00:00:00 1901 2
+00:00:00 2155 3
+00:00:00 2000 4
+00:00:00 2005 5
DROP VIEW v1;
@@ -3663,8 +3677,8 @@ NULL 1.7976931348623e+308 3
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3679,8 +3693,8 @@ NULL 1.7976931348623e+308 3
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
DROP VIEW v1;
@@ -3873,15 +3887,10 @@ my_year, id FROM t1_values
WHERE select_id = 47 OR select_id IS NULL order by id;
CAST(my_year AS DATETIME) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 00:00:00 1901 2
+2155-00-00 00:00:00 2155 3
+2000-00-00 00:00:00 2000 4
+2005-00-00 00:00:00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as datetime) AS `CAST(my_year AS DATETIME)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3890,15 +3899,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 47 OR select_id IS NULL) order by id;
CAST(my_year AS DATETIME) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 00:00:00 1901 2
+2155-00-00 00:00:00 2155 3
+2000-00-00 00:00:00 2000 4
+2005-00-00 00:00:00 2005 5
DROP VIEW v1;
@@ -3909,13 +3913,12 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
-0000-00-00 00:00:00 -838:59:59 2
-0000-00-00 00:00:00 838:59:59 3
+NULL -838:59:59 2
+0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
+Warning 1292 Truncated incorrect datetime value: '-838:59:59'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3924,13 +3927,12 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
-0000-00-00 00:00:00 -838:59:59 2
-0000-00-00 00:00:00 838:59:59 3
+NULL -838:59:59 2
+0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
-Warning 1292 Incorrect datetime value: '0000-00-00 838:59:59'
+Warning 1292 Truncated incorrect datetime value: '-838:59:59'
DROP VIEW v1;
@@ -4021,15 +4023,14 @@ CAST(my_double AS DATETIME) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 00:00:00 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
-Warning 1292 Incorrect datetime value: '200506271758'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
+Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 6
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as datetime) AS `CAST(my_double AS DATETIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4040,15 +4041,14 @@ CAST(my_double AS DATETIME) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 00:00:00 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
-Warning 1292 Incorrect datetime value: '200506271758'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1
DROP VIEW v1;
@@ -4253,15 +4253,10 @@ my_year, id FROM t1_values
WHERE select_id = 36 OR select_id IS NULL order by id;
CAST(my_year AS DATE) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 1901 2
+2155-00-00 2155 3
+2000-00-00 2000 4
+2005-00-00 2005 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_year` as date) AS `CAST(my_year AS DATE)`,`t1_values`.`my_year` AS `my_year`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4270,15 +4265,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 36 OR select_id IS NULL) order by id;
CAST(my_year AS DATE) my_year id
NULL NULL 1
-NULL 1901 2
-NULL 2155 3
-NULL 2000 4
-NULL 2005 5
-Warnings:
-Warning 1292 Incorrect datetime value: '1901'
-Warning 1292 Incorrect datetime value: '2155'
-Warning 1292 Incorrect datetime value: '2000'
-Warning 1292 Incorrect datetime value: '2005'
+1901-00-00 1901 2
+2155-00-00 2155 3
+2000-00-00 2000 4
+2005-00-00 2005 5
DROP VIEW v1;
@@ -4395,14 +4385,13 @@ CAST(my_double AS DATE) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 2
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 3
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as date) AS `CAST(my_double AS DATE)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -4413,14 +4402,13 @@ CAST(my_double AS DATE) my_double id
NULL NULL 1
NULL -1.7976931348623e+308 2
NULL 1.7976931348623e+308 3
-NULL 0 4
+0000-00-00 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '0'
-Warning 1292 Incorrect datetime value: '-1'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '1.7976931348623e+308' for column 'my_double' at row 1
+Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/myisam_storedproc_06.result b/mysql-test/suite/funcs_1/r/myisam_storedproc_06.result
index 096cbd1261e..ac66f0bb230 100644
--- a/mysql-test/suite/funcs_1/r/myisam_storedproc_06.result
+++ b/mysql-test/suite/funcs_1/r/myisam_storedproc_06.result
@@ -129,8 +129,6 @@ root@localhost db_storedproc_1
drop user 'user_1'@'localhost';
DROP PROCEDURE sp3;
DROP FUNCTION fn1;
-Warnings:
-Warning 1403 There is no such grant defined for user 'user_1' on host 'localhost' on routine 'fn1'
Testcase 3.1.6.4:
-----------------
diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
index d5b6cc17801..e5eeed7c82b 100644
--- a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
+++ b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
@@ -52,8 +52,6 @@ DROP TABLE test.t_processlist;
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION;
ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist'
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist;
-UPDATE test.v_processlist SET TIME=NOW() WHERE id = 1;
-ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
DROP VIEW test.v_processlist;
UPDATE processlist SET user='any_user' WHERE id=1 ;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
@@ -120,8 +118,6 @@ DROP TABLE test.t_processlist;
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION;
ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist'
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist;
-UPDATE test.v_processlist SET TIME=NOW() WHERE id = 1;
-ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema'
DROP VIEW test.v_processlist;
UPDATE processlist SET user='any_user' WHERE id=1 ;
ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema'
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index 15ae654458a..31008736389 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -142,7 +142,7 @@ BEGIN
SET @v1 = f1;
SELECT @v1;
END//
-ERROR 42000: Too big precision 256 specified for column ''. Maximum is 65.
+ERROR 42000: Too big precision 256 specified for ''. Maximum is 65.
DROP PROCEDURE IF EXISTS sp1//
Warnings:
Note 1305 PROCEDURE sp1 does not exist
@@ -152,7 +152,7 @@ BEGIN
SET @v1 = f1;
SELECT @v1;
END//
-ERROR 42000: Too big precision 66 specified for column ''. Maximum is 65.
+ERROR 42000: Too big precision 66 specified for ''. Maximum is 65.
DROP PROCEDURE IF EXISTS sp1//
Warnings:
Note 1305 PROCEDURE sp1 does not exist
@@ -1551,7 +1551,7 @@ BEGIN
SET f1 = 1000000 + f1;
RETURN f1;
END//
-ERROR 42000: Too big scale 31 specified for column ''. Maximum is 30.
+ERROR 42000: Too big scale 31 specified for ''. Maximum is 30.
SELECT fn1( 1.3326e+8 );
ERROR 42000: FUNCTION db_storedproc.fn1 does not exist
CREATE FUNCTION fn1( f1 DECIMAL(63, 30) ) RETURNS DECIMAL(63, 30)
@@ -5840,7 +5840,7 @@ fetch cur1 into e;
SELECT x, y, z, a, b, c, d, e;
close cur1;
END//
-ERROR 42000: Too big scale 255 specified for column ''. Maximum is 30.
+ERROR 42000: Too big scale 255 specified for ''. Maximum is 30.
CALL sp6();
ERROR 42000: PROCEDURE db_storedproc.sp6 does not exist
DROP PROCEDURE IF EXISTS sp6;
@@ -13934,7 +13934,7 @@ CALL sp1();
xx
0000-00-00 00:00:00
Warnings:
-Warning 1264 Out of range value for column 'xx' at row 1
+Warning 1265 Data truncated for column 'xx' at row 1
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1()
BEGIN
diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc
index 4ecca63351d..656b9a52e85 100644
--- a/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc
+++ b/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc
@@ -149,10 +149,6 @@ USE db_storedproc_1;
drop user 'user_1'@'localhost';
DROP PROCEDURE sp3;
-# This drop function shouldn't generated a warning as the
-# privileges should have been removed when the user was
-# dropped. Reported as Bug#36544 DROP USER does not remove
-# stored function privileges
DROP FUNCTION fn1;
diff --git a/mysql-test/suite/funcs_1/views/views_master.inc b/mysql-test/suite/funcs_1/views/views_master.inc
index 4f8439efc3a..5ab8d52629c 100644
--- a/mysql-test/suite/funcs_1/views/views_master.inc
+++ b/mysql-test/suite/funcs_1/views/views_master.inc
@@ -3830,6 +3830,7 @@ while ($num)
--error ER_NON_INSERTABLE_TABLE
INSERT INTO v1 VALUES (1002);
# --error ER_NON_UPDATABLE_TABLE, ER_UPDATE_TABLE_USED
+
--error ER_NON_UPDATABLE_TABLE
UPDATE v1 SET f61=1007;
--error ER_NON_UPDATABLE_TABLE
diff --git a/mysql-test/suite/innodb/r/innodb_bug30423.result b/mysql-test/suite/innodb/r/innodb_bug30423.result
new file mode 100644
index 00000000000..a19809366ae
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug30423.result
@@ -0,0 +1,95 @@
+set global innodb_stats_method = default;
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_equal
+select count(*) from bug30243_3 where org_id is not NULL;
+count(*)
+20
+select count(*) from bug30243_3 where org_id is NULL;
+count(*)
+16384
+select count(*) from bug30243_2 where org_id is not NULL;
+count(*)
+224
+select count(*) from bug30243_2 where org_id is NULL;
+count(*)
+65536
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_equal
+analyze table bug30243_1;
+Table Op Msg_type Msg_text
+test.bug30243_1 analyze status OK
+analyze table bug30243_2;
+Table Op Msg_type Msg_text
+test.bug30243_2 analyze status OK
+analyze table bug30243_3;
+Table Op Msg_type Msg_text
+test.bug30243_3 analyze status OK
+set global innodb_stats_method = "NULL";
+ERROR 42000: Variable 'stats_method' can't be set to the value of 'NULL'
+set global innodb_stats_method = "nulls_ignored";
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_ignored
+analyze table bug30243_1;
+Table Op Msg_type Msg_text
+test.bug30243_1 analyze status OK
+analyze table bug30243_2;
+Table Op Msg_type Msg_text
+test.bug30243_2 analyze status OK
+analyze table bug30243_3;
+Table Op Msg_type Msg_text
+test.bug30243_3 analyze status OK
+explain SELECT COUNT(*), 0
+FROM bug30243_1 orgs
+LEFT JOIN bug30243_3 sa_opportunities
+ON orgs.org_id=sa_opportunities.org_id
+LEFT JOIN bug30243_2 contacts
+ON orgs.org_id=contacts.org_id ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orgs index NULL org_id 4 NULL 128 Using index
+1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id 1 Using index
+1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id 1 Using index
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_ignored
+set global innodb_stats_method = "nulls_unequal";
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_unequal
+analyze table bug30243_1;
+Table Op Msg_type Msg_text
+test.bug30243_1 analyze status OK
+analyze table bug30243_2;
+Table Op Msg_type Msg_text
+test.bug30243_2 analyze status OK
+analyze table bug30243_3;
+Table Op Msg_type Msg_text
+test.bug30243_3 analyze status OK
+explain SELECT COUNT(*), 0
+FROM bug30243_1 orgs
+LEFT JOIN bug30243_3 sa_opportunities
+ON orgs.org_id=sa_opportunities.org_id
+LEFT JOIN bug30243_2 contacts
+ON orgs.org_id=contacts.org_id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orgs index NULL org_id 4 NULL 128 Using index
+1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id 1 Using index
+1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id 1 Using index
+SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL;
+COUNT(*)
+1024
+set global innodb_stats_method = "nulls_unequal";
+analyze table table_bug30423;
+Table Op Msg_type Msg_text
+test.table_bug30423 analyze status OK
+set global innodb_stats_method = "nulls_ignored";
+analyze table table_bug30423;
+Table Op Msg_type Msg_text
+test.table_bug30423 analyze status OK
+set global innodb_stats_method = nulls_equal;
+drop table bug30243_2;
+drop table bug30243_1;
+drop table bug30243_3;
+drop table table_bug30423;
diff --git a/mysql-test/suite/innodb/r/innodb_bug54044.result b/mysql-test/suite/innodb/r/innodb_bug54044.result
index 90ab812f2ae..3f607e20ddf 100644
--- a/mysql-test/suite/innodb/r/innodb_bug54044.result
+++ b/mysql-test/suite/innodb/r/innodb_bug54044.result
@@ -1,3 +1,2 @@
CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
AS SELECT IF(NULL IS NOT NULL, NULL, NULL);
-ERROR HY000: Can't create table 'test.table_54044' (errno: -1)
diff --git a/mysql-test/suite/innodb/r/innodb_bug60049.result b/mysql-test/suite/innodb/r/innodb_bug60049.result
new file mode 100644
index 00000000000..a1788a8ab0a
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug60049.result
@@ -0,0 +1,9 @@
+set @@global.innodb_fast_shutdown=0;
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+RENAME TABLE t TO u;
+DROP TABLE u;
+SELECT @@innodb_fast_shutdown;
+@@innodb_fast_shutdown
+0
+Last record of ID_IND root page (9):
+1808000018050074000000000000000c5359535f464f524549474e5f434f4c53
diff --git a/mysql-test/suite/innodb/r/innodb_gis.result b/mysql-test/suite/innodb/r/innodb_gis.result
index e44f2aec093..57d61bbd586 100644
--- a/mysql-test/suite/innodb/r/innodb_gis.result
+++ b/mysql-test/suite/innodb/r/innodb_gis.result
@@ -236,7 +236,7 @@ explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelo
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00
Warnings:
-Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
+Note 1003 select st_dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,st_geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,st_isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,st_astext(st_envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
SELECT fid, X(g) FROM gis_point ORDER by fid;
fid X(g)
101 10
@@ -253,7 +253,7 @@ explain extended select X(g),Y(g) FROM gis_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00
Warnings:
-Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
+Note 1003 select st_x(`test`.`gis_point`.`g`) AS `X(g)`,st_y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
fid AsText(StartPoint(g))
105 POINT(0 0)
@@ -288,7 +288,7 @@ explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),Num
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
+Note 1003 select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,st_astext(st_endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,st_length(`test`.`gis_line`.`g`) AS `GLength(g)`,st_numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,st_astext(st_pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,st_isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
@@ -318,7 +318,7 @@ explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumI
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
+Note 1003 select st_astext(st_centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,st_area(`test`.`gis_polygon`.`g`) AS `Area(g)`,st_astext(st_exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,st_numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,st_astext(st_interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
fid IsClosed(g)
114 0
@@ -357,7 +357,7 @@ explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
+Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
fid AsText(GeometryN(g, 2))
111 POINT(10 10)
@@ -385,17 +385,17 @@ explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
+Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_astext(st_geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
-120 120 1 1 0 1 0 0 1 0
+120 120 0 0 0 1 0 1 1 0
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
-121 121 1 1 0 1 0 0 1 0
+121 121 0 0 0 1 0 1 1 0
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
@@ -405,7 +405,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
+Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,st_within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,st_contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
a INTEGER PRIMARY KEY AUTO_INCREMENT,
@@ -500,7 +500,6 @@ mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
-center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
@@ -518,7 +517,6 @@ touches
down2,left2,right2,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
-big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
@@ -585,5 +583,17 @@ COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
+#
+# Test for bug #58650 "Failing assertion: primary_key_no == -1 ||
+# primary_key_no == 0".
+#
+drop table if exists t1;
+# The minimal test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a));
+drop table t1;
+# The original test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)));
+create unique index a on t1(a);
+drop table t1;
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
ERROR HY000: The used table type doesn't support SPATIAL indexes
diff --git a/mysql-test/suite/innodb/r/innodb_lock_wait_timeout_1.result b/mysql-test/suite/innodb/r/innodb_lock_wait_timeout_1.result
index bd8760b8f79..051266c526e 100644
--- a/mysql-test/suite/innodb/r/innodb_lock_wait_timeout_1.result
+++ b/mysql-test/suite/innodb/r/innodb_lock_wait_timeout_1.result
@@ -104,7 +104,7 @@ id 1
select_type PRIMARY
table <derived2>
type ALL
-possible_keys NULL
+possible_keys key0
key NULL
key_len NULL
ref NULL
@@ -308,7 +308,7 @@ id 1
select_type PRIMARY
table <derived2>
type ALL
-possible_keys NULL
+possible_keys key0
key NULL
key_len NULL
ref NULL
diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result
index ed2f0254e4d..9acc1f424d4 100644
--- a/mysql-test/suite/innodb/r/innodb_mysql.result
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result
@@ -1739,8 +1739,8 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index c3,c2 c2 10 NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 index_merge c3,c2 c3,c2 5,10 NULL 1 Using intersect(c3,c2); Using where; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3))
ENGINE=InnoDB;
@@ -1753,8 +1753,8 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index c3,c2 c2 18 NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 index_merge c3,c2 c3,c2 9,18 NULL 1 Using intersect(c3,c2); Using where; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2),
KEY (c3), KEY (c2, c3))
@@ -1768,8 +1768,8 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index c3,c2 c2 14 NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 index_merge c3,c2 c3,c2 7,14 NULL 1 Using intersect(c3,c2); Using where; Using filesort
DROP TABLE t1;
End of 5.1 tests
drop table if exists t1, t2, t3;
@@ -2535,7 +2535,7 @@ INSERT INTO t1 VALUES (0);
SET SQL_MODE='STRICT_ALL_TABLES';
CREATE TABLE t2
SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`;
-ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 1
+ERROR 22007: Incorrect datetime value: ''
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
#
@@ -2656,8 +2656,7 @@ SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
-2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 3537 Using sort_union(idx,PRIMARY); Using where
+1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 3537 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
diff --git a/mysql-test/suite/innodb/t/innodb_bug30423.test b/mysql-test/suite/innodb/t/innodb_bug30423.test
new file mode 100644
index 00000000000..f2a3ee8d099
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug30423.test
@@ -0,0 +1,211 @@
+# Test for Bug #30423, InnoDBs treatment of NULL in index stats causes
+# bad "rows examined" estimates.
+# Implemented InnoDB system variable "innodb_stats_method" with
+# "nulls_equal" (default), "nulls_unequal", and "nulls_ignored" options.
+
+-- source include/have_innodb.inc
+
+let $innodb_stats_method_orig = `select @@innodb_stats_method`;
+
+# default setting for innodb_stats_method is "nulls_equal"
+set global innodb_stats_method = default;
+
+select @@innodb_stats_method;
+
+# create three tables, bug30243_1, bug30243_2 and bug30243_3.
+# The test scenario is adopted from original bug #30423 report.
+# table bug30243_1 and bug30243_3 have many NULL values
+
+-- disable_result_log
+-- disable_query_log
+
+DROP TABLE IF EXISTS bug30243_1;
+CREATE TABLE bug30243_1 (
+ org_id int(11) NOT NULL default '0',
+ UNIQUE KEY (org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+LOCK TABLES bug30243_1 WRITE;
+INSERT INTO bug30243_1 VALUES (11),(15),(16),(17),(19),(20),(21),(23),(24),
+(25),(26),(27),(28),(29),(30),(31),(32),(33),(34),(35),(37),(38),(40),(41),
+(42),(43),(44),(45),(46),(47),(48),(49),(50),(51),(52),(53),(54),(55),(56),
+(57),(58),(59),(60),(61),(62),(63),(64),(65),(66),(67),(68),(69),(70),(71),
+(72),(73),(74),(75),(76),(77),(78),(79),(80),(81),(82),(83),(84),(85),(86),
+(87),(88),(89),(90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100),(101),
+(102),(103),(104),(105),(106),(107),(108),(109),(110),(111),(112),(113),(114),
+(115),(116),(117),(118),(119),(120),(121),(122),(123),(124),(125),(126),(127),
+(128),(129),(130),(131),(132),(133),(134),(135),(136),(137),(138),(139),(140),
+(141),(142),(143),(144),(145);
+UNLOCK TABLES;
+
+DROP TABLE IF EXISTS bug30243_3;
+CREATE TABLE bug30243_3 (
+ org_id int(11) default NULL,
+ KEY (org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO bug30243_3 VALUES (NULL);
+
+begin;
+let $i=14;
+while ($i)
+{
+ INSERT INTO bug30243_3 SELECT NULL FROM bug30243_3;
+ dec $i;
+}
+
+INSERT INTO bug30243_3 VALUES (34),(34),(35),(56),(58),(62),(62),(64),(65),(66),(80),(135),(137),(138),(139),(140),(142),(143),(144),(145);
+commit;
+
+DROP TABLE IF EXISTS bug30243_2;
+CREATE TABLE bug30243_2 (
+ org_id int(11) default NULL,
+ KEY `contacts$org_id` (org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO bug30243_2 VALUES (NULL);
+
+begin;
+let $i=16;
+while ($i)
+{
+ INSERT INTO bug30243_2 SELECT NULL FROM bug30243_2;
+ dec $i;
+}
+
+INSERT INTO bug30243_2 VALUES (11),(15),(16),(17),(20),(21),(23),(24),(25),
+(26),(27),(28),(29),(30),(31),(32),(33),(34),(37),(38),(40),(41),(42),(43),
+(44),(45),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(48),
+(48),(50),(51),(52),(52),(53),(54),(55),(57),(60),(61),(62),(62),(62),(62),
+(62),(63),(64),(64),(65),(66),(66),(67),(68),(69),(70),(71),(72),(73),(74),
+(75),(76),(77),(78),(79),(80),(80),(81),(82),(83),(84),(85),(86),(87),(88),
+(89),(90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100),(101),(102),
+(103),(104),(105),(106),(107),(108),(109),(110),(111),(112),(113),(114),
+(115),(116),(117),(118),(119),(120),(121),(122),(123),(124),(125),(126),
+(127),(128),(129),(130),(131),(132),(133),(133),(135),(135),(135),(135),
+(136),(136),(138),(138),(139),(139),(139),(140),(141),(141),(142),(143),
+(143),(145),(145);
+commit;
+
+
+-- enable_result_log
+-- enable_query_log
+
+# check tables's value
+select count(*) from bug30243_3 where org_id is not NULL;
+select count(*) from bug30243_3 where org_id is NULL;
+
+select count(*) from bug30243_2 where org_id is not NULL;
+select count(*) from bug30243_2 where org_id is NULL;
+
+select @@innodb_stats_method;
+
+analyze table bug30243_1;
+analyze table bug30243_2;
+analyze table bug30243_3;
+
+# Following query plan shows that we over estimate the rows per
+# unique value (since there are many NULLs).
+# Skip this query log since the stats estimate could vary from runs
+-- disable_query_log
+-- disable_result_log
+explain SELECT COUNT(*), 0
+ FROM bug30243_1 orgs
+ LEFT JOIN bug30243_3 sa_opportunities
+ ON orgs.org_id=sa_opportunities.org_id
+ LEFT JOIN bug30243_2 contacts
+ ON orgs.org_id=contacts.org_id ;
+-- enable_query_log
+-- enable_result_log
+
+# following set operation will fail
+#--error ER_WRONG_VALUE_FOR_VAR
+--error 1231
+set global innodb_stats_method = "NULL";
+
+set global innodb_stats_method = "nulls_ignored";
+
+select @@innodb_stats_method;
+
+# Regenerate the stats with "nulls_ignored" option
+
+analyze table bug30243_1;
+analyze table bug30243_2;
+analyze table bug30243_3;
+
+# Following query plan shows that we get the correct rows per
+# unique value (should be approximately 1 row per value)
+explain SELECT COUNT(*), 0
+ FROM bug30243_1 orgs
+ LEFT JOIN bug30243_3 sa_opportunities
+ ON orgs.org_id=sa_opportunities.org_id
+ LEFT JOIN bug30243_2 contacts
+ ON orgs.org_id=contacts.org_id ;
+
+select @@innodb_stats_method;
+
+# Try the "nulls_unequal" option
+set global innodb_stats_method = "nulls_unequal";
+
+select @@innodb_stats_method;
+
+analyze table bug30243_1;
+analyze table bug30243_2;
+analyze table bug30243_3;
+
+# Following query plan shows that we get the correct rows per
+# unique value (~1)
+explain SELECT COUNT(*), 0
+ FROM bug30243_1 orgs
+ LEFT JOIN bug30243_3 sa_opportunities
+ ON orgs.org_id=sa_opportunities.org_id
+ LEFT JOIN bug30243_2 contacts
+ ON orgs.org_id=contacts.org_id;
+
+
+# Create a table with all NULL values, make sure the stats calculation
+# does not crash with table of all NULL values
+-- disable_query_log
+CREATE TABLE table_bug30423 (
+ org_id int(11) default NULL,
+ KEY(org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO `table_bug30423` VALUES (NULL);
+
+begin;
+let $i=10;
+while ($i)
+{
+ INSERT INTO table_bug30423 SELECT NULL FROM table_bug30423;
+ dec $i;
+}
+commit;
+
+-- enable_query_log
+
+SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL;
+
+# calculate the statistics for the table for "nulls_ignored" and
+# "nulls_unequal" option
+set global innodb_stats_method = "nulls_unequal";
+analyze table table_bug30423;
+
+set global innodb_stats_method = "nulls_ignored";
+analyze table table_bug30423;
+
+
+eval set global innodb_stats_method = $innodb_stats_method_orig;
+
+drop table bug30243_2;
+
+drop table bug30243_1;
+
+drop table bug30243_3;
+
+drop table table_bug30423;
diff --git a/mysql-test/suite/innodb/t/innodb_bug53756.test b/mysql-test/suite/innodb/t/innodb_bug53756.test
index d3b0a77c680..7a48f130b2c 100644
--- a/mysql-test/suite/innodb/t/innodb_bug53756.test
+++ b/mysql-test/suite/innodb/t/innodb_bug53756.test
@@ -17,6 +17,9 @@
# This test case needs InnoDB.
--source include/have_innodb.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+
#
# Precautionary clean up.
#
diff --git a/mysql-test/suite/innodb/t/innodb_bug54044.test b/mysql-test/suite/innodb/t/innodb_bug54044.test
index a6722ed6399..32a4ca0e116 100644
--- a/mysql-test/suite/innodb/t/innodb_bug54044.test
+++ b/mysql-test/suite/innodb/t/innodb_bug54044.test
@@ -1,11 +1,4 @@
-# This is the test for bug #54044. Special handle MYSQL_TYPE_NULL type
-# during create table, so it will not trigger assertion failure.
-
--source include/have_innodb.inc
-# This 'create table' operation should fail because of
-# using NULL datatype
---error ER_CANT_CREATE_TABLE
CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
AS SELECT IF(NULL IS NOT NULL, NULL, NULL);
-
diff --git a/mysql-test/suite/innodb/t/innodb_bug56143.test b/mysql-test/suite/innodb/t/innodb_bug56143.test
index 6532022283f..106b225e4fd 100644
--- a/mysql-test/suite/innodb/t/innodb_bug56143.test
+++ b/mysql-test/suite/innodb/t/innodb_bug56143.test
@@ -9,6 +9,11 @@
-- disable_query_log
-- disable_result_log
+if ($VALGRIND_TEST)
+{
+ call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:");
+}
+
SET foreign_key_checks=0;
DROP TABLE IF EXISTS bug56143;
CREATE TABLE `bug56143` (
diff --git a/mysql-test/suite/innodb/t/innodb_bug60049-master.opt b/mysql-test/suite/innodb/t/innodb_bug60049-master.opt
new file mode 100644
index 00000000000..22a5d4ed221
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug60049-master.opt
@@ -0,0 +1 @@
+--innodb_fast_shutdown=0
diff --git a/mysql-test/suite/innodb/t/innodb_bug60049.test b/mysql-test/suite/innodb/t/innodb_bug60049.test
new file mode 100644
index 00000000000..fc977b3976f
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug60049.test
@@ -0,0 +1,44 @@
+# Bug #60049 Verify that purge leaves no garbage in unique secondary indexes
+# This test requires a fresh server start-up and a slow shutdown.
+# This was a suspected bug (not a bug).
+
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+#
+# This test will not work if we don't do full shutdown of innodb
+#
+set @@global.innodb_fast_shutdown=0;
+
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+RENAME TABLE t TO u;
+DROP TABLE u;
+SELECT @@innodb_fast_shutdown;
+let $MYSQLD_DATADIR=`select @@datadir`;
+
+# Shut down the server
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- shutdown_server 30
+-- source include/wait_until_disconnected.inc
+
+# Check the tail of ID_IND (SYS_TABLES.ID)
+let IBDATA1=$MYSQLD_DATADIR/ibdata1;
+perl;
+my $file = $ENV{'IBDATA1'};
+open(FILE, "<$file") || die "Unable to open $file";
+# Read DICT_HDR_TABLE_IDS, the root page number of ID_IND (SYS_TABLES.ID).
+seek(FILE, 7*16384+38+36, 0) || die "Unable to seek $file";
+die unless read(FILE, $_, 4) == 4;
+my $sys_tables_id_root = unpack("N", $_);
+print "Last record of ID_IND root page ($sys_tables_id_root):\n";
+# This should be the last record in ID_IND. Dump it in hexadecimal.
+seek(FILE, $sys_tables_id_root*16384 + 152, 0) || die "Unable to seek $file";
+read(FILE, $_, 32) || die "Unable to read $file";
+close(FILE);
+print unpack("H*", $_), "\n";
+EOF
+
+# Restart the server.
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
diff --git a/mysql-test/suite/innodb_plugin/r/binlog_consistent.result b/mysql-test/suite/innodb_plugin/r/binlog_consistent.result
index 428b828d699..09cbbd98fac 100644
--- a/mysql-test/suite/innodb_plugin/r/binlog_consistent.result
+++ b/mysql-test/suite/innodb_plugin/r/binlog_consistent.result
@@ -3,11 +3,11 @@ RESET MASTER;
CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb;
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000001 375
+master-bin.000001 380
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000001
-binlog_snapshot_position 375
+binlog_snapshot_position 380
BEGIN;
INSERT INTO t1 VALUES (0, "");
# Connection con1
@@ -38,10 +38,10 @@ a b
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000001
-binlog_snapshot_position 674
+binlog_snapshot_position 679
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000001 861
+master-bin.000001 866
SELECT * FROM t2 ORDER BY a;
a
2
@@ -60,40 +60,40 @@ a b
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000001
-binlog_snapshot_position 674
+binlog_snapshot_position 679
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000002 240
+master-bin.000002 245
COMMIT;
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000002
-binlog_snapshot_position 240
+binlog_snapshot_position 245
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000002 240
+master-bin.000002 245
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 4 Format_desc 1 240 Server ver: #, Binlog ver: #
-master-bin.000001 240 Query 1 375 use `test`; CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb
-master-bin.000001 375 Query 1 487 use `test`; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam
-master-bin.000001 487 Query 1 555 BEGIN
-master-bin.000001 555 Query 1 647 use `test`; INSERT INTO t1 VALUES (0, "")
-master-bin.000001 647 Xid 1 674 COMMIT /* XID */
-master-bin.000001 674 Query 1 742 BEGIN
-master-bin.000001 742 Query 1 834 use `test`; INSERT INTO t1 VALUES (4, "")
-master-bin.000001 834 Xid 1 861 COMMIT /* XID */
-master-bin.000001 861 Query 1 929 BEGIN
-master-bin.000001 929 Query 1 1021 use `test`; INSERT INTO t1 VALUES (1, "")
-master-bin.000001 1021 Xid 1 1048 COMMIT /* XID */
-master-bin.000001 1048 Query 1 1116 BEGIN
-master-bin.000001 1116 Query 1 1213 use `test`; INSERT INTO t1 VALUES (2, "first")
-master-bin.000001 1213 Query 1 1301 use `test`; INSERT INTO t2 VALUES (2)
-master-bin.000001 1301 Query 1 1399 use `test`; INSERT INTO t1 VALUES (2, "second")
-master-bin.000001 1399 Xid 1 1426 COMMIT /* XID */
-master-bin.000001 1426 Query 1 1494 BEGIN
-master-bin.000001 1494 Query 1 1586 use `test`; INSERT INTO t1 VALUES (3, "")
-master-bin.000001 1586 Query 1 1674 use `test`; INSERT INTO t2 VALUES (3)
-master-bin.000001 1674 Xid 1 1701 COMMIT /* XID */
-master-bin.000001 1701 Rotate 1 1745 master-bin.000002;pos=4
+master-bin.000001 4 Format_desc 1 245 Server ver: #, Binlog ver: #
+master-bin.000001 245 Query 1 380 use `test`; CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb
+master-bin.000001 380 Query 1 492 use `test`; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam
+master-bin.000001 492 Query 1 560 BEGIN
+master-bin.000001 560 Query 1 652 use `test`; INSERT INTO t1 VALUES (0, "")
+master-bin.000001 652 Xid 1 679 COMMIT /* XID */
+master-bin.000001 679 Query 1 747 BEGIN
+master-bin.000001 747 Query 1 839 use `test`; INSERT INTO t1 VALUES (4, "")
+master-bin.000001 839 Xid 1 866 COMMIT /* XID */
+master-bin.000001 866 Query 1 934 BEGIN
+master-bin.000001 934 Query 1 1026 use `test`; INSERT INTO t1 VALUES (1, "")
+master-bin.000001 1026 Xid 1 1053 COMMIT /* XID */
+master-bin.000001 1053 Query 1 1121 BEGIN
+master-bin.000001 1121 Query 1 1218 use `test`; INSERT INTO t1 VALUES (2, "first")
+master-bin.000001 1218 Query 1 1306 use `test`; INSERT INTO t2 VALUES (2)
+master-bin.000001 1306 Query 1 1404 use `test`; INSERT INTO t1 VALUES (2, "second")
+master-bin.000001 1404 Xid 1 1431 COMMIT /* XID */
+master-bin.000001 1431 Query 1 1499 BEGIN
+master-bin.000001 1499 Query 1 1591 use `test`; INSERT INTO t1 VALUES (3, "")
+master-bin.000001 1591 Query 1 1679 use `test`; INSERT INTO t2 VALUES (3)
+master-bin.000001 1679 Xid 1 1706 COMMIT /* XID */
+master-bin.000001 1706 Rotate 1 1750 master-bin.000002;pos=4
DROP TABLE t1,t2;
diff --git a/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos.result b/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos.result
index bfeb2474edb..79ade2acec7 100644
--- a/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos.result
+++ b/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos.result
@@ -30,6 +30,6 @@ a
1
2
3
-InnoDB: Last MySQL binlog file position 0 901, file name ./master-bin.000001
+InnoDB: Last MySQL binlog file position 0 906, file name ./master-bin.000001
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos_no_optimize_thread.result b/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos_no_optimize_thread.result
index a1c31cd411f..e6ea24a67bd 100644
--- a/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos_no_optimize_thread.result
+++ b/mysql-test/suite/innodb_plugin/r/group_commit_binlog_pos_no_optimize_thread.result
@@ -31,6 +31,6 @@ a
1
2
3
-InnoDB: Last MySQL binlog file position 0 901, file name ./master-bin.000001
+InnoDB: Last MySQL binlog file position 0 906, file name ./master-bin.000001
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb_plugin/r/group_commit_no_optimize_thread.result b/mysql-test/suite/innodb_plugin/r/group_commit_no_optimize_thread.result
index 7c2636fb472..34a638da2d5 100644
--- a/mysql-test/suite/innodb_plugin/r/group_commit_no_optimize_thread.result
+++ b/mysql-test/suite/innodb_plugin/r/group_commit_no_optimize_thread.result
@@ -7,6 +7,7 @@ SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group1_running WAI
INSERT INTO t1 VALUES ("con1");
set DEBUG_SYNC= "now WAIT_FOR group1_running";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con2";
+SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group2_running";
SET DEBUG_SYNC= "commit_after_release_LOCK_log WAIT_FOR group3_committed";
INSERT INTO t1 VALUES ("con2");
SET DEBUG_SYNC= "now WAIT_FOR group2_con2";
@@ -26,6 +27,7 @@ a
con1
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group3_con5";
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con5_leader WAIT_FOR con6_queued";
+set DEBUG_SYNC= "now WAIT_FOR group2_running";
INSERT INTO t1 VALUES ("con5");
SET DEBUG_SYNC= "now WAIT_FOR con5_leader";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con6_queued";
diff --git a/mysql-test/suite/innodb_plugin/r/innodb.result b/mysql-test/suite/innodb_plugin/r/innodb.result
index bff1b0c440e..20c90a9f440 100644
--- a/mysql-test/suite/innodb_plugin/r/innodb.result
+++ b/mysql-test/suite/innodb_plugin/r/innodb.result
@@ -1,5 +1,4 @@
-set optimizer_switch='index_condition_pushdown=off';
-set @@optimizer_use_mrr=disable;
+set optimizer_switch='index_condition_pushdown=off,mrr=off';
drop table if exists t1,t2,t3,t4;
drop database if exists mysqltest;
CREATE TABLE bug58912 (a BLOB, b TEXT, PRIMARY KEY(a(1))) ENGINE=InnoDB;
@@ -3244,6 +3243,5 @@ Variable_name Value
Handler_update 1
Variable_name Value
Handler_delete 1
-set optimizer_switch='index_condition_pushdown=default';
-set @@optimizer_use_mrr=default;
+set optimizer_switch=default;
DROP TABLE bug58912;
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result b/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result
new file mode 100644
index 00000000000..a19809366ae
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug30423.result
@@ -0,0 +1,95 @@
+set global innodb_stats_method = default;
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_equal
+select count(*) from bug30243_3 where org_id is not NULL;
+count(*)
+20
+select count(*) from bug30243_3 where org_id is NULL;
+count(*)
+16384
+select count(*) from bug30243_2 where org_id is not NULL;
+count(*)
+224
+select count(*) from bug30243_2 where org_id is NULL;
+count(*)
+65536
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_equal
+analyze table bug30243_1;
+Table Op Msg_type Msg_text
+test.bug30243_1 analyze status OK
+analyze table bug30243_2;
+Table Op Msg_type Msg_text
+test.bug30243_2 analyze status OK
+analyze table bug30243_3;
+Table Op Msg_type Msg_text
+test.bug30243_3 analyze status OK
+set global innodb_stats_method = "NULL";
+ERROR 42000: Variable 'stats_method' can't be set to the value of 'NULL'
+set global innodb_stats_method = "nulls_ignored";
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_ignored
+analyze table bug30243_1;
+Table Op Msg_type Msg_text
+test.bug30243_1 analyze status OK
+analyze table bug30243_2;
+Table Op Msg_type Msg_text
+test.bug30243_2 analyze status OK
+analyze table bug30243_3;
+Table Op Msg_type Msg_text
+test.bug30243_3 analyze status OK
+explain SELECT COUNT(*), 0
+FROM bug30243_1 orgs
+LEFT JOIN bug30243_3 sa_opportunities
+ON orgs.org_id=sa_opportunities.org_id
+LEFT JOIN bug30243_2 contacts
+ON orgs.org_id=contacts.org_id ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orgs index NULL org_id 4 NULL 128 Using index
+1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id 1 Using index
+1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id 1 Using index
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_ignored
+set global innodb_stats_method = "nulls_unequal";
+select @@innodb_stats_method;
+@@innodb_stats_method
+nulls_unequal
+analyze table bug30243_1;
+Table Op Msg_type Msg_text
+test.bug30243_1 analyze status OK
+analyze table bug30243_2;
+Table Op Msg_type Msg_text
+test.bug30243_2 analyze status OK
+analyze table bug30243_3;
+Table Op Msg_type Msg_text
+test.bug30243_3 analyze status OK
+explain SELECT COUNT(*), 0
+FROM bug30243_1 orgs
+LEFT JOIN bug30243_3 sa_opportunities
+ON orgs.org_id=sa_opportunities.org_id
+LEFT JOIN bug30243_2 contacts
+ON orgs.org_id=contacts.org_id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orgs index NULL org_id 4 NULL 128 Using index
+1 SIMPLE sa_opportunities ref org_id org_id 5 test.orgs.org_id 1 Using index
+1 SIMPLE contacts ref contacts$org_id contacts$org_id 5 test.orgs.org_id 1 Using index
+SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL;
+COUNT(*)
+1024
+set global innodb_stats_method = "nulls_unequal";
+analyze table table_bug30423;
+Table Op Msg_type Msg_text
+test.table_bug30423 analyze status OK
+set global innodb_stats_method = "nulls_ignored";
+analyze table table_bug30423;
+Table Op Msg_type Msg_text
+test.table_bug30423 analyze status OK
+set global innodb_stats_method = nulls_equal;
+drop table bug30243_2;
+drop table bug30243_1;
+drop table bug30243_3;
+drop table table_bug30423;
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug54044.result b/mysql-test/suite/innodb_plugin/r/innodb_bug54044.result
index 90ab812f2ae..3f607e20ddf 100644
--- a/mysql-test/suite/innodb_plugin/r/innodb_bug54044.result
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug54044.result
@@ -1,3 +1,2 @@
CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
AS SELECT IF(NULL IS NOT NULL, NULL, NULL);
-ERROR HY000: Can't create table 'test.table_54044' (errno: -1)
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug59307.result b/mysql-test/suite/innodb_plugin/r/innodb_bug59307.result
new file mode 100644
index 00000000000..0d726e83708
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug59307.result
@@ -0,0 +1,28 @@
+CREATE TABLE t1 (
+t1_int INT,
+t1_time TIME
+) ENGINE=innodb;
+CREATE TABLE t2 (
+t2_int int PRIMARY KEY,
+t2_int2 INT
+) ENGINE=INNODB;
+INSERT INTO t2 VALUES ();
+Warnings:
+Warning 1364 Field 't2_int' doesn't have a default value
+INSERT INTO t1 VALUES ();
+SELECT *
+FROM t1 AS t1a
+WHERE NOT EXISTS
+(SELECT *
+FROM t1 AS t1b
+WHERE t1b.t1_int NOT IN
+(SELECT t2.t2_int
+FROM t2
+WHERE t1b.t1_time LIKE t1b.t1_int
+OR t1b.t1_time <> t2.t2_int2
+AND 6=7
+)
+)
+;
+t1_int t1_time
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_bug60049.result b/mysql-test/suite/innodb_plugin/r/innodb_bug60049.result
new file mode 100644
index 00000000000..a1788a8ab0a
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/r/innodb_bug60049.result
@@ -0,0 +1,9 @@
+set @@global.innodb_fast_shutdown=0;
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+RENAME TABLE t TO u;
+DROP TABLE u;
+SELECT @@innodb_fast_shutdown;
+@@innodb_fast_shutdown
+0
+Last record of ID_IND root page (9):
+1808000018050074000000000000000c5359535f464f524549474e5f434f4c53
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_gis.result b/mysql-test/suite/innodb_plugin/r/innodb_gis.result
index e44f2aec093..57d61bbd586 100644
--- a/mysql-test/suite/innodb_plugin/r/innodb_gis.result
+++ b/mysql-test/suite/innodb_plugin/r/innodb_gis.result
@@ -236,7 +236,7 @@ explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelo
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00
Warnings:
-Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
+Note 1003 select st_dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,st_geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,st_isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,st_astext(st_envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
SELECT fid, X(g) FROM gis_point ORDER by fid;
fid X(g)
101 10
@@ -253,7 +253,7 @@ explain extended select X(g),Y(g) FROM gis_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00
Warnings:
-Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
+Note 1003 select st_x(`test`.`gis_point`.`g`) AS `X(g)`,st_y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
fid AsText(StartPoint(g))
105 POINT(0 0)
@@ -288,7 +288,7 @@ explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),Num
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
+Note 1003 select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,st_astext(st_endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,st_length(`test`.`gis_line`.`g`) AS `GLength(g)`,st_numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,st_astext(st_pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,st_isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
@@ -318,7 +318,7 @@ explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumI
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
+Note 1003 select st_astext(st_centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,st_area(`test`.`gis_polygon`.`g`) AS `Area(g)`,st_astext(st_exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,st_numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,st_astext(st_interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
fid IsClosed(g)
114 0
@@ -357,7 +357,7 @@ explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
+Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
fid AsText(GeometryN(g, 2))
111 POINT(10 10)
@@ -385,17 +385,17 @@ explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
+Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_astext(st_geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
-120 120 1 1 0 1 0 0 1 0
+120 120 0 0 0 1 0 1 1 0
120 121 0 0 1 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
-121 121 1 1 0 1 0 0 1 0
+121 121 0 0 0 1 0 1 1 0
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
@@ -405,7 +405,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
+Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,st_within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,st_contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
a INTEGER PRIMARY KEY AUTO_INCREMENT,
@@ -500,7 +500,6 @@ mbrwithin
big,center
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
contains
-center,small
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
disjoint
down3,left3,right3,up3
@@ -518,7 +517,6 @@ touches
down2,left2,right2,up2
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
within
-big,center
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
@@ -585,5 +583,17 @@ COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
+#
+# Test for bug #58650 "Failing assertion: primary_key_no == -1 ||
+# primary_key_no == 0".
+#
+drop table if exists t1;
+# The minimal test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a));
+drop table t1;
+# The original test case.
+create table t1 (a int not null, b linestring not null, unique key b (b(12)));
+create unique index a on t1(a);
+drop table t1;
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
ERROR HY000: The used table type doesn't support SPATIAL indexes
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_lock_wait_timeout_1.result b/mysql-test/suite/innodb_plugin/r/innodb_lock_wait_timeout_1.result
index bd8760b8f79..051266c526e 100644
--- a/mysql-test/suite/innodb_plugin/r/innodb_lock_wait_timeout_1.result
+++ b/mysql-test/suite/innodb_plugin/r/innodb_lock_wait_timeout_1.result
@@ -104,7 +104,7 @@ id 1
select_type PRIMARY
table <derived2>
type ALL
-possible_keys NULL
+possible_keys key0
key NULL
key_len NULL
ref NULL
@@ -308,7 +308,7 @@ id 1
select_type PRIMARY
table <derived2>
type ALL
-possible_keys NULL
+possible_keys key0
key NULL
key_len NULL
ref NULL
diff --git a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result
index 1256268d030..df23048f834 100644
--- a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result
+++ b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result
@@ -1739,8 +1739,8 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index c3,c2 c2 10 NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 index_merge c3,c2 c3,c2 5,10 NULL 1 Using intersect(c3,c2); Using where; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3))
ENGINE=InnoDB;
@@ -1753,8 +1753,8 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index c3,c2 c2 18 NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 index_merge c3,c2 c3,c2 9,18 NULL 1 Using intersect(c3,c2); Using where; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2),
KEY (c3), KEY (c2, c3))
@@ -1768,8 +1768,8 @@ EXPLAIN
SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t1 index c3,c2 c2 14 NULL 5
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 index_merge c3,c2 c3,c2 7,14 NULL 1 Using intersect(c3,c2); Using where; Using filesort
DROP TABLE t1;
End of 5.1 tests
drop table if exists t1, t2, t3;
@@ -2440,8 +2440,7 @@ SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
-2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 3537 Using sort_union(idx,PRIMARY); Using where
+1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 3537 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
diff --git a/mysql-test/suite/innodb_plugin/t/group_commit_no_optimize_thread.test b/mysql-test/suite/innodb_plugin/t/group_commit_no_optimize_thread.test
index ae3f1b516d4..a216cbd2965 100644
--- a/mysql-test/suite/innodb_plugin/t/group_commit_no_optimize_thread.test
+++ b/mysql-test/suite/innodb_plugin/t/group_commit_no_optimize_thread.test
@@ -37,6 +37,7 @@ send INSERT INTO t1 VALUES ("con1");
connection con2;
set DEBUG_SYNC= "now WAIT_FOR group1_running";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con2";
+SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group2_running";
SET DEBUG_SYNC= "commit_after_release_LOCK_log WAIT_FOR group3_committed";
send INSERT INTO t1 VALUES ("con2");
connection con3;
@@ -70,6 +71,7 @@ SELECT * FROM t1 ORDER BY a;
connection con5;
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group3_con5";
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con5_leader WAIT_FOR con6_queued";
+set DEBUG_SYNC= "now WAIT_FOR group2_running";
send INSERT INTO t1 VALUES ("con5");
connection con6;
diff --git a/mysql-test/suite/innodb_plugin/t/innodb.test b/mysql-test/suite/innodb_plugin/t/innodb.test
index d3474f90805..47f765e63f6 100644
--- a/mysql-test/suite/innodb_plugin/t/innodb.test
+++ b/mysql-test/suite/innodb_plugin/t/innodb.test
@@ -19,8 +19,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
let collation=utf8_unicode_ci;
--source include/have_collation.inc
-set optimizer_switch='index_condition_pushdown=off';
-set @@optimizer_use_mrr=disable;
+set optimizer_switch='index_condition_pushdown=off,mrr=off';
# Save the original values of some variables in order to be able to
# estimate how much they have changed during the tests. Previously this
@@ -2555,8 +2554,7 @@ SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig;
-- enable_query_log
-set optimizer_switch='index_condition_pushdown=default';
-set @@optimizer_use_mrr=default;
+set optimizer_switch=default;
# Clean up after the Bug#55284/Bug#58912 test case.
DROP TABLE bug58912;
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test b/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test
new file mode 100644
index 00000000000..458c2967e19
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug30423.test
@@ -0,0 +1,211 @@
+# Test for Bug #30423, InnoDBs treatment of NULL in index stats causes
+# bad "rows examined" estimates.
+# Implemented InnoDB system variable "innodb_stats_method" with
+# "nulls_equal" (default), "nulls_unequal", and "nulls_ignored" options.
+
+-- source include/have_innodb_plugin.inc
+
+let $innodb_stats_method_orig = `select @@innodb_stats_method`;
+
+# default setting for innodb_stats_method is "nulls_equal"
+set global innodb_stats_method = default;
+
+select @@innodb_stats_method;
+
+# create three tables, bug30243_1, bug30243_2 and bug30243_3.
+# The test scenario is adopted from original bug #30423 report.
+# table bug30243_1 and bug30243_3 have many NULL values
+
+-- disable_result_log
+-- disable_query_log
+
+DROP TABLE IF EXISTS bug30243_1;
+CREATE TABLE bug30243_1 (
+ org_id int(11) NOT NULL default '0',
+ UNIQUE KEY (org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+LOCK TABLES bug30243_1 WRITE;
+INSERT INTO bug30243_1 VALUES (11),(15),(16),(17),(19),(20),(21),(23),(24),
+(25),(26),(27),(28),(29),(30),(31),(32),(33),(34),(35),(37),(38),(40),(41),
+(42),(43),(44),(45),(46),(47),(48),(49),(50),(51),(52),(53),(54),(55),(56),
+(57),(58),(59),(60),(61),(62),(63),(64),(65),(66),(67),(68),(69),(70),(71),
+(72),(73),(74),(75),(76),(77),(78),(79),(80),(81),(82),(83),(84),(85),(86),
+(87),(88),(89),(90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100),(101),
+(102),(103),(104),(105),(106),(107),(108),(109),(110),(111),(112),(113),(114),
+(115),(116),(117),(118),(119),(120),(121),(122),(123),(124),(125),(126),(127),
+(128),(129),(130),(131),(132),(133),(134),(135),(136),(137),(138),(139),(140),
+(141),(142),(143),(144),(145);
+UNLOCK TABLES;
+
+DROP TABLE IF EXISTS bug30243_3;
+CREATE TABLE bug30243_3 (
+ org_id int(11) default NULL,
+ KEY (org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO bug30243_3 VALUES (NULL);
+
+begin;
+let $i=14;
+while ($i)
+{
+ INSERT INTO bug30243_3 SELECT NULL FROM bug30243_3;
+ dec $i;
+}
+
+INSERT INTO bug30243_3 VALUES (34),(34),(35),(56),(58),(62),(62),(64),(65),(66),(80),(135),(137),(138),(139),(140),(142),(143),(144),(145);
+commit;
+
+DROP TABLE IF EXISTS bug30243_2;
+CREATE TABLE bug30243_2 (
+ org_id int(11) default NULL,
+ KEY `contacts$org_id` (org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO bug30243_2 VALUES (NULL);
+
+begin;
+let $i=16;
+while ($i)
+{
+ INSERT INTO bug30243_2 SELECT NULL FROM bug30243_2;
+ dec $i;
+}
+
+INSERT INTO bug30243_2 VALUES (11),(15),(16),(17),(20),(21),(23),(24),(25),
+(26),(27),(28),(29),(30),(31),(32),(33),(34),(37),(38),(40),(41),(42),(43),
+(44),(45),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),
+(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(46),(48),
+(48),(50),(51),(52),(52),(53),(54),(55),(57),(60),(61),(62),(62),(62),(62),
+(62),(63),(64),(64),(65),(66),(66),(67),(68),(69),(70),(71),(72),(73),(74),
+(75),(76),(77),(78),(79),(80),(80),(81),(82),(83),(84),(85),(86),(87),(88),
+(89),(90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100),(101),(102),
+(103),(104),(105),(106),(107),(108),(109),(110),(111),(112),(113),(114),
+(115),(116),(117),(118),(119),(120),(121),(122),(123),(124),(125),(126),
+(127),(128),(129),(130),(131),(132),(133),(133),(135),(135),(135),(135),
+(136),(136),(138),(138),(139),(139),(139),(140),(141),(141),(142),(143),
+(143),(145),(145);
+commit;
+
+
+-- enable_result_log
+-- enable_query_log
+
+# check tables's value
+select count(*) from bug30243_3 where org_id is not NULL;
+select count(*) from bug30243_3 where org_id is NULL;
+
+select count(*) from bug30243_2 where org_id is not NULL;
+select count(*) from bug30243_2 where org_id is NULL;
+
+select @@innodb_stats_method;
+
+analyze table bug30243_1;
+analyze table bug30243_2;
+analyze table bug30243_3;
+
+# Following query plan shows that we over estimate the rows per
+# unique value (since there are many NULLs).
+# Skip this query log since the stats estimate could vary from runs
+-- disable_query_log
+-- disable_result_log
+explain SELECT COUNT(*), 0
+ FROM bug30243_1 orgs
+ LEFT JOIN bug30243_3 sa_opportunities
+ ON orgs.org_id=sa_opportunities.org_id
+ LEFT JOIN bug30243_2 contacts
+ ON orgs.org_id=contacts.org_id ;
+-- enable_query_log
+-- enable_result_log
+
+# following set operation will fail
+#--error ER_WRONG_VALUE_FOR_VAR
+--error 1231
+set global innodb_stats_method = "NULL";
+
+set global innodb_stats_method = "nulls_ignored";
+
+select @@innodb_stats_method;
+
+# Regenerate the stats with "nulls_ignored" option
+
+analyze table bug30243_1;
+analyze table bug30243_2;
+analyze table bug30243_3;
+
+# Following query plan shows that we get the correct rows per
+# unique value (should be approximately 1 row per value)
+explain SELECT COUNT(*), 0
+ FROM bug30243_1 orgs
+ LEFT JOIN bug30243_3 sa_opportunities
+ ON orgs.org_id=sa_opportunities.org_id
+ LEFT JOIN bug30243_2 contacts
+ ON orgs.org_id=contacts.org_id ;
+
+select @@innodb_stats_method;
+
+# Try the "nulls_unequal" option
+set global innodb_stats_method = "nulls_unequal";
+
+select @@innodb_stats_method;
+
+analyze table bug30243_1;
+analyze table bug30243_2;
+analyze table bug30243_3;
+
+# Following query plan shows that we get the correct rows per
+# unique value (~1)
+explain SELECT COUNT(*), 0
+ FROM bug30243_1 orgs
+ LEFT JOIN bug30243_3 sa_opportunities
+ ON orgs.org_id=sa_opportunities.org_id
+ LEFT JOIN bug30243_2 contacts
+ ON orgs.org_id=contacts.org_id;
+
+
+# Create a table with all NULL values, make sure the stats calculation
+# does not crash with table of all NULL values
+-- disable_query_log
+CREATE TABLE table_bug30423 (
+ org_id int(11) default NULL,
+ KEY(org_id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO `table_bug30423` VALUES (NULL);
+
+begin;
+let $i=10;
+while ($i)
+{
+ INSERT INTO table_bug30423 SELECT NULL FROM table_bug30423;
+ dec $i;
+}
+commit;
+
+-- enable_query_log
+
+SELECT COUNT(*) FROM table_bug30423 WHERE org_id IS NULL;
+
+# calculate the statistics for the table for "nulls_ignored" and
+# "nulls_unequal" option
+set global innodb_stats_method = "nulls_unequal";
+analyze table table_bug30423;
+
+set global innodb_stats_method = "nulls_ignored";
+analyze table table_bug30423;
+
+
+eval set global innodb_stats_method = $innodb_stats_method_orig;
+
+drop table bug30243_2;
+
+drop table bug30243_1;
+
+drop table bug30243_3;
+
+drop table table_bug30423;
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test
index 8c48550a64d..37a79ea3021 100644
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test
@@ -17,6 +17,9 @@
# This test case needs InnoDB.
-- source include/have_innodb_plugin.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+
#
# Precautionary clean up.
#
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug54044.test b/mysql-test/suite/innodb_plugin/t/innodb_bug54044.test
index 58f60a54130..10a18dff5ce 100644
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug54044.test
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug54044.test
@@ -1,11 +1,4 @@
-# This is the test for bug #54044. Special handle MYSQL_TYPE_NULL type
-# during create table, so it will not trigger assertion failure.
-
--source include/have_innodb_plugin.inc
-# This 'create table' operation should fail because of
-# using NULL datatype
---error ER_CANT_CREATE_TABLE
CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
AS SELECT IF(NULL IS NOT NULL, NULL, NULL);
-
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug56143.test b/mysql-test/suite/innodb_plugin/t/innodb_bug56143.test
index 7c7472303db..0f135a44f5d 100644
--- a/mysql-test/suite/innodb_plugin/t/innodb_bug56143.test
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug56143.test
@@ -8,6 +8,11 @@
-- disable_query_log
-- disable_result_log
+if ($VALGRIND_TEST)
+{
+ call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:");
+}
+
SET foreign_key_checks=0;
DROP TABLE IF EXISTS bug56143_1;
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug59307.test b/mysql-test/suite/innodb_plugin/t/innodb_bug59307.test
new file mode 100644
index 00000000000..9c68adf36cf
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug59307.test
@@ -0,0 +1,32 @@
+-- source include/have_innodb_plugin.inc
+# Bug #59307 uninitialized value in rw_lock_set_writer_id_and_recursion_flag()
+# when Valgrind instrumentation (UNIV_DEBUG_VALGRIND) is not enabled
+
+CREATE TABLE t1 (
+ t1_int INT,
+ t1_time TIME
+) ENGINE=innodb;
+
+CREATE TABLE t2 (
+ t2_int int PRIMARY KEY,
+ t2_int2 INT
+) ENGINE=INNODB;
+
+INSERT INTO t2 VALUES ();
+INSERT INTO t1 VALUES ();
+
+SELECT *
+FROM t1 AS t1a
+WHERE NOT EXISTS
+ (SELECT *
+ FROM t1 AS t1b
+ WHERE t1b.t1_int NOT IN
+ (SELECT t2.t2_int
+ FROM t2
+ WHERE t1b.t1_time LIKE t1b.t1_int
+ OR t1b.t1_time <> t2.t2_int2
+ AND 6=7
+ )
+)
+;
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug60049-master.opt b/mysql-test/suite/innodb_plugin/t/innodb_bug60049-master.opt
new file mode 100644
index 00000000000..22a5d4ed221
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug60049-master.opt
@@ -0,0 +1 @@
+--innodb_fast_shutdown=0
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug60049.test b/mysql-test/suite/innodb_plugin/t/innodb_bug60049.test
new file mode 100644
index 00000000000..f42451d2994
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/t/innodb_bug60049.test
@@ -0,0 +1,43 @@
+# Bug #60049 Verify that purge leaves no garbage in unique secondary indexes
+# This test requires a fresh server start-up and a slow shutdown.
+# This was a suspected bug (not a bug).
+
+-- source include/not_embedded.inc
+-- source include/have_innodb_plugin.inc
+
+# This test will not work if we don't do full shutdown of innodb
+#
+set @@global.innodb_fast_shutdown=0;
+
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+RENAME TABLE t TO u;
+DROP TABLE u;
+SELECT @@innodb_fast_shutdown;
+let $MYSQLD_DATADIR=`select @@datadir`;
+
+# Shut down the server
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- shutdown_server 30
+-- source include/wait_until_disconnected.inc
+
+# Check the tail of ID_IND (SYS_TABLES.ID)
+let IBDATA1=$MYSQLD_DATADIR/ibdata1;
+perl;
+my $file = $ENV{'IBDATA1'};
+open(FILE, "<$file") || die "Unable to open $file";
+# Read DICT_HDR_TABLE_IDS, the root page number of ID_IND (SYS_TABLES.ID).
+seek(FILE, 7*16384+38+36, 0) || die "Unable to seek $file";
+die unless read(FILE, $_, 4) == 4;
+my $sys_tables_id_root = unpack("N", $_);
+print "Last record of ID_IND root page ($sys_tables_id_root):\n";
+# This should be the last record in ID_IND. Dump it in hexadecimal.
+seek(FILE, $sys_tables_id_root*16384 + 152, 0) || die "Unable to seek $file";
+read(FILE, $_, 32) || die "Unable to read $file";
+close(FILE);
+print unpack("H*", $_), "\n";
+EOF
+
+# Restart the server.
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
diff --git a/mysql-test/suite/innodb_plugin/t/innodb_information_schema.test b/mysql-test/suite/innodb_plugin/t/innodb_information_schema.test
index 25255e0b2a9..20c25015c56 100644
--- a/mysql-test/suite/innodb_plugin/t/innodb_information_schema.test
+++ b/mysql-test/suite/innodb_plugin/t/innodb_information_schema.test
@@ -116,11 +116,29 @@ SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE;
# executes before some of them, resulting in less than expected number
# of rows being selected from innodb_locks. If there is a bug and there
# are no 14 rows in innodb_locks then this test will fail with timeout.
-let $count = 14;
-let $table = INFORMATION_SCHEMA.INNODB_LOCKS;
--- source include/wait_until_rows_count.inc
-# the above enables the query log, re-disable it
--- disable_query_log
+# Notice that if we query INNODB_LOCKS more often than once per 0.1 sec
+# then its contents will never change because the cache from which it is
+# filled is updated only if it has not been read for 0.1 seconds. See
+# CACHE_MIN_IDLE_TIME_US in trx/trx0i_s.c.
+let $cnt=10;
+while ($cnt)
+{
+ let $success=`SELECT COUNT(*) = 14 FROM INFORMATION_SCHEMA.INNODB_LOCKS`;
+ if ($success)
+ {
+ let $cnt=0;
+ }
+ if (!$success)
+ {
+ real_sleep 0.2;
+ dec $cnt;
+ }
+}
+if (!$success)
+{
+ -- echo Timeout waiting for rows in INNODB_LOCKS to appear
+}
+
SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data
FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data;
diff --git a/mysql-test/suite/maria/r/compat_aliases.result b/mysql-test/suite/maria/r/compat_aliases.result
deleted file mode 100644
index bcc9ece0986..00000000000
--- a/mysql-test/suite/maria/r/compat_aliases.result
+++ /dev/null
@@ -1,58 +0,0 @@
-select * from information_schema.plugins where plugin_name like '%aria';
-PLUGIN_NAME PLUGIN_VERSION PLUGIN_STATUS PLUGIN_TYPE PLUGIN_TYPE_VERSION PLUGIN_LIBRARY PLUGIN_LIBRARY_VERSION PLUGIN_AUTHOR PLUGIN_DESCRIPTION PLUGIN_LICENSE PLUGIN_MATURITY PLUGIN_AUTH_VERSION
-Maria 1.5 ACTIVE DAEMON # NULL NULL Monty Program Ab Compatibility aliases for the Aria engine GPL Gamma 1.5
-Aria 1.5 ACTIVE STORAGE ENGINE # NULL NULL Monty Program Ab Crash-safe tables with MyISAM heritage GPL Gamma 1.5
-select maria_vars.variable_name, aria_vars.variable_name from
-information_schema.session_variables as maria_vars left join
-information_schema.session_variables as aria_vars
-on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
-where maria_vars.variable_name like 'maria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-variable_name variable_name
-select maria_vars.variable_name, aria_vars.variable_name from
-information_schema.session_status as maria_vars left join
-information_schema.session_status as aria_vars
-on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
-where maria_vars.variable_name like 'maria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-variable_name variable_name
-select maria_vars.variable_name, aria_vars.variable_name from
-information_schema.session_variables as aria_vars left join
-information_schema.session_variables as maria_vars
-on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
-where aria_vars.variable_name like 'aria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-variable_name variable_name
-select maria_vars.variable_name, aria_vars.variable_name from
-information_schema.session_status as aria_vars left join
-information_schema.session_status as maria_vars
-on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
-where aria_vars.variable_name like 'aria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-variable_name variable_name
-set @old_checkpoint_interval=@@global.aria_checkpoint_interval;
-set global maria_checkpoint_interval=10;
-select @@global.aria_checkpoint_interval;
-@@global.aria_checkpoint_interval
-10
-set global maria_checkpoint_interval=@old_checkpoint_interval;
-set @old_sort_buffer_size=@@global.maria_sort_buffer_size;
-set global aria_sort_buffer_size=1024;
-select @@global.maria_sort_buffer_size;
-@@global.maria_sort_buffer_size
-1024
-set global aria_sort_buffer_size=@old_sort_buffer_size;
-set @old_sort_buffer_size=@@session.maria_sort_buffer_size;
-set session aria_sort_buffer_size=2048;
-select @@session.maria_sort_buffer_size;
-@@session.maria_sort_buffer_size
-2048
-set session aria_sort_buffer_size=@old_sort_buffer_size;
-set @old_max_sort_file_size=@@global.maria_max_sort_file_size,
-@old_repair_threads=@@global.aria_repair_threads;
-set @@global.maria_max_sort_file_size=default, @@global.aria_repair_threads=default;
-select @@global.maria_max_sort_file_size, @@global.aria_repair_threads;
-@@global.maria_max_sort_file_size @@global.aria_repair_threads
-9223372036853727232 1
-set @@global.aria_max_sort_file_size=@old_max_sort_file_size,
-@@global.maria_repair_threads=@old_repair_threads;
diff --git a/mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result b/mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result
index 743f1785f5c..e8df5e5c8ab 100644
--- a/mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result
+++ b/mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result
@@ -168,7 +168,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 11 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 150 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
@@ -181,7 +181,6 @@ fid AsText(g)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
-11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -302,414 +301,410 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 4 Using where
+1 SIMPLE t2 range g g 34 NULL 1 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
-45 LINESTRING(51 51,60 60)
-46 LINESTRING(51 41,60 50)
-55 LINESTRING(41 51,50 60)
-56 LINESTRING(41 41,50 50)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-99
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-98
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-97
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-96
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-95
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-94
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-93
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-92
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-91
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-90
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-89
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-88
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-87
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-86
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-85
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-84
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-83
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-82
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-81
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-80
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-79
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-78
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-77
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-76
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-75
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-74
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-73
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-72
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-71
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-70
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-69
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-68
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-67
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-66
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-65
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-64
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-63
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-62
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-61
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-60
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-59
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-58
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-57
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-56
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-55
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-54
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-53
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-52
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-51
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-50
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-49
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-48
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-47
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-46
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-45
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-44
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-43
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-42
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-41
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-40
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-39
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-38
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-37
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-36
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-35
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-34
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-33
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-32
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-31
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-30
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-29
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-28
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-27
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-26
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-25
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-24
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-23
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-22
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-21
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-20
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-19
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-18
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-17
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-16
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-15
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-14
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-13
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-12
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-11
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-10
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-9
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-8
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-7
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-6
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-5
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-4
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-3
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-2
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-1
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-0
+100
DROP TABLE t2;
drop table if exists t1;
Warnings:
diff --git a/mysql-test/suite/maria/r/maria-gis-rtree-trans.result b/mysql-test/suite/maria/r/maria-gis-rtree-trans.result
index ae37b9d454d..b529cde47ca 100644
--- a/mysql-test/suite/maria/r/maria-gis-rtree-trans.result
+++ b/mysql-test/suite/maria/r/maria-gis-rtree-trans.result
@@ -168,7 +168,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 11 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 150 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
@@ -181,7 +181,6 @@ fid AsText(g)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
-11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -302,414 +301,410 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 4 Using where
+1 SIMPLE t2 range g g 34 NULL 1 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
-45 LINESTRING(51 51,60 60)
-46 LINESTRING(51 41,60 50)
-55 LINESTRING(41 51,50 60)
-56 LINESTRING(41 41,50 50)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-99
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-98
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-97
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-96
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-95
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-94
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-93
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-92
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-91
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-90
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-89
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-88
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-87
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-86
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-85
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-84
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-83
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-82
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-81
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-80
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-79
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-78
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-77
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-76
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-75
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-74
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-73
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-72
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-71
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-70
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-69
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-68
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-67
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-66
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-65
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-64
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-63
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-62
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-61
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-60
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-59
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-58
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-57
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-56
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-55
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-54
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-53
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-52
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-51
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-50
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-49
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-48
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-47
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-46
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-45
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-44
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-43
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-42
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-41
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-40
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-39
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-38
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-37
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-36
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-35
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-34
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-33
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-32
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-31
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-30
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-29
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-28
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-27
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-26
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-25
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-24
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-23
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-22
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-21
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-20
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-19
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-18
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-17
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-16
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-15
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-14
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-13
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-12
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-11
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-10
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-9
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-8
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-7
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-6
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-5
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-4
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-3
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-2
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-1
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-0
+100
DROP TABLE t2;
drop table if exists t1;
Warnings:
diff --git a/mysql-test/suite/maria/r/maria-gis-rtree.result b/mysql-test/suite/maria/r/maria-gis-rtree.result
index a61e93d2a3a..514883729af 100644
--- a/mysql-test/suite/maria/r/maria-gis-rtree.result
+++ b/mysql-test/suite/maria/r/maria-gis-rtree.result
@@ -168,7 +168,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range g g 34 NULL 11 Using where
+1 SIMPLE t1 ALL g NULL NULL NULL 150 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
@@ -181,7 +181,6 @@ fid AsText(g)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
-11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -302,414 +301,410 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range g g 34 NULL 4 Using where
+1 SIMPLE t2 range g g 34 NULL 1 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
-45 LINESTRING(51 51,60 60)
-46 LINESTRING(51 41,60 50)
-55 LINESTRING(41 51,50 60)
-56 LINESTRING(41 41,50 50)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-99
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-98
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-97
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-96
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-95
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-94
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-93
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-92
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-91
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-90
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-89
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-88
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-87
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-86
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-85
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-84
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-83
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-82
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-81
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-80
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-79
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-78
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-77
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-76
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-75
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-74
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-73
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-72
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-71
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-70
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-69
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-68
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-67
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-66
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-65
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-64
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-63
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-62
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-61
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-60
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-59
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-58
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-57
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-56
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-55
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-54
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-53
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-52
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-51
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-50
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-49
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-48
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-47
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-46
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-45
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-44
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-43
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-42
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-41
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-40
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-39
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-38
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-37
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-36
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-35
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-34
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-33
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-32
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-31
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-30
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-29
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-28
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-27
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-26
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-25
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-24
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-23
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-22
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-21
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-20
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-19
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-18
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-17
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-16
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-15
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-14
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-13
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-12
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-11
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-10
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
-9
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
-8
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
-7
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
-6
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
-5
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
-4
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
-3
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
-2
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
-1
+100
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
-0
+100
DROP TABLE t2;
drop table if exists t1;
Warnings:
diff --git a/mysql-test/suite/maria/r/maria-recover.result b/mysql-test/suite/maria/r/maria-recover.result
index 128467a278c..9b84c47720a 100644
--- a/mysql-test/suite/maria/r/maria-recover.result
+++ b/mysql-test/suite/maria/r/maria-recover.result
@@ -20,7 +20,7 @@ create table t1 (a varchar(1000), index(a)) engine=aria;
insert into t1 values("ThursdayMorningsMarket");
flush table t1;
insert into t1 select concat(a,'b') from t1 limit 1;
-set global maria_checkpoint_interval=1000;
+set global aria_checkpoint_interval=1000;
select * from t_corrupted2;
a
ThursdayMorningsMarket
diff --git a/mysql-test/suite/maria/r/maria3.result b/mysql-test/suite/maria/r/maria3.result
index 490059587ad..056147c69c0 100644
--- a/mysql-test/suite/maria/r/maria3.result
+++ b/mysql-test/suite/maria/r/maria3.result
@@ -312,7 +312,7 @@ aria_log_file_size 4294959104
aria_log_purge_type immediate
aria_max_sort_file_size 9223372036853727232
aria_pagecache_age_threshold 300
-aria_pagecache_buffer_size 134213632
+aria_pagecache_buffer_size 134217720
aria_pagecache_division_limit 100
aria_page_checksum OFF
aria_recover NORMAL
diff --git a/mysql-test/suite/maria/r/ps_maria.result b/mysql-test/suite/maria/r/ps_maria.result
index 04c14f9c1e4..8ac0fee6f50 100644
--- a/mysql-test/suite/maria/r/ps_maria.result
+++ b/mysql-test/suite/maria/r/ps_maria.result
@@ -63,8 +63,8 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63
def test t9 t9 c12 c12 246 10 6 Y 0 4 63
def test t9 t9 c13 c13 10 10 10 Y 128 0 63
def test t9 t9 c14 c14 12 19 19 Y 128 0 63
-def test t9 t9 c15 c15 7 19 19 N 9441 0 63
-def test t9 t9 c16 c16 11 8 8 Y 128 0 63
+def test t9 t9 c15 c15 7 19 19 N 9377 0 63
+def test t9 t9 c16 c16 11 10 8 Y 128 0 63
def test t9 t9 c17 c17 13 4 4 Y 32864 0 63
def test t9 t9 c18 c18 1 4 1 Y 32768 0 63
def test t9 t9 c19 c19 1 1 1 Y 32768 0 63
@@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longblob,
- `const10` int(10) NOT NULL DEFAULT '0',
- `param10` bigint(20) DEFAULT NULL,
+ `const10` decimal(22,6) NOT NULL DEFAULT '0.000000',
+ `param10` decimal(65,30) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
-def test t5 t5 const10 const10 3 10 9 N 32769 0 63
-def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
+def test t5 t5 const10 const10 246 24 16 N 1 6 63
+def test t5 t5 param10 param10 246 67 40 Y 0 30 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861
-param10 662680861
+const10 662680861.000000
+param10 662680861.000000000000000000000000000000
const11 1991
param11 1991
const12 NULL
@@ -2762,46 +2762,212 @@ c12 -9999.9999
execute my_delete ;
test_sequence
-- insert into string columns --
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 20, '20', '20', '20', '20', '20', '20', '20', '20', '20', '20', '20' ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '21' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 22, '22', '22', '22', '22', '22', '22', '22', '22', '22', '22', '22' )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '23';
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 23, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 30, CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary), CAST('30' as binary),
+CAST('30' as binary), CAST('30' as binary) ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= '31' ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 32, CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary), CAST('32' as binary),
+ CAST('32' as binary), CAST('32' as binary) )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= CAST('33' as binary);
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 33, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 41 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 43;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 43, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 50, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 51.0 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 52, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0, 52.0 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 53.0;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 53, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 54, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1, 5.4e+1,
+5.4e+1, 5.4e+1, 5.4e+1 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.5e+1 ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 55, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 56, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1, 5.6e+1,
+ 5.6e+1, 5.6e+1, 5.6e+1 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 5.7e+1;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 57, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 61, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt1 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 2 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 71, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+( 81, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00 ) ;
+prepare stmt2 from "insert into t9
+ ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 )
+values
+ ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
+@arg00, @arg00, @arg00, @arg00 ;
select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30
from t9 where c1 >= 20
order by c1 ;
@@ -2960,70 +3126,208 @@ true
delete from t9 ;
test_sequence
-- insert into date/time columns --
+set @arg00= '1991-01-01 01:01:01' ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 20, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+'1991-01-01 01:01:01', '1991-01-01 01:01:01') ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 21, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 22, '1991-01-01 01:01:01', '1991-01-01 01:01:01', '1991-01-01 01:01:01',
+ '1991-01-01 01:01:01', '1991-01-01 01:01:01')" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 23, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 30, CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime),
+CAST('1991-01-01 01:01:01' as datetime)) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 31, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 32, CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime),
+ CAST('1991-01-01 01:01:01' as datetime))" ;
+execute stmt1 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 33, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Note 1265 Data truncated for column 'c13' at row 1
+Note 1265 Data truncated for column 'c16' at row 1
Warning 1265 Data truncated for column 'c17' at row 1
+set @arg00= 2000000000 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 40, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 ) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 41, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 42, 2000000000, 2000000000, 2000000000, 2000000000, 2000000000 )" ;
+execute stmt1 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 43, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
-Warning 1264 Out of range value for column 'c13' at row 1
-Warning 1264 Out of range value for column 'c14' at row 1
+Warning 1265 Data truncated for column 'c13' at row 1
+Warning 1265 Data truncated for column 'c14' at row 1
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 1.0e+10 ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 50, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 ) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 51, @arg00, @arg00, @arg00, @arg00, @arg00) ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
Warning 1264 Out of range value for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 52, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10, 1.0e+10 )" ;
+execute stmt1 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 53, ?, ?, ?, ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
Warnings:
Warning 1265 Data truncated for column 'c15' at row 1
-Warning 1264 Out of range value for column 'c16' at row 1
+Warning 1265 Data truncated for column 'c16' at row 1
Warning 1264 Out of range value for column 'c17' at row 1
+set @arg00= 'abc' ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 60, NULL, NULL, '1991-01-01 01:01:01',
+NULL, NULL) ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 61, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt1 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 62, NULL, NULL, '1991-01-01 01:01:01',
+ NULL, NULL)" ;
+execute stmt1 ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 63, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 71, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 73, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
+set @arg00= 8.0 ;
+set @arg00= NULL ;
+insert into t9
+( c1, c13, c14, c15, c16, c17 )
+values
+( 81, @arg00, @arg00, '1991-01-01 01:01:01', @arg00, @arg00) ;
+prepare stmt2 from "insert into t9
+ ( c1, c13, c14, c15, c16, c17 )
+values
+ ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ;
+execute stmt2 using @arg00, @arg00, @arg00, @arg00 ;
select c1, c13, c14, c15, c16, c17 from t9 order by c1 ;
c1 c13 c14 c15 c16 c17
20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
@@ -3034,14 +3338,14 @@ c1 c13 c14 c15 c16 c17
31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991
-40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
+53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
61 NULL NULL 1991-01-01 01:01:01 NULL NULL
62 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -3055,25 +3359,25 @@ test_sequence
set @arg00= '1991-01-01 01:01:01' ;
select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
-c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01' ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and
- c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and
+ c15= '1991-01-01 01:01:01' and
c17= '1991-01-01 01:01:01'" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
found
true
set @arg00= CAST('1991-01-01 01:01:01' as datetime) ;
@@ -3081,12 +3385,11 @@ select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
-c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime) ;
found
true
select 'true' as found from t9
-where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00
+where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00
and c17= @arg00 ;
found
true
@@ -3094,14 +3397,43 @@ prepare stmt1 from "select 'true' as found from t9
where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and
c14= CAST('1991-01-01 01:01:01' as datetime) and
c15= CAST('1991-01-01 01:01:01' as datetime) and
- c16= CAST('1991-01-01 01:01:01' as datetime) and
c17= CAST('1991-01-01 01:01:01' as datetime)" ;
execute stmt1 ;
found
true
prepare stmt1 from "select 'true' as found from t9
-where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ;
-execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ;
+where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ;
+execute stmt1 using @arg00, @arg00, @arg00, @arg00 ;
+found
+true
+set @arg00= '01:01:01' ;
+select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
+found
+true
+set @arg00= CAST('01:01:01' as time) ;
+select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ;
+found
+true
+select 'true' as found from t9 where c1= 20 and c16= @arg00 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ;
+execute stmt1 ;
+found
+true
+prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ;
+execute stmt1 using @arg00 ;
found
true
set @arg00= 1991 ;
diff --git a/mysql-test/suite/maria/t/compat_aliases-master.opt b/mysql-test/suite/maria/t/compat_aliases-master.opt
deleted file mode 100644
index 73f18586361..00000000000
--- a/mysql-test/suite/maria/t/compat_aliases-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---maria-max-sort-file-size=100M --aria-repair-threads=10000
diff --git a/mysql-test/suite/maria/t/compat_aliases.test b/mysql-test/suite/maria/t/compat_aliases.test
deleted file mode 100644
index 7b94d24e643..00000000000
--- a/mysql-test/suite/maria/t/compat_aliases.test
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# test for maria* aliases (system variables, status variables,
-# command-line options). They should match aria* variables.
-#
-
---replace_column 5 #
-select * from information_schema.plugins where plugin_name like '%aria';
-
-select maria_vars.variable_name, aria_vars.variable_name from
- information_schema.session_variables as maria_vars left join
- information_schema.session_variables as aria_vars
- on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
- where maria_vars.variable_name like 'maria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-
-select maria_vars.variable_name, aria_vars.variable_name from
- information_schema.session_status as maria_vars left join
- information_schema.session_status as aria_vars
- on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
- where maria_vars.variable_name like 'maria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-
-select maria_vars.variable_name, aria_vars.variable_name from
- information_schema.session_variables as aria_vars left join
- information_schema.session_variables as maria_vars
- on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
- where aria_vars.variable_name like 'aria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-
-select maria_vars.variable_name, aria_vars.variable_name from
- information_schema.session_status as aria_vars left join
- information_schema.session_status as maria_vars
- on (maria_vars.variable_name = concat('m', aria_vars.variable_name))
- where aria_vars.variable_name like 'aria_%'
- and not (maria_vars.variable_value <=> aria_vars.variable_value);
-
-set @old_checkpoint_interval=@@global.aria_checkpoint_interval;
-set global maria_checkpoint_interval=10;
-select @@global.aria_checkpoint_interval;
-set global maria_checkpoint_interval=@old_checkpoint_interval;
-
-set @old_sort_buffer_size=@@global.maria_sort_buffer_size;
-set global aria_sort_buffer_size=1024;
-select @@global.maria_sort_buffer_size;
-set global aria_sort_buffer_size=@old_sort_buffer_size;
-
-set @old_sort_buffer_size=@@session.maria_sort_buffer_size;
-set session aria_sort_buffer_size=2048;
-select @@session.maria_sort_buffer_size;
-set session aria_sort_buffer_size=@old_sort_buffer_size;
-
-set @old_max_sort_file_size=@@global.maria_max_sort_file_size,
- @old_repair_threads=@@global.aria_repair_threads;
-set @@global.maria_max_sort_file_size=default, @@global.aria_repair_threads=default;
---replace_result 4293918720 9223372036853727232
-select @@global.maria_max_sort_file_size, @@global.aria_repair_threads;
-set @@global.aria_max_sort_file_size=@old_max_sort_file_size,
- @@global.maria_repair_threads=@old_repair_threads;
-
diff --git a/mysql-test/suite/maria/t/maria-recover.test b/mysql-test/suite/maria/t/maria-recover.test
index 29b05879967..56259ad9a31 100644
--- a/mysql-test/suite/maria/t/maria-recover.test
+++ b/mysql-test/suite/maria/t/maria-recover.test
@@ -10,7 +10,7 @@ call mtr.add_suppression("Recovering table: '\\..mysqltest.t_corrupted2'");
call mtr.add_suppression("Table '\\..mysqltest.t_corrupted2' is marked as crashed and should be repaired");
call mtr.add_suppression("Table 't_corrupted2' is marked as crashed and should be repaired");
-let $def_checkinterval=`select @@global.maria_checkpoint_interval`;
+let $def_checkinterval=`select @@global.aria_checkpoint_interval`;
--enable_query_log
@@ -39,7 +39,7 @@ insert into t1 values("ThursdayMorningsMarket");
flush table t1; # put index page on disk
insert into t1 select concat(a,'b') from t1 limit 1;
# force a checkpoint to get the open count > 0
-set global maria_checkpoint_interval=1000;
+set global aria_checkpoint_interval=1000;
# Wait for checkpoint to happen
--sleep 1
# now t1 has its open_count>0 and so will t2_corrupted.
diff --git a/mysql-test/suite/maria/t/maria3.test b/mysql-test/suite/maria/t/maria3.test
index b73b75ecfce..bc1dc47337f 100644
--- a/mysql-test/suite/maria/t/maria3.test
+++ b/mysql-test/suite/maria/t/maria3.test
@@ -260,7 +260,7 @@ check table t1 extended;
drop table t1;
# Fix if we are using safemalloc
---replace_result 8388572 8388600
+--replace_result 8388572 8388600 134217692 134217720
select lower(variable_name) as Variable_name, Variable_value as Value from information_schema.session_variables where variable_name like "aria%" and variable_name not like "aria_used_for_temp_tables" order by 1;
--replace_column 2 #
show status like 'aria%';
diff --git a/mysql-test/suite/ndb/r/ndb_basic.result b/mysql-test/suite/ndb/r/ndb_basic.result
index 9f4f8c0755c..ee50352220e 100644
--- a/mysql-test/suite/ndb/r/ndb_basic.result
+++ b/mysql-test/suite/ndb/r/ndb_basic.result
@@ -585,6 +585,8 @@ c127 int,
c128 int,
primary key using hash(c1)) engine=ndb partition by key(c1);
drop table t1;
+create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
+ERROR HY000: Field in list of fields for partition function not found in table
create table t1 (
a1234567890123456789012345678901234567890 int primary key,
a12345678901234567890123456789a1234567890 int,
diff --git a/mysql-test/suite/ndb/t/ndb_basic.test b/mysql-test/suite/ndb/t/ndb_basic.test
index 2fc140288ca..5d6221d1784 100644
--- a/mysql-test/suite/ndb/t/ndb_basic.test
+++ b/mysql-test/suite/ndb/t/ndb_basic.test
@@ -548,6 +548,13 @@ primary key using hash(c1)) engine=ndb partition by key(c1);
drop table t1;
#
+# test bug#53354 - crash when creating partitioned table with multiple columns in the partition key
+#
+
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
+
+#
# test max size of attribute name and truncation
#
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1-innodb.result b/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1-innodb.result
index 94b024a9c8f..96c8e1c6d43 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1-innodb.result
+++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1-innodb.result
@@ -1,4 +1,5 @@
-set optimizer_use_mrr='disable';
+set @bug41996_extra1_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=off';
DROP DATABASE IF EXISTS d1;
DROP DATABASE IF EXISTS d2;
DROP DATABASE IF EXISTS d3;
@@ -1106,3 +1107,4 @@ c1 c2
DROP DATABASE d1;
DROP DATABASE d2;
DROP DATABASE d3;
+set optimizer_switch=@bug41996_extra1_tmp;
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1.result b/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1.result
index 94b024a9c8f..ab24c2c1166 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1.result
+++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug41996-extra1.result
@@ -1,4 +1,5 @@
-set optimizer_use_mrr='disable';
+set @bug41996_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=off';
DROP DATABASE IF EXISTS d1;
DROP DATABASE IF EXISTS d2;
DROP DATABASE IF EXISTS d3;
@@ -1106,3 +1107,4 @@ c1 c2
DROP DATABASE d1;
DROP DATABASE d2;
DROP DATABASE d3;
+set optimizer_switch=@bug41996_tmp;
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/r/bug43618.result b/mysql-test/suite/optimizer_unfixed_bugs/r/bug43618.result
index 4350c912a31..35cbe35bc7e 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug43618.result
+++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug43618.result
@@ -43,15 +43,9 @@ SELECT * FROM t1 WHERE c1 BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' ORDER B
c1 c2 c3 c4
2009-01-29 11:11:27 2009-01-29 00:00:00 2009-01-29 2009-01-29 00:00:00
2008-01-01 00:00:00 NULL 2008-01-02 2008-01-03 00:00:00
-Warnings:
-Warning 1292 Incorrect datetime value: '2010-00-01 00:00:00' for column 'c1' at row 1
-Warning 1292 Incorrect datetime value: '2010-00-01 00:00:00' for column 'c1' at row 1
SELECT * FROM t1 WHERE c2 BETWEEN '1971-01-01 00:00:01' AND '2010-10-00 00:00:00' ORDER BY c2 DESC LIMIT 2;
c1 c2 c3 c4
2009-01-29 11:11:27 2009-01-29 00:00:00 2009-01-29 2009-01-29 00:00:00
2007-05-25 00:00:00 2007-05-25 00:00:00 2007-05-26 2007-05-26 00:00:00
-Warnings:
-Warning 1292 Incorrect datetime value: '2010-10-00 00:00:00' for column 'c2' at row 1
-Warning 1292 Incorrect datetime value: '2010-10-00 00:00:00' for column 'c2' at row 1
DROP TABLE t1;
set time_zone= @save_time_zone;
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1-innodb.test b/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1-innodb.test
index deb90136326..09fcccb06d1 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1-innodb.test
+++ b/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1-innodb.test
@@ -1,4 +1,5 @@
-set optimizer_use_mrr='disable';
+set @bug41996_extra1_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=off';
--disable_warnings
DROP DATABASE IF EXISTS d1;
DROP DATABASE IF EXISTS d2;
@@ -484,4 +485,5 @@ SELECT * FROM d3.t3 ORDER BY c1;
DROP DATABASE d1;
DROP DATABASE d2;
DROP DATABASE d3;
+set optimizer_switch=@bug41996_extra1_tmp;
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1.test b/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1.test
index deb90136326..5170ec22c59 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1.test
+++ b/mysql-test/suite/optimizer_unfixed_bugs/t/bug41996-extra1.test
@@ -1,4 +1,5 @@
-set optimizer_use_mrr='disable';
+set @bug41996_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=off';
--disable_warnings
DROP DATABASE IF EXISTS d1;
DROP DATABASE IF EXISTS d2;
@@ -484,4 +485,4 @@ SELECT * FROM d3.t3 ORDER BY c1;
DROP DATABASE d1;
DROP DATABASE d2;
DROP DATABASE d3;
-
+set optimizer_switch=@bug41996_tmp;
diff --git a/mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test b/mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test
index 0daa1c3c739..0b1e560b58d 100644
--- a/mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test
+++ b/mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test
@@ -26,6 +26,7 @@ CREATE TABLE t3(
disable_query_log;
+begin;
let $1 = 100;
while ($1)
{
@@ -44,6 +45,7 @@ while ($1)
}
dec $1;
}
+commit;
enable_query_log;
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc
index 49d0b6fc69f..844ba70df4a 100644
--- a/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc
@@ -16,12 +16,14 @@
--echo --- Delete rows and partitions of tables with $sqlfunc
--echo -------------------------------------------------------------------------
+begin;
eval delete from $t1 where col1=$val2;
eval delete from $t2 where col1=$val2;
eval delete from $t3 where col1=$val2;
eval delete from $t4 where col1=$val2;
eval delete from $t5 where col1=$val2;
eval delete from $t6 where col1=$val2;
+commit;
eval select * from $t1 order by col1;
eval select * from $t2 order by col1;
@@ -29,12 +31,14 @@ eval select * from $t3 order by col1;
eval select * from $t4 order by colint;
eval select * from $t5 order by colint;
+begin;
eval insert into $t1 values ($val2);
eval insert into $t2 values ($val2);
eval insert into $t3 values ($val2);
eval insert into $t4 values (60,$val2);
eval insert into $t5 values (60,$val2);
eval insert into $t6 values (60,$val2);
+commit;
eval select * from $t1 order by col1;
eval select * from $t2 order by col1;
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
index b7a170dd9d8..565731db75b 100644
--- a/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
@@ -114,7 +114,7 @@ let $val4 = '10:30';
let $sqlfunc = microsecond(col1);
let $valsqlfunc = microsecond('10:30:10.000010');
-let $coltype = time;
+let $coltype = time(6);
let $infile = part_supported_sql_funcs_int_time.inc;
let $val1 = '09:09:15.000002';
let $val2 = '04:30:01.000018';
@@ -164,6 +164,8 @@ let $val3 = '2006-09-25';
let $val4 = '2006-07-30';
--source suite/parts/inc/partition_supported_sql_funcs.inc
+# time_to_sec() is now a double function, so it can't be portioned upon
+--disable_parsing
let $sqlfunc = time_to_sec(col1)-(time_to_sec(col1)-20);
let $valsqlfunc = time_to_sec('18:30:14')-(time_to_sec('17:59:59'));
let $coltype = time;
@@ -173,6 +175,7 @@ let $val2 = '14:30:45';
let $val3 = '21:59:22';
let $val4 = '10:33:11';
--source suite/parts/inc/partition_supported_sql_funcs.inc
+--enable_parsing
# to_days(non_date_col) is disabled after bug#54483.
#let $sqlfunc = to_days(col1)-to_days('2006-01-01');
diff --git a/mysql-test/suite/parts/inc/partition_check_drop.inc b/mysql-test/suite/parts/inc/partition_check_drop.inc
index cd4a4cfe2f5..517e13bb1c3 100644
--- a/mysql-test/suite/parts/inc/partition_check_drop.inc
+++ b/mysql-test/suite/parts/inc/partition_check_drop.inc
@@ -69,7 +69,7 @@ if ($found_garbage)
--remove_files_wildcard $MYSQLD_DATADIR/test t1*
if ($with_directories)
{
- --remove_files_wildcard $MYSQLD_DATADIR/test/tmp t1*
+ --remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*
}
}
--enable_query_log
diff --git a/mysql-test/suite/parts/inc/partition_layout_check1.inc b/mysql-test/suite/parts/inc/partition_layout_check1.inc
index bca41b6f9c7..66a93d5d8d7 100644
--- a/mysql-test/suite/parts/inc/partition_layout_check1.inc
+++ b/mysql-test/suite/parts/inc/partition_layout_check1.inc
@@ -29,14 +29,10 @@ DELETE FROM t0_definition;
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
-# Dump the current definition of the table t1 to tmp1
-# This complicated method - let another mysqltest collect the output - is used
-# because of two reasons
+# Save the current definition of the table t1
# - SHOW CREATE TABLE t1 is at least currently most probably more reliable than
# the corresponding SELECT on the INFORMATION_SCHEMA
-# - SHOW CREATE TABLE .. cannot write its out put into a file like SELECT
-let $show_file= $MYSQLD_DATADIR/test/tmp1;
---exec echo "SHOW CREATE TABLE t1; exit; " | $MYSQL_TEST > $show_file 2>&1
+let $show_create= `SHOW CREATE TABLE t1`;
if ($do_file_tests)
{
# List the files belonging to the table t1
@@ -57,12 +53,13 @@ if (!$do_file_tests)
# Insert the current definition of the table t1 into t0_definition
eval INSERT INTO t0_definition SET state = 'old',
- create_command = load_file('$show_file'),
+ create_command = "$show_create",
file_list = @aux;
# Print the create table statement into the protocol
+# Added the concat to avoid changing the result files
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR '\r' ''
-SELECT create_command FROM t0_definition WHERE state = 'old';
+SELECT concat('SHOW CREATE TABLE t1;\nTable\tCreate Table\n',create_command,'\n') as `create_command` FROM t0_definition WHERE state = 'old';
if ($do_file_tests)
{
# We stored the list of files, therefore printing the content makes sense
diff --git a/mysql-test/suite/parts/inc/partition_layout_check2.inc b/mysql-test/suite/parts/inc/partition_layout_check2.inc
index 7ff871a4c45..2f74455a811 100644
--- a/mysql-test/suite/parts/inc/partition_layout_check2.inc
+++ b/mysql-test/suite/parts/inc/partition_layout_check2.inc
@@ -28,9 +28,8 @@ DELETE FROM t0_definition WHERE state = 'new';
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
-# Dump the current definition of the table t1 to tmp1
-let $show_file= $MYSQLD_DATADIR/test/tmp1;
---exec echo "SHOW CREATE TABLE t1; exit; " | $MYSQL_TEST > $show_file 2>&1
+# Save the current definition of the table t1
+let $show_create= `SHOW CREATE TABLE t1`;
if ($do_file_tests)
{
@@ -52,7 +51,7 @@ if (!$do_file_tests)
# Insert the current definition of the table t1 into t0_definition
eval INSERT INTO t0_definition SET state = 'new',
- create_command = load_file('$show_file'),
+ create_command = "$show_create",
file_list = @aux;
# Print the old and new table layout, if they differ
diff --git a/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc b/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc
index 83d0fa37375..0de6bd7d2f5 100644
--- a/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc
+++ b/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc
@@ -113,6 +113,7 @@ $part_t6;
--echo --- Access tables with $sqlfunc
--echo -------------------------------------------------------------------------
+begin;
eval insert into t1 values ($val1);
eval insert into t1 values ($val2);
@@ -123,6 +124,7 @@ eval insert into t2 values ($val3);
eval insert into t3 values ($val1);
eval insert into t3 values ($val2);
eval insert into t3 values ($val3);
+commit;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data infile '$MYSQLTEST_VARDIR/std_data/parts/$infile' into table t4;
@@ -142,12 +144,14 @@ select * from t6 order by colint;
if ($do_long_tests)
{
+ begin;
eval update t1 set col1=$val4 where col1=$val1;
eval update t2 set col1=$val4 where col1=$val1;
eval update t3 set col1=$val4 where col1=$val1;
eval update t4 set col1=$val4 where col1=$val1;
eval update t5 set col1=$val4 where col1=$val1;
eval update t6 set col1=$val4 where col1=$val1;
+ commit;
select * from t1 order by col1;
select * from t2 order by col1;
diff --git a/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result b/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result
index c5b4e0a8665..c4eeb25d6b4 100644
--- a/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result
+++ b/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result
@@ -47,6 +47,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with abs(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values (5 );
insert into t1 values (13 );
insert into t2 values (5 );
@@ -55,6 +56,7 @@ insert into t2 values (17 );
insert into t3 values (5 );
insert into t3 values (13 );
insert into t3 values (17 );
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6;
@@ -217,12 +219,14 @@ colint col1
50 56
51 34
55 123
+begin;
update t1 set col1=15 where col1=5 ;
update t2 set col1=15 where col1=5 ;
update t3 set col1=15 where col1=5 ;
update t4 set col1=15 where col1=5 ;
update t5 set col1=15 where col1=5 ;
update t6 set col1=15 where col1=5 ;
+commit;
select * from t1 order by col1;
col1
13
@@ -877,12 +881,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with abs(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1=13 ;
delete from t2 where col1=13 ;
delete from t3 where col1=13 ;
delete from t4 where col1=13 ;
delete from t5 where col1=13 ;
delete from t6 where col1=13 ;
+commit;
select * from t1 order by col1;
col1
15
@@ -986,12 +992,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t1 values (13 );
insert into t2 values (13 );
insert into t3 values (13 );
insert into t4 values (60,13 );
insert into t5 values (60,13 );
insert into t6 values (60,13 );
+commit;
select * from t1 order by col1;
col1
13
@@ -1274,12 +1282,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with abs(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1=13 ;
delete from t22 where col1=13 ;
delete from t33 where col1=13 ;
delete from t44 where col1=13 ;
delete from t55 where col1=13 ;
delete from t66 where col1=13 ;
+commit;
select * from t11 order by col1;
col1
15
@@ -1383,12 +1393,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t11 values (13 );
insert into t22 values (13 );
insert into t33 values (13 );
insert into t44 values (60,13 );
insert into t55 values (60,13 );
insert into t66 values (60,13 );
+commit;
select * from t11 order by col1;
col1
13
@@ -1732,6 +1744,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with mod(col1,10)
-------------------------------------------------------------------------
+begin;
insert into t1 values (5);
insert into t1 values (19);
insert into t2 values (5);
@@ -1740,6 +1753,7 @@ insert into t2 values (17);
insert into t3 values (5);
insert into t3 values (19);
insert into t3 values (17);
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6;
@@ -1902,12 +1916,14 @@ colint col1
50 56
51 34
55 123
+begin;
update t1 set col1=15 where col1=5;
update t2 set col1=15 where col1=5;
update t3 set col1=15 where col1=5;
update t4 set col1=15 where col1=5;
update t5 set col1=15 where col1=5;
update t6 set col1=15 where col1=5;
+commit;
select * from t1 order by col1;
col1
15
@@ -2562,12 +2578,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with mod(col1,10)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1=19;
delete from t2 where col1=19;
delete from t3 where col1=19;
delete from t4 where col1=19;
delete from t5 where col1=19;
delete from t6 where col1=19;
+commit;
select * from t1 order by col1;
col1
15
@@ -2673,12 +2691,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t1 values (19);
insert into t2 values (19);
insert into t3 values (19);
insert into t4 values (60,19);
insert into t5 values (60,19);
insert into t6 values (60,19);
+commit;
select * from t1 order by col1;
col1
15
@@ -2970,12 +2990,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with mod(col1,10)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1=19;
delete from t22 where col1=19;
delete from t33 where col1=19;
delete from t44 where col1=19;
delete from t55 where col1=19;
delete from t66 where col1=19;
+commit;
select * from t11 order by col1;
col1
15
@@ -3081,12 +3103,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t11 values (19);
insert into t22 values (19);
insert into t33 values (19);
insert into t44 values (60,19);
insert into t55 values (60,19);
insert into t66 values (60,19);
+commit;
select * from t11 order by col1;
col1
15
@@ -3439,6 +3463,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with day(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-02-03');
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-02-03');
@@ -3447,6 +3472,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-02-03');
insert into t3 values ('2006-01-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -3486,12 +3512,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-02-03';
update t2 set col1='2006-02-05' where col1='2006-02-03';
update t3 set col1='2006-02-05' where col1='2006-02-03';
update t4 set col1='2006-02-05' where col1='2006-02-03';
update t5 set col1='2006-02-05' where col1='2006-02-03';
update t6 set col1='2006-02-05' where col1='2006-02-03';
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -3695,12 +3723,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with day(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-01-17';
delete from t2 where col1='2006-01-17';
delete from t3 where col1='2006-01-17';
delete from t4 where col1='2006-01-17';
delete from t5 where col1='2006-01-17';
delete from t6 where col1='2006-01-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -3722,12 +3752,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-17');
insert into t3 values ('2006-01-17');
insert into t4 values (60,'2006-01-17');
insert into t5 values (60,'2006-01-17');
insert into t6 values (60,'2006-01-17');
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -3789,12 +3821,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with day(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-01-17';
delete from t22 where col1='2006-01-17';
delete from t33 where col1='2006-01-17';
delete from t44 where col1='2006-01-17';
delete from t55 where col1='2006-01-17';
delete from t66 where col1='2006-01-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -3816,12 +3850,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-01-17');
insert into t22 values ('2006-01-17');
insert into t33 values ('2006-01-17');
insert into t44 values (60,'2006-01-17');
insert into t55 values (60,'2006-01-17');
insert into t66 values (60,'2006-01-17');
+commit;
select * from t11 order by col1;
col1
2006-01-17
@@ -3944,6 +3980,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with dayofmonth(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-02-03');
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-02-03');
@@ -3952,6 +3989,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-02-03');
insert into t3 values ('2006-01-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -3991,12 +4029,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-02-03';
update t2 set col1='2006-02-05' where col1='2006-02-03';
update t3 set col1='2006-02-05' where col1='2006-02-03';
update t4 set col1='2006-02-05' where col1='2006-02-03';
update t5 set col1='2006-02-05' where col1='2006-02-03';
update t6 set col1='2006-02-05' where col1='2006-02-03';
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -4200,12 +4240,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofmonth(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-01-17';
delete from t2 where col1='2006-01-17';
delete from t3 where col1='2006-01-17';
delete from t4 where col1='2006-01-17';
delete from t5 where col1='2006-01-17';
delete from t6 where col1='2006-01-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4227,12 +4269,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-17');
insert into t3 values ('2006-01-17');
insert into t4 values (60,'2006-01-17');
insert into t5 values (60,'2006-01-17');
insert into t6 values (60,'2006-01-17');
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -4294,12 +4338,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofmonth(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-01-17';
delete from t22 where col1='2006-01-17';
delete from t33 where col1='2006-01-17';
delete from t44 where col1='2006-01-17';
delete from t55 where col1='2006-01-17';
delete from t66 where col1='2006-01-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -4321,12 +4367,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-01-17');
insert into t22 values ('2006-01-17');
insert into t33 values ('2006-01-17');
insert into t44 values (60,'2006-01-17');
insert into t55 values (60,'2006-01-17');
insert into t66 values (60,'2006-01-17');
+commit;
select * from t11 order by col1;
col1
2006-01-17
@@ -4449,6 +4497,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with dayofweek(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-01-03');
@@ -4457,6 +4506,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-02-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -4496,12 +4546,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-01-03';
update t2 set col1='2006-02-05' where col1='2006-01-03';
update t3 set col1='2006-02-05' where col1='2006-01-03';
update t4 set col1='2006-02-05' where col1='2006-01-03';
update t5 set col1='2006-02-05' where col1='2006-01-03';
update t6 set col1='2006-02-05' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4705,12 +4757,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofweek(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-02-17';
delete from t2 where col1='2006-02-17';
delete from t3 where col1='2006-02-17';
delete from t4 where col1='2006-02-17';
delete from t5 where col1='2006-02-17';
delete from t6 where col1='2006-02-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4734,12 +4788,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-02-17');
insert into t3 values ('2006-02-17');
insert into t4 values (60,'2006-02-17');
insert into t5 values (60,'2006-02-17');
insert into t6 values (60,'2006-02-17');
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4805,12 +4861,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofweek(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-02-17';
delete from t22 where col1='2006-02-17';
delete from t33 where col1='2006-02-17';
delete from t44 where col1='2006-02-17';
delete from t55 where col1='2006-02-17';
delete from t66 where col1='2006-02-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -4834,12 +4892,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-02-17');
insert into t22 values ('2006-02-17');
insert into t33 values ('2006-02-17');
insert into t44 values (60,'2006-02-17');
insert into t55 values (60,'2006-02-17');
insert into t66 values (60,'2006-02-17');
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -4966,6 +5026,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with dayofyear(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-03');
@@ -4974,6 +5035,7 @@ insert into t2 values ('2006-02-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-01-17');
insert into t3 values ('2006-02-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -5013,12 +5075,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-01-03';
update t2 set col1='2006-02-05' where col1='2006-01-03';
update t3 set col1='2006-02-05' where col1='2006-01-03';
update t4 set col1='2006-02-05' where col1='2006-01-03';
update t5 set col1='2006-02-05' where col1='2006-01-03';
update t6 set col1='2006-02-05' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -5222,12 +5286,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofyear(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-01-17';
delete from t2 where col1='2006-01-17';
delete from t3 where col1='2006-01-17';
delete from t4 where col1='2006-01-17';
delete from t5 where col1='2006-01-17';
delete from t6 where col1='2006-01-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5249,12 +5315,14 @@ colint col1
1 2006-02-03
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-17');
insert into t3 values ('2006-01-17');
insert into t4 values (60,'2006-01-17');
insert into t5 values (60,'2006-01-17');
insert into t6 values (60,'2006-01-17');
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -5317,12 +5385,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofyear(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-01-17';
delete from t22 where col1='2006-01-17';
delete from t33 where col1='2006-01-17';
delete from t44 where col1='2006-01-17';
delete from t55 where col1='2006-01-17';
delete from t66 where col1='2006-01-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -5344,12 +5414,14 @@ colint col1
1 2006-02-03
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-01-17');
insert into t22 values ('2006-01-17');
insert into t33 values ('2006-01-17');
insert into t44 values (60,'2006-01-17');
insert into t55 values (60,'2006-01-17');
insert into t66 values (60,'2006-01-17');
+commit;
select * from t11 order by col1;
col1
2006-01-17
@@ -5473,6 +5545,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with extract(month from col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-01-03');
@@ -5481,6 +5554,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-02-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -5520,12 +5594,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-01-03';
update t2 set col1='2006-02-05' where col1='2006-01-03';
update t3 set col1='2006-02-05' where col1='2006-01-03';
update t4 set col1='2006-02-05' where col1='2006-01-03';
update t5 set col1='2006-02-05' where col1='2006-01-03';
update t6 set col1='2006-02-05' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5729,12 +5805,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with extract(month from col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-02-17';
delete from t2 where col1='2006-02-17';
delete from t3 where col1='2006-02-17';
delete from t4 where col1='2006-02-17';
delete from t5 where col1='2006-02-17';
delete from t6 where col1='2006-02-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5758,12 +5836,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-02-17');
insert into t3 values ('2006-02-17');
insert into t4 values (60,'2006-02-17');
insert into t5 values (60,'2006-02-17');
insert into t6 values (60,'2006-02-17');
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5824,12 +5904,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with extract(month from col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-02-17';
delete from t22 where col1='2006-02-17';
delete from t33 where col1='2006-02-17';
delete from t44 where col1='2006-02-17';
delete from t55 where col1='2006-02-17';
delete from t66 where col1='2006-02-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -5853,12 +5935,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-02-17');
insert into t22 values ('2006-02-17');
insert into t33 values ('2006-02-17');
insert into t44 values (60,'2006-02-17');
insert into t55 values (60,'2006-02-17');
insert into t66 values (60,'2006-02-17');
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -5980,6 +6064,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with hour(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09');
insert into t1 values ('14:30');
insert into t2 values ('09:09');
@@ -5988,6 +6073,7 @@ insert into t2 values ('21:59');
insert into t3 values ('09:09');
insert into t3 values ('14:30');
insert into t3 values ('21:59');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
@@ -6027,12 +6113,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
update t1 set col1='10:30' where col1='09:09';
update t2 set col1='10:30' where col1='09:09';
update t3 set col1='10:30' where col1='09:09';
update t4 set col1='10:30' where col1='09:09';
update t5 set col1='10:30' where col1='09:09';
update t6 set col1='10:30' where col1='09:09';
+commit;
select * from t1 order by col1;
col1
10:30:00
@@ -6236,12 +6324,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with hour(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='14:30';
delete from t2 where col1='14:30';
delete from t3 where col1='14:30';
delete from t4 where col1='14:30';
delete from t5 where col1='14:30';
delete from t6 where col1='14:30';
+commit;
select * from t1 order by col1;
col1
10:30:00
@@ -6265,12 +6355,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t1 values ('14:30');
insert into t2 values ('14:30');
insert into t3 values ('14:30');
insert into t4 values (60,'14:30');
insert into t5 values (60,'14:30');
insert into t6 values (60,'14:30');
+commit;
select * from t1 order by col1;
col1
10:30:00
@@ -6334,12 +6426,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with hour(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='14:30';
delete from t22 where col1='14:30';
delete from t33 where col1='14:30';
delete from t44 where col1='14:30';
delete from t55 where col1='14:30';
delete from t66 where col1='14:30';
+commit;
select * from t11 order by col1;
col1
10:30:00
@@ -6363,12 +6457,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t11 values ('14:30');
insert into t22 values ('14:30');
insert into t33 values ('14:30');
insert into t44 values (60,'14:30');
insert into t55 values (60,'14:30');
insert into t66 values (60,'14:30');
+commit;
select * from t11 order by col1;
col1
10:30:00
@@ -6445,7 +6541,7 @@ drop table if exists t44 ;
drop table if exists t55 ;
drop table if exists t66 ;
-------------------------------------------------------------------------
---- microsecond(col1) in partition with coltype time
+--- microsecond(col1) in partition with coltype time(6)
-------------------------------------------------------------------------
drop table if exists t1 ;
drop table if exists t2 ;
@@ -6456,11 +6552,11 @@ drop table if exists t6 ;
-------------------------------------------------------------------------
--- Create tables with microsecond(col1)
-------------------------------------------------------------------------
-create table t1 (col1 time) engine='INNODB'
+create table t1 (col1 time(6)) engine='INNODB'
partition by range(microsecond(col1))
(partition p0 values less than (15),
partition p1 values less than maxvalue);
-create table t2 (col1 time) engine='INNODB'
+create table t2 (col1 time(6)) engine='INNODB'
partition by list(microsecond(col1))
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
@@ -6469,14 +6565,14 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40),
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
);
-create table t3 (col1 time) engine='INNODB'
+create table t3 (col1 time(6)) engine='INNODB'
partition by hash(microsecond(col1));
-create table t4 (colint int, col1 time) engine='INNODB'
+create table t4 (colint int, col1 time(6)) engine='INNODB'
partition by range(colint)
subpartition by hash(microsecond(col1)) subpartitions 2
(partition p0 values less than (15),
partition p1 values less than maxvalue);
-create table t5 (colint int, col1 time) engine='INNODB'
+create table t5 (colint int, col1 time(6)) engine='INNODB'
partition by list(colint)
subpartition by hash(microsecond(col1)) subpartitions 2
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
@@ -6486,13 +6582,14 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40),
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
);
-create table t6 (colint int, col1 time) engine='INNODB'
+create table t6 (colint int, col1 time(6)) engine='INNODB'
partition by range(colint)
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with microsecond(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09:15.000002');
insert into t1 values ('04:30:01.000018');
insert into t2 values ('09:09:15.000002');
@@ -6501,83 +6598,86 @@ insert into t2 values ('00:59:22.000024');
insert into t3 values ('09:09:15.000002');
insert into t3 values ('04:30:01.000018');
insert into t3 values ('00:59:22.000024');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
select microsecond(col1) from t1 order by col1;
microsecond(col1)
-0
-0
+18
+2
select * from t1 order by col1;
col1
-04:30:01
-09:09:15
+04:30:01.000018
+09:09:15.000002
select * from t2 order by col1;
col1
-00:59:22
-04:30:01
-09:09:15
+00:59:22.000024
+04:30:01.000018
+09:09:15.000002
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-09:09:15
+00:59:22.000024
+04:30:01.000018
+09:09:15.000002
select * from t4 order by colint;
colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t5 order by colint;
colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t6 order by colint;
colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+begin;
update t1 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t2 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t3 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t4 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t5 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t6 set col1='05:30:34.000037' where col1='09:09:15.000002';
+commit;
select * from t1 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t2 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t4 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t5 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t6 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
-------------------------------------------------------------------------
--- Alter tables with microsecond(col1)
-------------------------------------------------------------------------
@@ -6629,36 +6729,36 @@ partition by range(colint)
partition p1 values less than maxvalue);
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t22 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t44 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t55 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
---------------------------
---- some alter table begin
---------------------------
@@ -6667,16 +6767,16 @@ reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
alter table t11
reorganize partition s1 into
(partition p0 values less than (15),
partition p1 values less than maxvalue);
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
alter table t55
partition by list(colint)
subpartition by hash(microsecond(col1)) subpartitions 5
@@ -6691,7 +6791,7 @@ show create table t55;
Table Create Table
t55 CREATE TABLE `t55` (
`colint` int(11) DEFAULT NULL,
- `col1` time DEFAULT NULL
+ `col1` time(6) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (colint)
SUBPARTITION BY HASH (microsecond(col1))
@@ -6704,116 +6804,120 @@ SUBPARTITIONS 5
PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
select * from t55 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition s1 into
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition s1 into
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with microsecond(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='04:30:01.000018';
delete from t2 where col1='04:30:01.000018';
delete from t3 where col1='04:30:01.000018';
delete from t4 where col1='04:30:01.000018';
delete from t5 where col1='04:30:01.000018';
delete from t6 where col1='04:30:01.000018';
+commit;
select * from t1 order by col1;
col1
-05:30:34
+05:30:34.000037
select * from t2 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t4 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
select * from t5 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+begin;
insert into t1 values ('04:30:01.000018');
insert into t2 values ('04:30:01.000018');
insert into t3 values ('04:30:01.000018');
insert into t4 values (60,'04:30:01.000018');
insert into t5 values (60,'04:30:01.000018');
insert into t6 values (60,'04:30:01.000018');
+commit;
select * from t1 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t2 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t4 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t5 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t6 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
alter table t1 drop partition p0;
alter table t2 drop partition p0;
alter table t4 drop partition p0;
@@ -6821,90 +6925,99 @@ alter table t5 drop partition p0;
alter table t6 drop partition p0;
select * from t1 order by col1;
col1
+04:30:01.000018
+05:30:34.000037
select * from t2 order by col1;
col1
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t4 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t5 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t6 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with microsecond(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='04:30:01.000018';
delete from t22 where col1='04:30:01.000018';
delete from t33 where col1='04:30:01.000018';
delete from t44 where col1='04:30:01.000018';
delete from t55 where col1='04:30:01.000018';
delete from t66 where col1='04:30:01.000018';
+commit;
select * from t11 order by col1;
col1
-05:30:34
+05:30:34.000037
select * from t22 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t44 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
select * from t55 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+begin;
insert into t11 values ('04:30:01.000018');
insert into t22 values ('04:30:01.000018');
insert into t33 values ('04:30:01.000018');
insert into t44 values (60,'04:30:01.000018');
insert into t55 values (60,'04:30:01.000018');
insert into t66 values (60,'04:30:01.000018');
+commit;
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t22 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t44 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t55 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t66 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
alter table t11 drop partition p0;
alter table t22 drop partition p0;
alter table t44 drop partition p0;
@@ -6912,22 +7025,27 @@ alter table t55 drop partition p0;
alter table t66 drop partition p0;
select * from t11 order by col1;
col1
+04:30:01.000018
+05:30:34.000037
select * from t22 order by col1;
col1
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t44 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t55 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t66 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
-------------------------
---- some alter table end
-------------------------
@@ -6992,6 +7110,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with minute(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09:15');
insert into t1 values ('14:30:45');
insert into t2 values ('09:09:15');
@@ -7000,6 +7119,7 @@ insert into t2 values ('21:59:22');
insert into t3 values ('09:09:15');
insert into t3 values ('14:30:45');
insert into t3 values ('21:59:22');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
@@ -7039,12 +7159,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
update t1 set col1='10:24:23' where col1='09:09:15';
update t2 set col1='10:24:23' where col1='09:09:15';
update t3 set col1='10:24:23' where col1='09:09:15';
update t4 set col1='10:24:23' where col1='09:09:15';
update t5 set col1='10:24:23' where col1='09:09:15';
update t6 set col1='10:24:23' where col1='09:09:15';
+commit;
select * from t1 order by col1;
col1
10:24:23
@@ -7248,12 +7370,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with minute(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='14:30:45';
delete from t2 where col1='14:30:45';
delete from t3 where col1='14:30:45';
delete from t4 where col1='14:30:45';
delete from t5 where col1='14:30:45';
delete from t6 where col1='14:30:45';
+commit;
select * from t1 order by col1;
col1
10:24:23
@@ -7277,12 +7401,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t1 values ('14:30:45');
insert into t2 values ('14:30:45');
insert into t3 values ('14:30:45');
insert into t4 values (60,'14:30:45');
insert into t5 values (60,'14:30:45');
insert into t6 values (60,'14:30:45');
+commit;
select * from t1 order by col1;
col1
10:24:23
@@ -7349,12 +7475,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with minute(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='14:30:45';
delete from t22 where col1='14:30:45';
delete from t33 where col1='14:30:45';
delete from t44 where col1='14:30:45';
delete from t55 where col1='14:30:45';
delete from t66 where col1='14:30:45';
+commit;
select * from t11 order by col1;
col1
10:24:23
@@ -7378,12 +7506,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t11 values ('14:30:45');
insert into t22 values ('14:30:45');
insert into t33 values ('14:30:45');
insert into t44 values (60,'14:30:45');
insert into t55 values (60,'14:30:45');
insert into t66 values (60,'14:30:45');
+commit;
select * from t11 order by col1;
col1
10:24:23
@@ -7511,6 +7641,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with second(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09:09');
insert into t1 values ('14:30:20');
insert into t2 values ('09:09:09');
@@ -7519,6 +7650,7 @@ insert into t2 values ('21:59:22');
insert into t3 values ('09:09:09');
insert into t3 values ('14:30:20');
insert into t3 values ('21:59:22');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
@@ -7558,12 +7690,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
update t1 set col1='10:22:33' where col1='09:09:09';
update t2 set col1='10:22:33' where col1='09:09:09';
update t3 set col1='10:22:33' where col1='09:09:09';
update t4 set col1='10:22:33' where col1='09:09:09';
update t5 set col1='10:22:33' where col1='09:09:09';
update t6 set col1='10:22:33' where col1='09:09:09';
+commit;
select * from t1 order by col1;
col1
10:22:33
@@ -7767,12 +7901,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with second(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='14:30:20';
delete from t2 where col1='14:30:20';
delete from t3 where col1='14:30:20';
delete from t4 where col1='14:30:20';
delete from t5 where col1='14:30:20';
delete from t6 where col1='14:30:20';
+commit;
select * from t1 order by col1;
col1
10:22:33
@@ -7796,12 +7932,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t1 values ('14:30:20');
insert into t2 values ('14:30:20');
insert into t3 values ('14:30:20');
insert into t4 values (60,'14:30:20');
insert into t5 values (60,'14:30:20');
insert into t6 values (60,'14:30:20');
+commit;
select * from t1 order by col1;
col1
10:22:33
@@ -7868,12 +8006,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with second(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='14:30:20';
delete from t22 where col1='14:30:20';
delete from t33 where col1='14:30:20';
delete from t44 where col1='14:30:20';
delete from t55 where col1='14:30:20';
delete from t66 where col1='14:30:20';
+commit;
select * from t11 order by col1;
col1
10:22:33
@@ -7897,12 +8037,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t11 values ('14:30:20');
insert into t22 values ('14:30:20');
insert into t33 values ('14:30:20');
insert into t44 values (60,'14:30:20');
insert into t55 values (60,'14:30:20');
insert into t66 values (60,'14:30:20');
+commit;
select * from t11 order by col1;
col1
10:22:33
@@ -8030,6 +8172,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with month(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-01-03');
@@ -8038,6 +8181,7 @@ insert into t2 values ('2006-05-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-12-17');
insert into t3 values ('2006-05-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -8077,12 +8221,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-11-06' where col1='2006-01-03';
update t2 set col1='2006-11-06' where col1='2006-01-03';
update t3 set col1='2006-11-06' where col1='2006-01-03';
update t4 set col1='2006-11-06' where col1='2006-01-03';
update t5 set col1='2006-11-06' where col1='2006-01-03';
update t6 set col1='2006-11-06' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-11-06
@@ -8286,12 +8432,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with month(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-12-17';
delete from t2 where col1='2006-12-17';
delete from t3 where col1='2006-12-17';
delete from t4 where col1='2006-12-17';
delete from t5 where col1='2006-12-17';
delete from t6 where col1='2006-12-17';
+commit;
select * from t1 order by col1;
col1
2006-11-06
@@ -8315,12 +8463,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-12-17');
insert into t3 values ('2006-12-17');
insert into t4 values (60,'2006-12-17');
insert into t5 values (60,'2006-12-17');
insert into t6 values (60,'2006-12-17');
+commit;
select * from t1 order by col1;
col1
2006-11-06
@@ -8384,12 +8534,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with month(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-12-17';
delete from t22 where col1='2006-12-17';
delete from t33 where col1='2006-12-17';
delete from t44 where col1='2006-12-17';
delete from t55 where col1='2006-12-17';
delete from t66 where col1='2006-12-17';
+commit;
select * from t11 order by col1;
col1
2006-11-06
@@ -8413,12 +8565,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-12-17');
insert into t22 values ('2006-12-17');
insert into t33 values ('2006-12-17');
insert into t44 values (60,'2006-12-17');
insert into t55 values (60,'2006-12-17');
insert into t66 values (60,'2006-12-17');
+commit;
select * from t11 order by col1;
col1
2006-11-06
@@ -8543,6 +8697,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with quarter(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-01-03');
@@ -8551,6 +8706,7 @@ insert into t2 values ('2006-09-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-12-17');
insert into t3 values ('2006-09-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -8590,12 +8746,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-07-30' where col1='2006-01-03';
update t2 set col1='2006-07-30' where col1='2006-01-03';
update t3 set col1='2006-07-30' where col1='2006-01-03';
update t4 set col1='2006-07-30' where col1='2006-01-03';
update t5 set col1='2006-07-30' where col1='2006-01-03';
update t6 set col1='2006-07-30' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-07-30
@@ -8799,12 +8957,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with quarter(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-12-17';
delete from t2 where col1='2006-12-17';
delete from t3 where col1='2006-12-17';
delete from t4 where col1='2006-12-17';
delete from t5 where col1='2006-12-17';
delete from t6 where col1='2006-12-17';
+commit;
select * from t1 order by col1;
col1
2006-07-30
@@ -8828,12 +8988,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-12-17');
insert into t3 values ('2006-12-17');
insert into t4 values (60,'2006-12-17');
insert into t5 values (60,'2006-12-17');
insert into t6 values (60,'2006-12-17');
+commit;
select * from t1 order by col1;
col1
2006-07-30
@@ -8896,12 +9058,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with quarter(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-12-17';
delete from t22 where col1='2006-12-17';
delete from t33 where col1='2006-12-17';
delete from t44 where col1='2006-12-17';
delete from t55 where col1='2006-12-17';
delete from t66 where col1='2006-12-17';
+commit;
select * from t11 order by col1;
col1
2006-07-30
@@ -8925,12 +9089,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-12-17');
insert into t22 values ('2006-12-17');
insert into t33 values ('2006-12-17');
insert into t44 values (60,'2006-12-17');
insert into t55 values (60,'2006-12-17');
insert into t66 values (60,'2006-12-17');
+commit;
select * from t11 order by col1;
col1
2006-07-30
@@ -9006,523 +9172,6 @@ drop table if exists t44 ;
drop table if exists t55 ;
drop table if exists t66 ;
-------------------------------------------------------------------------
---- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time
--------------------------------------------------------------------------
-drop table if exists t1 ;
-drop table if exists t2 ;
-drop table if exists t3 ;
-drop table if exists t4 ;
-drop table if exists t5 ;
-drop table if exists t6 ;
--------------------------------------------------------------------------
---- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-create table t1 (col1 time) engine='INNODB'
-partition by range(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-create table t2 (col1 time) engine='INNODB'
-partition by list(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-create table t3 (col1 time) engine='INNODB'
-partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
-create table t4 (colint int, col1 time) engine='INNODB'
-partition by range(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-create table t5 (colint int, col1 time) engine='INNODB'
-partition by list(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-create table t6 (colint int, col1 time) engine='INNODB'
-partition by range(colint)
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
--------------------------------------------------------------------------
---- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-insert into t1 values ('09:09:15');
-insert into t1 values ('14:30:45');
-insert into t2 values ('09:09:15');
-insert into t2 values ('14:30:45');
-insert into t2 values ('21:59:22');
-insert into t3 values ('09:09:15');
-insert into t3 values ('14:30:45');
-insert into t3 values ('21:59:22');
-load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
-load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
-load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
-select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1;
-time_to_sec(col1)-(time_to_sec(col1)-20)
-20
-20
-select * from t1 order by col1;
-col1
-09:09:15
-14:30:45
-select * from t2 order by col1;
-col1
-09:09:15
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-09:09:15
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t5 order by colint;
-colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t6 order by colint;
-colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
-update t1 set col1='10:33:11' where col1='09:09:15';
-update t2 set col1='10:33:11' where col1='09:09:15';
-update t3 set col1='10:33:11' where col1='09:09:15';
-update t4 set col1='10:33:11' where col1='09:09:15';
-update t5 set col1='10:33:11' where col1='09:09:15';
-update t6 set col1='10:33:11' where col1='09:09:15';
-select * from t1 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t2 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t5 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t6 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
--------------------------------------------------------------------------
---- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-drop table if exists t11 ;
-drop table if exists t22 ;
-drop table if exists t33 ;
-drop table if exists t44 ;
-drop table if exists t55 ;
-drop table if exists t66 ;
-create table t11 engine='INNODB' as select * from t1;
-create table t22 engine='INNODB' as select * from t2;
-create table t33 engine='INNODB' as select * from t3;
-create table t44 engine='INNODB' as select * from t4;
-create table t55 engine='INNODB' as select * from t5;
-create table t66 engine='INNODB' as select * from t6;
-alter table t11
-partition by range(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-alter table t22
-partition by list(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-alter table t33
-partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
-alter table t44
-partition by range(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-alter table t55
-partition by list(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-alter table t66
-partition by range(colint)
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t22 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t44 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
----------------------------
----- some alter table begin
----------------------------
-alter table t11
-reorganize partition p0,p1 into
-(partition s1 values less than maxvalue);
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-alter table t11
-reorganize partition s1 into
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-alter table t55
-partition by list(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5
-(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-show create table t55;
-Table Create Table
-t55 CREATE TABLE `t55` (
- `colint` int(11) DEFAULT NULL,
- `col1` time DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST (colint)
-SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20))
-SUBPARTITIONS 5
-(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
- PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
- PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
- PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
- PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
- PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition p0,p1 into
-(partition s1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition s1 into
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition p0,p1 into
-(partition s1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition s1 into
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
--------------------------------------------------------------------------
---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-delete from t1 where col1='14:30:45';
-delete from t2 where col1='14:30:45';
-delete from t3 where col1='14:30:45';
-delete from t4 where col1='14:30:45';
-delete from t5 where col1='14:30:45';
-delete from t6 where col1='14:30:45';
-select * from t1 order by col1;
-col1
-10:33:11
-select * from t2 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t5 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-insert into t1 values ('14:30:45');
-insert into t2 values ('14:30:45');
-insert into t3 values ('14:30:45');
-insert into t4 values (60,'14:30:45');
-insert into t5 values (60,'14:30:45');
-insert into t6 values (60,'14:30:45');
-select * from t1 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t2 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t5 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t6 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-alter table t1 drop partition p0;
-alter table t2 drop partition p0;
-alter table t4 drop partition p0;
-alter table t5 drop partition p0;
-alter table t6 drop partition p0;
-select * from t1 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t2 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-60 14:30:45
-select * from t5 order by colint;
-colint col1
-60 14:30:45
-select * from t6 order by colint;
-colint col1
--------------------------------------------------------------------------
---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-delete from t11 where col1='14:30:45';
-delete from t22 where col1='14:30:45';
-delete from t33 where col1='14:30:45';
-delete from t44 where col1='14:30:45';
-delete from t55 where col1='14:30:45';
-delete from t66 where col1='14:30:45';
-select * from t11 order by col1;
-col1
-10:33:11
-select * from t22 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t44 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-insert into t11 values ('14:30:45');
-insert into t22 values ('14:30:45');
-insert into t33 values ('14:30:45');
-insert into t44 values (60,'14:30:45');
-insert into t55 values (60,'14:30:45');
-insert into t66 values (60,'14:30:45');
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t22 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t44 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-alter table t11 drop partition p0;
-alter table t22 drop partition p0;
-alter table t44 drop partition p0;
-alter table t55 drop partition p0;
-alter table t66 drop partition p0;
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t22 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t44 order by colint;
-colint col1
-60 14:30:45
-select * from t55 order by colint;
-colint col1
-60 14:30:45
-select * from t66 order by colint;
-colint col1
--------------------------
----- some alter table end
--------------------------
-drop table if exists t1 ;
-drop table if exists t2 ;
-drop table if exists t3 ;
-drop table if exists t4 ;
-drop table if exists t5 ;
-drop table if exists t6 ;
-drop table if exists t11 ;
-drop table if exists t22 ;
-drop table if exists t33 ;
-drop table if exists t44 ;
-drop table if exists t55 ;
-drop table if exists t66 ;
--------------------------------------------------------------------------
--- weekday(col1) in partition with coltype date
-------------------------------------------------------------------------
drop table if exists t1 ;
@@ -9571,6 +9220,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with weekday(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-12-03');
insert into t1 values ('2006-11-17');
insert into t2 values ('2006-12-03');
@@ -9579,6 +9229,7 @@ insert into t2 values ('2006-05-25');
insert into t3 values ('2006-12-03');
insert into t3 values ('2006-11-17');
insert into t3 values ('2006-05-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -9618,12 +9269,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-06' where col1='2006-12-03';
update t2 set col1='2006-02-06' where col1='2006-12-03';
update t3 set col1='2006-02-06' where col1='2006-12-03';
update t4 set col1='2006-02-06' where col1='2006-12-03';
update t5 set col1='2006-02-06' where col1='2006-12-03';
update t6 set col1='2006-02-06' where col1='2006-12-03';
+commit;
select * from t1 order by col1;
col1
2006-02-06
@@ -9827,12 +9480,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with weekday(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-11-17';
delete from t2 where col1='2006-11-17';
delete from t3 where col1='2006-11-17';
delete from t4 where col1='2006-11-17';
delete from t5 where col1='2006-11-17';
delete from t6 where col1='2006-11-17';
+commit;
select * from t1 order by col1;
col1
2006-02-06
@@ -9856,12 +9511,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-11-17');
insert into t2 values ('2006-11-17');
insert into t3 values ('2006-11-17');
insert into t4 values (60,'2006-11-17');
insert into t5 values (60,'2006-11-17');
insert into t6 values (60,'2006-11-17');
+commit;
select * from t1 order by col1;
col1
2006-02-06
@@ -9923,12 +9580,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with weekday(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-11-17';
delete from t22 where col1='2006-11-17';
delete from t33 where col1='2006-11-17';
delete from t44 where col1='2006-11-17';
delete from t55 where col1='2006-11-17';
delete from t66 where col1='2006-11-17';
+commit;
select * from t11 order by col1;
col1
2006-02-06
@@ -9952,12 +9611,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-11-17');
insert into t22 values ('2006-11-17');
insert into t33 values ('2006-11-17');
insert into t44 values (60,'2006-11-17');
insert into t55 values (60,'2006-11-17');
insert into t66 values (60,'2006-11-17');
+commit;
select * from t11 order by col1;
col1
2006-02-06
@@ -10080,6 +9741,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with year(col1)-1990
-------------------------------------------------------------------------
+begin;
insert into t1 values ('1996-01-03');
insert into t1 values ('2000-02-17');
insert into t2 values ('1996-01-03');
@@ -10088,6 +9750,7 @@ insert into t2 values ('2004-05-25');
insert into t3 values ('1996-01-03');
insert into t3 values ('2000-02-17');
insert into t3 values ('2004-05-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -10127,12 +9790,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2002-02-15' where col1='1996-01-03';
update t2 set col1='2002-02-15' where col1='1996-01-03';
update t3 set col1='2002-02-15' where col1='1996-01-03';
update t4 set col1='2002-02-15' where col1='1996-01-03';
update t5 set col1='2002-02-15' where col1='1996-01-03';
update t6 set col1='2002-02-15' where col1='1996-01-03';
+commit;
select * from t1 order by col1;
col1
2000-02-17
@@ -10336,12 +10001,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with year(col1)-1990
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2000-02-17';
delete from t2 where col1='2000-02-17';
delete from t3 where col1='2000-02-17';
delete from t4 where col1='2000-02-17';
delete from t5 where col1='2000-02-17';
delete from t6 where col1='2000-02-17';
+commit;
select * from t1 order by col1;
col1
2002-02-15
@@ -10365,12 +10032,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2000-02-17');
insert into t2 values ('2000-02-17');
insert into t3 values ('2000-02-17');
insert into t4 values (60,'2000-02-17');
insert into t5 values (60,'2000-02-17');
insert into t6 values (60,'2000-02-17');
+commit;
select * from t1 order by col1;
col1
2000-02-17
@@ -10434,12 +10103,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with year(col1)-1990
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2000-02-17';
delete from t22 where col1='2000-02-17';
delete from t33 where col1='2000-02-17';
delete from t44 where col1='2000-02-17';
delete from t55 where col1='2000-02-17';
delete from t66 where col1='2000-02-17';
+commit;
select * from t11 order by col1;
col1
2002-02-15
@@ -10463,12 +10134,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2000-02-17');
insert into t22 values ('2000-02-17');
insert into t33 values ('2000-02-17');
insert into t44 values (60,'2000-02-17');
insert into t55 values (60,'2000-02-17');
insert into t66 values (60,'2000-02-17');
+commit;
select * from t11 order by col1;
col1
2000-02-17
@@ -10593,6 +10266,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with yearweek(col1)-200600
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-08-17');
insert into t2 values ('2006-01-03');
@@ -10601,6 +10275,7 @@ insert into t2 values ('2006-03-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-08-17');
insert into t3 values ('2006-03-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -10640,12 +10315,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-11-15' where col1='2006-01-03';
update t2 set col1='2006-11-15' where col1='2006-01-03';
update t3 set col1='2006-11-15' where col1='2006-01-03';
update t4 set col1='2006-11-15' where col1='2006-01-03';
update t5 set col1='2006-11-15' where col1='2006-01-03';
update t6 set col1='2006-11-15' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-08-17
@@ -10849,12 +10526,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with yearweek(col1)-200600
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-08-17';
delete from t2 where col1='2006-08-17';
delete from t3 where col1='2006-08-17';
delete from t4 where col1='2006-08-17';
delete from t5 where col1='2006-08-17';
delete from t6 where col1='2006-08-17';
+commit;
select * from t1 order by col1;
col1
2006-11-15
@@ -10878,12 +10557,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-08-17');
insert into t2 values ('2006-08-17');
insert into t3 values ('2006-08-17');
insert into t4 values (60,'2006-08-17');
insert into t5 values (60,'2006-08-17');
insert into t6 values (60,'2006-08-17');
+commit;
select * from t1 order by col1;
col1
2006-08-17
@@ -10950,12 +10631,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with yearweek(col1)-200600
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-08-17';
delete from t22 where col1='2006-08-17';
delete from t33 where col1='2006-08-17';
delete from t44 where col1='2006-08-17';
delete from t55 where col1='2006-08-17';
delete from t66 where col1='2006-08-17';
+commit;
select * from t11 order by col1;
col1
2006-11-15
@@ -10979,12 +10662,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-08-17');
insert into t22 values ('2006-08-17');
insert into t33 values ('2006-08-17');
insert into t44 values (60,'2006-08-17');
insert into t55 values (60,'2006-08-17');
insert into t66 values (60,'2006-08-17');
+commit;
select * from t11 order by col1;
col1
2006-08-17
diff --git a/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result b/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result
index 3cd8e10a4f3..e4bf955f16a 100644
--- a/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result
+++ b/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result
@@ -47,6 +47,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with abs(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values (5 );
insert into t1 values (13 );
insert into t2 values (5 );
@@ -55,6 +56,7 @@ insert into t2 values (17 );
insert into t3 values (5 );
insert into t3 values (13 );
insert into t3 values (17 );
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6;
@@ -217,12 +219,14 @@ colint col1
50 56
51 34
55 123
+begin;
update t1 set col1=15 where col1=5 ;
update t2 set col1=15 where col1=5 ;
update t3 set col1=15 where col1=5 ;
update t4 set col1=15 where col1=5 ;
update t5 set col1=15 where col1=5 ;
update t6 set col1=15 where col1=5 ;
+commit;
select * from t1 order by col1;
col1
13
@@ -877,12 +881,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with abs(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1=13 ;
delete from t2 where col1=13 ;
delete from t3 where col1=13 ;
delete from t4 where col1=13 ;
delete from t5 where col1=13 ;
delete from t6 where col1=13 ;
+commit;
select * from t1 order by col1;
col1
15
@@ -986,12 +992,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t1 values (13 );
insert into t2 values (13 );
insert into t3 values (13 );
insert into t4 values (60,13 );
insert into t5 values (60,13 );
insert into t6 values (60,13 );
+commit;
select * from t1 order by col1;
col1
13
@@ -1274,12 +1282,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with abs(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1=13 ;
delete from t22 where col1=13 ;
delete from t33 where col1=13 ;
delete from t44 where col1=13 ;
delete from t55 where col1=13 ;
delete from t66 where col1=13 ;
+commit;
select * from t11 order by col1;
col1
15
@@ -1383,12 +1393,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t11 values (13 );
insert into t22 values (13 );
insert into t33 values (13 );
insert into t44 values (60,13 );
insert into t55 values (60,13 );
insert into t66 values (60,13 );
+commit;
select * from t11 order by col1;
col1
13
@@ -1732,6 +1744,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with mod(col1,10)
-------------------------------------------------------------------------
+begin;
insert into t1 values (5);
insert into t1 values (19);
insert into t2 values (5);
@@ -1740,6 +1753,7 @@ insert into t2 values (17);
insert into t3 values (5);
insert into t3 values (19);
insert into t3 values (17);
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6;
@@ -1902,12 +1916,14 @@ colint col1
50 56
51 34
55 123
+begin;
update t1 set col1=15 where col1=5;
update t2 set col1=15 where col1=5;
update t3 set col1=15 where col1=5;
update t4 set col1=15 where col1=5;
update t5 set col1=15 where col1=5;
update t6 set col1=15 where col1=5;
+commit;
select * from t1 order by col1;
col1
15
@@ -2562,12 +2578,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with mod(col1,10)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1=19;
delete from t2 where col1=19;
delete from t3 where col1=19;
delete from t4 where col1=19;
delete from t5 where col1=19;
delete from t6 where col1=19;
+commit;
select * from t1 order by col1;
col1
15
@@ -2673,12 +2691,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t1 values (19);
insert into t2 values (19);
insert into t3 values (19);
insert into t4 values (60,19);
insert into t5 values (60,19);
insert into t6 values (60,19);
+commit;
select * from t1 order by col1;
col1
15
@@ -2970,12 +2990,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with mod(col1,10)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1=19;
delete from t22 where col1=19;
delete from t33 where col1=19;
delete from t44 where col1=19;
delete from t55 where col1=19;
delete from t66 where col1=19;
+commit;
select * from t11 order by col1;
col1
15
@@ -3081,12 +3103,14 @@ colint col1
50 56
51 34
55 123
+begin;
insert into t11 values (19);
insert into t22 values (19);
insert into t33 values (19);
insert into t44 values (60,19);
insert into t55 values (60,19);
insert into t66 values (60,19);
+commit;
select * from t11 order by col1;
col1
15
@@ -3439,6 +3463,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with day(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-02-03');
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-02-03');
@@ -3447,6 +3472,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-02-03');
insert into t3 values ('2006-01-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -3486,12 +3512,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-02-03';
update t2 set col1='2006-02-05' where col1='2006-02-03';
update t3 set col1='2006-02-05' where col1='2006-02-03';
update t4 set col1='2006-02-05' where col1='2006-02-03';
update t5 set col1='2006-02-05' where col1='2006-02-03';
update t6 set col1='2006-02-05' where col1='2006-02-03';
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -3695,12 +3723,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with day(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-01-17';
delete from t2 where col1='2006-01-17';
delete from t3 where col1='2006-01-17';
delete from t4 where col1='2006-01-17';
delete from t5 where col1='2006-01-17';
delete from t6 where col1='2006-01-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -3722,12 +3752,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-17');
insert into t3 values ('2006-01-17');
insert into t4 values (60,'2006-01-17');
insert into t5 values (60,'2006-01-17');
insert into t6 values (60,'2006-01-17');
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -3789,12 +3821,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with day(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-01-17';
delete from t22 where col1='2006-01-17';
delete from t33 where col1='2006-01-17';
delete from t44 where col1='2006-01-17';
delete from t55 where col1='2006-01-17';
delete from t66 where col1='2006-01-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -3816,12 +3850,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-01-17');
insert into t22 values ('2006-01-17');
insert into t33 values ('2006-01-17');
insert into t44 values (60,'2006-01-17');
insert into t55 values (60,'2006-01-17');
insert into t66 values (60,'2006-01-17');
+commit;
select * from t11 order by col1;
col1
2006-01-17
@@ -3944,6 +3980,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with dayofmonth(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-02-03');
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-02-03');
@@ -3952,6 +3989,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-02-03');
insert into t3 values ('2006-01-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -3991,12 +4029,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-02-03';
update t2 set col1='2006-02-05' where col1='2006-02-03';
update t3 set col1='2006-02-05' where col1='2006-02-03';
update t4 set col1='2006-02-05' where col1='2006-02-03';
update t5 set col1='2006-02-05' where col1='2006-02-03';
update t6 set col1='2006-02-05' where col1='2006-02-03';
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -4200,12 +4240,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofmonth(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-01-17';
delete from t2 where col1='2006-01-17';
delete from t3 where col1='2006-01-17';
delete from t4 where col1='2006-01-17';
delete from t5 where col1='2006-01-17';
delete from t6 where col1='2006-01-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4227,12 +4269,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-17');
insert into t3 values ('2006-01-17');
insert into t4 values (60,'2006-01-17');
insert into t5 values (60,'2006-01-17');
insert into t6 values (60,'2006-01-17');
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -4294,12 +4338,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofmonth(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-01-17';
delete from t22 where col1='2006-01-17';
delete from t33 where col1='2006-01-17';
delete from t44 where col1='2006-01-17';
delete from t55 where col1='2006-01-17';
delete from t66 where col1='2006-01-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -4321,12 +4367,14 @@ colint col1
1 2006-02-05
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-01-17');
insert into t22 values ('2006-01-17');
insert into t33 values ('2006-01-17');
insert into t44 values (60,'2006-01-17');
insert into t55 values (60,'2006-01-17');
insert into t66 values (60,'2006-01-17');
+commit;
select * from t11 order by col1;
col1
2006-01-17
@@ -4449,6 +4497,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with dayofweek(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-01-03');
@@ -4457,6 +4506,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-02-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -4496,12 +4546,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-01-03';
update t2 set col1='2006-02-05' where col1='2006-01-03';
update t3 set col1='2006-02-05' where col1='2006-01-03';
update t4 set col1='2006-02-05' where col1='2006-01-03';
update t5 set col1='2006-02-05' where col1='2006-01-03';
update t6 set col1='2006-02-05' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4705,12 +4757,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofweek(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-02-17';
delete from t2 where col1='2006-02-17';
delete from t3 where col1='2006-02-17';
delete from t4 where col1='2006-02-17';
delete from t5 where col1='2006-02-17';
delete from t6 where col1='2006-02-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4734,12 +4788,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-02-17');
insert into t3 values ('2006-02-17');
insert into t4 values (60,'2006-02-17');
insert into t5 values (60,'2006-02-17');
insert into t6 values (60,'2006-02-17');
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -4805,12 +4861,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofweek(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-02-17';
delete from t22 where col1='2006-02-17';
delete from t33 where col1='2006-02-17';
delete from t44 where col1='2006-02-17';
delete from t55 where col1='2006-02-17';
delete from t66 where col1='2006-02-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -4834,12 +4892,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-02-17');
insert into t22 values ('2006-02-17');
insert into t33 values ('2006-02-17');
insert into t44 values (60,'2006-02-17');
insert into t55 values (60,'2006-02-17');
insert into t66 values (60,'2006-02-17');
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -4966,6 +5026,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with dayofyear(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-03');
@@ -4974,6 +5035,7 @@ insert into t2 values ('2006-02-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-01-17');
insert into t3 values ('2006-02-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -5013,12 +5075,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-01-03';
update t2 set col1='2006-02-05' where col1='2006-01-03';
update t3 set col1='2006-02-05' where col1='2006-01-03';
update t4 set col1='2006-02-05' where col1='2006-01-03';
update t5 set col1='2006-02-05' where col1='2006-01-03';
update t6 set col1='2006-02-05' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -5222,12 +5286,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofyear(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-01-17';
delete from t2 where col1='2006-01-17';
delete from t3 where col1='2006-01-17';
delete from t4 where col1='2006-01-17';
delete from t5 where col1='2006-01-17';
delete from t6 where col1='2006-01-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5249,12 +5315,14 @@ colint col1
1 2006-02-03
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-01-17');
insert into t2 values ('2006-01-17');
insert into t3 values ('2006-01-17');
insert into t4 values (60,'2006-01-17');
insert into t5 values (60,'2006-01-17');
insert into t6 values (60,'2006-01-17');
+commit;
select * from t1 order by col1;
col1
2006-01-17
@@ -5317,12 +5385,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with dayofyear(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-01-17';
delete from t22 where col1='2006-01-17';
delete from t33 where col1='2006-01-17';
delete from t44 where col1='2006-01-17';
delete from t55 where col1='2006-01-17';
delete from t66 where col1='2006-01-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -5344,12 +5414,14 @@ colint col1
1 2006-02-03
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-01-17');
insert into t22 values ('2006-01-17');
insert into t33 values ('2006-01-17');
insert into t44 values (60,'2006-01-17');
insert into t55 values (60,'2006-01-17');
insert into t66 values (60,'2006-01-17');
+commit;
select * from t11 order by col1;
col1
2006-01-17
@@ -5473,6 +5545,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with extract(month from col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-01-03');
@@ -5481,6 +5554,7 @@ insert into t2 values ('2006-01-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-02-17');
insert into t3 values ('2006-01-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -5520,12 +5594,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-05' where col1='2006-01-03';
update t2 set col1='2006-02-05' where col1='2006-01-03';
update t3 set col1='2006-02-05' where col1='2006-01-03';
update t4 set col1='2006-02-05' where col1='2006-01-03';
update t5 set col1='2006-02-05' where col1='2006-01-03';
update t6 set col1='2006-02-05' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5729,12 +5805,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with extract(month from col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-02-17';
delete from t2 where col1='2006-02-17';
delete from t3 where col1='2006-02-17';
delete from t4 where col1='2006-02-17';
delete from t5 where col1='2006-02-17';
delete from t6 where col1='2006-02-17';
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5758,12 +5836,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-02-17');
insert into t2 values ('2006-02-17');
insert into t3 values ('2006-02-17');
insert into t4 values (60,'2006-02-17');
insert into t5 values (60,'2006-02-17');
insert into t6 values (60,'2006-02-17');
+commit;
select * from t1 order by col1;
col1
2006-02-05
@@ -5824,12 +5904,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with extract(month from col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-02-17';
delete from t22 where col1='2006-02-17';
delete from t33 where col1='2006-02-17';
delete from t44 where col1='2006-02-17';
delete from t55 where col1='2006-02-17';
delete from t66 where col1='2006-02-17';
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -5853,12 +5935,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-02-17');
insert into t22 values ('2006-02-17');
insert into t33 values ('2006-02-17');
insert into t44 values (60,'2006-02-17');
insert into t55 values (60,'2006-02-17');
insert into t66 values (60,'2006-02-17');
+commit;
select * from t11 order by col1;
col1
2006-02-05
@@ -5980,6 +6064,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with hour(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09');
insert into t1 values ('14:30');
insert into t2 values ('09:09');
@@ -5988,6 +6073,7 @@ insert into t2 values ('21:59');
insert into t3 values ('09:09');
insert into t3 values ('14:30');
insert into t3 values ('21:59');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
@@ -6027,12 +6113,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
update t1 set col1='10:30' where col1='09:09';
update t2 set col1='10:30' where col1='09:09';
update t3 set col1='10:30' where col1='09:09';
update t4 set col1='10:30' where col1='09:09';
update t5 set col1='10:30' where col1='09:09';
update t6 set col1='10:30' where col1='09:09';
+commit;
select * from t1 order by col1;
col1
10:30:00
@@ -6236,12 +6324,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with hour(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='14:30';
delete from t2 where col1='14:30';
delete from t3 where col1='14:30';
delete from t4 where col1='14:30';
delete from t5 where col1='14:30';
delete from t6 where col1='14:30';
+commit;
select * from t1 order by col1;
col1
10:30:00
@@ -6265,12 +6355,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t1 values ('14:30');
insert into t2 values ('14:30');
insert into t3 values ('14:30');
insert into t4 values (60,'14:30');
insert into t5 values (60,'14:30');
insert into t6 values (60,'14:30');
+commit;
select * from t1 order by col1;
col1
10:30:00
@@ -6334,12 +6426,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with hour(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='14:30';
delete from t22 where col1='14:30';
delete from t33 where col1='14:30';
delete from t44 where col1='14:30';
delete from t55 where col1='14:30';
delete from t66 where col1='14:30';
+commit;
select * from t11 order by col1;
col1
10:30:00
@@ -6363,12 +6457,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t11 values ('14:30');
insert into t22 values ('14:30');
insert into t33 values ('14:30');
insert into t44 values (60,'14:30');
insert into t55 values (60,'14:30');
insert into t66 values (60,'14:30');
+commit;
select * from t11 order by col1;
col1
10:30:00
@@ -6445,7 +6541,7 @@ drop table if exists t44 ;
drop table if exists t55 ;
drop table if exists t66 ;
-------------------------------------------------------------------------
---- microsecond(col1) in partition with coltype time
+--- microsecond(col1) in partition with coltype time(6)
-------------------------------------------------------------------------
drop table if exists t1 ;
drop table if exists t2 ;
@@ -6456,11 +6552,11 @@ drop table if exists t6 ;
-------------------------------------------------------------------------
--- Create tables with microsecond(col1)
-------------------------------------------------------------------------
-create table t1 (col1 time) engine='MYISAM'
+create table t1 (col1 time(6)) engine='MYISAM'
partition by range(microsecond(col1))
(partition p0 values less than (15),
partition p1 values less than maxvalue);
-create table t2 (col1 time) engine='MYISAM'
+create table t2 (col1 time(6)) engine='MYISAM'
partition by list(microsecond(col1))
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
@@ -6469,14 +6565,14 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40),
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
);
-create table t3 (col1 time) engine='MYISAM'
+create table t3 (col1 time(6)) engine='MYISAM'
partition by hash(microsecond(col1));
-create table t4 (colint int, col1 time) engine='MYISAM'
+create table t4 (colint int, col1 time(6)) engine='MYISAM'
partition by range(colint)
subpartition by hash(microsecond(col1)) subpartitions 2
(partition p0 values less than (15),
partition p1 values less than maxvalue);
-create table t5 (colint int, col1 time) engine='MYISAM'
+create table t5 (colint int, col1 time(6)) engine='MYISAM'
partition by list(colint)
subpartition by hash(microsecond(col1)) subpartitions 2
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
@@ -6486,13 +6582,14 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40),
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
);
-create table t6 (colint int, col1 time) engine='MYISAM'
+create table t6 (colint int, col1 time(6)) engine='MYISAM'
partition by range(colint)
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with microsecond(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09:15.000002');
insert into t1 values ('04:30:01.000018');
insert into t2 values ('09:09:15.000002');
@@ -6501,83 +6598,86 @@ insert into t2 values ('00:59:22.000024');
insert into t3 values ('09:09:15.000002');
insert into t3 values ('04:30:01.000018');
insert into t3 values ('00:59:22.000024');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
select microsecond(col1) from t1 order by col1;
microsecond(col1)
-0
-0
+18
+2
select * from t1 order by col1;
col1
-04:30:01
-09:09:15
+04:30:01.000018
+09:09:15.000002
select * from t2 order by col1;
col1
-00:59:22
-04:30:01
-09:09:15
+00:59:22.000024
+04:30:01.000018
+09:09:15.000002
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-09:09:15
+00:59:22.000024
+04:30:01.000018
+09:09:15.000002
select * from t4 order by colint;
colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t5 order by colint;
colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t6 order by colint;
colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
+begin;
update t1 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t2 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t3 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t4 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t5 set col1='05:30:34.000037' where col1='09:09:15.000002';
update t6 set col1='05:30:34.000037' where col1='09:09:15.000002';
+commit;
select * from t1 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t2 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t4 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t5 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t6 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
-------------------------------------------------------------------------
--- Alter tables with microsecond(col1)
-------------------------------------------------------------------------
@@ -6629,36 +6729,36 @@ partition by range(colint)
partition p1 values less than maxvalue);
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t22 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t44 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t55 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
---------------------------
---- some alter table begin
---------------------------
@@ -6667,16 +6767,16 @@ reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
alter table t11
reorganize partition s1 into
(partition p0 values less than (15),
partition p1 values less than maxvalue);
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
alter table t55
partition by list(colint)
subpartition by hash(microsecond(col1)) subpartitions 5
@@ -6691,7 +6791,7 @@ show create table t55;
Table Create Table
t55 CREATE TABLE `t55` (
`colint` int(11) DEFAULT NULL,
- `col1` time DEFAULT NULL
+ `col1` time(6) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (colint)
SUBPARTITION BY HASH (microsecond(col1))
@@ -6704,116 +6804,120 @@ SUBPARTITIONS 5
PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */
select * from t55 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition s1 into
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition p0,p1 into
(partition s1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
alter table t66
reorganize partition s1 into
(partition p0 values less than (microsecond('10:30:10.000010')),
partition p1 values less than maxvalue);
select * from t66 order by colint;
colint col1
-1 05:30:34
-2 04:30:01
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with microsecond(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='04:30:01.000018';
delete from t2 where col1='04:30:01.000018';
delete from t3 where col1='04:30:01.000018';
delete from t4 where col1='04:30:01.000018';
delete from t5 where col1='04:30:01.000018';
delete from t6 where col1='04:30:01.000018';
+commit;
select * from t1 order by col1;
col1
-05:30:34
+05:30:34.000037
select * from t2 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t4 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
select * from t5 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+begin;
insert into t1 values ('04:30:01.000018');
insert into t2 values ('04:30:01.000018');
insert into t3 values ('04:30:01.000018');
insert into t4 values (60,'04:30:01.000018');
insert into t5 values (60,'04:30:01.000018');
insert into t6 values (60,'04:30:01.000018');
+commit;
select * from t1 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t2 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t4 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t5 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t6 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
alter table t1 drop partition p0;
alter table t2 drop partition p0;
alter table t4 drop partition p0;
@@ -6821,90 +6925,99 @@ alter table t5 drop partition p0;
alter table t6 drop partition p0;
select * from t1 order by col1;
col1
+04:30:01.000018
+05:30:34.000037
select * from t2 order by col1;
col1
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t3 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t4 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t5 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t6 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with microsecond(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='04:30:01.000018';
delete from t22 where col1='04:30:01.000018';
delete from t33 where col1='04:30:01.000018';
delete from t44 where col1='04:30:01.000018';
delete from t55 where col1='04:30:01.000018';
delete from t66 where col1='04:30:01.000018';
+commit;
select * from t11 order by col1;
col1
-05:30:34
+05:30:34.000037
select * from t22 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-05:30:34
+00:59:22.000024
+05:30:34.000037
select * from t44 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
select * from t55 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+begin;
insert into t11 values ('04:30:01.000018');
insert into t22 values ('04:30:01.000018');
insert into t33 values ('04:30:01.000018');
insert into t44 values (60,'04:30:01.000018');
insert into t55 values (60,'04:30:01.000018');
insert into t66 values (60,'04:30:01.000018');
+commit;
select * from t11 order by col1;
col1
-04:30:01
-05:30:34
+04:30:01.000018
+05:30:34.000037
select * from t22 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t44 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t55 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
select * from t66 order by colint;
colint col1
-1 05:30:34
-3 00:59:22
-4 05:30:34
-60 04:30:01
+1 05:30:34.000037
+3 00:59:22.000024
+4 05:30:34.000037
+60 04:30:01.000018
alter table t11 drop partition p0;
alter table t22 drop partition p0;
alter table t44 drop partition p0;
@@ -6912,22 +7025,27 @@ alter table t55 drop partition p0;
alter table t66 drop partition p0;
select * from t11 order by col1;
col1
+04:30:01.000018
+05:30:34.000037
select * from t22 order by col1;
col1
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t33 order by col1;
col1
-00:59:22
-04:30:01
-05:30:34
+00:59:22.000024
+04:30:01.000018
+05:30:34.000037
select * from t44 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t55 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
select * from t66 order by colint;
colint col1
-60 04:30:01
+60 04:30:01.000018
-------------------------
---- some alter table end
-------------------------
@@ -6992,6 +7110,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with minute(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09:15');
insert into t1 values ('14:30:45');
insert into t2 values ('09:09:15');
@@ -7000,6 +7119,7 @@ insert into t2 values ('21:59:22');
insert into t3 values ('09:09:15');
insert into t3 values ('14:30:45');
insert into t3 values ('21:59:22');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
@@ -7039,12 +7159,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
update t1 set col1='10:24:23' where col1='09:09:15';
update t2 set col1='10:24:23' where col1='09:09:15';
update t3 set col1='10:24:23' where col1='09:09:15';
update t4 set col1='10:24:23' where col1='09:09:15';
update t5 set col1='10:24:23' where col1='09:09:15';
update t6 set col1='10:24:23' where col1='09:09:15';
+commit;
select * from t1 order by col1;
col1
10:24:23
@@ -7248,12 +7370,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with minute(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='14:30:45';
delete from t2 where col1='14:30:45';
delete from t3 where col1='14:30:45';
delete from t4 where col1='14:30:45';
delete from t5 where col1='14:30:45';
delete from t6 where col1='14:30:45';
+commit;
select * from t1 order by col1;
col1
10:24:23
@@ -7277,12 +7401,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t1 values ('14:30:45');
insert into t2 values ('14:30:45');
insert into t3 values ('14:30:45');
insert into t4 values (60,'14:30:45');
insert into t5 values (60,'14:30:45');
insert into t6 values (60,'14:30:45');
+commit;
select * from t1 order by col1;
col1
10:24:23
@@ -7349,12 +7475,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with minute(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='14:30:45';
delete from t22 where col1='14:30:45';
delete from t33 where col1='14:30:45';
delete from t44 where col1='14:30:45';
delete from t55 where col1='14:30:45';
delete from t66 where col1='14:30:45';
+commit;
select * from t11 order by col1;
col1
10:24:23
@@ -7378,12 +7506,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t11 values ('14:30:45');
insert into t22 values ('14:30:45');
insert into t33 values ('14:30:45');
insert into t44 values (60,'14:30:45');
insert into t55 values (60,'14:30:45');
insert into t66 values (60,'14:30:45');
+commit;
select * from t11 order by col1;
col1
10:24:23
@@ -7511,6 +7641,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with second(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('09:09:09');
insert into t1 values ('14:30:20');
insert into t2 values ('09:09:09');
@@ -7519,6 +7650,7 @@ insert into t2 values ('21:59:22');
insert into t3 values ('09:09:09');
insert into t3 values ('14:30:20');
insert into t3 values ('21:59:22');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
@@ -7558,12 +7690,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
update t1 set col1='10:22:33' where col1='09:09:09';
update t2 set col1='10:22:33' where col1='09:09:09';
update t3 set col1='10:22:33' where col1='09:09:09';
update t4 set col1='10:22:33' where col1='09:09:09';
update t5 set col1='10:22:33' where col1='09:09:09';
update t6 set col1='10:22:33' where col1='09:09:09';
+commit;
select * from t1 order by col1;
col1
10:22:33
@@ -7767,12 +7901,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with second(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='14:30:20';
delete from t2 where col1='14:30:20';
delete from t3 where col1='14:30:20';
delete from t4 where col1='14:30:20';
delete from t5 where col1='14:30:20';
delete from t6 where col1='14:30:20';
+commit;
select * from t1 order by col1;
col1
10:22:33
@@ -7796,12 +7932,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t1 values ('14:30:20');
insert into t2 values ('14:30:20');
insert into t3 values ('14:30:20');
insert into t4 values (60,'14:30:20');
insert into t5 values (60,'14:30:20');
insert into t6 values (60,'14:30:20');
+commit;
select * from t1 order by col1;
col1
10:22:33
@@ -7868,12 +8006,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with second(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='14:30:20';
delete from t22 where col1='14:30:20';
delete from t33 where col1='14:30:20';
delete from t44 where col1='14:30:20';
delete from t55 where col1='14:30:20';
delete from t66 where col1='14:30:20';
+commit;
select * from t11 order by col1;
col1
10:22:33
@@ -7897,12 +8037,14 @@ colint col1
2 04:30:01
3 00:59:22
4 05:30:34
+begin;
insert into t11 values ('14:30:20');
insert into t22 values ('14:30:20');
insert into t33 values ('14:30:20');
insert into t44 values (60,'14:30:20');
insert into t55 values (60,'14:30:20');
insert into t66 values (60,'14:30:20');
+commit;
select * from t11 order by col1;
col1
10:22:33
@@ -8030,6 +8172,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with month(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-01-03');
@@ -8038,6 +8181,7 @@ insert into t2 values ('2006-05-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-12-17');
insert into t3 values ('2006-05-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -8077,12 +8221,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-11-06' where col1='2006-01-03';
update t2 set col1='2006-11-06' where col1='2006-01-03';
update t3 set col1='2006-11-06' where col1='2006-01-03';
update t4 set col1='2006-11-06' where col1='2006-01-03';
update t5 set col1='2006-11-06' where col1='2006-01-03';
update t6 set col1='2006-11-06' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-11-06
@@ -8286,12 +8432,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with month(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-12-17';
delete from t2 where col1='2006-12-17';
delete from t3 where col1='2006-12-17';
delete from t4 where col1='2006-12-17';
delete from t5 where col1='2006-12-17';
delete from t6 where col1='2006-12-17';
+commit;
select * from t1 order by col1;
col1
2006-11-06
@@ -8315,12 +8463,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-12-17');
insert into t3 values ('2006-12-17');
insert into t4 values (60,'2006-12-17');
insert into t5 values (60,'2006-12-17');
insert into t6 values (60,'2006-12-17');
+commit;
select * from t1 order by col1;
col1
2006-11-06
@@ -8384,12 +8534,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with month(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-12-17';
delete from t22 where col1='2006-12-17';
delete from t33 where col1='2006-12-17';
delete from t44 where col1='2006-12-17';
delete from t55 where col1='2006-12-17';
delete from t66 where col1='2006-12-17';
+commit;
select * from t11 order by col1;
col1
2006-11-06
@@ -8413,12 +8565,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-12-17');
insert into t22 values ('2006-12-17');
insert into t33 values ('2006-12-17');
insert into t44 values (60,'2006-12-17');
insert into t55 values (60,'2006-12-17');
insert into t66 values (60,'2006-12-17');
+commit;
select * from t11 order by col1;
col1
2006-11-06
@@ -8543,6 +8697,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with quarter(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-01-03');
@@ -8551,6 +8706,7 @@ insert into t2 values ('2006-09-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-12-17');
insert into t3 values ('2006-09-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -8590,12 +8746,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-07-30' where col1='2006-01-03';
update t2 set col1='2006-07-30' where col1='2006-01-03';
update t3 set col1='2006-07-30' where col1='2006-01-03';
update t4 set col1='2006-07-30' where col1='2006-01-03';
update t5 set col1='2006-07-30' where col1='2006-01-03';
update t6 set col1='2006-07-30' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-07-30
@@ -8799,12 +8957,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with quarter(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-12-17';
delete from t2 where col1='2006-12-17';
delete from t3 where col1='2006-12-17';
delete from t4 where col1='2006-12-17';
delete from t5 where col1='2006-12-17';
delete from t6 where col1='2006-12-17';
+commit;
select * from t1 order by col1;
col1
2006-07-30
@@ -8828,12 +8988,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-12-17');
insert into t2 values ('2006-12-17');
insert into t3 values ('2006-12-17');
insert into t4 values (60,'2006-12-17');
insert into t5 values (60,'2006-12-17');
insert into t6 values (60,'2006-12-17');
+commit;
select * from t1 order by col1;
col1
2006-07-30
@@ -8896,12 +9058,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with quarter(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-12-17';
delete from t22 where col1='2006-12-17';
delete from t33 where col1='2006-12-17';
delete from t44 where col1='2006-12-17';
delete from t55 where col1='2006-12-17';
delete from t66 where col1='2006-12-17';
+commit;
select * from t11 order by col1;
col1
2006-07-30
@@ -8925,12 +9089,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-12-17');
insert into t22 values ('2006-12-17');
insert into t33 values ('2006-12-17');
insert into t44 values (60,'2006-12-17');
insert into t55 values (60,'2006-12-17');
insert into t66 values (60,'2006-12-17');
+commit;
select * from t11 order by col1;
col1
2006-07-30
@@ -9006,523 +9172,6 @@ drop table if exists t44 ;
drop table if exists t55 ;
drop table if exists t66 ;
-------------------------------------------------------------------------
---- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time
--------------------------------------------------------------------------
-drop table if exists t1 ;
-drop table if exists t2 ;
-drop table if exists t3 ;
-drop table if exists t4 ;
-drop table if exists t5 ;
-drop table if exists t6 ;
--------------------------------------------------------------------------
---- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-create table t1 (col1 time) engine='MYISAM'
-partition by range(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-create table t2 (col1 time) engine='MYISAM'
-partition by list(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-create table t3 (col1 time) engine='MYISAM'
-partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
-create table t4 (colint int, col1 time) engine='MYISAM'
-partition by range(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-create table t5 (colint int, col1 time) engine='MYISAM'
-partition by list(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-create table t6 (colint int, col1 time) engine='MYISAM'
-partition by range(colint)
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
--------------------------------------------------------------------------
---- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-insert into t1 values ('09:09:15');
-insert into t1 values ('14:30:45');
-insert into t2 values ('09:09:15');
-insert into t2 values ('14:30:45');
-insert into t2 values ('21:59:22');
-insert into t3 values ('09:09:15');
-insert into t3 values ('14:30:45');
-insert into t3 values ('21:59:22');
-load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
-load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
-load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
-select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1;
-time_to_sec(col1)-(time_to_sec(col1)-20)
-20
-20
-select * from t1 order by col1;
-col1
-09:09:15
-14:30:45
-select * from t2 order by col1;
-col1
-09:09:15
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-09:09:15
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t5 order by colint;
-colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t6 order by colint;
-colint col1
-1 09:09:15
-2 04:30:01
-3 00:59:22
-4 05:30:34
-update t1 set col1='10:33:11' where col1='09:09:15';
-update t2 set col1='10:33:11' where col1='09:09:15';
-update t3 set col1='10:33:11' where col1='09:09:15';
-update t4 set col1='10:33:11' where col1='09:09:15';
-update t5 set col1='10:33:11' where col1='09:09:15';
-update t6 set col1='10:33:11' where col1='09:09:15';
-select * from t1 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t2 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t5 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t6 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
--------------------------------------------------------------------------
---- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-drop table if exists t11 ;
-drop table if exists t22 ;
-drop table if exists t33 ;
-drop table if exists t44 ;
-drop table if exists t55 ;
-drop table if exists t66 ;
-create table t11 engine='MYISAM' as select * from t1;
-create table t22 engine='MYISAM' as select * from t2;
-create table t33 engine='MYISAM' as select * from t3;
-create table t44 engine='MYISAM' as select * from t4;
-create table t55 engine='MYISAM' as select * from t5;
-create table t66 engine='MYISAM' as select * from t6;
-alter table t11
-partition by range(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-alter table t22
-partition by list(time_to_sec(col1)-(time_to_sec(col1)-20))
-(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-alter table t33
-partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
-alter table t44
-partition by range(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-alter table t55
-partition by list(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2
-(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-alter table t66
-partition by range(colint)
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t22 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t44 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
----------------------------
----- some alter table begin
----------------------------
-alter table t11
-reorganize partition p0,p1 into
-(partition s1 values less than maxvalue);
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-alter table t11
-reorganize partition s1 into
-(partition p0 values less than (15),
-partition p1 values less than maxvalue);
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-alter table t55
-partition by list(colint)
-subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5
-(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
-partition p1 values in (11,12,13,14,15,16,17,18,19,20),
-partition p2 values in (21,22,23,24,25,26,27,28,29,30),
-partition p3 values in (31,32,33,34,35,36,37,38,39,40),
-partition p4 values in (41,42,43,44,45,46,47,48,49,50),
-partition p5 values in (51,52,53,54,55,56,57,58,59,60)
-);
-show create table t55;
-Table Create Table
-t55 CREATE TABLE `t55` (
- `colint` int(11) DEFAULT NULL,
- `col1` time DEFAULT NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST (colint)
-SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20))
-SUBPARTITIONS 5
-(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM,
- PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM,
- PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM,
- PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = MyISAM,
- PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = MyISAM,
- PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition p0,p1 into
-(partition s1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition s1 into
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition p0,p1 into
-(partition s1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-alter table t66
-reorganize partition s1 into
-(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
-partition p1 values less than maxvalue);
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
--------------------------------------------------------------------------
---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-delete from t1 where col1='14:30:45';
-delete from t2 where col1='14:30:45';
-delete from t3 where col1='14:30:45';
-delete from t4 where col1='14:30:45';
-delete from t5 where col1='14:30:45';
-delete from t6 where col1='14:30:45';
-select * from t1 order by col1;
-col1
-10:33:11
-select * from t2 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t5 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-insert into t1 values ('14:30:45');
-insert into t2 values ('14:30:45');
-insert into t3 values ('14:30:45');
-insert into t4 values (60,'14:30:45');
-insert into t5 values (60,'14:30:45');
-insert into t6 values (60,'14:30:45');
-select * from t1 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t2 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t5 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t6 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-alter table t1 drop partition p0;
-alter table t2 drop partition p0;
-alter table t4 drop partition p0;
-alter table t5 drop partition p0;
-alter table t6 drop partition p0;
-select * from t1 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t2 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t3 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t4 order by colint;
-colint col1
-60 14:30:45
-select * from t5 order by colint;
-colint col1
-60 14:30:45
-select * from t6 order by colint;
-colint col1
--------------------------------------------------------------------------
---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20)
--------------------------------------------------------------------------
-delete from t11 where col1='14:30:45';
-delete from t22 where col1='14:30:45';
-delete from t33 where col1='14:30:45';
-delete from t44 where col1='14:30:45';
-delete from t55 where col1='14:30:45';
-delete from t66 where col1='14:30:45';
-select * from t11 order by col1;
-col1
-10:33:11
-select * from t22 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-21:59:22
-select * from t44 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-insert into t11 values ('14:30:45');
-insert into t22 values ('14:30:45');
-insert into t33 values ('14:30:45');
-insert into t44 values (60,'14:30:45');
-insert into t55 values (60,'14:30:45');
-insert into t66 values (60,'14:30:45');
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t22 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t44 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t55 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-select * from t66 order by colint;
-colint col1
-1 10:33:11
-2 04:30:01
-3 00:59:22
-4 05:30:34
-60 14:30:45
-alter table t11 drop partition p0;
-alter table t22 drop partition p0;
-alter table t44 drop partition p0;
-alter table t55 drop partition p0;
-alter table t66 drop partition p0;
-select * from t11 order by col1;
-col1
-10:33:11
-14:30:45
-select * from t22 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t33 order by col1;
-col1
-10:33:11
-14:30:45
-21:59:22
-select * from t44 order by colint;
-colint col1
-60 14:30:45
-select * from t55 order by colint;
-colint col1
-60 14:30:45
-select * from t66 order by colint;
-colint col1
--------------------------
----- some alter table end
--------------------------
-drop table if exists t1 ;
-drop table if exists t2 ;
-drop table if exists t3 ;
-drop table if exists t4 ;
-drop table if exists t5 ;
-drop table if exists t6 ;
-drop table if exists t11 ;
-drop table if exists t22 ;
-drop table if exists t33 ;
-drop table if exists t44 ;
-drop table if exists t55 ;
-drop table if exists t66 ;
--------------------------------------------------------------------------
--- weekday(col1) in partition with coltype date
-------------------------------------------------------------------------
drop table if exists t1 ;
@@ -9571,6 +9220,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with weekday(col1)
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-12-03');
insert into t1 values ('2006-11-17');
insert into t2 values ('2006-12-03');
@@ -9579,6 +9229,7 @@ insert into t2 values ('2006-05-25');
insert into t3 values ('2006-12-03');
insert into t3 values ('2006-11-17');
insert into t3 values ('2006-05-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -9618,12 +9269,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-02-06' where col1='2006-12-03';
update t2 set col1='2006-02-06' where col1='2006-12-03';
update t3 set col1='2006-02-06' where col1='2006-12-03';
update t4 set col1='2006-02-06' where col1='2006-12-03';
update t5 set col1='2006-02-06' where col1='2006-12-03';
update t6 set col1='2006-02-06' where col1='2006-12-03';
+commit;
select * from t1 order by col1;
col1
2006-02-06
@@ -9827,12 +9480,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with weekday(col1)
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-11-17';
delete from t2 where col1='2006-11-17';
delete from t3 where col1='2006-11-17';
delete from t4 where col1='2006-11-17';
delete from t5 where col1='2006-11-17';
delete from t6 where col1='2006-11-17';
+commit;
select * from t1 order by col1;
col1
2006-02-06
@@ -9856,12 +9511,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-11-17');
insert into t2 values ('2006-11-17');
insert into t3 values ('2006-11-17');
insert into t4 values (60,'2006-11-17');
insert into t5 values (60,'2006-11-17');
insert into t6 values (60,'2006-11-17');
+commit;
select * from t1 order by col1;
col1
2006-02-06
@@ -9923,12 +9580,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with weekday(col1)
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-11-17';
delete from t22 where col1='2006-11-17';
delete from t33 where col1='2006-11-17';
delete from t44 where col1='2006-11-17';
delete from t55 where col1='2006-11-17';
delete from t66 where col1='2006-11-17';
+commit;
select * from t11 order by col1;
col1
2006-02-06
@@ -9952,12 +9611,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-11-17');
insert into t22 values ('2006-11-17');
insert into t33 values ('2006-11-17');
insert into t44 values (60,'2006-11-17');
insert into t55 values (60,'2006-11-17');
insert into t66 values (60,'2006-11-17');
+commit;
select * from t11 order by col1;
col1
2006-02-06
@@ -10080,6 +9741,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with year(col1)-1990
-------------------------------------------------------------------------
+begin;
insert into t1 values ('1996-01-03');
insert into t1 values ('2000-02-17');
insert into t2 values ('1996-01-03');
@@ -10088,6 +9750,7 @@ insert into t2 values ('2004-05-25');
insert into t3 values ('1996-01-03');
insert into t3 values ('2000-02-17');
insert into t3 values ('2004-05-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -10127,12 +9790,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2002-02-15' where col1='1996-01-03';
update t2 set col1='2002-02-15' where col1='1996-01-03';
update t3 set col1='2002-02-15' where col1='1996-01-03';
update t4 set col1='2002-02-15' where col1='1996-01-03';
update t5 set col1='2002-02-15' where col1='1996-01-03';
update t6 set col1='2002-02-15' where col1='1996-01-03';
+commit;
select * from t1 order by col1;
col1
2000-02-17
@@ -10336,12 +10001,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with year(col1)-1990
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2000-02-17';
delete from t2 where col1='2000-02-17';
delete from t3 where col1='2000-02-17';
delete from t4 where col1='2000-02-17';
delete from t5 where col1='2000-02-17';
delete from t6 where col1='2000-02-17';
+commit;
select * from t1 order by col1;
col1
2002-02-15
@@ -10365,12 +10032,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2000-02-17');
insert into t2 values ('2000-02-17');
insert into t3 values ('2000-02-17');
insert into t4 values (60,'2000-02-17');
insert into t5 values (60,'2000-02-17');
insert into t6 values (60,'2000-02-17');
+commit;
select * from t1 order by col1;
col1
2000-02-17
@@ -10434,12 +10103,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with year(col1)-1990
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2000-02-17';
delete from t22 where col1='2000-02-17';
delete from t33 where col1='2000-02-17';
delete from t44 where col1='2000-02-17';
delete from t55 where col1='2000-02-17';
delete from t66 where col1='2000-02-17';
+commit;
select * from t11 order by col1;
col1
2002-02-15
@@ -10463,12 +10134,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2000-02-17');
insert into t22 values ('2000-02-17');
insert into t33 values ('2000-02-17');
insert into t44 values (60,'2000-02-17');
insert into t55 values (60,'2000-02-17');
insert into t66 values (60,'2000-02-17');
+commit;
select * from t11 order by col1;
col1
2000-02-17
@@ -10593,6 +10266,7 @@ partition p1 values less than maxvalue);
-------------------------------------------------------------------------
--- Access tables with yearweek(col1)-200600
-------------------------------------------------------------------------
+begin;
insert into t1 values ('2006-01-03');
insert into t1 values ('2006-08-17');
insert into t2 values ('2006-01-03');
@@ -10601,6 +10275,7 @@ insert into t2 values ('2006-03-25');
insert into t3 values ('2006-01-03');
insert into t3 values ('2006-08-17');
insert into t3 values ('2006-03-25');
+commit;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
@@ -10640,12 +10315,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
update t1 set col1='2006-11-15' where col1='2006-01-03';
update t2 set col1='2006-11-15' where col1='2006-01-03';
update t3 set col1='2006-11-15' where col1='2006-01-03';
update t4 set col1='2006-11-15' where col1='2006-01-03';
update t5 set col1='2006-11-15' where col1='2006-01-03';
update t6 set col1='2006-11-15' where col1='2006-01-03';
+commit;
select * from t1 order by col1;
col1
2006-08-17
@@ -10849,12 +10526,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with yearweek(col1)-200600
-------------------------------------------------------------------------
+begin;
delete from t1 where col1='2006-08-17';
delete from t2 where col1='2006-08-17';
delete from t3 where col1='2006-08-17';
delete from t4 where col1='2006-08-17';
delete from t5 where col1='2006-08-17';
delete from t6 where col1='2006-08-17';
+commit;
select * from t1 order by col1;
col1
2006-11-15
@@ -10878,12 +10557,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t1 values ('2006-08-17');
insert into t2 values ('2006-08-17');
insert into t3 values ('2006-08-17');
insert into t4 values (60,'2006-08-17');
insert into t5 values (60,'2006-08-17');
insert into t6 values (60,'2006-08-17');
+commit;
select * from t1 order by col1;
col1
2006-08-17
@@ -10950,12 +10631,14 @@ colint col1
-------------------------------------------------------------------------
--- Delete rows and partitions of tables with yearweek(col1)-200600
-------------------------------------------------------------------------
+begin;
delete from t11 where col1='2006-08-17';
delete from t22 where col1='2006-08-17';
delete from t33 where col1='2006-08-17';
delete from t44 where col1='2006-08-17';
delete from t55 where col1='2006-08-17';
delete from t66 where col1='2006-08-17';
+commit;
select * from t11 order by col1;
col1
2006-11-15
@@ -10979,12 +10662,14 @@ colint col1
2 2006-01-17
3 2006-01-25
4 2006-02-05
+begin;
insert into t11 values ('2006-08-17');
insert into t22 values ('2006-08-17');
insert into t33 values ('2006-08-17');
insert into t44 values (60,'2006-08-17');
insert into t55 values (60,'2006-08-17');
insert into t66 values (60,'2006-08-17');
+commit;
select * from t11 order by col1;
col1
2006-08-17
diff --git a/mysql-test/suite/parts/r/partition_bit_innodb.result b/mysql-test/suite/parts/r/partition_bit_innodb.result
index a9ae917f13d..2e802d85b1f 100644
--- a/mysql-test/suite/parts/r/partition_bit_innodb.result
+++ b/mysql-test/suite/parts/r/partition_bit_innodb.result
@@ -1,7 +1,7 @@
SET @max_row = 20;
drop table if exists t1;
create table t1 (a bit(65), primary key (a)) engine='INNODB' partition by key (a);
-ERROR 42000: Display width out of range for column 'a' (max = 64)
+ERROR 42000: Display width out of range for 'a' (max = 64)
create table t1 (a bit(0), primary key (a)) engine='INNODB' partition by key (a);
show create table t1;
Table Create Table
diff --git a/mysql-test/suite/parts/r/partition_bit_myisam.result b/mysql-test/suite/parts/r/partition_bit_myisam.result
index 680845c9971..c396cf66521 100644
--- a/mysql-test/suite/parts/r/partition_bit_myisam.result
+++ b/mysql-test/suite/parts/r/partition_bit_myisam.result
@@ -1,7 +1,7 @@
SET @max_row = 20;
drop table if exists t1;
create table t1 (a bit(65), primary key (a)) engine='MyISAM' partition by key (a);
-ERROR 42000: Display width out of range for column 'a' (max = 64)
+ERROR 42000: Display width out of range for 'a' (max = 64)
create table t1 (a bit(0), primary key (a)) engine='MyISAM' partition by key (a);
show create table t1;
Table Create Table
diff --git a/mysql-test/suite/parts/r/partition_repair_myisam.result b/mysql-test/suite/parts/r/partition_repair_myisam.result
index 4af00ddcc6d..a34627a91cb 100644
--- a/mysql-test/suite/parts/r/partition_repair_myisam.result
+++ b/mysql-test/suite/parts/r/partition_repair_myisam.result
@@ -393,6 +393,8 @@ partition b a length(c)
6 34 6 row 2 64
6 83 64
6 97 zzzzzZzzzzz 64
+SET @save_optimizer_switch= @@optimizer_switch;
+SET @@optimizer_switch='derived_merge=off';
SELECT (b % 7) AS partition, b, a FROM (SELECT b,a FROM t1_will_crash) q
WHERE (b % 7) = 6
ORDER BY partition, b, a;
@@ -404,6 +406,7 @@ partition b a
6 62 6 row 6
6 83
6 97 zzzzzZzzzzz
+SET @@optimizer_switch=@save_optimizer_switch;
ALTER TABLE t1_will_crash CHECK PARTITION p6;
Table Op Msg_type Msg_text
test.t1_will_crash check warning Size of datafile is: 868 Should be: 604
diff --git a/mysql-test/suite/parts/r/rpl_partition.result b/mysql-test/suite/parts/r/rpl_partition.result
index 00247f218e4..048ae77b367 100644
--- a/mysql-test/suite/parts/r/rpl_partition.result
+++ b/mysql-test/suite/parts/r/rpl_partition.result
@@ -96,13 +96,19 @@ DELETE FROM t3 WHERE id = del_count;
SET del_count = del_count - 2;
END WHILE;
END|
+begin;
CALL p1();
+commit;
SELECT count(*) as "Master regular" FROM t1;
Master regular 500
+begin;
CALL p2();
+commit;
SELECT count(*) as "Master bykey" FROM t2;
Master bykey 500
+begin;
CALL p3();
+commit;
SELECT count(*) as "Master byrange" FROM t3;
Master byrange 500
show create table t3;
diff --git a/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test b/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test
index 115bc08a624..20348cc331d 100644
--- a/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test
+++ b/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test
@@ -26,13 +26,11 @@ let $debug= 0;
let $do_long_tests= 1;
#
+# This test takes long time, so only run it with the --big mtr-flag.
--source include/big_test.inc
# The server must support partitioning.
--source include/have_partition.inc
-# This test takes long time, so only run it with the --big mtr-flag.
---source include/big_test.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
diff --git a/mysql-test/suite/parts/t/partition_repair_myisam.test b/mysql-test/suite/parts/t/partition_repair_myisam.test
index a7ceb5b7faf..849f175b920 100644
--- a/mysql-test/suite/parts/t/partition_repair_myisam.test
+++ b/mysql-test/suite/parts/t/partition_repair_myisam.test
@@ -230,9 +230,12 @@ FLUSH TABLES;
SELECT (b % 7) AS partition, b, a, length(c) FROM t1_will_crash
WHERE (b % 7) = 6
ORDER BY partition, b, a;
+SET @save_optimizer_switch= @@optimizer_switch;
+SET @@optimizer_switch='derived_merge=off';
SELECT (b % 7) AS partition, b, a FROM (SELECT b,a FROM t1_will_crash) q
WHERE (b % 7) = 6
ORDER BY partition, b, a;
+SET @@optimizer_switch=@save_optimizer_switch;
# NOTE: REBUILD PARTITION without CHECK before, 2 + (1) records will be lost!
#ALTER TABLE t1_will_crash REBUILD PARTITION p6;
ALTER TABLE t1_will_crash CHECK PARTITION p6;
diff --git a/mysql-test/suite/parts/t/rpl_partition.test b/mysql-test/suite/parts/t/rpl_partition.test
index 409f428b34b..5294ff9fe3c 100644
--- a/mysql-test/suite/parts/t/rpl_partition.test
+++ b/mysql-test/suite/parts/t/rpl_partition.test
@@ -127,11 +127,17 @@ delimiter ;|
############ Test Section ###################
+begin;
CALL p1();
+commit;
SELECT count(*) as "Master regular" FROM t1;
+begin;
CALL p2();
+commit;
SELECT count(*) as "Master bykey" FROM t2;
+begin;
CALL p3();
+commit;
SELECT count(*) as "Master byrange" FROM t3;
--sync_slave_with_master
diff --git a/mysql-test/suite/pbxt/r/cast.result b/mysql-test/suite/pbxt/r/cast.result
index bc0c983c8e1..262c8ea48e5 100644
--- a/mysql-test/suite/pbxt/r/cast.result
+++ b/mysql-test/suite/pbxt/r/cast.result
@@ -1,9 +1,13 @@
select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED)
18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select CAST('10 ' as unsigned integer);
CAST('10 ' as unsigned integer)
10
@@ -12,9 +16,15 @@ Warning 1292 Truncated incorrect INTEGER value: '10 '
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
18446744073709551611 18446744073709551611
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
18446744073709551610 18446744073709551612
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select ~5, cast(~5 as signed);
~5 cast(~5 as signed)
18446744073709551610 -6
@@ -254,7 +264,7 @@ cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
1
select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03"
-0
+1
select cast(NULL as DATE);
cast(NULL as DATE)
NULL
diff --git a/mysql-test/suite/pbxt/r/client_xml.result b/mysql-test/suite/pbxt/r/client_xml.result
index 6a148954fcd..20730ff0a09 100644
--- a/mysql-test/suite/pbxt/r/client_xml.result
+++ b/mysql-test/suite/pbxt/r/client_xml.result
@@ -18,9 +18,9 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="test">
<table_structure name="t1">
- <field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" />
- <field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" />
- <field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" />
+ <field Field="a&amp;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="a&lt;b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
+ <field Field="a&gt;b" Type="text" Null="YES" Key="" Extra="" Comment="" />
</table_structure>
<table_data name="t1">
<row>
diff --git a/mysql-test/suite/pbxt/r/date_formats.result b/mysql-test/suite/pbxt/r/date_formats.result
index 808c84d7c13..da62ff7a2f8 100644
--- a/mysql-test/suite/pbxt/r/date_formats.result
+++ b/mysql-test/suite/pbxt/r/date_formats.result
@@ -185,16 +185,16 @@ date format datetime
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
-2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
-2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
-2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
10:20:10 %H:%i:%s 0000-00-00 10:20:10
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
10:20:10 %T 0000-00-00 10:20:10
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
10:20:10AM %r 0000-00-00 10:20:10
-10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
+10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
15 September 2001 %d %M %Y 2001-09-15 00:00:00
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
@@ -404,14 +404,14 @@ date format str_to_date
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
Warnings:
-Warning 1292 Incorrect datetime value: '10:20:10AM'
+Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
select date,format,concat(str_to_date(date, format),'') as con from t1;
date format con
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
Warnings:
-Warning 1292 Incorrect datetime value: '10:20:10AM'
+Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
drop table t1;
select get_format(DATE, 'USA') as a;
a
@@ -454,14 +454,14 @@ str_to_date("2003-01-02", "%Y-%m-%d") as f3,
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
describe t1;
Field Type Null Key Default Extra
-f1 datetime YES NULL
-f2 time YES NULL
+f1 datetime(6) YES NULL
+f2 time(6) YES NULL
f3 date YES NULL
f4 date YES NULL
f5 time YES NULL
select * from t1;
f1 f2 f3 f4 f5
-2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00
+2003-01-02 10:11:12.001200 10:11:12.001200 2003-01-02 0000-00-02 58:00:00
drop table t1;
create table t1 select "02 10" as a, "%d %H" as b;
select str_to_date(a,b) from t1;
@@ -470,7 +470,7 @@ str_to_date(a,b)
create table t2 select str_to_date(a,b) from t1;
describe t2;
Field Type Null Key Default Extra
-str_to_date(a,b) datetime YES NULL
+str_to_date(a,b) datetime(6) YES NULL
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
@@ -478,7 +478,7 @@ str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
str_to_date("02 10", "%d %f") as f6;
f1 f2 f3 f4 f5 f6
-2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12 58:11:12 48:00:00.100000
+2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12.000000 58:11:12 48:00:00.100000
Warnings:
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012'
drop table t1, t2;
diff --git a/mysql-test/suite/pbxt/r/derived.result b/mysql-test/suite/pbxt/r/derived.result
index 56d2f8ac929..b4c1762e81a 100644
--- a/mysql-test/suite/pbxt/r/derived.result
+++ b/mysql-test/suite/pbxt/r/derived.result
@@ -57,9 +57,8 @@ a b a b
3 c 3 c
explain select * from t1 as x1, (select * from t1) as x2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY x1 ALL NULL NULL NULL NULL 4
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 4
+1 SIMPLE x1 ALL NULL NULL NULL NULL 4
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
drop table if exists t2,t3;
select * from (select 1) as a;
1
@@ -91,7 +90,7 @@ a b
2 b
explain select * from (select * from t1 union select * from t1) a;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8
2 DERIVED t1 ALL NULL NULL NULL NULL 4
3 UNION t1 ALL NULL NULL NULL NULL 4
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
@@ -113,9 +112,8 @@ a b
3 c
explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t2 ALL NULL NULL NULL NULL 1
-2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
drop table t1, t2;
create table t1(a int not null, t char(8), index(a));
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
@@ -142,9 +140,8 @@ a t
20 20
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY tt1 index NULL a 4 NULL 10000 Using index
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10000 Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 10000
+1 SIMPLE tt1 index NULL a 4 NULL 10000 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using join buffer (flat, BNL join)
drop table t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
(SELECT * FROM (SELECT 1 as a) as a )
@@ -173,30 +170,30 @@ insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd'
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
pla_id mat_id
-100 1
-101 1
102 1
-103 2
+101 1
+100 1
104 2
+103 2
105 3
SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
pla_id test
-100 1
-101 1
102 1
-103 2
+101 1
+100 1
104 2
+103 2
105 3
explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
drop table t1,t2;
@@ -234,9 +231,8 @@ count(*)
2
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where
-2 DERIVED A ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE A ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.A.E2 1 Using where
3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
drop table t1;
create table t1 (a int);
@@ -249,8 +245,8 @@ a a
2 2
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-1 PRIMARY <derived4> ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
+1 PRIMARY <derived4> ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
4 DERIVED t1 ALL NULL NULL NULL NULL 2
5 UNION t1 ALL NULL NULL NULL NULL 2
NULL UNION RESULT <union4,5> ALL NULL NULL NULL NULL NULL
@@ -315,7 +311,7 @@ a 7.0000
b 3.5000
explain SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 289 Using temporary; Using filesort
2 DERIVED x ALL NULL NULL NULL NULL 17 Using temporary; Using filesort
2 DERIVED y ALL NULL NULL NULL NULL 17 Using where; Using join buffer (flat, BNL join)
drop table t1;
@@ -326,8 +322,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
explain select a from (select a from t2 where a>1) tt;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
drop table t2;
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
diff --git a/mysql-test/suite/pbxt/r/errors.result b/mysql-test/suite/pbxt/r/errors.result
index 0c84f24a2e4..eca18ed6434 100644
--- a/mysql-test/suite/pbxt/r/errors.result
+++ b/mysql-test/suite/pbxt/r/errors.result
@@ -24,7 +24,7 @@ select count(*),b from t1;
ERROR 42S22: Unknown column 'b' in 'field list'
drop table t1;
create table t1 (a int(256));
-ERROR 42000: Display width out of range for column 'a' (max = 255)
+ERROR 42000: Display width out of range for 'a' (max = 255)
set sql_mode='traditional';
create table t1 (a varchar(66000));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
diff --git a/mysql-test/suite/pbxt/r/func_in.result b/mysql-test/suite/pbxt/r/func_in.result
index 167f75240a7..b6b9e8be16e 100644
--- a/mysql-test/suite/pbxt/r/func_in.result
+++ b/mysql-test/suite/pbxt/r/func_in.result
@@ -419,15 +419,9 @@ id select_type table type possible_keys key key_len ref rows Extra
select f2 from t2 where f2 in ('a','b');
f2
0
-Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'a'
-Warning 1292 Truncated incorrect DOUBLE value: 'b'
explain select f2 from t2 where f2 in ('a','b');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
-Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'a'
-Warning 1292 Truncated incorrect DOUBLE value: 'b'
select f2 from t2 where f2 in (1,'b');
f2
0
diff --git a/mysql-test/suite/pbxt/r/func_sapdb.result b/mysql-test/suite/pbxt/r/func_sapdb.result
index b0c697e54ac..9e8775c876a 100644
--- a/mysql-test/suite/pbxt/r/func_sapdb.result
+++ b/mysql-test/suite/pbxt/r/func_sapdb.result
@@ -104,10 +104,10 @@ subtime("01:00:00.999999", "02:00:00.999998")
-00:59:59.999999
select subtime("02:01:01.999999", "01:01:01.999999");
subtime("02:01:01.999999", "01:01:01.999999")
-01:00:00.000000
+01:00:00
select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
-838:59:59
+838:59:59.999999
Warnings:
Warning 1292 Truncated incorrect time value: '8807:59:59.999999'
select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
@@ -186,17 +186,17 @@ time("1997-12-31 23:59:59.000001") as f9;
describe t1;
Field Type Null Key Default Extra
f1 date YES NULL
-f2 datetime YES NULL
-f3 time YES NULL
-f4 time YES NULL
-f5 time YES NULL
+f2 datetime(6) YES NULL
+f3 time(6) YES NULL
+f4 time(6) YES NULL
+f5 time(6) YES NULL
f6 time YES NULL
-f7 datetime YES NULL
+f7 datetime(6) YES NULL
f8 date YES NULL
-f9 time YES NULL
+f9 time(6) YES NULL
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8 f9
-1997-01-01 1998-01-02 01:01:00 49:01:01 46:58:57 -24:00:00 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
+1997-01-01 1998-01-02 01:01:00.000002 49:01:00.000002 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
insert into test values
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
@@ -241,6 +241,8 @@ a
select microsecond(19971231235959.01) as a;
a
10000
+Warnings:
+Warning 1292 Truncated incorrect time value: '19971231235959.01'
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
a
1997-12-31 00:00:10.090000
diff --git a/mysql-test/suite/pbxt/r/func_str.result b/mysql-test/suite/pbxt/r/func_str.result
index 4dc909f42e4..39d79d7ec45 100644
--- a/mysql-test/suite/pbxt/r/func_str.result
+++ b/mysql-test/suite/pbxt/r/func_str.result
@@ -1504,7 +1504,7 @@ select locate('lo','hello',-18446744073709551615);
locate('lo','hello',-18446744073709551615)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select locate('lo','hello',18446744073709551615);
locate('lo','hello',18446744073709551615)
0
@@ -1512,22 +1512,22 @@ select locate('lo','hello',-18446744073709551616);
locate('lo','hello',-18446744073709551616)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select locate('lo','hello',18446744073709551616);
locate('lo','hello',18446744073709551616)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select locate('lo','hello',-18446744073709551617);
locate('lo','hello',-18446744073709551617)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select locate('lo','hello',18446744073709551617);
locate('lo','hello',18446744073709551617)
0
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select left('hello', 10);
left('hello', 10)
hello
@@ -1559,8 +1559,8 @@ select left('hello', -18446744073709551615);
left('hello', -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select left('hello', 18446744073709551615);
left('hello', 18446744073709551615)
hello
@@ -1568,26 +1568,26 @@ select left('hello', -18446744073709551616);
left('hello', -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select left('hello', 18446744073709551616);
left('hello', 18446744073709551616)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select left('hello', -18446744073709551617);
left('hello', -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select left('hello', 18446744073709551617);
left('hello', 18446744073709551617)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select right('hello', 10);
right('hello', 10)
hello
@@ -1619,8 +1619,8 @@ select right('hello', -18446744073709551615);
right('hello', -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select right('hello', 18446744073709551615);
right('hello', 18446744073709551615)
hello
@@ -1628,26 +1628,26 @@ select right('hello', -18446744073709551616);
right('hello', -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select right('hello', 18446744073709551616);
right('hello', 18446744073709551616)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select right('hello', -18446744073709551617);
right('hello', -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select right('hello', 18446744073709551617);
right('hello', 18446744073709551617)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 2, -1);
substring('hello', 2, -1)
@@ -1679,8 +1679,8 @@ select substring('hello', -18446744073709551615, 1);
substring('hello', -18446744073709551615, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 1);
substring('hello', 18446744073709551615, 1)
@@ -1688,26 +1688,26 @@ select substring('hello', -18446744073709551616, 1);
substring('hello', -18446744073709551616, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 1);
substring('hello', 18446744073709551616, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, 1);
substring('hello', -18446744073709551617, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 1);
substring('hello', 18446744073709551617, 1)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', 1, -1);
substring('hello', 1, -1)
@@ -1733,8 +1733,8 @@ select substring('hello', 1, -18446744073709551615);
substring('hello', 1, -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 1, 18446744073709551615);
substring('hello', 1, 18446744073709551615)
hello
@@ -1742,26 +1742,26 @@ select substring('hello', 1, -18446744073709551616);
substring('hello', 1, -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 1, 18446744073709551616);
substring('hello', 1, 18446744073709551616)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', 1, -18446744073709551617);
substring('hello', 1, -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 1, 18446744073709551617);
substring('hello', 1, 18446744073709551617)
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select substring('hello', -1, -1);
substring('hello', -1, -1)
@@ -1787,10 +1787,10 @@ select substring('hello', -18446744073709551615, -18446744073709551615);
substring('hello', -18446744073709551615, -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select substring('hello', 18446744073709551615, 18446744073709551615);
substring('hello', 18446744073709551615, 18446744073709551615)
@@ -1798,34 +1798,34 @@ select substring('hello', -18446744073709551616, -18446744073709551616);
substring('hello', -18446744073709551616, -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select substring('hello', 18446744073709551616, 18446744073709551616);
substring('hello', 18446744073709551616, 18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select substring('hello', -18446744073709551617, -18446744073709551617);
substring('hello', -18446744073709551617, -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select substring('hello', 18446744073709551617, 18446744073709551617);
substring('hello', 18446744073709551617, 18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, 1, 'hi');
insert('hello', -1, 1, 'hi')
hello
@@ -1851,7 +1851,7 @@ select insert('hello', -18446744073709551615, 1, 'hi');
insert('hello', -18446744073709551615, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 1, 'hi');
insert('hello', 18446744073709551615, 1, 'hi')
hello
@@ -1859,22 +1859,22 @@ select insert('hello', -18446744073709551616, 1, 'hi');
insert('hello', -18446744073709551616, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 1, 'hi');
insert('hello', 18446744073709551616, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, 1, 'hi');
insert('hello', -18446744073709551617, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 1, 'hi');
insert('hello', 18446744073709551617, 1, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', 1, -1, 'hi');
insert('hello', 1, -1, 'hi')
hi
@@ -1900,7 +1900,7 @@ select insert('hello', 1, -18446744073709551615, 'hi');
insert('hello', 1, -18446744073709551615, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 1, 18446744073709551615, 'hi');
insert('hello', 1, 18446744073709551615, 'hi')
hi
@@ -1908,22 +1908,22 @@ select insert('hello', 1, -18446744073709551616, 'hi');
insert('hello', 1, -18446744073709551616, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 1, 18446744073709551616, 'hi');
insert('hello', 1, 18446744073709551616, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', 1, -18446744073709551617, 'hi');
insert('hello', 1, -18446744073709551617, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 1, 18446744073709551617, 'hi');
insert('hello', 1, 18446744073709551617, 'hi')
hi
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select insert('hello', -1, -1, 'hi');
insert('hello', -1, -1, 'hi')
hello
@@ -1949,8 +1949,8 @@ select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
hello
@@ -1958,26 +1958,26 @@ select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
hello
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
select repeat('hello', -1);
repeat('hello', -1)
@@ -2009,8 +2009,8 @@ select repeat('hello', -18446744073709551615);
repeat('hello', -18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select repeat('hello', 18446744073709551615);
repeat('hello', 18446744073709551615)
NULL
@@ -2020,27 +2020,27 @@ select repeat('hello', -18446744073709551616);
repeat('hello', -18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select repeat('hello', 18446744073709551616);
repeat('hello', 18446744073709551616)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select repeat('hello', -18446744073709551617);
repeat('hello', -18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select repeat('hello', 18446744073709551617);
repeat('hello', 18446744073709551617)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-1);
space(-1)
@@ -2073,8 +2073,8 @@ select space(-18446744073709551615);
space(-18446744073709551615)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select space(18446744073709551615);
space(18446744073709551615)
NULL
@@ -2084,27 +2084,27 @@ select space(-18446744073709551616);
space(-18446744073709551616)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select space(18446744073709551616);
space(18446744073709551616)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select space(-18446744073709551617);
space(-18446744073709551617)
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select space(18446744073709551617);
space(18446744073709551617)
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -1, '1');
rpad('hello', -1, '1')
@@ -2137,8 +2137,8 @@ select rpad('hello', -18446744073709551615, '1');
rpad('hello', -18446744073709551615, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select rpad('hello', 18446744073709551615, '1');
rpad('hello', 18446744073709551615, '1')
NULL
@@ -2148,27 +2148,27 @@ select rpad('hello', -18446744073709551616, '1');
rpad('hello', -18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select rpad('hello', 18446744073709551616, '1');
rpad('hello', 18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551617, '1');
rpad('hello', -18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select rpad('hello', 18446744073709551617, '1');
rpad('hello', 18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -1, '1');
lpad('hello', -1, '1')
@@ -2201,8 +2201,8 @@ select lpad('hello', -18446744073709551615, '1');
lpad('hello', -18446744073709551615, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated.
select lpad('hello', 18446744073709551615, '1');
lpad('hello', 18446744073709551615, '1')
NULL
@@ -2212,27 +2212,27 @@ select lpad('hello', -18446744073709551616, '1');
lpad('hello', -18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated.
select lpad('hello', 18446744073709551616, '1');
lpad('hello', 18446744073709551616, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551617, '1');
lpad('hello', -18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated.
select lpad('hello', 18446744073709551617, '1');
lpad('hello', 18446744073709551617, '1')
NULL
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
+Error 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated.
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
diff --git a/mysql-test/suite/pbxt/r/func_timestamp.result b/mysql-test/suite/pbxt/r/func_timestamp.result
index 495fedea9e6..18fcbd947e7 100644
--- a/mysql-test/suite/pbxt/r/func_timestamp.result
+++ b/mysql-test/suite/pbxt/r/func_timestamp.result
@@ -7,7 +7,7 @@ SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
FROM t1;
Date Unix
-1998-9-16 09:26:00 905927160
-1998-9-16 09:26:00 905927160
+1998-9-16 09:26:00 905927160.000000
+1998-9-16 09:26:00 905927160.000000
drop table t1;
set time_zone= @@global.time_zone;
diff --git a/mysql-test/suite/pbxt/r/grant_cache.result b/mysql-test/suite/pbxt/r/grant_cache.result
index 500965fd646..d5189532370 100644
--- a/mysql-test/suite/pbxt/r/grant_cache.result
+++ b/mysql-test/suite/pbxt/r/grant_cache.result
@@ -168,7 +168,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
-Qcache_not_cached 7
+Qcache_not_cached 4
select "user4";
user4
user4
@@ -198,7 +198,7 @@ Variable_name Value
Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
-Qcache_not_cached 8
+Qcache_not_cached 5
set names binary;
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
diff --git a/mysql-test/suite/pbxt/r/group_min_max.result b/mysql-test/suite/pbxt/r/group_min_max.result
index e4ba16ce527..ab00cdeff59 100644
--- a/mysql-test/suite/pbxt/r/group_min_max.result
+++ b/mysql-test/suite/pbxt/r/group_min_max.result
@@ -1364,7 +1364,7 @@ explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range NULL idx_t1_1 147 NULL 129 Using index for group-by
+1 PRIMARY t1 range NULL idx_t1_1 147 NULL 129 Using where; Using index for group-by
2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
explain select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
@@ -2247,17 +2247,17 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
-2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
+2 SUBQUERY t1 index NULL a 10 NULL 1 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index
-2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
+2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
@@ -2267,7 +2267,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
AND t1_outer1.b = t1_outer2.b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
+1 PRIMARY t1_outer1 ref a a 5 const 1 Using index
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join)
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
diff --git a/mysql-test/suite/pbxt/r/join.result b/mysql-test/suite/pbxt/r/join.result
index 2e49a7f02bf..570d04bfbfc 100644
--- a/mysql-test/suite/pbxt/r/join.result
+++ b/mysql-test/suite/pbxt/r/join.result
@@ -699,9 +699,9 @@ select * from v1a join v1b on t1.b = t2.b;
ERROR 42S22: Unknown column 't1.b' in 'on clause'
select * from information_schema.statistics join information_schema.columns
using(table_name,column_name) where table_name='user';
-TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
-user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI #
-user User NULL mysql 0 mysql PRIMARY 2 A 3 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI #
+TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
+user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI #
+user User NULL mysql 0 mysql PRIMARY 2 A 3 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI #
drop table t1;
drop table t2;
drop table t3;
diff --git a/mysql-test/suite/pbxt/r/join_nested.result b/mysql-test/suite/pbxt/r/join_nested.result
index d6c4b9a7322..b4edf18f2f5 100644
--- a/mysql-test/suite/pbxt/r/join_nested.result
+++ b/mysql-test/suite/pbxt/r/join_nested.result
@@ -854,7 +854,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 1 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on((((`test`.`t3`.`a` = 1) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`))) and (`test`.`t3`.`b` is not null))) where 1
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM (t3,t4)
LEFT JOIN
@@ -966,7 +966,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on((((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`)) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
+Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`)))
CREATE INDEX idx_b ON t8(b);
EXPLAIN
SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
diff --git a/mysql-test/suite/pbxt/r/metadata.result b/mysql-test/suite/pbxt/r/metadata.result
index c46c6e26ce4..878163a360e 100644
--- a/mysql-test/suite/pbxt/r/metadata.result
+++ b/mysql-test/suite/pbxt/r/metadata.result
@@ -21,7 +21,7 @@ def test t1 t1 g g 5 4 0 Y 32768 3 63
def test t1 t1 h h 246 7 0 Y 0 4 63
def test t1 t1 i i 13 4 0 Y 32864 0 63
def test t1 t1 j j 10 10 0 Y 128 0 63
-def test t1 t1 k k 7 19 0 N 9441 0 63
+def test t1 t1 k k 7 19 0 N 9377 0 63
def test t1 t1 l l 12 19 0 Y 128 0 63
def test t1 t1 m m 254 1 0 Y 256 0 8
def test t1 t1 n n 254 3 0 Y 2048 0 8
diff --git a/mysql-test/suite/pbxt/r/ps_11bugs.result b/mysql-test/suite/pbxt/r/ps_11bugs.result
index fad35b97b24..dd09e9d14f3 100644
--- a/mysql-test/suite/pbxt/r/ps_11bugs.result
+++ b/mysql-test/suite/pbxt/r/ps_11bugs.result
@@ -120,9 +120,9 @@ create table t1 (a int primary key);
insert into t1 values (1);
explain select * from t1 where 3 in (select (1+1) union select 1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
-3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 1 Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
select * from t1 where 3 in (select (1+1) union select 1);
a
diff --git a/mysql-test/suite/pbxt/r/range.result b/mysql-test/suite/pbxt/r/range.result
index 3dd496f65b9..7d2d17bdc1e 100644
--- a/mysql-test/suite/pbxt/r/range.result
+++ b/mysql-test/suite/pbxt/r/range.result
@@ -362,6 +362,7 @@ name char(1) not null,
uid int not null,
primary key (id),
index uid_index (uid));
+begin;
insert into t1(id, uid, name) values(1, 0, ' ');
insert into t1(uid, name) values(0, ' ');
insert into t2(uid, name) select uid, name from t1;
@@ -410,6 +411,7 @@ insert into t2(uid, name) values
insert into t1(uid, name) select uid, name from t2 order by uid;
delete from t2;
insert into t2(id, uid, name) select id, uid, name from t1;
+commit;
select count(*) from t1;
count(*)
1026
@@ -921,16 +923,10 @@ INSERT INTO t1 VALUES
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using index condition
-Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
-A1 2005-11-01 08:00:00 1000.000
-A1 2005-11-15 00:00:00 2000.000
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -939,14 +935,10 @@ DROP INDEX `PRIMARY` ON t1;
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
-Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
-A1 2005-11-01 08:00:00 1000.000
-A1 2005-11-15 00:00:00 2000.000
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
diff --git a/mysql-test/suite/pbxt/r/select.result b/mysql-test/suite/pbxt/r/select.result
index 9afbea9199e..51e5d95edea 100644
--- a/mysql-test/suite/pbxt/r/select.result
+++ b/mysql-test/suite/pbxt/r/select.result
@@ -2121,8 +2121,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
-Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -3265,7 +3265,7 @@ f1 f2
4 2005-10-01
5 2005-12-30
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
select * from t1 where f2 <= '2005-09-31';
f1 f2
1 2005-01-01
@@ -3276,7 +3276,7 @@ f1 f2
1 2005-01-01
2 2005-09-01
Warnings:
-Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1
+Warning 1292 Truncated incorrect date value: '2005-09-3a'
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (1, 30), (2, 20), (3, 10);
diff --git a/mysql-test/suite/pbxt/r/subselect.result b/mysql-test/suite/pbxt/r/subselect.result
index 42b3a097b8a..e183cf389c0 100644
--- a/mysql-test/suite/pbxt/r/subselect.result
+++ b/mysql-test/suite/pbxt/r/subselect.result
@@ -50,7 +50,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><'1'>((select '1')) = 1)
+Note 1003 select 1 AS `1` from (select 1 AS `a`) `b` having (<expr_cache><1>((select 1)) = 1)
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
@@ -199,11 +199,10 @@ select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> system NULL NULL NULL NULL 1 100.00
-3 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using filesort
Warnings:
-Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,'2' AS `a` from (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` > 1)) `tt`
+Note 1003 select (select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`a` < 8) order by 1 desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,`test`.`t2`.`a` AS `a` from `test`.`t2` where (`test`.`t2`.`a` > 1)
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
a
2
@@ -270,7 +269,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2);
a
7
@@ -363,11 +362,11 @@ INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
-4 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
-3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index
+3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
Warnings:
-Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1
+Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))
SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
t8 WHERE pseudo='joce');
ERROR 21000: Operand should contain 1 column(s)
@@ -420,7 +419,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select 1 AS `1` from `test`.`t1` where 1
+Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
drop table t1;
CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
@@ -540,13 +539,13 @@ EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')
+Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)
EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
Warnings:
-Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1'))
+Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = 3))
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
@@ -908,7 +907,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3;
create table t1 (a float);
select 10.5 IN (SELECT * from t1 LIMIT 1);
@@ -1179,9 +1178,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a)
@@ -1189,9 +1188,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
-2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
-Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)`
+Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1;
CREATE TABLE `t1` (
`i` int(11) NOT NULL default '0',
@@ -1498,7 +1497,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < (select max(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < (select max(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= some (select b from t2);
a
explain extended select * from t3 where a >= some (select b from t2);
@@ -1506,7 +1505,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where a >= all (select b from t2 group by 1);
a
6
@@ -1515,49 +1514,49 @@ a
explain extended select * from t3 where a >= all (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` < <max>(select `test`.`t2`.`b` from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` < <max>(select `test`.`t2`.`b` from `test`.`t2` group by 1))))
select * from t3 where a >= some (select b from t2 group by 1);
a
explain extended select * from t3 where a >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((`test`.`t3`.`a` >= <min>(select `test`.`t2`.`b` from `test`.`t2` group by 1)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` >= <min>(select `test`.`t2`.`b` from `test`.`t2` group by 1))))
select * from t3 where NULL >= any (select b from t2);
a
explain extended select * from t3 where NULL >= any (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where NULL >= any (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select `test`.`t2`.`b` from `test`.`t2` group by 1))))
select * from t3 where NULL >= some (select b from t2);
a
explain extended select * from t3 where NULL >= some (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= (select min(`test`.`t2`.`b`) from `test`.`t2`))))
select * from t3 where NULL >= some (select b from t2 group by 1);
a
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,(NULL >= <min>(select `test`.`t2`.`b` from `test`.`t2` group by 1))))
insert into t2 values (2,2), (2,1), (3,3), (3,1);
select * from t3 where a > all (select max(b) from t2 group by a);
a
@@ -1566,9 +1565,9 @@ a
explain extended select * from t3 where a > all (select max(b) from t2 group by a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>((`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`)))
+Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(`test`.`t3`.`a` <= <max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`))))
drop table t2, t3;
CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
@@ -1619,7 +1618,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 ALL NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where 1
+Note 1003 select `test`.`t1`.`s1` AS `s1` from `test`.`t1` where <nop>(<in_optimizer>('f',('f' > <min>(select `test`.`t1`.`s1` from `test`.`t1` union select `test`.`t1`.`s1` from `test`.`t1`))))
drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
@@ -2829,14 +2828,13 @@ Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cac
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-1 PRIMARY subselect2 eq_ref unique_key unique_key 10 func 1 1.00
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1)
Warnings:
-Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`flag` = 'N'))
+Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N'))
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00
-2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`two`,`test`.`t1`.`one`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1`
DROP TABLE t1,t2;
@@ -3112,10 +3110,10 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
-4
1
+2
3
+4
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
@@ -3124,8 +3122,8 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
-2
1
+2
3
4
SELECT a FROM t1
@@ -3422,7 +3420,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary
ALTER TABLE t1 ADD INDEX(a);
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
a b
@@ -3433,7 +3431,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
DROP TABLE t1;
create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
diff --git a/mysql-test/suite/pbxt/r/type_bit.result b/mysql-test/suite/pbxt/r/type_bit.result
index c2969d00f74..bfe4e2aa8d9 100644
--- a/mysql-test/suite/pbxt/r/type_bit.result
+++ b/mysql-test/suite/pbxt/r/type_bit.result
@@ -36,7 +36,7 @@ select 0 + b'1000000000000001';
32769
drop table if exists t1,t2;
create table t1 (a bit(65));
-ERROR 42000: Display width out of range for column 'a' (max = 64)
+ERROR 42000: Display width out of range for 'a' (max = 64)
create table t1 (a bit(0));
show create table t1;
Table Create Table
diff --git a/mysql-test/suite/pbxt/r/type_datetime.result b/mysql-test/suite/pbxt/r/type_datetime.result
index 4ad10269211..255e8c33735 100644
--- a/mysql-test/suite/pbxt/r/type_datetime.result
+++ b/mysql-test/suite/pbxt/r/type_datetime.result
@@ -53,7 +53,7 @@ t
truncate table t1;
insert into t1 values("2003-0303 12:13:14");
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 1
select * from t1;
t
0000-00-00 00:00:00
@@ -116,12 +116,12 @@ create table t1 (t datetime);
insert into t1 values (20030102030460),(20030102036301),(20030102240401),
(20030132030401),(20031302030401),(100001202030401);
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
-Warning 1264 Out of range value for column 't' at row 3
-Warning 1264 Out of range value for column 't' at row 4
-Warning 1264 Out of range value for column 't' at row 5
-Warning 1264 Out of range value for column 't' at row 6
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 3
+Warning 1265 Data truncated for column 't' at row 4
+Warning 1265 Data truncated for column 't' at row 5
+Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
0000-00-00 00:00:00
@@ -135,12 +135,12 @@ insert into t1 values
("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"),
("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00");
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
-Warning 1264 Out of range value for column 't' at row 3
-Warning 1264 Out of range value for column 't' at row 4
-Warning 1264 Out of range value for column 't' at row 5
-Warning 1264 Out of range value for column 't' at row 6
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 3
+Warning 1265 Data truncated for column 't' at row 4
+Warning 1265 Data truncated for column 't' at row 5
+Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
0000-00-00 00:00:00
@@ -152,8 +152,8 @@ t
delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
Warnings:
-Warning 1264 Out of range value for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't' at row 2
select * from t1 order by t;
t
0000-00-00 00:00:00
@@ -191,4 +191,4 @@ CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMA
20060810101112.000014
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
-101112.098700
+101112.000000
diff --git a/mysql-test/suite/pbxt/r/type_decimal.result b/mysql-test/suite/pbxt/r/type_decimal.result
index a478a369404..138e804362d 100644
--- a/mysql-test/suite/pbxt/r/type_decimal.result
+++ b/mysql-test/suite/pbxt/r/type_decimal.result
@@ -720,7 +720,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=PBXT DEFAULT CHARSET=latin1
drop table t1;
create table t1 (d decimal(66,0));
-ERROR 42000: Too big precision 66 specified for column 'd'. Maximum is 65.
+ERROR 42000: Too big precision 66 specified for 'd'. Maximum is 65.
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
diff --git a/mysql-test/suite/pbxt/r/type_float.result b/mysql-test/suite/pbxt/r/type_float.result
index 4029909bce3..df5499f91a5 100644
--- a/mysql-test/suite/pbxt/r/type_float.result
+++ b/mysql-test/suite/pbxt/r/type_float.result
@@ -133,7 +133,7 @@ min(a)
-0.010
drop table t1;
create table t1 (a float(200,100), b double(200,100));
-ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30.
+ERROR 42000: Too big scale 100 specified for 'a'. Maximum is 30.
create table t1 (c20 char);
insert into t1 values (5000.0);
Warnings:
diff --git a/mysql-test/suite/pbxt/r/type_newdecimal.result b/mysql-test/suite/pbxt/r/type_newdecimal.result
index 4978a244c76..565c37bb6e1 100644
--- a/mysql-test/suite/pbxt/r/type_newdecimal.result
+++ b/mysql-test/suite/pbxt/r/type_newdecimal.result
@@ -825,7 +825,7 @@ Error 1365 Division by 0
Error 1365 Division by 0
Error 1365 Division by 0
INSERT INTO Sow6_2f VALUES ('a59b');
-ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
+ERROR 22007: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f;
select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000
@@ -838,12 +838,12 @@ select 9999999999999999999999999999999999999999999999999999999999999999999999999
x
99999999999999999999999999999999999999999999999999999999999999999
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
x
100000000000000000000000000000000000000000000000000000000000000000
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
select 0.190287977636363637 + 0.040372670 * 0 - 0;
0.190287977636363637 + 0.040372670 * 0 - 0
0.190287977636363637
@@ -923,11 +923,11 @@ ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column
select cast(ln(14000) as decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
create table t1 (sl decimal(70,30));
-ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
+ERROR 42000: Too big precision 70 specified for 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
-ERROR 42000: Too big scale 31 specified for column 'sl'. Maximum is 30.
+ERROR 42000: Too big scale 31 specified for 'sl'. Maximum is 30.
create table t1 (sl decimal(0,38));
-ERROR 42000: Too big scale 38 specified for column 'sl'. Maximum is 30.
+ERROR 42000: Too big scale 38 specified for 'sl'. Maximum is 30.
create table t1 (sl decimal(0,30));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'sl').
create table t1 (sl decimal(5, 5));
@@ -1368,15 +1368,15 @@ create table t1 (c1 decimal(64));
insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
+Error 1916 Got overflow when converting '' to DECIMAL. Value truncated.
Warning 1264 Out of range value for column 'c1' at row 1
insert into t1 values(1e100);
Warnings:
@@ -1447,4 +1447,4 @@ select cast(19999999999999999999 as unsigned);
cast(19999999999999999999 as unsigned)
18446744073709551615
Warnings:
-Error 1292 Truncated incorrect DECIMAL value: ''
+Error 1916 Got overflow when converting '19999999999999999999' to UNSIGNED INT. Value truncated.
diff --git a/mysql-test/suite/pbxt/r/type_time.result b/mysql-test/suite/pbxt/r/type_time.result
index ce820c0cb8e..86aef8683ce 100644
--- a/mysql-test/suite/pbxt/r/type_time.result
+++ b/mysql-test/suite/pbxt/r/type_time.result
@@ -1,6 +1,8 @@
drop table if exists t1;
create table t1 (t time);
insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
+Warnings:
+Note 1265 Data truncated for column 't' at row 13
insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
select * from t1;
t
@@ -26,9 +28,9 @@ t
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
Warnings:
Warning 1265 Data truncated for column 't' at row 1
-Warning 1264 Out of range value for column 't' at row 2
-Warning 1264 Out of range value for column 't' at row 3
-Warning 1264 Out of range value for column 't' at row 4
+Warning 1265 Data truncated for column 't' at row 2
+Warning 1265 Data truncated for column 't' at row 3
+Warning 1265 Data truncated for column 't' at row 4
Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
@@ -53,8 +55,8 @@ t
36:30:31
00:00:10
00:00:00
-838:59:59
-838:59:59
+00:00:00
+00:00:00
262:22:00
00:00:12
drop table t1;
diff --git a/mysql-test/suite/pbxt/r/type_timestamp.result b/mysql-test/suite/pbxt/r/type_timestamp.result
index b04dcf01b9c..fdc86a3cf61 100644
--- a/mysql-test/suite/pbxt/r/type_timestamp.result
+++ b/mysql-test/suite/pbxt/r/type_timestamp.result
@@ -97,30 +97,6 @@ date date_time time_stamp
2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00
2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
-t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
-t14 timestamp(14));
-Warnings:
-Warning 1287 'TIMESTAMP(2)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(4)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(6)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(8)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(10)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(12)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-Warning 1287 'TIMESTAMP(14)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-t2 t4 t6 t8 t10 t12 t14
-0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
-1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
-select * from t1;
-t2 t4 t6 t8 t10 t12 t14
-0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
-1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
-drop table t1;
create table t1 (ix timestamp);
insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
Warnings:
@@ -436,12 +412,12 @@ max(t)
2004-02-01 00:00:00
drop table t1;
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp(5));
show create table t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" datetime DEFAULT NULL,
- "b" datetime DEFAULT NULL
+ "b" datetime(5) DEFAULT NULL
)
set sql_mode='';
drop table t1;
diff --git a/mysql-test/suite/pbxt/r/union.result b/mysql-test/suite/pbxt/r/union.result
index 50d4df6e241..82327b6d2f8 100644
--- a/mysql-test/suite/pbxt/r/union.result
+++ b/mysql-test/suite/pbxt/r/union.result
@@ -362,7 +362,7 @@ a
2
select found_rows();
found_rows()
-6
+5
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100;
a
1
@@ -372,7 +372,7 @@ a
5
select found_rows();
found_rows()
-6
+5
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2;
a
1
@@ -405,7 +405,7 @@ a
4
select found_rows();
found_rows()
-6
+5
SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2;
a
3
@@ -480,7 +480,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 (select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where 1)
+Note 1003 (select 1 AS `a`,1 AS `b` from `test`.`t1` where 1) union (select 1 AS `a`,10 AS `b` from `test`.`t2` where 1)
(select * from t1 where a=5) union (select * from t2 where a=1);
a b
1 10
@@ -1166,9 +1166,12 @@ a b
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
+2 b
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
+2 b
+3 c
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
a b
1 a
@@ -1426,4 +1429,17 @@ select _utf8'12' union select _latin1'12345';
12
12
12345
+create table t1 (a int);
+insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10);
+select a from t1 where false UNION select a from t1 limit 8;
+a
+10
+2
+3
+4
+5
+6
+7
+8
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/suite/pbxt/r/view_grant.result b/mysql-test/suite/pbxt/r/view_grant.result
index f66ff458761..23484398203 100644
--- a/mysql-test/suite/pbxt/r/view_grant.result
+++ b/mysql-test/suite/pbxt/r/view_grant.result
@@ -110,7 +110,7 @@ show create view mysqltest.v1;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
explain select c from mysqltest.v2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
2 DERIVED t1 ALL NULL NULL NULL NULL 0
show create view mysqltest.v2;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2'
@@ -131,7 +131,7 @@ View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci
explain select c from mysqltest.v2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
2 DERIVED t1 ALL NULL NULL NULL NULL 0
show create view mysqltest.v2;
View Create View character_set_client collation_connection
@@ -144,7 +144,7 @@ View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci
explain select c from mysqltest.v4;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
2 DERIVED t2 ALL NULL NULL NULL NULL 0
show create view mysqltest.v4;
View Create View character_set_client collation_connection
diff --git a/mysql-test/suite/pbxt/t/grant_cache.test b/mysql-test/suite/pbxt/t/grant_cache.test
index f3faa579035..ce53a88ac0c 100644
--- a/mysql-test/suite/pbxt/t/grant_cache.test
+++ b/mysql-test/suite/pbxt/t/grant_cache.test
@@ -5,6 +5,17 @@
--source include/add_anonymous_users.inc
#
+# some statements have different results in ps-mode
+#
+let $actual1=4;
+let $actual2=5;
+if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0`)
+{
+ let $actual1=3;
+ let $actual2=4;
+}
+
+#
# Test grants with query cache
#
--disable_warnings
@@ -112,6 +123,7 @@ select * from t2;
select mysqltest.t1.c from test.t1,mysqltest.t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
+--replace_result $actual1 4
show status like "Qcache_not_cached";
# Connect without a database
@@ -128,6 +140,7 @@ select a from mysqltest.t1;
select a from mysqltest.t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
+--replace_result $actual2 5
show status like "Qcache_not_cached";
# Cleanup
diff --git a/mysql-test/suite/pbxt/t/join.test b/mysql-test/suite/pbxt/t/join.test
index 7e7e1c10f06..02c17d8bcaa 100644
--- a/mysql-test/suite/pbxt/t/join.test
+++ b/mysql-test/suite/pbxt/t/join.test
@@ -521,7 +521,7 @@ select * from v1a join v1b on t1.b = t2.b;
# Bug #17523 natural join and information_schema
#
# We mask out the Privileges column because it differs with embedded server
---replace_column 31 #
+--replace_column 32 #
select * from information_schema.statistics join information_schema.columns
using(table_name,column_name) where table_name='user';
diff --git a/mysql-test/suite/pbxt/t/mysqlshow.test b/mysql-test/suite/pbxt/t/mysqlshow.test
index d8f5c20afcd..41505cc0b10 100644
--- a/mysql-test/suite/pbxt/t/mysqlshow.test
+++ b/mysql-test/suite/pbxt/t/mysqlshow.test
@@ -1,5 +1,6 @@
# Can't run test of external client with embedded server
-- source include/not_embedded.inc
+-- source include/have_innodb.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,test1,test2;
diff --git a/mysql-test/suite/pbxt/t/range.test b/mysql-test/suite/pbxt/t/range.test
index 8d02089ee1b..0c0349c49c9 100644
--- a/mysql-test/suite/pbxt/t/range.test
+++ b/mysql-test/suite/pbxt/t/range.test
@@ -322,6 +322,7 @@ create table t2 (
primary key (id),
index uid_index (uid));
+begin;
insert into t1(id, uid, name) values(1, 0, ' ');
insert into t1(uid, name) values(0, ' ');
@@ -375,6 +376,8 @@ insert into t1(uid, name) select uid, name from t2 order by uid;
delete from t2;
insert into t2(id, uid, name) select id, uid, name from t1;
+commit;
+
select count(*) from t1;
select count(*) from t2;
diff --git a/mysql-test/suite/pbxt/t/subselect.test b/mysql-test/suite/pbxt/t/subselect.test
index 19658cb202e..3f4d6a9a870 100644
--- a/mysql-test/suite/pbxt/t/subselect.test
+++ b/mysql-test/suite/pbxt/t/subselect.test
@@ -2052,7 +2052,7 @@ SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2);
--error 1242
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1);
-
+--sorted_result
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
@@ -2060,7 +2060,7 @@ SELECT a FROM t1 GROUP BY a
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
-
+--sorted_result
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
@@ -2068,7 +2068,7 @@ SELECT a FROM t1 GROUP BY a
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3;
-
+--sorted_result
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
@@ -2076,7 +2076,7 @@ SELECT a FROM t1
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
-
+--sorted_result
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
diff --git a/mysql-test/suite/pbxt/t/type_timestamp.test b/mysql-test/suite/pbxt/t/type_timestamp.test
index 88b4c4e2587..65659b2acca 100644
--- a/mysql-test/suite/pbxt/t/type_timestamp.test
+++ b/mysql-test/suite/pbxt/t/type_timestamp.test
@@ -67,17 +67,6 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1;
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
- t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
- t14 timestamp(14));
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-select * from t1;
-drop table t1;
-
#
# Let us check if we properly treat wrong datetimes and produce proper warnings
# (for both strings and numbers)
@@ -298,7 +287,7 @@ drop table t1;
# mode regardless of whether a display width is given.
#
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp(5));
show create table t1;
# restore default mode
set sql_mode='';
diff --git a/mysql-test/suite/pbxt/t/union.test b/mysql-test/suite/pbxt/t/union.test
index 02c73d4bb57..c216b3caceb 100644
--- a/mysql-test/suite/pbxt/t/union.test
+++ b/mysql-test/suite/pbxt/t/union.test
@@ -904,6 +904,15 @@ drop table t1, t2;
#
select _utf8'12' union select _latin1'12345';
+#
+# lp:732124 union + limit returns wrong result
+#
+create table t1 (a int);
+insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10);
+--sorted_result
+select a from t1 where false UNION select a from t1 limit 8;
+drop table t1;
+
--disable_query_log
drop database pbxt;
diff --git a/mysql-test/suite/percona/disabled.def b/mysql-test/suite/percona/disabled.def
index a99b952a5eb..2155df55a7f 100644
--- a/mysql-test/suite/percona/disabled.def
+++ b/mysql-test/suite/percona/disabled.def
@@ -20,3 +20,4 @@ percona_server_variables: Feature not merged into MariaDB
percona_slow_query_log-log_slow_verbosity: InnoDB filtering information not fully merged into MariaDB
percona_innodb_buffer_pool_shm: Requires big shmmax not default on many systems
+userstat_bug602047: Feature not merged into MariaDB
diff --git a/mysql-test/suite/percona/innodb_fix_misc_bug51325.result b/mysql-test/suite/percona/innodb_fix_misc_bug51325.result
new file mode 100644
index 00000000000..c63a33accdd
--- /dev/null
+++ b/mysql-test/suite/percona/innodb_fix_misc_bug51325.result
@@ -0,0 +1,13 @@
+DROP TABLE IF EXISTS t1;
+SET GLOBAL innodb_file_per_table=ON;
+SHOW VARIABLES LIKE 'innodb_lazy_drop_table';
+Variable_name Value
+innodb_lazy_drop_table 0
+SET GLOBAL innodb_lazy_drop_table=1;
+SHOW VARIABLES LIKE 'innodb_lazy_drop_table';
+Variable_name Value
+innodb_lazy_drop_table 1
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+DROP TABLE t1;
+SET GLOBAL innodb_lazy_drop_table=default;
+SET GLOBAL innodb_file_per_table=default;
diff --git a/mysql-test/suite/percona/innodb_fix_misc_bug51325.test b/mysql-test/suite/percona/innodb_fix_misc_bug51325.test
new file mode 100644
index 00000000000..78d6e60046a
--- /dev/null
+++ b/mysql-test/suite/percona/innodb_fix_misc_bug51325.test
@@ -0,0 +1,13 @@
+# Test for 'innodb_lazy_drop_table' variable
+--source include/have_innodb.inc
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+SET GLOBAL innodb_file_per_table=ON;
+SHOW VARIABLES LIKE 'innodb_lazy_drop_table';
+SET GLOBAL innodb_lazy_drop_table=1;
+SHOW VARIABLES LIKE 'innodb_lazy_drop_table';
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+DROP TABLE t1;
+SET GLOBAL innodb_lazy_drop_table=default;
+SET GLOBAL innodb_file_per_table=default;
diff --git a/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.result b/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.result
index a028aeadde4..15cefd67c1e 100644
--- a/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.result
+++ b/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.result
@@ -1,9 +1,5 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
+include/master-slave.inc
+[connection master]
DROP TABLE IF EXISTS t;
CREATE TABLE t(id INT);
INSERT INTO t SELECT SLEEP(10);
@@ -15,7 +11,11 @@ master 1
slave count(*)
slave 0
SHOW SLAVE STATUS NOLOCK;
+include/wait_for_slave_to_stop.inc
START SLAVE;
+include/wait_for_slave_to_start.inc
slave count(*)
slave 1
DROP TABLE t;
+STOP SLAVE;
+include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.test b/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.test
index 9e856d24956..d8ae98262ea 100644
--- a/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.test
+++ b/mysql-test/suite/percona/show_slave_status_nolock.patch/percona_show_slave_status_nolock.test
@@ -45,3 +45,6 @@ connection slave;
connection master;
DROP TABLE t;
sync_slave_with_master;
+
+STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_innodb_stats.result b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_innodb_stats.result
index 162c92afbd9..c2292c4d2ac 100644
--- a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_innodb_stats.result
+++ b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_innodb_stats.result
@@ -1,9 +1,5 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
+include/master-slave.inc
+[connection master]
DROP TABLE IF EXISTS t;
CREATE TABLE t(id INT,data CHAR(30)) ENGINE=InnoDB;
INSERT INTO t VALUES
@@ -15,7 +11,9 @@ INSERT INTO t VALUES
INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2;
INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2;
STOP SLAVE;
+include/wait_for_slave_to_stop.inc
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t SELECT t.id,t.data from t;
DROP TABLE IF EXISTS t;
FLUSH LOGS;
diff --git a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.result b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.result
index 386faf225ec..e96126e34c7 100644
--- a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.result
+++ b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.result
@@ -1,15 +1,12 @@
# Activate master-slave replication
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
+include/master-slave.inc
+[connection master]
# Make table t for test
DROP TABLE IF EXISTS t;
CREATE TABLE t(id INT);
# Start slave replication
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t VALUES (1);
# Read and change log_slow_slave_statements to ON on slave
show variables like 'log_slow_slave_statements';
@@ -22,7 +19,9 @@ log_slow_slave_statements ON
INSERT INTO t VALUES (2);
# Restart slave
STOP SLAVE;
+include/wait_for_slave_to_stop.inc
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t VALUES (3);
show variables like 'long_query_time';
Variable_name Value
@@ -91,3 +90,5 @@ FLUSH LOGS;
1
set global log_slow_slave_statements=OFF;
DROP TABLE t;
+STOP SLAVE;
+include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.test b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.test
index b5a6154bbfc..755b83fa93b 100644
--- a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.test
+++ b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements-and-use_global_long_query_time.test
@@ -111,3 +111,6 @@ DROP TABLE t;
sync_slave_with_master;
connection slave;
+
+STOP SLAVE;
+-- source include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.result b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.result
index 9f9085ff444..6563d6d863e 100644
--- a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.result
+++ b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.result
@@ -1,15 +1,12 @@
# Activate master-slave replication
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
+include/master-slave.inc
+[connection master]
# Make table t for test
DROP TABLE IF EXISTS t;
CREATE TABLE t(id INT);
# Start slave replication
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t VALUES (1);
# Read information about master binlog
# Sync(1) slave thread
@@ -26,7 +23,9 @@ INSERT INTO t VALUES (2);
# Sync slave(2) thread
# Restart slave
STOP SLAVE;
+include/wait_for_slave_to_stop.inc
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t VALUES (3);
# Read information about master binlog
# Sync(3) slave thread
@@ -43,7 +42,9 @@ INSERT INTO t VALUES (4);
# Sync slave(4) thread
# Restart slave
STOP SLAVE;
+include/wait_for_slave_to_stop.inc
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t VALUES (5);
# Read information about master binlog
# Sync slave(5) thread
@@ -60,7 +61,9 @@ INSERT INTO t VALUES (6);
# Sync slave(6) thread
# Restart slave
STOP SLAVE;
+include/wait_for_slave_to_stop.inc
START SLAVE;
+include/wait_for_slave_to_start.inc
INSERT INTO t VALUES (7);
# Read information about master binlog
# Sync slave(7) thread
@@ -86,3 +89,5 @@ set global log_slow_slave_statements=OFF;
DROP TABLE t;
# Read information about master binlog
# Sync slave(8) thread
+STOP SLAVE;
+include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.test b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.test
index bce7a5f0530..bdf37533933 100644
--- a/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.test
+++ b/mysql-test/suite/percona/slow_extended.patch/percona_slow_extended-slave_statements.test
@@ -163,3 +163,6 @@ let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
-- echo # Sync slave(8) thread
connection slave;
let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+
+STOP SLAVE;
+-- source include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/percona/userstat_bug602047.result b/mysql-test/suite/percona/userstat_bug602047.result
new file mode 100644
index 00000000000..bc14ca3362a
--- /dev/null
+++ b/mysql-test/suite/percona/userstat_bug602047.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+SET @userstat_running_old= @@userstat_running;
+SET GLOBAL userstat_running=ON;
+CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+10
+SELECT ROWS_READ FROM information_schema.table_statistics WHERE TABLE_NAME='t1';
+ROWS_READ
+10
+SELECT ROWS_READ FROM information_schema.index_statistics WHERE TABLE_NAME='t1';
+ROWS_READ
+10
+SET GLOBAL userstat_running= @userstat_running_old;
+DROP TABLE t1;
diff --git a/mysql-test/suite/percona/userstat_bug602047.test b/mysql-test/suite/percona/userstat_bug602047.test
new file mode 100644
index 00000000000..37c08d32bf0
--- /dev/null
+++ b/mysql-test/suite/percona/userstat_bug602047.test
@@ -0,0 +1,13 @@
+--source include/have_innodb.inc
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+SET @userstat_running_old= @@userstat_running;
+SET GLOBAL userstat_running=ON;
+CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+SELECT COUNT(*) FROM t1;
+SELECT ROWS_READ FROM information_schema.table_statistics WHERE TABLE_NAME='t1';
+SELECT ROWS_READ FROM information_schema.index_statistics WHERE TABLE_NAME='t1';
+SET GLOBAL userstat_running= @userstat_running_old;
+DROP TABLE t1;
diff --git a/mysql-test/suite/rpl/extension/README.checksum b/mysql-test/suite/rpl/extension/README.checksum
new file mode 100644
index 00000000000..1adcaff49ca
--- /dev/null
+++ b/mysql-test/suite/rpl/extension/README.checksum
@@ -0,0 +1,23 @@
+Binlog checksum testing
+=======================
+
+1. How it works.
+The script copies a <suite> to directory <suite>_checksum,
+collects test case names for t/ directory (except tests from
+disabled def), randomly choose 90% of tests and add them
+to disabled.def.
+It means that mtr will run only 10% of random tests from each
+suite.
+At end the script run mtr:
+./mysql-test-run.pl --suite=aaa_checksum,bbb_checksum \
+ --mysqld=--binlog-checksum=CRC32 arg1 ... argN
+
+aaa,bbb - suite names from --suite option
+arg1,argN - other command-line arguments of checksum.pl
+
+2. The options:
+
+--suite=suite1,suite2. Mandatory option. The list of suites for
+ binlog checksum testing.
+
+--percent=N, where N is 1..99. Percent of running tests.
diff --git a/mysql-test/suite/rpl/extension/checksum.pl b/mysql-test/suite/rpl/extension/checksum.pl
new file mode 100644
index 00000000000..60dca18c8f8
--- /dev/null
+++ b/mysql-test/suite/rpl/extension/checksum.pl
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+use File::Basename;
+use File::Copy qw(copy);
+use File::Spec qw(catdir);
+use File::Path;
+use IO::File;
+use strict;
+
+# Constants and variables with default values
+my $suites;
+my $suffix = "_checksum";
+my $percent_random_test = 10;
+my $mtr_script;
+my @mtr_argv;
+my @mtr_suites;
+
+# Check some arguments
+foreach my $arg ( @ARGV )
+{
+ if ($arg =~ m/\-\-suite\=(.+)/i)
+ {
+ $suites = $1;
+ }
+ elsif ($arg =~ m/\-\-percent\=(\d{1,2})/i)
+ {
+ $percent_random_test= $1;
+ }
+ else
+ {
+ push(@mtr_argv, $arg);
+ }
+
+}
+if (! defined( $suites ) )
+{
+ die("The script requires --suite argument");
+}
+
+print "#################################################################\n";
+print "# Binlog checksum testing\n";
+print "# Run randomly $percent_random_test\% of tests from following suites: $suites\n";
+print "#################################################################\n";
+
+# Set extension directory
+my $ext_dir= dirname(File::Spec->rel2abs($0));
+# Set mysql-test directory
+my $mysql_test_dir= $ext_dir;
+$mysql_test_dir =~ s/(\/|\\)suite(\/|\\)rpl(\/|\\)extension$//;
+
+# Main loop
+foreach my $src_suite (split(",", $suites))
+{
+ $src_suite=~ s/ //g;
+ my $dest_suite= $src_suite . $suffix;
+ push( @mtr_suites, $dest_suite);
+ print "Creating suite $dest_suite\n";
+ # *** Set platform-independent pathes ***
+ # Set source directory of suite
+ my $src_suite_dir = File::Spec->catdir($mysql_test_dir, "suite", $src_suite);
+ # Set destination directory of suite
+ my $dest_suite_dir = File::Spec->catdir($mysql_test_dir, "suite", $dest_suite);
+ print "Copying files\n\tfrom '$src_suite_dir'\n\tto '$dest_suite_dir'\n";
+ dircopy($src_suite_dir, $dest_suite_dir);
+ my $test_case_dir= File::Spec->catdir($dest_suite_dir, "t");
+ # Read disabled.def
+ my %disabled = ();
+ print "Read disabled.def\n";
+ my $fh = new IO::File File::Spec->catdir($test_case_dir, "disabled.def"), "r";
+ if ( defined $fh )
+ {
+ my @lines = <$fh>;
+ undef $fh;
+ foreach my $line ( @lines )
+ {
+ if ($line =~ m/^([a-zA-Z0-9_]+).+\:.+/i)
+ {
+ $disabled{$1}= 1;
+ }
+ }
+ }
+ # Read test case list
+ my %tests = ();
+ print "Generate test case list\n";
+ opendir my ($dh), $test_case_dir or die "Could not open dir '$test_case_dir': $!";
+ for my $entry (readdir $dh)
+ {
+ if ( $entry =~ m/^([a-zA-Z0-9_]+)\.test$/i )
+ {
+ my $test= $1;
+ if ( ! defined( $disabled{$test}) )
+ {
+ $tests{$test}= 1;
+ }
+ }
+ }
+ closedir($dh);
+ #
+ my @excluded = ();
+ my $excluded_test= int((((100 - $percent_random_test)/100) * scalar( keys %tests )));
+ while ( $excluded_test > 0 )
+ {
+ my @cases = keys %tests;
+ my $test = $cases[int(rand(scalar(@cases)))];
+ push ( @excluded, $test . "\t\t: Excluded for $dest_suite\n" );
+ delete $tests{$test};
+ $excluded_test--;
+ }
+ my $fh = new IO::File File::Spec->catdir($test_case_dir, "disabled.def"), O_WRONLY|O_APPEND;
+ if (defined $fh) {
+ print $fh join ("", sort @excluded);
+ undef $fh;
+ }
+ print "\t" . join("\n\t", sort keys %tests) . "\n";
+
+}
+
+# Set path to mtr with arguments
+my $mtr_script = "perl " . File::Spec->catdir($mysql_test_dir, "mysql-test-run.pl") .
+ " --suite=" . join(",", @mtr_suites) . " " .
+ " --mysqld=--binlog-checksum=CRC32 " .
+ join (" ", @mtr_argv);
+
+print "Run $mtr_script\n";
+system( $mtr_script );
+
+sub dircopy
+{
+ my ($from_dir, $to_dir)= @_;
+ mkdir $to_dir if (! -e $to_dir);
+ opendir my($dh), $from_dir or die "Could not open dir '$from_dir': $!";
+ for my $entry (readdir $dh)
+ {
+ next if $entry =~ /^(\.|\.\.)$/;
+ my $source = File::Spec->catdir($from_dir, $entry);
+ my $destination = File::Spec->catdir($to_dir, $entry);
+ if (-d $source)
+ {
+ mkdir $destination or die "mkdir '$destination' failed: $!" if not -e $destination;
+ dircopy($source, $destination);
+ }
+ else
+ {
+ copy($source, $destination) or die "copy '$source' to '$destination' failed: $!";
+ }
+ }
+ closedir $dh;
+ return;
+}
diff --git a/mysql-test/suite/rpl/include/hrtime.inc b/mysql-test/suite/rpl/include/hrtime.inc
new file mode 100644
index 00000000000..b49bf0c7792
--- /dev/null
+++ b/mysql-test/suite/rpl/include/hrtime.inc
@@ -0,0 +1,27 @@
+--source include/master-slave.inc
+
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
+
+create table t1 (a timestamp(4), b varchar(100), c datetime(2));
+
+insert t1 (b,c) values (now(6), now(6));
+
+insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010');
+
+set timestamp=unix_timestamp('2022-02-02 02:02:02') + 0.654321;
+insert t1 (b,c) values (now(), now());
+insert t1 (b,c) values (0,0);
+insert t1 (a,b,c) values (0,0,now(6));
+
+select * from t1;
+
+sync_slave_with_master;
+connection slave;
+set time_zone='+03:00';
+select * from t1;
+connection master;
+drop table t1;
+
+--source include/rpl_end.inc
+
diff --git a/mysql-test/suite/rpl/r/rpl_binlog_corruption.result b/mysql-test/suite/rpl/r/rpl_binlog_corruption.result
index 4f1eca42e1a..a2a065e0a4f 100644
--- a/mysql-test/suite/rpl/r/rpl_binlog_corruption.result
+++ b/mysql-test/suite/rpl/r/rpl_binlog_corruption.result
@@ -1,6 +1,7 @@
include/master-slave.inc
[connection master]
call mtr.add_suppression('Found invalid event in binary log');
+call mtr.add_suppression('Slave SQL.*Relay log read failure: Could not parse relay log event entry.* 1594');
==== Initialize ====
include/stop_slave.inc
RESET SLAVE;
diff --git a/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result
index a7e8b86ac79..2d5676a82d6 100644
--- a/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result
+++ b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result
@@ -125,6 +125,7 @@ include/stop_slave.inc
include/start_slave.inc
CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*");
CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*");
+CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master. Message: error writing to the binary log");
TRUNCATE t1;
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
diff --git a/mysql-test/suite/rpl/r/rpl_bug33931.result b/mysql-test/suite/rpl/r/rpl_bug33931.result
index d27308db1d5..ce8b6b169c7 100644
--- a/mysql-test/suite/rpl/r/rpl_bug33931.result
+++ b/mysql-test/suite/rpl/r/rpl_bug33931.result
@@ -1,6 +1,7 @@
include/master-slave.inc
[connection master]
call mtr.add_suppression("Failed during slave I/O thread initialization");
+call mtr.add_suppression("Slave SQL.*Failed during slave thread initialization.* 1593");
include/stop_slave.inc
reset slave;
SET GLOBAL debug="d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
diff --git a/mysql-test/suite/rpl/r/rpl_bug37426.result b/mysql-test/suite/rpl/r/rpl_bug37426.result
new file mode 100644
index 00000000000..bf96255c7b4
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_bug37426.result
@@ -0,0 +1,12 @@
+include/master-slave.inc
+[connection master]
+CREATE TABLE char128_utf8 (i1 INT NOT NULL, c CHAR(128) CHARACTER SET utf8 NOT NULL, i2 INT NOT NULL);
+INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
+SELECT * FROM char128_utf8;
+i1 c i2
+1 123 1
+SELECT * FROM char128_utf8;
+i1 c i2
+1 123 1
+DROP TABLE char128_utf8;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_change_master.result b/mysql-test/suite/rpl/r/rpl_change_master.result
index 6674ab168ef..1b1f040b726 100644
--- a/mysql-test/suite/rpl/r/rpl_change_master.result
+++ b/mysql-test/suite/rpl/r/rpl_change_master.result
@@ -1,5 +1,6 @@
include/master-slave.inc
[connection master]
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
create table t1(n int);
select * from t1;
n
diff --git a/mysql-test/suite/rpl/r/rpl_checksum.result b/mysql-test/suite/rpl/r/rpl_checksum.result
new file mode 100644
index 00000000000..3613ffd25e1
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_checksum.result
@@ -0,0 +1,135 @@
+include/master-slave.inc
+[connection master]
+call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
+call mtr.add_suppression('Replication event checksum verification failed');
+call mtr.add_suppression('Relay log write failure: could not queue event from master');
+call mtr.add_suppression('Master is configured to log replication events with checksum, but will not send such events to slaves that cannot process them');
+set @master_save_binlog_checksum= @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
+must be CRC32 because of the command line option
+CRC32
+select @@session.binlog_checksum as 'no session var';
+ERROR HY000: Variable 'binlog_checksum' is a GLOBAL variable
+select @@global.master_verify_checksum as 'must be zero because of default';
+must be zero because of default
+0
+select @@session.master_verify_checksum as 'no session var';
+ERROR HY000: Variable 'master_verify_checksum' is a GLOBAL variable
+set @slave_save_binlog_checksum= @@global.binlog_checksum;
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+select @@global.slave_sql_verify_checksum as 'must be one because of default';
+must be one because of default
+1
+select @@session.slave_sql_verify_checksum as 'no session var';
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+set @@global.binlog_checksum = NONE;
+select @@global.binlog_checksum;
+@@global.binlog_checksum
+NONE
+*** must be rotations seen ***
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+master-bin.000002 #
+set @@global.binlog_checksum = default;
+select @@global.binlog_checksum;
+@@global.binlog_checksum
+NONE
+set @@global.binlog_checksum = CRC32;
+select @@global.binlog_checksum;
+@@global.binlog_checksum
+CRC32
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+set @@global.binlog_checksum = ADLER32;
+ERROR 42000: Variable 'checksum' can't be set to the value of 'ADLER32'
+set @@global.master_verify_checksum = 2;
+ERROR 42000: Variable 'master_verify_checksum' can't be set to the value of '2'
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+set @@global.slave_sql_verify_checksum = 2;
+ERROR 42000: Variable 'slave_sql_verify_checksum' can't be set to the value of '2'
+set @@global.binlog_checksum = NONE;
+create table t1 (a int);
+flush logs;
+flush logs;
+flush logs;
+flush logs;
+flush logs;
+flush logs;
+select count(*) as zero from t1;
+zero
+0
+include/stop_slave.inc
+set @@global.binlog_checksum = CRC32;
+insert into t1 values (1) /* will not be applied on slave due to simulation */;
+set @@global.debug='d,simulate_slave_unaware_checksum';
+start slave;
+include/wait_for_slave_io_error.inc [errno=1236]
+Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log''
+select count(*) as zero from t1;
+zero
+0
+set @@global.debug='';
+include/start_slave.inc
+set @@global.master_verify_checksum = 1;
+set @@session.debug='d,simulate_checksum_test_failure';
+show binlog events;
+ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
+set @@session.debug='';
+set @@global.master_verify_checksum = default;
+include/stop_slave.inc
+create table t2 (a int);
+set @@global.debug='d,simulate_checksum_test_failure';
+start slave io_thread;
+include/wait_for_slave_io_error.inc [errno=1595]
+Last_IO_Error = 'Relay log write failure: could not queue event from master'
+set @@global.debug='';
+start slave io_thread;
+include/wait_for_slave_param.inc [Read_Master_Log_Pos]
+set @@global.slave_sql_verify_checksum = 1;
+set @@global.debug='d,simulate_checksum_test_failure';
+start slave sql_thread;
+include/wait_for_slave_sql_error.inc [errno=1593]
+Last_SQL_Error = 'Error initializing relay log position: I/O error reading event at position 4'
+set @@global.debug='';
+include/start_slave.inc
+select count(*) as 'must be zero' from t2;
+must be zero
+0
+stop slave;
+reset slave;
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+flush logs;
+set @@global.binlog_checksum= CRC32;
+reset master;
+flush logs;
+create table t3 (a int, b char(5));
+include/start_slave.inc
+select count(*) as 'must be zero' from t3;
+must be zero
+0
+include/stop_slave.inc
+change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
+flush logs;
+reset master;
+insert into t3 value (1, @@global.binlog_checksum);
+include/start_slave.inc
+flush logs;
+select count(*) as 'must be one' from t3;
+must be one
+1
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+insert into t3 value (1, @@global.binlog_checksum);
+drop table t1, t2, t3;
+set @@global.binlog_checksum = @master_save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+set @@global.binlog_checksum = @slave_save_binlog_checksum;
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
+End of tests
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_checksum_cache.result b/mysql-test/suite/rpl/r/rpl_checksum_cache.result
new file mode 100644
index 00000000000..9508e94e7f2
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_checksum_cache.result
@@ -0,0 +1,119 @@
+include/master-slave.inc
+[connection master]
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t2 set data=repeat.*'a', @act_size.*");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t1 values.* NAME_CONST.*'n',.*, @data .*");
+set @save_binlog_cache_size = @@global.binlog_cache_size;
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_cache_size = 4096;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+include/stop_slave.inc
+include/start_slave.inc
+flush status;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 0
+show status like "binlog_cache_disk_use";
+Variable_name Value
+Binlog_cache_disk_use 0
+drop table if exists t1;
+create table t1 (a int PRIMARY KEY, b CHAR(32)) engine=innodb;
+create procedure test.p_init (n int, size int)
+begin
+while n > 0 do
+select round(RAND() * size) into @act_size;
+set @data = repeat('a', @act_size);
+insert into t1 values(n, @data );
+set n= n-1;
+end while;
+end|
+begin;
+call test.p_init(4000, 32);
+commit;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 1
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name Value
+Binlog_cache_disk_use 1
+include/diff_tables.inc [master:test.t1, slave:test.t1]
+begin;
+delete from t1;
+commit;
+flush status;
+create table t2(a int auto_increment primary key, data VARCHAR(12288)) ENGINE=Innodb;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 1
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name Value
+Binlog_cache_disk_use 1
+include/diff_tables.inc [master:test.t2, slave:test.t2]
+begin;
+delete from t2;
+commit;
+flush status;
+create table t3(a int auto_increment primary key, data VARCHAR(8192)) engine=innodb;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 1
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name Value
+Binlog_cache_disk_use 1
+include/diff_tables.inc [master:test.t3, slave:test.t3]
+begin;
+delete from t3;
+commit;
+flush status;
+create procedure test.p1 (n int)
+begin
+while n > 0 do
+case (select (round(rand()*100) % 3) + 1)
+when 1 then
+select round(RAND() * 32) into @act_size;
+set @data = repeat('a', @act_size);
+insert into t1 values(n, @data);
+when 2 then
+begin
+select round(8192 + RAND() * 4096) into @act_size;
+insert into t2 set data=repeat('a', @act_size);
+end;
+when 3 then
+begin
+select round(3686.4000 + RAND() * 819.2000) into @act_size;
+insert into t3 set data= repeat('a', @act_size);
+end;
+end case;
+set n= n-1;
+end while;
+end|
+set autocommit= 0;
+begin;
+call test.p1(1000);
+commit;
+show status like "binlog_cache_use";
+Variable_name Value
+Binlog_cache_use 1
+*** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+Variable_name Value
+Binlog_cache_disk_use 1
+include/diff_tables.inc [master:test.t1, slave:test.t1]
+include/diff_tables.inc [master:test.t2, slave:test.t2]
+include/diff_tables.inc [master:test.t3, slave:test.t3]
+begin;
+delete from t1;
+delete from t2;
+delete from t3;
+commit;
+drop table t1, t2, t3;
+set @@global.binlog_cache_size = @save_binlog_cache_size;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+drop procedure test.p_init;
+drop procedure test.p1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
index fb1d3f8258e..412021d6446 100644
--- a/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
+++ b/mysql-test/suite/rpl/r/rpl_circular_for_4_hosts.result
@@ -46,6 +46,7 @@ SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
include/start_slave.inc
INSERT INTO t1 VALUES(6,'C',2);
INSERT INTO t1(b,c) VALUES('B',2);
+call mtr.add_suppression("Slave SQL.*Duplicate entry .6. for key .PRIMARY.* Error_code: 1062");
include/wait_for_slave_sql_error.inc [errno=1062]
INSERT INTO t1(b,c) VALUES('A',2);
INSERT INTO t1(b,c) VALUES('D',2);
@@ -121,11 +122,11 @@ Master D 12 D
* Remove wrong event from C and restore B->C->D *
include/stop_slave.inc
DELETE FROM t1 WHERE a = 6;
-START SLAVE;
+include/start_slave.inc
RESET MASTER;
RESET SLAVE;
include/rpl_change_topology.inc [new topology=1->2->3->4->1]
-START SLAVE;
+include/start_slave.inc
include/rpl_sync.inc
* Check data inserted before restoring schema A->B->C->D->A *
diff --git a/mysql-test/suite/rpl/r/rpl_corruption.result b/mysql-test/suite/rpl/r/rpl_corruption.result
new file mode 100644
index 00000000000..a35bfbad92c
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_corruption.result
@@ -0,0 +1,51 @@
+include/master-slave.inc
+[connection master]
+call mtr.add_suppression('Found invalid event in binary log');
+call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
+call mtr.add_suppression('event read from binlog did not pass crc check');
+call mtr.add_suppression('Replication event checksum verification failed');
+call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
+call mtr.add_suppression('Slave SQL: Error initializing relay log position: I/O error reading event at position .*, Error_code: 1593');
+SET @old_master_verify_checksum = @@master_verify_checksum;
+# 1. Creating test table/data and set corruption position for testing
+* insert/update/delete rows in table t1 *
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100));
+include/stop_slave.inc
+# 2. Corruption in master binlog and SHOW BINLOG EVENTS
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+SHOW BINLOG EVENTS;
+ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+# 3. Master read a corrupted event from binlog and send the error to slave
+SET GLOBAL debug="+d,corrupt_read_log_event2";
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_error.inc [errno=1236]
+SET GLOBAL debug="-d,corrupt_read_log_event2";
+# 4. Master read a corrupted event from binlog and send it to slave
+SET GLOBAL master_verify_checksum=0;
+SET GLOBAL debug="+d,corrupt_read_log_event2";
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_error.inc [errno=1595,1722]
+SET GLOBAL debug="-d,corrupt_read_log_event2";
+SET GLOBAL debug= "";
+SET GLOBAL master_verify_checksum=1;
+# 5. Slave. Corruption in network
+SET GLOBAL debug="+d,corrupt_queue_event";
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_error.inc [errno=1595,1722]
+SET GLOBAL debug="-d,corrupt_queue_event";
+# 6. Slave. Corruption in relay log
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+START SLAVE SQL_THREAD;
+include/wait_for_slave_sql_error.inc [errno=1593]
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+SET GLOBAL debug= "";
+# 7. Seek diff for tables on master and slave
+include/start_slave.inc
+include/diff_tables.inc [master:test.t1, slave:test.t1]
+# 8. Clean up
+SET GLOBAL debug= "";
+SET GLOBAL master_verify_checksum = @old_master_verify_checksum;
+DROP TABLE t1;
+SET GLOBAL debug= "";
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result b/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result
index 9ea319379c0..e71f408ae85 100644
--- a/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result
@@ -460,6 +460,9 @@ c4 BLOB, c5 CHAR(5)) ENGINE='InnoDB';
RESET MASTER;
*** Start Slave ***
START SLAVE;
+call mtr.add_suppression("Slave SQL.*Error .Unknown table .t6.. on query.* Error_code: 1051");
+call mtr.add_suppression("Slave SQL.*Error .Duplicate column name .c6.. on query.* Error_code: 1060");
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column . ...e mismatch.* Error_code: 1535");
*** Master Data Insert ***
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result b/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result
index 716a35b3464..51ca555b545 100644
--- a/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result
@@ -460,6 +460,9 @@ c4 BLOB, c5 CHAR(5)) ENGINE='MyISAM';
RESET MASTER;
*** Start Slave ***
START SLAVE;
+call mtr.add_suppression("Slave SQL.*Error .Unknown table .t6.. on query.* Error_code: 1051");
+call mtr.add_suppression("Slave SQL.*Error .Duplicate column name .c6.. on query.* Error_code: 1060");
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column . ...e mismatch.* Error_code: 1535");
*** Master Data Insert ***
set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
diff --git a/mysql-test/suite/rpl/r/rpl_filter_tables_not_exist.result b/mysql-test/suite/rpl/r/rpl_filter_tables_not_exist.result
index 4eaf61e5f9e..c88dcee9dbc 100644
--- a/mysql-test/suite/rpl/r/rpl_filter_tables_not_exist.result
+++ b/mysql-test/suite/rpl/r/rpl_filter_tables_not_exist.result
@@ -42,6 +42,7 @@ UPDATE t4 LEFT JOIN (t1, t2, t5) ON (t1.id=t4.id and t2.id=t4.id and t5.id=t4.id
UPDATE t4 LEFT JOIN (t1, t6, t7) ON (t4.id=t1.id and t4.id=t6.id and t4.id=t7.id) SET a=0, d=0, f=0, g=0 where t4.id=1;
UPDATE t7 LEFT JOIN (t4, t1, t2) ON (t7.id=t4.id and t7.id=t1.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1;
UPDATE t7 LEFT JOIN (t8, t4, t1) ON (t7.id=t8.id and t7.id=t4.id and t7.id=t1.id) SET a=0, d=0, g=0, h=0 where t7.id=1;
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t[47]. doesn.t exist. on query.* Error_code: 1146");
UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0 where t1.id=1;
include/wait_for_slave_sql_error_and_skip.inc [errno=1146]
Last_SQL_Error = 'Error 'Table 'test.t4' doesn't exist' on query. Default database: 'test'. Query: 'UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0 where t1.id=1''
diff --git a/mysql-test/suite/rpl/r/rpl_hrtime.result b/mysql-test/suite/rpl/r/rpl_hrtime.result
new file mode 100644
index 00000000000..67b29de687b
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_hrtime.result
@@ -0,0 +1,67 @@
+include/master-slave.inc
+[connection master]
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
+create table t1 (a timestamp(4), b varchar(100), c datetime(2));
+insert t1 (b,c) values (now(6), now(6));
+insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010');
+set timestamp=unix_timestamp('2022-02-02 02:02:02') + 0.654321;
+insert t1 (b,c) values (now(), now());
+insert t1 (b,c) values (0,0);
+insert t1 (a,b,c) values (0,0,now(6));
+select * from t1;
+a b c
+2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
+2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
+2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
+2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
+0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
+set time_zone='+03:00';
+select * from t1;
+a b c
+2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
+2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
+2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
+2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
+0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
+drop table t1;
+include/rpl_end.inc
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1293832861/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+create table t1 (a timestamp(4), b varchar(100), c datetime(2))
+/*!*/;
+SET TIMESTAMP=1293832861.123456/*!*/;
+SET @@session.time_zone='+03:00'/*!*/;
+insert t1 (b,c) values (now(6), now(6))
+/*!*/;
+SET TIMESTAMP=1293832861/*!*/;
+insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010')
+/*!*/;
+SET TIMESTAMP=1643756522.654321/*!*/;
+insert t1 (b,c) values (now(), now())
+/*!*/;
+SET TIMESTAMP=1643756522.654321/*!*/;
+insert t1 (b,c) values (0,0)
+/*!*/;
+SET TIMESTAMP=1643756522.654321/*!*/;
+insert t1 (a,b,c) values (0,0,now(6))
+/*!*/;
+SET TIMESTAMP=1643756522/*!*/;
+drop table t1
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
diff --git a/mysql-test/suite/rpl/r/rpl_hrtime_row.result b/mysql-test/suite/rpl/r/rpl_hrtime_row.result
new file mode 100644
index 00000000000..aaf8b1c2466
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_hrtime_row.result
@@ -0,0 +1,28 @@
+include/master-slave.inc
+[connection master]
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
+create table t1 (a timestamp(4), b varchar(100), c datetime(2));
+insert t1 (b,c) values (now(6), now(6));
+insert t1 values ('2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010','2010-10-10 10:10:10.101010');
+set timestamp=unix_timestamp('2022-02-02 02:02:02') + 0.654321;
+insert t1 (b,c) values (now(), now());
+insert t1 (b,c) values (0,0);
+insert t1 (a,b,c) values (0,0,now(6));
+select * from t1;
+a b c
+2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
+2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
+2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
+2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
+0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
+set time_zone='+03:00';
+select * from t1;
+a b c
+2011-01-01 01:01:01.1234 2011-01-01 01:01:01.123456 2011-01-01 01:01:01.12
+2010-10-10 10:10:10.1010 2010-10-10 10:10:10.101010 2010-10-10 10:10:10.10
+2022-02-02 02:02:02.6543 2022-02-02 02:02:02 2022-02-02 02:02:02.00
+2022-02-02 02:02:02.6543 0 0000-00-00 00:00:00.00
+0000-00-00 00:00:00.0000 0 2022-02-02 02:02:02.65
+drop table t1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_idempotency.result b/mysql-test/suite/rpl/r/rpl_idempotency.result
index e25d5f81c91..76abd0f64c0 100644
--- a/mysql-test/suite/rpl/r/rpl_idempotency.result
+++ b/mysql-test/suite/rpl/r/rpl_idempotency.result
@@ -1,9 +1,9 @@
include/master-slave.inc
[connection master]
-call mtr.add_suppression("Slave: Can't find record in 't.' Error_code: 1032");
-call mtr.add_suppression("Can't find record in 't.'");
+call mtr.add_suppression("Can.t find record in .t[12].* Error_code: 1032");
call mtr.add_suppression("Slave: Cannot delete or update a parent row: a foreign key constraint fails .* Error_code: 1451");
call mtr.add_suppression("Slave: Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452");
+call mtr.add_suppression("Slave SQL.*Could not execute Write_rows event on table test.* Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
SET @old_slave_exec_mode= @@global.slave_exec_mode;
CREATE TABLE t1 (a INT PRIMARY KEY);
CREATE TABLE t2 (a INT);
diff --git a/mysql-test/suite/rpl/r/rpl_ignore_table.result b/mysql-test/suite/rpl/r/rpl_ignore_table.result
index 374053f322a..20d51b72f96 100644
--- a/mysql-test/suite/rpl/r/rpl_ignore_table.result
+++ b/mysql-test/suite/rpl/r/rpl_ignore_table.result
@@ -116,6 +116,7 @@ show grants for mysqltest4@localhost;
Grants for mysqltest4@localhost
GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7'
set global slave_exec_mode='IDEMPOTENT';
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table mysql.* Error_code: 1032");
drop table t1, mysqltest2.t2;
drop table t4;
drop database mysqltest2;
diff --git a/mysql-test/suite/rpl/r/rpl_incident.result b/mysql-test/suite/rpl/r/rpl_incident.result
index b54d7d400f7..d528fb3297a 100644
--- a/mysql-test/suite/rpl/r/rpl_incident.result
+++ b/mysql-test/suite/rpl/r/rpl_incident.result
@@ -15,6 +15,7 @@ a
2
3
4
+call mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master.* 1590");
include/wait_for_slave_sql_error.inc [errno=1590]
Last_SQL_Error = 'The incident LOST_EVENTS occured on the master. Message: <none>'
**** On Slave ****
diff --git a/mysql-test/suite/rpl/r/rpl_init_slave_errors.result b/mysql-test/suite/rpl/r/rpl_init_slave_errors.result
index 46bc66cbb65..a185afc5af2 100644
--- a/mysql-test/suite/rpl/r/rpl_init_slave_errors.result
+++ b/mysql-test/suite/rpl/r/rpl_init_slave_errors.result
@@ -6,7 +6,7 @@ SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on
start slave;
include/wait_for_slave_sql_error.inc [errno=1593]
Last_SQL_Error = 'Failed during slave thread initialization'
-call mtr.add_suppression("Failed during slave I/O thread initialization");
+call mtr.add_suppression("Failed during slave.* thread initialization");
SET GLOBAL debug= "";
reset slave;
SET GLOBAL init_slave= "garbage";
diff --git a/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result b/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result
index f8734b48295..b02164ac61b 100644
--- a/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result
+++ b/mysql-test/suite/rpl/r/rpl_innodb_bug28430.result
@@ -90,13 +90,19 @@ DELETE FROM test.byrange_tbl WHERE id = del_count;
SET del_count = del_count - 2;
END WHILE;
END|
+begin;
CALL test.proc_norm();
+commit;
SELECT count(*) as "Master regular" FROM test.regular_tbl;
Master regular 500
+begin;
CALL test.proc_bykey();
+commit;
SELECT count(*) as "Master bykey" FROM test.bykey_tbl;
Master bykey 500
+begin;
CALL test.proc_byrange();
+commit;
SELECT count(*) as "Master byrange" FROM test.byrange_tbl;
Master byrange 500
show create table test.byrange_tbl;
diff --git a/mysql-test/suite/rpl/r/rpl_insert_duplicate.result b/mysql-test/suite/rpl/r/rpl_insert_duplicate.result
new file mode 100644
index 00000000000..61ebbaaa5a9
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_insert_duplicate.result
@@ -0,0 +1,29 @@
+include/master-slave.inc
+[connection master]
+CREATE TABLE t1 (
+a INT UNSIGNED NOT NULL PRIMARY KEY
+) ENGINE=innodb;
+CREATE TABLE t2 (
+a INT UNSIGNED
+) ENGINE=innodb;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a;
+include/assert.inc [Sum of elements in t1 should be 1.]
+include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
+include/diff_tables.inc [master:test.t1 , slave:test.t1]
+drop table t1, t2;
+CREATE TABLE t1 (
+a INT UNSIGNED NOT NULL PRIMARY KEY
+) ENGINE=myisam;
+CREATE TABLE t2 (
+a INT UNSIGNED
+) ENGINE=myisam;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a;
+include/assert.inc [Sum of elements in t1 should be 1.]
+include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
+include/diff_tables.inc [master:test.t1 , slave:test.t1]
+drop table t1, t2;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_insert_ignore.result b/mysql-test/suite/rpl/r/rpl_insert_ignore.result
index 6937c3d0987..63b9244a40d 100644
--- a/mysql-test/suite/rpl/r/rpl_insert_ignore.result
+++ b/mysql-test/suite/rpl/r/rpl_insert_ignore.result
@@ -20,48 +20,36 @@ INSERT INTO t2 VALUES (4, 3);
INSERT INTO t2 VALUES (5, 4);
INSERT INTO t2 VALUES (6, 6);
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
-SELECT * FROM t1 ORDER BY a;
-a b
-1 1
-2 2
-3 3
-4 4
-5 5
-6 6
-SELECT * FROM t1 ORDER BY a;
-a b
-1 1
-2 2
-3 3
-4 4
-5 5
-6 6
-drop table t1;
+include/assert.inc [Count of elements in t1 should be 6.]
+include/diff_tables.inc [master:test.t1 , slave:test.t1]
+INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
+include/assert.inc [Count of elements in t1 should be 6.]
+include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
+drop table t1, t2;
CREATE TABLE t1 (
a int unsigned not null auto_increment primary key,
b int unsigned,
unique (b)
) ENGINE=myisam;
-INSERT INTO t1 VALUES (1, 1);
-INSERT INTO t1 VALUES (2, 2);
-INSERT INTO t1 VALUES (3, 3);
-INSERT INTO t1 VALUES (4, 4);
+CREATE TABLE t2 (
+a int unsigned, # to force INSERT SELECT to have a certain order
+b int unsigned
+) ENGINE=myisam;
+INSERT INTO t1 VALUES (NULL, 1);
+INSERT INTO t1 VALUES (NULL, 2);
+INSERT INTO t1 VALUES (NULL, 3);
+INSERT INTO t1 VALUES (NULL, 4);
+INSERT INTO t2 VALUES (1, 1);
+INSERT INTO t2 VALUES (2, 2);
+INSERT INTO t2 VALUES (3, 5);
+INSERT INTO t2 VALUES (4, 3);
+INSERT INTO t2 VALUES (5, 4);
+INSERT INTO t2 VALUES (6, 6);
+INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
+include/assert.inc [Count of elements in t1 should be 6.]
+include/diff_tables.inc [master:test.t1 , slave:test.t1]
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
-SELECT * FROM t1 ORDER BY a;
-a b
-1 1
-2 2
-3 3
-4 4
-5 5
-6 6
-SELECT * FROM t1 ORDER BY a;
-a b
-1 1
-2 2
-3 3
-4 4
-5 5
-6 6
+include/assert.inc [Count of elements in t1 should be 6.]
+include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
drop table t1, t2;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
index 52980e81523..972e877bf18 100644
--- a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
+++ b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
@@ -7,6 +7,7 @@ SELECT * FROM t1;
a b
1 10
2 2
+call mtr.add_suppression("Slave SQL.*suffer.*http:..bugs.mysql.com.bug.php.id=24432");
include/wait_for_slave_sql_error.inc [errno=1105]
Last_SQL_Error = 'Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10''
SELECT * FROM t1;
diff --git a/mysql-test/suite/rpl/r/rpl_loaddata.result b/mysql-test/suite/rpl/r/rpl_loaddata.result
index bd8bc5093aa..c4bcb692133 100644
--- a/mysql-test/suite/rpl/r/rpl_loaddata.result
+++ b/mysql-test/suite/rpl/r/rpl_loaddata.result
@@ -27,6 +27,8 @@ drop table t3;
create table t1(a int, b int, unique(b));
insert into t1 values(1,10);
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .10. for key .b.. on query.* Error_code: 1062");
+call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.*error code=1062.*Error on slave:.*Error_code: 0");
include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
include/check_slave_no_error.inc
set sql_log_bin=0;
diff --git a/mysql-test/suite/rpl/r/rpl_loaddata_concurrent.result b/mysql-test/suite/rpl/r/rpl_loaddata_concurrent.result
index bc40f32842d..d1c7bf65624 100644
--- a/mysql-test/suite/rpl/r/rpl_loaddata_concurrent.result
+++ b/mysql-test/suite/rpl/r/rpl_loaddata_concurrent.result
@@ -38,6 +38,8 @@ drop table t3;
create table t1(a int, b int, unique(b));
insert into t1 values(1,10);
load data CONCURRENT infile '../../std_data/rpl_loaddata.dat' into table t1;
+call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .10. for key .b.. on query.* Error_code: 1062");
+call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.*error code=1062.*Error on slave:.*Error_code: 0");
include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
include/check_slave_no_error.inc
set sql_log_bin=0;
diff --git a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result
index a81813de19f..b13e2ced183 100644
--- a/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result
+++ b/mysql-test/suite/rpl/r/rpl_loaddata_fatal.result
@@ -3,6 +3,7 @@ include/master-slave.inc
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (1,10);
LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE t1;
+call mtr.add_suppression("Slave SQL.*Fatal error: Not enough memory, Error_code: 1593");
include/wait_for_slave_sql_error_and_skip.inc [errno=1593]
Last_SQL_Error = 'Fatal error: Not enough memory'
DROP TABLE t1;
diff --git a/mysql-test/suite/rpl/r/rpl_packet.result b/mysql-test/suite/rpl/r/rpl_packet.result
index 9239a718504..7a7f8141ac8 100644
--- a/mysql-test/suite/rpl/r/rpl_packet.result
+++ b/mysql-test/suite/rpl/r/rpl_packet.result
@@ -49,6 +49,8 @@ SET @max_allowed_packet_2= @@session.max_allowed_packet;
==== clean up ====
DROP TABLE t1;
SET @@global.max_allowed_packet= 1024;
+Warnings:
+Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SET @@global.net_buffer_length= 1024;
DROP TABLE t1;
RESET SLAVE;
diff --git a/mysql-test/suite/rpl/r/rpl_rewrt_db.result b/mysql-test/suite/rpl/r/rpl_rewrt_db.result
index 12071faecfd..6cbd107fdcf 100644
--- a/mysql-test/suite/rpl/r/rpl_rewrt_db.result
+++ b/mysql-test/suite/rpl/r/rpl_rewrt_db.result
@@ -25,8 +25,8 @@ Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
-Warning 1265 Data truncated for column 'a' at row 2
-Warning 1265 Data truncated for column 'b' at row 2
+Warning 1264 Out of range value for column 'a' at row 2
+Warning 1264 Out of range value for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
select * from rewrite.t1;
@@ -40,7 +40,7 @@ load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
-Warning 1265 Data truncated for column 'b' at row 2
+Warning 1264 Out of range value for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
select * from rewrite.t1;
a b c d
diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
index e41f56c0a71..329a480783a 100644
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
@@ -36,6 +36,7 @@ drop table temp_table, t3;
insert into t2 values(1234);
set insert_id=1234;
insert into t2 values(NULL);
+call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .1234. for key .PRIMARY.. on query.* Error_code: 1062");
include/wait_for_slave_sql_error_and_skip.inc [errno=1062]
purge master logs to 'master-bin.000002';
show master logs;
@@ -69,7 +70,7 @@ insert into temp_table values ("testing temporary tables part 2");
create table t3 (n int);
select count(*) from t3 where n >= 4;
count(*)
-100
+90
create table t4 select * from temp_table;
show binary logs;
Log_name File_size
@@ -88,7 +89,7 @@ include/check_slave_is_running.inc
lock tables t3 read;
select count(*) from t3 where n >= 4;
count(*)
-100
+90
unlock tables;
drop table if exists t1,t2,t3,t4;
End of 4.1 tests
diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result
index d13d6722dc7..247e22f1a8d 100644
--- a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result
@@ -68,6 +68,7 @@ DROP TABLE t1;
include/rpl_reset.inc
**** On Slave ****
SET GLOBAL QUERY_CACHE_SIZE=0;
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.t1.* Error_code: 1032");
**** On Master ****
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result b/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result
index 7afc70bfa5c..4f051d19e4b 100644
--- a/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result
@@ -478,6 +478,8 @@ include/diff_tables.inc [master:t2, slave:t2]
[expecting slave to stop]
INSERT INTO t3 VALUES (1, "", 1);
INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2);
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 1 size mismatch.* Error_code: 1535");
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.* Error_code: 1032");
include/wait_for_slave_sql_error.inc [errno=1535]
Last_SQL_Error = 'Table definition on master and slave does not match: Column 1 size mismatch - master has size 384, test.t3 on slave has size 49. Master's column size should be <= the slave's column size.'
include/rpl_reset.inc
diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result b/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result
index b8620894bd1..1ae1cd84579 100644
--- a/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result
@@ -478,6 +478,8 @@ include/diff_tables.inc [master:t2, slave:t2]
[expecting slave to stop]
INSERT INTO t3 VALUES (1, "", 1);
INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2);
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 1 size mismatch.* Error_code: 1535");
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table test.t1.* Error_code: 1032");
include/wait_for_slave_sql_error.inc [errno=1535]
Last_SQL_Error = 'Table definition on master and slave does not match: Column 1 size mismatch - master has size 384, test.t3 on slave has size 49. Master's column size should be <= the slave's column size.'
include/rpl_reset.inc
diff --git a/mysql-test/suite/rpl/r/rpl_row_colSize.result b/mysql-test/suite/rpl/r/rpl_row_colSize.result
index 49753d2b25c..d31f6d1c54e 100644
--- a/mysql-test/suite/rpl/r/rpl_row_colSize.result
+++ b/mysql-test/suite/rpl/r/rpl_row_colSize.result
@@ -265,6 +265,7 @@ STOP SLAVE;
RESET SLAVE;
RESET MASTER;
START SLAVE;
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 0 ...e mismatch.* Error_code: 1535");
*** Cleanup ***
DROP TABLE IF EXISTS t1;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_row_conflicts.result b/mysql-test/suite/rpl/r/rpl_row_conflicts.result
index 7ad0c06448e..05da799ba6f 100644
--- a/mysql-test/suite/rpl/r/rpl_row_conflicts.result
+++ b/mysql-test/suite/rpl/r/rpl_row_conflicts.result
@@ -22,7 +22,8 @@ a
[on slave]
---- Wait until slave stops with an error ----
include/wait_for_slave_sql_error.inc [errno=1062]
-Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 480 (expected "duplicate key" error)
+Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 485 (expected "duplicate key" error)
+call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
SELECT * FROM t1;
a
1
@@ -49,6 +50,7 @@ SELECT * FROM t1;
a
[on slave]
---- Wait until slave stops with an error ----
+call mtr.add_suppression("Can.t find record in .t1., Error_code: 1032");
include/wait_for_slave_sql_error.inc [errno=1032]
Last_SQL_Error (expected "duplicate key" error)
Could not execute Delete_rows event on table test.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000001, end_log_pos END_LOG_POS
diff --git a/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result b/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result
index 148840cc8c5..20fbcbb7763 100644
--- a/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result
+++ b/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result
@@ -10,6 +10,7 @@ DROP TABLE t1;
INSERT INTO t1 VALUES (1);
==== Verify error on slave ====
[on slave]
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t1. doesn.t exist. on opening tables, Error_code: 1146");
include/wait_for_slave_sql_error.inc [errno=1146]
==== Clean up ====
include/stop_slave_io.inc
diff --git a/mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result b/mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result
index d9ebb52493b..523564a222e 100644
--- a/mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result
@@ -25,4 +25,10 @@ INSERT INTO t1(c1) VALUES (NULL);
UPDATE t1 SET c1= 0;
include/diff_tables.inc [master:t1, slave:t1]
DROP TABLE t1;
+include/rpl_reset.inc
+CREATE TABLE t1 (c1 int(11) NOT NULL, c2 int(11) NOT NULL, c3 int(11) DEFAULT '-1') ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1,2,NULL);
+UPDATE t1 SET c1=1, c2=2, c3=-1 WHERE c1=1 AND c2=2 AND ISNULL(c3);
+include/diff_tables.inc [master:test.t1, slave:test.t1]
+DROP TABLE t1;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result b/mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result
index e9ffcc927be..4dc7c0bc7a3 100644
--- a/mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result
@@ -1,5 +1,14 @@
include/master-slave.inc
[connection master]
+## coverage purposes - Field_bits
+## 1 X bit + 2 Null bits + 5 bits => last_null_bit_pos==0
+include/rpl_reset.inc
+CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bit(5)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1(c1,c2) VALUES (10, b'1');
+INSERT INTO t1(c1,c2) VALUES (NULL, b'1');
+UPDATE t1 SET c1= 0;
+include/diff_tables.inc [master:t1, slave:t1]
+DROP TABLE t1;
## case #1 - last_null_bit_pos==0 in record_compare without X bit
include/rpl_reset.inc
CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bigint(20) DEFAULT 0, c3 bigint(20) DEFAULT 0, c4 varchar(1) DEFAULT '', c5 bigint(20) DEFAULT 0, c6 bigint(20) DEFAULT 0, c7 bigint(20) DEFAULT 0, c8 bigint(20) DEFAULT 0) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -25,13 +34,10 @@ INSERT INTO t1(c1) VALUES (NULL);
UPDATE t1 SET c1= 0;
include/diff_tables.inc [master:t1, slave:t1]
DROP TABLE t1;
-## coverage purposes - Field_bits
-## 1 X bit + 2 Null bits + 5 bits => last_null_bit_pos==0
include/rpl_reset.inc
-CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bit(5)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-INSERT INTO t1(c1,c2) VALUES (10, b'1');
-INSERT INTO t1(c1,c2) VALUES (NULL, b'1');
-UPDATE t1 SET c1= 0;
-include/diff_tables.inc [master:t1, slave:t1]
+CREATE TABLE t1 (c1 int(11) NOT NULL, c2 int(11) NOT NULL, c3 int(11) DEFAULT '-1') ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1,2,NULL);
+UPDATE t1 SET c1=1, c2=2, c3=-1 WHERE c1=1 AND c2=2 AND ISNULL(c3);
+include/diff_tables.inc [master:test.t1, slave:test.t1]
DROP TABLE t1;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result
index 5a29acfda1d..593aaa7ae51 100644
--- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result
+++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result
@@ -117,6 +117,7 @@ a
include/check_slave_is_running.inc
INSERT INTO t9 VALUES (4);
INSERT INTO t4 VALUES (4);
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column [012] type mismatch.* Error_code: 1535");
include/wait_for_slave_sql_error_and_skip.inc [errno=1535]
Last_SQL_Error = 'Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4'
INSERT INTO t9 VALUES (5);
diff --git a/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result b/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result
index f6620ecf05f..e89118ac0a7 100644
--- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result
@@ -117,6 +117,7 @@ a
include/check_slave_is_running.inc
INSERT INTO t9 VALUES (4);
INSERT INTO t4 VALUES (4);
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column [012] type mismatch.* Error_code: 1535");
include/wait_for_slave_sql_error_and_skip.inc [errno=1535]
Last_SQL_Error = 'Table definition on master and slave does not match: Column 0 type mismatch - received type 3, test.t4 has type 4'
INSERT INTO t9 VALUES (5);
diff --git a/mysql-test/suite/rpl/r/rpl_skip_error.result b/mysql-test/suite/rpl/r/rpl_skip_error.result
index d46338fd5b0..f5675b5e25f 100644
--- a/mysql-test/suite/rpl/r/rpl_skip_error.result
+++ b/mysql-test/suite/rpl/r/rpl_skip_error.result
@@ -56,6 +56,7 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET SQL_LOG_BIN=1;
+call mtr.add_suppression("Slave SQL.*Could not execute .*te_rows event on table test.t.; Duplicate entry.* Error_code: 1062");
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
SHOW CREATE TABLE t1;
Table Create Table
diff --git a/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result b/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
index 25deb65fa0f..a90c3c7b68f 100644
--- a/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
+++ b/mysql-test/suite/rpl/r/rpl_slave_grp_exec.result
@@ -29,6 +29,7 @@ a b
SELECT * FROM t3 ORDER BY a;
a b
1 ZZ
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t3. doesn.t exist. on.* Error_code: 1146");
include/wait_for_slave_sql_error.inc [errno=1146]
SHOW TABLES LIKE 't%';
Tables_in_test (t%)
diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
index 213ab06f0c1..425611e2175 100644
--- a/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
@@ -13,4 +13,5 @@ include/stop_slave_io.inc
RESET SLAVE;
drop table t1;
call mtr.add_suppression("Slave: Error writing file 'UNKNOWN' .Errcode: 9. Error_code: 3");
+call mtr.add_suppression("Slave SQL.*Error in Begin_load_query event: write to.* failed, Error_code: 9");
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result
index 8cd6218dcdc..262404ff6f9 100644
--- a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result
@@ -1,6 +1,7 @@
include/master-slave.inc
[connection master]
START SLAVE;
+call mtr.add_suppression("Slave SQL.*Unable to use slave.s temporary directory.* Error_code: 12");
include/wait_for_slave_sql_error.inc [errno=12]
include/stop_slave_io.inc
RESET SLAVE;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result b/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result
index 0e83f1dfb67..d4a14adc6b8 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_EE_err2.result
@@ -8,6 +8,7 @@ insert into t1 values(1),(2);
ERROR 23000: Duplicate entry '2' for key 'a'
drop table t1;
include/wait_for_slave_sql_to_stop.inc
+call mtr.add_suppression("Slave SQL.*Query caused different errors on master and slave.*Error on master:.* error code=1062.*Error on slave:.* Error_code: 0");
Error: "Query caused different errors on master and slave. Error on master: message (format)='Duplicate entry '%-.192s' for key %d' error code=1062 ; Error on slave: actual message='no error', error code=0. Default database: 'test'. Query: 'insert into t1 values(1),(2)'" (expected different error codes on master and slave)
Errno: "0" (expected 0)
drop table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_conflicts.result b/mysql-test/suite/rpl/r/rpl_stm_conflicts.result
index b56297a5487..ee137c34fd0 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_conflicts.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_conflicts.result
@@ -17,6 +17,7 @@ a
---- Wait until slave stops with an error ----
include/wait_for_slave_sql_error.inc [errno=1062]
Last_SQL_Error = Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (1)' (expected "duplicate key" error)
+call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
SELECT * FROM t1;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_stop_slave.result b/mysql-test/suite/rpl/r/rpl_stop_slave.result
index 38b85f0d30d..56199b003c5 100644
--- a/mysql-test/suite/rpl/r/rpl_stop_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stop_slave.result
@@ -132,5 +132,49 @@ START SLAVE SQL_THREAD;
include/wait_for_slave_sql_to_start.inc
# Test end
SET GLOBAL debug= '$debug_save';
+include/restart_slave.inc
+[connection master]
+DROP TABLE t1, t2;
+
+# Bug#58546 test rpl_packet timeout failure sporadically on PB
+# ----------------------------------------------------------------------
+# STOP SLAVE stopped IO thread first and then stopped SQL thread. It was
+# possible that IO thread stopped after replicating part of a transaction
+# which SQL thread was executing. SQL thread would be hung if the
+# transaction could not be rolled back safely.
+# It caused some sporadic failures on PB2.
+#
+# This test verifies that when 'STOP SLAVE' is issued by a user, IO
+# thread will continue to fetch the rest events of the transaction which
+# is being executed by SQL thread and is not able to be rolled back safely.
+CREATE TABLE t1 (c1 INT KEY, c2 INT) ENGINE=InnoDB;
+CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES(1, 1);
+[connection master]
+SET GLOBAL debug= 'd,dump_thread_wait_before_send_xid';
+[connection slave]
+include/restart_slave.inc
+BEGIN;
+UPDATE t1 SET c2 = 2 WHERE c1 = 1;
+[connection master]
+BEGIN;
+INSERT INTO t1 VALUES(2, 2);
+INSERT INTO t2 VALUES(1);
+UPDATE t1 SET c2 = 3 WHERE c1 = 1;
+COMMIT;
+[connection slave1]
+STOP SLAVE;
+[connection slave]
+ROLLBACK;
+[connection master]
+SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
+SET DEBUG_SYNC= 'RESET';
+[connection slave]
+include/wait_for_slave_to_stop.inc
+[connection slave1]
+include/start_slave.inc
+[connection master]
DROP TABLE t1, t2;
+SET GLOBAL debug= $debug_save;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result b/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result
index bd3d170c9f0..b88071391c5 100644
--- a/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result
+++ b/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result
@@ -135,6 +135,8 @@ create table t2 ENGINE=MyISAM select rpad(UUID(),100,' ');
create table t3 select 1 union select UUID();
create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
+Warnings:
+Warning 1292 Incorrect datetime value: '3'
insert into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
create procedure foo()
begin
diff --git a/mysql-test/suite/rpl/r/rpl_temporary_errors.result b/mysql-test/suite/rpl/r/rpl_temporary_errors.result
index b7bbed328dd..79da0932875 100644
--- a/mysql-test/suite/rpl/r/rpl_temporary_errors.result
+++ b/mysql-test/suite/rpl/r/rpl_temporary_errors.result
@@ -38,6 +38,7 @@ a b
3 3
4 4
include/check_slave_is_running.inc
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.t1");
**** On Master ****
DROP TABLE t1;
SET SESSION BINLOG_FORMAT=MIXED;
diff --git a/mysql-test/suite/rpl/r/rpl_variables_stm.result b/mysql-test/suite/rpl/r/rpl_variables_stm.result
index 553a1710d77..faef89f2d80 100644
--- a/mysql-test/suite/rpl/r/rpl_variables_stm.result
+++ b/mysql-test/suite/rpl/r/rpl_variables_stm.result
@@ -482,8 +482,8 @@ id num text
52 NULL latin7
53 NULL latin7_estonian_cs
54 NULL latin7
-55 NULL 47114711
-56 NULL 47124712
+55 NULL 47114711.000000
+56 NULL 47124712.000000
57 NULL 1616
58 NULL 1717
include/diff_tables.inc [master:tstmt,tproc,tfunc,ttrig,tprep, slave:tstmt,tproc,tfunc,ttrig,tprep]
diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def
index 93d21fd6653..33f65ff3ecc 100644
--- a/mysql-test/suite/rpl/t/disabled.def
+++ b/mysql-test/suite/rpl/t/disabled.def
@@ -11,5 +11,6 @@
##############################################################################
rpl_row_create_table : Bug#51574 Feb 27 2010 andrei failed different way than earlier with bug#45576
-#rpl_log_pos : BUG#55675 Sep 10 2010 27 2010 alfranio rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle
rpl_get_master_version_and_clock : Bug#59178 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock
+rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
+rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_corruption.test b/mysql-test/suite/rpl/t/rpl_binlog_corruption.test
index d613a72e48c..f9624904649 100644
--- a/mysql-test/suite/rpl/t/rpl_binlog_corruption.test
+++ b/mysql-test/suite/rpl/t/rpl_binlog_corruption.test
@@ -22,7 +22,7 @@
--connection slave
call mtr.add_suppression('Found invalid event in binary log');
-
+call mtr.add_suppression('Slave SQL.*Relay log read failure: Could not parse relay log event entry.* 1594');
#
# BUG#40482: server/mysqlbinlog crashes when reading invalid Incident_log_event
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test
index 265bde2ccf6..06ba1fdc38e 100644
--- a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test
+++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test
@@ -398,6 +398,7 @@ source include/stop_slave.inc;
source include/start_slave.inc;
CALL mtr.add_suppression("Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage.*");
CALL mtr.add_suppression("Writing one row to the row-based binary log failed.*");
+CALL mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master. Message: error writing to the binary log");
connection master;
TRUNCATE t1;
diff --git a/mysql-test/suite/rpl/t/rpl_bug33931.test b/mysql-test/suite/rpl/t/rpl_bug33931.test
index c2cf5811938..7ee6da94357 100644
--- a/mysql-test/suite/rpl/t/rpl_bug33931.test
+++ b/mysql-test/suite/rpl/t/rpl_bug33931.test
@@ -9,6 +9,7 @@ connection slave;
# Add suppression for expected warnings in slaves error log
call mtr.add_suppression("Failed during slave I/O thread initialization");
+call mtr.add_suppression("Slave SQL.*Failed during slave thread initialization.* 1593");
--source include/stop_slave.inc
reset slave;
diff --git a/mysql-test/suite/bugs/t/rpl_bug37426.test b/mysql-test/suite/rpl/t/rpl_bug37426.test
index 4c7729ab837..d0a60524fef 100644
--- a/mysql-test/suite/bugs/t/rpl_bug37426.test
+++ b/mysql-test/suite/rpl/t/rpl_bug37426.test
@@ -7,15 +7,16 @@ source include/master-slave.inc;
source include/have_binlog_format_row.inc;
connection master;
-CREATE TABLE char128_utf8 (
- i1 INT NOT NULL,
- c CHAR(128) CHARACTER SET utf8 NOT NULL,
- i2 INT NOT NULL);
-
+CREATE TABLE char128_utf8 (i1 INT NOT NULL, c CHAR(128) CHARACTER SET utf8 NOT NULL, i2 INT NOT NULL);
INSERT INTO char128_utf8 VALUES ( 1, "123", 1 );
SELECT * FROM char128_utf8;
sync_slave_with_master;
SELECT * FROM char128_utf8;
+
+# Clean up
+connection master;
+DROP TABLE char128_utf8;
+sync_slave_with_master;
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_change_master.test b/mysql-test/suite/rpl/t/rpl_change_master.test
index 65af5e72865..36db1de8d40 100644
--- a/mysql-test/suite/rpl/t/rpl_change_master.test
+++ b/mysql-test/suite/rpl/t/rpl_change_master.test
@@ -3,6 +3,7 @@
# I/O thread left (some old bug fixed in 4.0.17)
source include/master-slave.inc;
+call mtr.add_suppression("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum");
connection master;
# Make SQL slave thread advance a bit
diff --git a/mysql-test/suite/rpl/t/rpl_checksum-master.opt b/mysql-test/suite/rpl/t/rpl_checksum-master.opt
new file mode 100644
index 00000000000..a6e99a9fd5a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_checksum-master.opt
@@ -0,0 +1 @@
+--binlog-checksum=CRC32
diff --git a/mysql-test/suite/rpl/t/rpl_checksum.test b/mysql-test/suite/rpl/t/rpl_checksum.test
new file mode 100644
index 00000000000..237fffaf33e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_checksum.test
@@ -0,0 +1,264 @@
+# WL2540 replication events checksum
+# Testing configuration parameters
+
+--source include/master-slave.inc
+--source include/have_debug.inc
+--source include/have_binlog_format_mixed.inc
+
+call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
+call mtr.add_suppression('Replication event checksum verification failed');
+# due to C failure simulation
+call mtr.add_suppression('Relay log write failure: could not queue event from master');
+call mtr.add_suppression('Master is configured to log replication events with checksum, but will not send such events to slaves that cannot process them');
+
+# A. read/write access to the global vars:
+# binlog_checksum master_verify_checksum slave_sql_verify_checksum
+
+connection master;
+
+set @master_save_binlog_checksum= @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+
+select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.binlog_checksum as 'no session var';
+
+select @@global.master_verify_checksum as 'must be zero because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.master_verify_checksum as 'no session var';
+
+connection slave;
+
+set @slave_save_binlog_checksum= @@global.binlog_checksum;
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+
+select @@global.slave_sql_verify_checksum as 'must be one because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.slave_sql_verify_checksum as 'no session var';
+
+connection master;
+
+source include/show_binary_logs.inc;
+set @@global.binlog_checksum = NONE;
+select @@global.binlog_checksum;
+--echo *** must be rotations seen ***
+source include/show_binary_logs.inc;
+
+set @@global.binlog_checksum = default;
+select @@global.binlog_checksum;
+
+# testing lack of side-effects in non-effective update of binlog_checksum:
+set @@global.binlog_checksum = CRC32;
+select @@global.binlog_checksum;
+set @@global.binlog_checksum = CRC32;
+
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.binlog_checksum = ADLER32;
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.master_verify_checksum = 2; # the var is of bool type
+
+connection slave;
+
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.slave_sql_verify_checksum = 2; # the var is of bool type
+
+#
+# B. Old Slave to New master conditions
+#
+# while master does not send a checksum-ed binlog the Old Slave can
+# work with the New Master
+
+connection master;
+
+set @@global.binlog_checksum = NONE;
+create table t1 (a int);
+
+# testing that binlog rotation preserves opt_binlog_checksum value
+flush logs;
+flush logs;
+flush logs;
+
+sync_slave_with_master;
+#connection slave;
+# checking that rotation on the slave side leaves slave stable
+flush logs;
+flush logs;
+flush logs;
+select count(*) as zero from t1;
+
+source include/stop_slave.inc;
+
+connection master;
+set @@global.binlog_checksum = CRC32;
+insert into t1 values (1) /* will not be applied on slave due to simulation */;
+
+# instruction to the dump thread
+
+connection slave;
+set @@global.debug='d,simulate_slave_unaware_checksum';
+start slave;
+--let $slave_io_errno= 1236
+--let $show_slave_io_error= 1
+source include/wait_for_slave_io_error.inc;
+
+select count(*) as zero from t1;
+
+###connection master;
+set @@global.debug='';
+
+connection slave;
+source include/start_slave.inc;
+
+#
+# C. checksum failure simulations
+#
+
+# C1. Failure by a client thread
+connection master;
+set @@global.master_verify_checksum = 1;
+set @@session.debug='d,simulate_checksum_test_failure';
+--error ER_ERROR_WHEN_EXECUTING_COMMAND
+show binlog events;
+set @@session.debug='';
+set @@global.master_verify_checksum = default;
+
+#connection master;
+sync_slave_with_master;
+
+connection slave;
+source include/stop_slave.inc;
+
+connection master;
+create table t2 (a int);
+let $pos_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+connection slave;
+
+# C2. Failure by IO thread
+# instruction to io thread
+set @@global.debug='d,simulate_checksum_test_failure';
+start slave io_thread;
+--let $slave_io_errno= 1595
+--let $show_slave_io_error= 1
+source include/wait_for_slave_io_error.inc;
+set @@global.debug='';
+
+# to make IO thread re-read it again w/o the failure
+start slave io_thread;
+let $slave_param= Read_Master_Log_Pos;
+let $slave_param_value= $pos_master;
+source include/wait_for_slave_param.inc;
+
+# C3. Failure by SQL thread
+# instruction to sql thread;
+set @@global.slave_sql_verify_checksum = 1;
+
+set @@global.debug='d,simulate_checksum_test_failure';
+
+start slave sql_thread;
+--let $slave_sql_errno= 1593
+--let $show_slave_sql_error= 1
+source include/wait_for_slave_sql_error.inc;
+
+# resuming SQL thread to parse out the event w/o the failure
+
+set @@global.debug='';
+source include/start_slave.inc;
+
+connection master;
+sync_slave_with_master;
+
+#connection slave;
+select count(*) as 'must be zero' from t2;
+
+#
+# D. Reset slave, Change-Master, Binlog & Relay-log rotations with
+# random value on binlog_checksum on both master and slave
+#
+connection slave;
+stop slave;
+reset slave;
+
+# randomize slave server's own checksum policy
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+flush logs;
+
+connection master;
+set @@global.binlog_checksum= CRC32;
+reset master;
+flush logs;
+create table t3 (a int, b char(5));
+
+connection slave;
+source include/start_slave.inc;
+
+connection master;
+sync_slave_with_master;
+
+#connection slave;
+select count(*) as 'must be zero' from t3;
+source include/stop_slave.inc;
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
+
+connection master;
+flush logs;
+reset master;
+insert into t3 value (1, @@global.binlog_checksum);
+
+connection slave;
+source include/start_slave.inc;
+flush logs;
+
+connection master;
+sync_slave_with_master;
+
+#connection slave;
+select count(*) as 'must be one' from t3;
+
+connection master;
+set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
+insert into t3 value (1, @@global.binlog_checksum);
+sync_slave_with_master;
+
+#connection slave;
+
+#clean-up
+
+connection master;
+drop table t1, t2, t3;
+set @@global.binlog_checksum = @master_save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+
+#
+# BUG#58564: flush_read_lock fails in mysql-trunk-bugfixing after merging with WL#2540
+#
+# Sanity check that verifies that no assertions are triggered because
+# of old FD events (generated by versions prior to server released with
+# checksums feature)
+#
+# There is no need for query log, if something wrong this should trigger
+# an assertion
+
+--disable_query_log
+
+BINLOG '
+MfmqTA8BAAAAZwAAAGsAAAABAAQANS41LjctbTMtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAx+apMEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
+';
+
+--enable_query_log
+
+#connection slave;
+sync_slave_with_master;
+set @@global.binlog_checksum = @slave_save_binlog_checksum;
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
+
+--echo End of tests
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_checksum_cache.test b/mysql-test/suite/rpl/t/rpl_checksum_cache.test
new file mode 100644
index 00000000000..5667d599aff
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_checksum_cache.test
@@ -0,0 +1,255 @@
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+
+--disable_warnings
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t2 set data=repeat.*'a', @act_size.*");
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into t1 values.* NAME_CONST.*'n',.*, @data .*");
+--enable_warnings
+
+connection master;
+set @save_binlog_cache_size = @@global.binlog_cache_size;
+set @save_binlog_checksum = @@global.binlog_checksum;
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+set @@global.binlog_cache_size = 4096;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 1;
+
+# restart slave to force the dump thread to verify events (on master side)
+connection slave;
+source include/stop_slave.inc;
+source include/start_slave.inc;
+
+connection master;
+
+#
+# Testing a critical part of checksum handling dealing with transaction cache.
+# The cache's buffer size is set to be less than the transaction's footprint
+# in binlog.
+#
+# To verify combined buffer-by-buffer read out of the file and fixing crc per event
+# there are the following parts:
+#
+# 1. the event size is much less than the cache's buffer
+# 2. the event size is bigger than the cache's buffer
+# 3. the event size if approximately the same as the cache's buffer
+# 4. all in above
+
+#
+# 1. the event size is much less than the cache's buffer
+#
+
+flush status;
+show status like "binlog_cache_use";
+show status like "binlog_cache_disk_use";
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# parameter to ensure the test slightly varies binlog content
+# between different invocations
+#
+let $deviation_size=32;
+eval create table t1 (a int PRIMARY KEY, b CHAR($deviation_size)) engine=innodb;
+
+# Now we are going to create transaction which is long enough so its
+# transaction binlog will be flushed to disk...
+
+delimiter |;
+create procedure test.p_init (n int, size int)
+begin
+ while n > 0 do
+ select round(RAND() * size) into @act_size;
+ set @data = repeat('a', @act_size);
+ insert into t1 values(n, @data );
+ set n= n-1;
+ end while;
+end|
+
+delimiter ;|
+
+let $1 = 4000; # PB2 can run it slow to time out on following sync_slave_with_master:s
+
+begin;
+--disable_warnings
+# todo: check if it is really so.
+#+Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave.
+eval call test.p_init($1, $deviation_size);
+--enable_warnings
+commit;
+
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_tables=master:test.t1, slave:test.t1;
+source include/diff_tables.inc;
+
+# undoing changes with verifying the above once again
+connection master;
+
+begin;
+delete from t1;
+commit;
+
+sync_slave_with_master;
+
+
+#
+# 2. the event size is bigger than the cache's buffer
+#
+connection master;
+
+flush status;
+let $t2_data_size= `select 3 * @@global.binlog_cache_size`;
+let $t2_aver_size= `select 2 * @@global.binlog_cache_size`;
+let $t2_max_rand= `select 1 * @@global.binlog_cache_size`;
+
+eval create table t2(a int auto_increment primary key, data VARCHAR($t2_data_size)) ENGINE=Innodb;
+let $1=100;
+--disable_query_log
+begin;
+while ($1)
+{
+ eval select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size;
+ set @data = repeat('a', @act_size);
+ insert into t2 set data = @data;
+ dec $1;
+}
+commit;
+--enable_query_log
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_tables=master:test.t2, slave:test.t2;
+source include/diff_tables.inc;
+
+# undoing changes with verifying the above once again
+connection master;
+
+begin;
+delete from t2;
+commit;
+
+sync_slave_with_master;
+
+#
+# 3. the event size if approximately the same as the cache's buffer
+#
+
+connection master;
+
+flush status;
+let $t3_data_size= `select 2 * @@global.binlog_cache_size`;
+let $t3_aver_size= `select (9 * @@global.binlog_cache_size) / 10`;
+let $t3_max_rand= `select (2 * @@global.binlog_cache_size) / 10`;
+
+eval create table t3(a int auto_increment primary key, data VARCHAR($t3_data_size)) engine=innodb;
+
+let $1= 300;
+--disable_query_log
+begin;
+while ($1)
+{
+ eval select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size;
+ insert into t3 set data= repeat('a', @act_size);
+ dec $1;
+}
+commit;
+--enable_query_log
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_tables=master:test.t3, slave:test.t3;
+source include/diff_tables.inc;
+
+# undoing changes with verifying the above once again
+connection master;
+
+begin;
+delete from t3;
+commit;
+
+sync_slave_with_master;
+
+
+#
+# 4. all in above
+#
+
+connection master;
+flush status;
+
+delimiter |;
+eval create procedure test.p1 (n int)
+begin
+ while n > 0 do
+ case (select (round(rand()*100) % 3) + 1)
+ when 1 then
+ select round(RAND() * $deviation_size) into @act_size;
+ set @data = repeat('a', @act_size);
+ insert into t1 values(n, @data);
+ when 2 then
+ begin
+ select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size;
+ insert into t2 set data=repeat('a', @act_size);
+ end;
+ when 3 then
+ begin
+ select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size;
+ insert into t3 set data= repeat('a', @act_size);
+ end;
+ end case;
+ set n= n-1;
+ end while;
+end|
+delimiter ;|
+
+let $1= 1000;
+set autocommit= 0;
+begin;
+--disable_warnings
+eval call test.p1($1);
+--enable_warnings
+commit;
+
+show status like "binlog_cache_use";
+--echo *** binlog_cache_disk_use must be non-zero ***
+show status like "binlog_cache_disk_use";
+
+sync_slave_with_master;
+
+let $diff_tables=master:test.t1, slave:test.t1;
+source include/diff_tables.inc;
+
+let $diff_tables=master:test.t2, slave:test.t2;
+source include/diff_tables.inc;
+
+let $diff_tables=master:test.t3, slave:test.t3;
+source include/diff_tables.inc;
+
+
+connection master;
+
+begin;
+delete from t1;
+delete from t2;
+delete from t3;
+commit;
+
+drop table t1, t2, t3;
+set @@global.binlog_cache_size = @save_binlog_cache_size;
+set @@global.binlog_checksum = @save_binlog_checksum;
+set @@global.master_verify_checksum = @save_master_verify_checksum;
+drop procedure test.p_init;
+drop procedure test.p1;
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
index 6099637e3e9..1380b3d97cf 100644
--- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
+++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test
@@ -82,6 +82,7 @@ INSERT INTO t1(b,c) VALUES('B',2);
# Wait while C will stop.
--connection server_3
# 1062 = ER_DUP_ENTRY
+call mtr.add_suppression("Slave SQL.*Duplicate entry .6. for key .PRIMARY.* Error_code: 1062");
--let $slave_sql_errno= 1062
--source include/wait_for_slave_sql_error.inc
--connection server_1
@@ -175,7 +176,7 @@ SELECT 'Master D',a,b FROM t1 WHERE c = 3 ORDER BY a,b;
source include/stop_slave.inc;
--connection server_3
DELETE FROM t1 WHERE a = 6;
-START SLAVE;
+--source include/start_slave.inc
--connection server_2
--sync_slave_with_master server_3
RESET MASTER;
@@ -189,7 +190,7 @@ RESET SLAVE;
--source include/rpl_change_topology.inc
#--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 $file_d LOG_FILE $pos_d LOG_POS
#--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SERVER_MYPORT_3,master_user='root',master_log_file='$file_d',master_log_pos=$pos_d
-START SLAVE;
+--source include/start_slave.inc
--connection server_3
--sync_slave_with_master server_4
--source include/rpl_sync.inc
diff --git a/mysql-test/suite/rpl/t/rpl_corruption-master.opt b/mysql-test/suite/rpl/t/rpl_corruption-master.opt
new file mode 100644
index 00000000000..2612c17aa67
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_corruption-master.opt
@@ -0,0 +1 @@
+--binlog-checksum=CRC32 --master-verify-checksum=1
diff --git a/mysql-test/suite/rpl/t/rpl_corruption-slave.opt b/mysql-test/suite/rpl/t/rpl_corruption-slave.opt
new file mode 100644
index 00000000000..b32a52403c2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_corruption-slave.opt
@@ -0,0 +1 @@
+--binlog-checksum=CRC32 --slave-sql-verify-checksum=1
diff --git a/mysql-test/suite/rpl/t/rpl_corruption.test b/mysql-test/suite/rpl/t/rpl_corruption.test
new file mode 100644
index 00000000000..a46325bf1f4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_corruption.test
@@ -0,0 +1,165 @@
+############################################################
+# Purpose: WL#5064 Testing with corrupted events.
+# The test emulates the corruption at the vary stages
+# of replication:
+# - in binlog file
+# - in network
+# - in relay log
+############################################################
+
+#
+# The tests intensively utilize @@global.debug. Note,
+# Bug#11765758 - 58754,
+# @@global.debug is read by the slave threads through dbug-interface.
+# Hence, before a client thread set @@global.debug we have to ensure that:
+# (a) the slave threads are stopped, or (b) the slave threads are in
+# sync and waiting.
+
+--source include/have_debug.inc
+--source include/master-slave.inc
+
+# Block legal errors for MTR
+call mtr.add_suppression('Found invalid event in binary log');
+call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
+call mtr.add_suppression('event read from binlog did not pass crc check');
+call mtr.add_suppression('Replication event checksum verification failed');
+call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
+call mtr.add_suppression('Slave SQL: Error initializing relay log position: I/O error reading event at position .*, Error_code: 1593');
+
+SET @old_master_verify_checksum = @@master_verify_checksum;
+
+# Creating test table/data and set corruption position for testing
+--echo # 1. Creating test table/data and set corruption position for testing
+--connection master
+--echo * insert/update/delete rows in table t1 *
+# Corruption algorithm modifies only the first event and
+# then will be reset. To avoid checking always the first event
+# from binlog (usually it is FD) we randomly execute different
+# statements and set position for corruption inside events.
+
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100));
+--disable_query_log
+let $i=`SELECT 3+CEILING(10*RAND())`;
+let $j=1;
+let $pos=0;
+while ($i) {
+ eval INSERT INTO t1 VALUES ($j, 'a', NULL);
+ if (`SELECT RAND() > 0.7`)
+ {
+ eval UPDATE t1 SET c = REPEAT('a', 20) WHERE a = $j;
+ }
+ if (`SELECT RAND() > 0.8`)
+ {
+ eval DELETE FROM t1 WHERE a = $j;
+ }
+ if (!$pos) {
+ let $pos= query_get_value(SHOW MASTER STATUS, Position, 1);
+ --sync_slave_with_master
+ --source include/stop_slave.inc
+ --disable_query_log
+ --connection master
+ }
+ dec $i;
+ inc $j;
+}
+--enable_query_log
+
+
+# Emulate corruption in binlog file when SHOW BINLOG EVENTS is executing
+--echo # 2. Corruption in master binlog and SHOW BINLOG EVENTS
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+--echo SHOW BINLOG EVENTS;
+--disable_query_log
+send_eval SHOW BINLOG EVENTS FROM $pos;
+--enable_query_log
+--error ER_ERROR_WHEN_EXECUTING_COMMAND
+reap;
+
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+
+# Emulate corruption on master with crc checking on master
+--echo # 3. Master read a corrupted event from binlog and send the error to slave
+
+# We have a rare but nasty potential race here: if the dump thread on
+# the master for the _old_ slave connection has not yet discovered
+# that the slave has disconnected, we will inject the corrupt event on
+# the wrong connection, and the test will fail
+# (+d,corrupt_read_log_event2 corrupts only one event).
+# So kill any lingering dump thread (we need to kill; otherwise dump thread
+# could manage to send all events down the socket before seeing it close, and
+# hang forever waiting for new binlog events to be created).
+let $id= `select id from information_schema.processlist where command = "Binlog Dump"`;
+if ($id)
+{
+ --disable_query_log
+ --error 0,1094
+ eval kill $id;
+ --enable_query_log
+}
+let $wait_condition=
+ SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE command = 'Binlog Dump';
+--source include/wait_condition.inc
+
+SET GLOBAL debug="+d,corrupt_read_log_event2";
+--connection slave
+START SLAVE IO_THREAD;
+let $slave_io_errno= 1236;
+--source include/wait_for_slave_io_error.inc
+--connection master
+SET GLOBAL debug="-d,corrupt_read_log_event2";
+
+# Emulate corruption on master without crc checking on master
+--echo # 4. Master read a corrupted event from binlog and send it to slave
+--connection master
+SET GLOBAL master_verify_checksum=0;
+SET GLOBAL debug="+d,corrupt_read_log_event2";
+--connection slave
+START SLAVE IO_THREAD;
+let $slave_io_errno= 1595,1722;
+--source include/wait_for_slave_io_error.inc
+--connection master
+SET GLOBAL debug="-d,corrupt_read_log_event2";
+SET GLOBAL debug= "";
+SET GLOBAL master_verify_checksum=1;
+
+# Emulate corruption in network
+--echo # 5. Slave. Corruption in network
+--connection slave
+SET GLOBAL debug="+d,corrupt_queue_event";
+START SLAVE IO_THREAD;
+let $slave_io_errno= 1595,1722;
+--source include/wait_for_slave_io_error.inc
+SET GLOBAL debug="-d,corrupt_queue_event";
+
+# Emulate corruption in relay log
+--echo # 6. Slave. Corruption in relay log
+
+SET GLOBAL debug="+d,corrupt_read_log_event_char";
+
+START SLAVE SQL_THREAD;
+let $slave_sql_errno= 1593;
+--source include/wait_for_slave_sql_error.inc
+
+SET GLOBAL debug="-d,corrupt_read_log_event_char";
+SET GLOBAL debug= "";
+
+# Start normal replication and compare same table on master
+# and slave
+--echo # 7. Seek diff for tables on master and slave
+--connection slave
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+let $diff_tables= master:test.t1, slave:test.t1;
+--source include/diff_tables.inc
+
+# Clean up
+--echo # 8. Clean up
+--connection master
+SET GLOBAL debug= "";
+SET GLOBAL master_verify_checksum = @old_master_verify_checksum;
+DROP TABLE t1;
+--sync_slave_with_master
+SET GLOBAL debug= "";
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test b/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test
index 8e1c9eb98b2..13c66f9f64b 100644
--- a/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test
+++ b/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test
@@ -122,6 +122,8 @@ UPDATE t7 LEFT JOIN (t8, t4, t1) ON (t7.id=t8.id and t7.id=t4.id and t7.id=t1.id
# if any of the above statement are not ignored, it would cause error
# and stop slave sql thread.
sync_slave_with_master;
+connection slave;
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t[47]. doesn.t exist. on query.* Error_code: 1146");
connection master;
# Parameters for include/wait_for_slave_sql_error_and_skip.inc:
diff --git a/mysql-test/suite/rpl/t/rpl_hrtime.test b/mysql-test/suite/rpl/t/rpl_hrtime.test
new file mode 100644
index 00000000000..98b08abec67
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_hrtime.test
@@ -0,0 +1,7 @@
+--source include/have_binlog_format_mixed_or_statement.inc
+
+--source suite/rpl/include/hrtime.inc
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001
+
diff --git a/mysql-test/suite/rpl/t/rpl_hrtime_row.test b/mysql-test/suite/rpl/t/rpl_hrtime_row.test
new file mode 100644
index 00000000000..e1d49f5324b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_hrtime_row.test
@@ -0,0 +1,3 @@
+--source include/have_binlog_format_row.inc
+--source suite/rpl/include/hrtime.inc
+
diff --git a/mysql-test/suite/rpl/t/rpl_idempotency.test b/mysql-test/suite/rpl/t/rpl_idempotency.test
index ffdc21a5756..aa63ac47d81 100644
--- a/mysql-test/suite/rpl/t/rpl_idempotency.test
+++ b/mysql-test/suite/rpl/t/rpl_idempotency.test
@@ -8,10 +8,11 @@ connection slave;
source include/have_innodb.inc;
# Add suppression for expected warning(s) in slaves error log
-call mtr.add_suppression("Slave: Can't find record in 't.' Error_code: 1032");
-call mtr.add_suppression("Can't find record in 't.'");
+
+call mtr.add_suppression("Can.t find record in .t[12].* Error_code: 1032");
call mtr.add_suppression("Slave: Cannot delete or update a parent row: a foreign key constraint fails .* Error_code: 1451");
call mtr.add_suppression("Slave: Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452");
+call mtr.add_suppression("Slave SQL.*Could not execute Write_rows event on table test.* Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
SET @old_slave_exec_mode= @@global.slave_exec_mode;
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_table.test b/mysql-test/suite/rpl/t/rpl_ignore_table.test
index 64a3338b16e..bcd840af177 100644
--- a/mysql-test/suite/rpl/t/rpl_ignore_table.test
+++ b/mysql-test/suite/rpl/t/rpl_ignore_table.test
@@ -131,6 +131,7 @@ show grants for mysqltest4@localhost;
# where mysqltest1 does not exist on slave,
# to succeed on slave the mode is temporarily changed
set global slave_exec_mode='IDEMPOTENT';
+call mtr.add_suppression("Slave SQL.*Could not execute Delete_rows event on table mysql.* Error_code: 1032");
connection master;
drop table t1, mysqltest2.t2;
diff --git a/mysql-test/suite/rpl/t/rpl_incident.test b/mysql-test/suite/rpl/t/rpl_incident.test
index b65441c7d50..d6034009f4f 100644
--- a/mysql-test/suite/rpl/t/rpl_incident.test
+++ b/mysql-test/suite/rpl/t/rpl_incident.test
@@ -15,6 +15,7 @@ SELECT * FROM t1;
connection slave;
# Wait until SQL thread stops with error LOST_EVENT on master
+call mtr.add_suppression("Slave SQL.*The incident LOST_EVENTS occured on the master.* 1590");
let $slave_sql_errno= 1590;
let $show_slave_sql_error= 1;
source include/wait_for_slave_sql_error.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_init_slave_errors.test b/mysql-test/suite/rpl/t/rpl_init_slave_errors.test
index cf72de18e13..4dab13856d4 100644
--- a/mysql-test/suite/rpl/t/rpl_init_slave_errors.test
+++ b/mysql-test/suite/rpl/t/rpl_init_slave_errors.test
@@ -58,7 +58,7 @@ start slave;
--let $show_slave_sql_error= 1
--source include/wait_for_slave_sql_error.inc
-call mtr.add_suppression("Failed during slave I/O thread initialization");
+call mtr.add_suppression("Failed during slave.* thread initialization");
SET GLOBAL debug= "";
diff --git a/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test b/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test
index 782c01ec04f..afc0c2cbd4b 100644
--- a/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test
+++ b/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test
@@ -127,11 +127,17 @@ delimiter ;|
############ Test Section ###################
+begin;
CALL test.proc_norm();
+commit;
SELECT count(*) as "Master regular" FROM test.regular_tbl;
+begin;
CALL test.proc_bykey();
+commit;
SELECT count(*) as "Master bykey" FROM test.bykey_tbl;
+begin;
CALL test.proc_byrange();
+commit;
SELECT count(*) as "Master byrange" FROM test.byrange_tbl;
--sync_slave_with_master
diff --git a/mysql-test/suite/rpl/t/rpl_insert_duplicate.test b/mysql-test/suite/rpl/t/rpl_insert_duplicate.test
new file mode 100644
index 00000000000..7dd38a696ae
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_duplicate.test
@@ -0,0 +1,14 @@
+#########################################
+# Wrapper for rpl_insert_duplicate.test #
+#########################################
+-- source include/master-slave.inc
+-- source include/have_innodb.inc
+#-- source include/have_binlog_format_mixed_or_statement.inc
+
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_insert_duplicate.test
+
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_insert_duplicate.test
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_insert_ignore.test b/mysql-test/suite/rpl/t/rpl_insert_ignore.test
index 1d6c8e7168e..4129d4d553e 100644
--- a/mysql-test/suite/rpl/t/rpl_insert_ignore.test
+++ b/mysql-test/suite/rpl/t/rpl_insert_ignore.test
@@ -4,7 +4,11 @@
-- source include/not_ndb_default.inc
-- source include/have_innodb.inc
-- source include/master-slave.inc
-let $engine_type=innodb;
-let $engine_type2=myisam;
+
+-- let $engine_type=innodb
-- source extra/rpl_tests/rpl_insert_ignore.test
+
+-- let $engine_type=myisam
+-- source extra/rpl_tests/rpl_insert_ignore.test
+
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
index a8c7c2c1f5b..db603c3f5ba 100644
--- a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
+++ b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
@@ -4,11 +4,14 @@
# imitate the bug, so it has to stop).
source include/have_debug.inc;
+# because of pretend_version_50034_in_binlog the test can't run with checksum
+source include/have_binlog_checksum_off.inc;
source include/master-slave.inc;
# Currently only statement-based-specific bugs are here
-- source include/have_binlog_format_mixed_or_statement.inc
+
#
# This is to test that slave properly detects if
# master may suffer from:
@@ -30,6 +33,7 @@ connection slave;
#1105 = ER_UNKNOWN_ERROR
--let $slave_sql_errno= 1105
--let $show_slave_sql_error= 1
+call mtr.add_suppression("Slave SQL.*suffer.*http:..bugs.mysql.com.bug.php.id=24432");
--source include/wait_for_slave_sql_error.inc
# show that it was not replicated
SELECT * FROM t1;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test b/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test
index ecbaddb6995..be099c1b6c4 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_fatal.test
@@ -15,6 +15,7 @@ connection master;
LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE t1;
connection slave;
+call mtr.add_suppression("Slave SQL.*Fatal error: Not enough memory, Error_code: 1593");
let $slave_sql_errno= 1593;
let $show_slave_sql_error= 1;
source include/wait_for_slave_sql_error_and_skip.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt b/mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt
index 831680eb5ef..5fdeb855110 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt
@@ -1 +1 @@
---read_buffer_size=12K --max_allowed_packet=8K
+--read_buffer_size=12K --max_allowed_packet=8K --net-buffer-length=8K
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt b/mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt
index 95f55bcf7d8..7d404fae240 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt
@@ -1 +1 @@
---max_allowed_packet=8K
+--max_allowed_packet=8K --net-buffer-length=8K
diff --git a/mysql-test/suite/rpl/t/rpl_packet.test b/mysql-test/suite/rpl/t/rpl_packet.test
index b11bd0a227e..3197b6160cd 100644
--- a/mysql-test/suite/rpl/t/rpl_packet.test
+++ b/mysql-test/suite/rpl/t/rpl_packet.test
@@ -26,8 +26,8 @@ let $old_net_buffer_length= `SELECT @@global.net_buffer_length`;
SET @@global.max_allowed_packet=1024;
SET @@global.net_buffer_length=1024;
+sync_slave_with_master;
# Restart slave for setting to take effect
-connection slave;
source include/stop_slave.inc;
source include/start_slave.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
index 68a3a20b501..6002666a70a 100644
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
@@ -93,6 +93,7 @@ set insert_id=1234;
insert into t2 values(NULL);
connection slave;
# 1062 = ER_DUP_ENTRY
+call mtr.add_suppression("Slave SQL.*Error .Duplicate entry .1234. for key .PRIMARY.. on query.* Error_code: 1062");
--let $slave_sql_errno= 1062
--source include/wait_for_slave_sql_error_and_skip.inc
@@ -142,7 +143,10 @@ select * from t2;
connection master;
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");
-let $1=100;
+
+# the nummber of produced logs is sensitive to whether checksum is NONE or CRC32
+# the value of 90 makes it even
+let $1=90;
create table t3 (n int);
disable_query_log;
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test
index b7fc0d3bd2a..8003595e578 100644
--- a/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test
@@ -1,3 +1,4 @@
+-- source include/have_query_cache.inc
--source include/have_binlog_format_row.inc
let $SERVER_VERSION=`select version()`;
@@ -66,6 +67,7 @@ DROP TABLE t1;
--echo **** On Slave ****
connection slave;
SET GLOBAL QUERY_CACHE_SIZE=0;
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.t1.* Error_code: 1032");
--echo **** On Master ****
connection master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_colSize.test b/mysql-test/suite/rpl/t/rpl_row_colSize.test
index 04434517518..be7d72e858e 100644
--- a/mysql-test/suite/rpl/t/rpl_row_colSize.test
+++ b/mysql-test/suite/rpl/t/rpl_row_colSize.test
@@ -160,6 +160,9 @@ let $test_table_slave = CREATE TABLE t1 (a TINYBLOB);
let $test_insert = INSERT INTO t1 VALUES ('This is a test.');
source include/test_fieldsize.inc;
+connection slave;
+call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 0 ...e mismatch.* Error_code: 1535");
+
--echo *** Cleanup ***
connection master;
DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test
index b695428dd38..4c8e56d626f 100644
--- a/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test
+++ b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test
@@ -30,6 +30,7 @@ INSERT INTO t1 VALUES (1);
connection slave;
# slave should have stopped because can't find table t1
# 1146 = ER_NO_SUCH_TABLE
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t1. doesn.t exist. on opening tables, Error_code: 1146");
--let $slave_sql_errno= 1146
--source include/wait_for_slave_sql_error.inc
diff --git a/mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test b/mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test
index e40cd615ca6..f96603f69ed 100644
--- a/mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test
+++ b/mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test
@@ -1,12 +1,11 @@
-- source include/have_binlog_format_row.inc
-- source include/master-slave.inc
+-- let $engine= MyISAM
#
# BUG#52868 Wrong handling of NULL value during update, replication out of sync
#
--- let $engine= MyISAM
--- source extra/rpl_tests/rpl_record_compare.test
-- echo ## coverage purposes - Field_bits
-- echo ## 1 X bit + 2 Null bits + 5 bits => last_null_bit_pos==0
@@ -28,4 +27,7 @@ UPDATE t1 SET c1= 0;
-- connection master
DROP TABLE t1;
-- sync_slave_with_master
+
+-- source extra/rpl_tests/rpl_record_compare.test
+
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test
index 2853c95b212..82d6e61a2cd 100644
--- a/mysql-test/suite/rpl/t/rpl_skip_error.test
+++ b/mysql-test/suite/rpl/t/rpl_skip_error.test
@@ -102,6 +102,8 @@ SET SQL_LOG_BIN=1;
connection slave;
+call mtr.add_suppression("Slave SQL.*Could not execute .*te_rows event on table test.t.; Duplicate entry.* Error_code: 1062");
+
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
SHOW CREATE TABLE t1;
diff --git a/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test b/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
index 70ebba0047b..8525718283e 100644
--- a/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
+++ b/mysql-test/suite/rpl/t/rpl_slave_grp_exec.test
@@ -63,6 +63,7 @@ SELECT * FROM t3 ORDER BY a;
--connection slave
# 1146 = ER_NO_SUCH_TABLE
+call mtr.add_suppression("Slave SQL.*Error .Table .test.t3. doesn.t exist. on.* Error_code: 1146");
--let $slave_sql_errno= 1146
--source include/wait_for_slave_sql_error.inc
SHOW TABLES LIKE 't%';
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
index d80a2ed9e25..c718f072e11 100644
--- a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
@@ -49,5 +49,6 @@ RESET SLAVE;
drop table t1;
call mtr.add_suppression("Slave: Error writing file 'UNKNOWN' .Errcode: 9. Error_code: 3");
+call mtr.add_suppression("Slave SQL.*Error in Begin_load_query event: write to.* failed, Error_code: 9");
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
index 0481581998c..b99c71b1ca0 100644
--- a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
@@ -11,6 +11,7 @@
--connection slave
START SLAVE;
# Why 12???
+call mtr.add_suppression("Slave SQL.*Unable to use slave.s temporary directory.* Error_code: 12");
--let $slave_sql_errno= 12
source include/wait_for_slave_sql_error.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
index 15f98916485..fff457b2e55 100644
--- a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
@@ -12,7 +12,7 @@ create table t1(n int);
sync_slave_with_master;
stop slave;
connection master;
-let $1=5000;
+let $1=2500;
disable_query_log;
while ($1)
{
diff --git a/mysql-test/suite/rpl/t/rpl_stop_slave.test b/mysql-test/suite/rpl/t/rpl_stop_slave.test
index e7c67448dbe..1502c694ea0 100644
--- a/mysql-test/suite/rpl/t/rpl_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_stop_slave.test
@@ -54,7 +54,72 @@ source extra/rpl_tests/rpl_stop_slave.test;
--echo # Test end
SET GLOBAL debug= '$debug_save';
+source include/restart_slave_sql.inc;
-connection master;
+--source include/rpl_connection_master.inc
DROP TABLE t1, t2;
+
+--echo
+--echo # Bug#58546 test rpl_packet timeout failure sporadically on PB
+--echo # ----------------------------------------------------------------------
+--echo # STOP SLAVE stopped IO thread first and then stopped SQL thread. It was
+--echo # possible that IO thread stopped after replicating part of a transaction
+--echo # which SQL thread was executing. SQL thread would be hung if the
+--echo # transaction could not be rolled back safely.
+--echo # It caused some sporadic failures on PB2.
+--echo #
+--echo # This test verifies that when 'STOP SLAVE' is issued by a user, IO
+--echo # thread will continue to fetch the rest events of the transaction which
+--echo # is being executed by SQL thread and is not able to be rolled back safely.
+
+CREATE TABLE t1 (c1 INT KEY, c2 INT) ENGINE=InnoDB;
+CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES(1, 1);
+
+sync_slave_with_master;
+
+--source include/rpl_connection_master.inc
+
+let $debug_save= `SELECT @@GLOBAL.debug`;
+SET GLOBAL debug= 'd,dump_thread_wait_before_send_xid';
+
+--source include/rpl_connection_slave.inc
+source include/restart_slave_sql.inc;
+
+BEGIN;
+UPDATE t1 SET c2 = 2 WHERE c1 = 1;
+
+--source include/rpl_connection_master.inc
+BEGIN;
+INSERT INTO t1 VALUES(2, 2);
+INSERT INTO t2 VALUES(1);
+UPDATE t1 SET c2 = 3 WHERE c1 = 1;
+COMMIT;
+
+--source include/rpl_connection_slave1.inc
+let $show_statement= SHOW PROCESSLIST;
+let $field= Info;
+let $condition= = 'UPDATE t1 SET c2 = 3 WHERE c1 = 1';
+source include/wait_show_condition.inc;
+
+send STOP SLAVE;
+
+--source include/rpl_connection_slave.inc
+ROLLBACK;
+
+--source include/rpl_connection_master.inc
+SET DEBUG_SYNC= 'now SIGNAL signal.continue';
+SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
+SET DEBUG_SYNC= 'RESET';
+
+--source include/rpl_connection_slave.inc
+source include/wait_for_slave_to_stop.inc;
+
+--source include/rpl_connection_slave1.inc
+reap;
+source include/start_slave.inc;
+
+--source include/rpl_connection_master.inc
+DROP TABLE t1, t2;
+SET GLOBAL debug= $debug_save;
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_temporary_errors.test b/mysql-test/suite/rpl/t/rpl_temporary_errors.test
index e441dd8cb85..4990b351c8d 100644
--- a/mysql-test/suite/rpl/t/rpl_temporary_errors.test
+++ b/mysql-test/suite/rpl/t/rpl_temporary_errors.test
@@ -29,6 +29,9 @@ SHOW STATUS LIKE 'Slave_retried_transactions';
SELECT * FROM t1;
source include/check_slave_is_running.inc;
+connection slave;
+call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.t1");
+
--echo **** On Master ****
connection master;
DROP TABLE t1;
diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test
index 65093319fbe..a245b054ebd 100644
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test
@@ -37,8 +37,10 @@ stop slave;
# get the master binlog pos from the epoch, from the _other_ "master", server2
connection server2;
--replace_result $the_epoch <the_epoch>
+--disable_result_log
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
FROM mysql.ndb_binlog_index WHERE epoch = $the_epoch ;
+--enable_result_log
let $the_pos= `SELECT @the_pos` ;
let $the_file= `SELECT @the_file` ;
diff --git a/mysql-test/suite/sys_vars/r/binlog_checksum_basic.result b/mysql-test/suite/sys_vars/r/binlog_checksum_basic.result
new file mode 100644
index 00000000000..2821a4a7e63
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/binlog_checksum_basic.result
@@ -0,0 +1,14 @@
+set @save_binlog_checksum= @@global.binlog_checksum;
+set @@global.binlog_checksum = default;
+select @@global.binlog_checksum as 'must be NONE by default';
+must be NONE by default
+NONE
+select @@session.binlog_checksum as 'no session var';
+ERROR HY000: Variable 'binlog_checksum' is a GLOBAL variable
+set @@global.binlog_checksum = CRC32;
+set @@global.binlog_checksum = CRC32;
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+set @@global.binlog_checksum = ADLER32;
+ERROR 42000: Variable 'checksum' can't be set to the value of 'ADLER32'
+set @@global.binlog_checksum = @save_binlog_checksum;
diff --git a/mysql-test/suite/sys_vars/r/general_log_file_basic.result b/mysql-test/suite/sys_vars/r/general_log_file_basic.result
index 5c0b93cf4ab..31fdd07d06e 100644
--- a/mysql-test/suite/sys_vars/r/general_log_file_basic.result
+++ b/mysql-test/suite/sys_vars/r/general_log_file_basic.result
@@ -16,4 +16,4 @@ FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='general_log_file';
@@global.general_log_file = VARIABLE_VALUE
1
-SET @@global.general_log_file= 'test.log';
+SET @@global.general_log_file= 'start_value';
diff --git a/mysql-test/suite/sys_vars/r/innodb_max_dirty_pages_pct_func.result b/mysql-test/suite/sys_vars/r/innodb_max_dirty_pages_pct_func.result
index baf06092126..55de5adbc33 100644
--- a/mysql-test/suite/sys_vars/r/innodb_max_dirty_pages_pct_func.result
+++ b/mysql-test/suite/sys_vars/r/innodb_max_dirty_pages_pct_func.result
@@ -64,12 +64,12 @@ SET last = pct;
END IF;
END WHILE;
END//
-CREATE PROCEDURE check_pct(IN num DECIMAL)
+CREATE PROCEDURE check_pct(IN success_on_wait BOOLEAN)
BEGIN
-IF (dirty_pct() < num) THEN
+IF (success_on_wait > 0) THEN
SELECT 'BELOW_MAX' AS PCT_VALUE;
ELSE
-SELECT 'ABOVE_MAX' AS PCT_VALUE;
+SELECT 'ABOVE_MAX or TimeOut Of The Test' AS PCT_VALUE;
END IF;
END//
CREATE TABLE t1(
@@ -83,7 +83,7 @@ CALL add_until(10);
FLUSH TABLES;
CALL add_records(500);
'We expect dirty pages pct to be BELOW_MAX after some time depending on performance'
-CALL check_pct(10);
+CALL check_pct(1);
PCT_VALUE
BELOW_MAX
DROP PROCEDURE add_records;
diff --git a/mysql-test/suite/sys_vars/r/log_output_func.result b/mysql-test/suite/sys_vars/r/log_output_func.result
index 00a8e824f78..24703f4317b 100644
--- a/mysql-test/suite/sys_vars/r/log_output_func.result
+++ b/mysql-test/suite/sys_vars/r/log_output_func.result
@@ -52,7 +52,7 @@ count(*)
DROP TABLE t1;
connection default;
SET @@global.general_log= 'OFF';
-SET @@global.general_log_file= '/home/horst/bzr/5.1-52501/mysql-test/var/mysqld.1/mysqld.log';
+SET @@global.general_log_file= 'start_general_log_file';
SET @@global.log_output= @start_value;
SET @@global.general_log= @start_general_log;
SET @@global.general_log= 'ON';
diff --git a/mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result b/mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result
new file mode 100644
index 00000000000..83a1283c358
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result
@@ -0,0 +1,11 @@
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+select @@global.master_verify_checksum as 'must be zero because of default';
+must be zero because of default
+0
+select @@session.master_verify_checksum as 'no session var';
+ERROR HY000: Variable 'master_verify_checksum' is a GLOBAL variable
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+set @@global.master_verify_checksum = 2;
+ERROR 42000: Variable 'master_verify_checksum' can't be set to the value of '2'
+set @@global.master_verify_checksum = @save_master_verify_checksum;
diff --git a/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result b/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result
new file mode 100644
index 00000000000..cd80381239a
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result
@@ -0,0 +1,11 @@
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+select @@global.slave_sql_verify_checksum as 'must be one because of default';
+must be one because of default
+1
+select @@session.slave_sql_verify_checksum as 'no session var';
+ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+set @@global.slave_sql_verify_checksum = 2;
+ERROR 42000: Variable 'slave_sql_verify_checksum' can't be set to the value of '2'
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result b/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result
index 3cd62187d0b..ce4fd8094bf 100644
--- a/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result
+++ b/mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result
@@ -14,4 +14,4 @@ FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='slow_query_log_file';
@@global.slow_query_log_file = VARIABLE_VALUE
1
-SET @@global.slow_query_log_file= 'slowtest.log';
+SET @@global.slow_query_log_file= 'start_value';
diff --git a/mysql-test/suite/sys_vars/t/binlog_checksum_basic.test b/mysql-test/suite/sys_vars/t/binlog_checksum_basic.test
new file mode 100644
index 00000000000..fb3d8e33fa1
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/binlog_checksum_basic.test
@@ -0,0 +1,25 @@
+--source include/not_embedded.inc
+
+# suite/rpl/t/rpl_checksum.test contains similar testing of
+# all checksum related system variables.
+
+set @save_binlog_checksum= @@global.binlog_checksum;
+set @@global.binlog_checksum = default;
+
+select @@global.binlog_checksum as 'must be NONE by default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.binlog_checksum as 'no session var';
+
+
+# testing lack of side-effects in non-effective update of binlog_checksum:
+set @@global.binlog_checksum = CRC32;
+set @@global.binlog_checksum = CRC32;
+
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.binlog_checksum = ADLER32;
+
+# cleanup
+set @@global.binlog_checksum = @save_binlog_checksum;
diff --git a/mysql-test/suite/sys_vars/t/div_precision_increment_func.test b/mysql-test/suite/sys_vars/t/div_precision_increment_func.test
index aebca88abf9..ba7bc65eb48 100644
--- a/mysql-test/suite/sys_vars/t/div_precision_increment_func.test
+++ b/mysql-test/suite/sys_vars/t/div_precision_increment_func.test
@@ -19,7 +19,7 @@
# #
################################################################################
-let $save_div_precision_increment = `SELECT @@global.div_precision_increment`
+let $save_div_precision_increment = `SELECT @@global.div_precision_increment`;
#SET @save_div_precision_increment = @@global.div_precision_increment;
diff --git a/mysql-test/suite/sys_vars/t/general_log_file_basic.test b/mysql-test/suite/sys_vars/t/general_log_file_basic.test
index 35905bad987..f02c59736e3 100644
--- a/mysql-test/suite/sys_vars/t/general_log_file_basic.test
+++ b/mysql-test/suite/sys_vars/t/general_log_file_basic.test
@@ -70,6 +70,7 @@ FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='general_log_file';
#SET @@global.general_log_file= @start_value;
+--replace_result $start_value start_value
eval SET @@global.general_log_file= '$start_value';
#####################################################
diff --git a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test
index b577ae5fcc4..c7a9e567e69 100644
--- a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test
+++ b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test
@@ -117,12 +117,12 @@ BEGIN
END WHILE;
END//
-CREATE PROCEDURE check_pct(IN num DECIMAL)
+CREATE PROCEDURE check_pct(IN success_on_wait BOOLEAN)
BEGIN
- IF (dirty_pct() < num) THEN
+ IF (success_on_wait > 0) THEN
SELECT 'BELOW_MAX' AS PCT_VALUE;
ELSE
- SELECT 'ABOVE_MAX' AS PCT_VALUE;
+ SELECT 'ABOVE_MAX or TimeOut Of The Test' AS PCT_VALUE;
END IF;
END//
@@ -155,7 +155,8 @@ let $wait_condition= SELECT (dirty_pct() <= @@global.innodb_max_dirty_pages_pct)
--source include/wait_condition.inc
--echo 'We expect dirty pages pct to be BELOW_MAX after some time depending on performance'
-CALL check_pct(10);
+# Value For $sucess will be set from include/wait_condition.inc file. It can have values 1 or 0. It will be 1 if dirty_pct() <= @@global.innodb_max_dirty_pages_pct else it will be 0.
+eval CALL check_pct($success);
DROP PROCEDURE add_records;
DROP PROCEDURE add_until;
DROP PROCEDURE check_pct;
diff --git a/mysql-test/suite/sys_vars/t/log_output_func.test b/mysql-test/suite/sys_vars/t/log_output_func.test
index 8a2fbe0728b..6b7c01a7dab 100644
--- a/mysql-test/suite/sys_vars/t/log_output_func.test
+++ b/mysql-test/suite/sys_vars/t/log_output_func.test
@@ -115,6 +115,7 @@ file_exists $MYSQLTEST_VARDIR/run/mytest.log ;
connection default;
SET @@global.general_log= 'OFF';
#SET @@global.general_log_file= @start_general_log_file;
+--replace_result $start_general_log_file start_general_log_file
eval SET @@global.general_log_file= '$start_general_log_file';
SET @@global.log_output= @start_value;
SET @@global.general_log= @start_general_log;
diff --git a/mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test b/mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test
new file mode 100644
index 00000000000..b70040ff2a2
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test
@@ -0,0 +1,19 @@
+--source include/not_embedded.inc
+
+# suite/rpl/t/rpl_checksum.test contains similar testing of
+# all checksum related system variables.
+
+set @save_master_verify_checksum = @@global.master_verify_checksum;
+
+select @@global.master_verify_checksum as 'must be zero because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.master_verify_checksum as 'no session var';
+
+set @@global.master_verify_checksum = 0;
+set @@global.master_verify_checksum = default;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.master_verify_checksum = 2; # the var is of bool type
+
+# cleanup
+set @@global.master_verify_checksum = @save_master_verify_checksum;
diff --git a/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test b/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test
new file mode 100644
index 00000000000..3eb4f4b4e6d
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test
@@ -0,0 +1,18 @@
+--source include/not_embedded.inc
+
+# suite/rpl/t/rpl_checksum.test contains similar testing of
+# all checksum related system variables.
+
+set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
+
+select @@global.slave_sql_verify_checksum as 'must be one because of default';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.slave_sql_verify_checksum as 'no session var';
+
+set @@global.slave_sql_verify_checksum = 0;
+set @@global.slave_sql_verify_checksum = default;
+--error ER_WRONG_VALUE_FOR_VAR
+set @@global.slave_sql_verify_checksum = 2; # the var is of bool type
+
+# cleanup
+set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test b/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test
index 810588b8f4e..4eb747d888b 100644
--- a/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test
+++ b/mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test
@@ -68,6 +68,7 @@ FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='slow_query_log_file';
#SET @@global.slow_query_log_file= @start_value;
+--replace_result $start_value start_value
eval SET @@global.slow_query_log_file= '$start_value';
#SELECT @start_value;
#####################################################
diff --git a/mysql-test/suite/vcol/inc/vcol_keys.inc b/mysql-test/suite/vcol/inc/vcol_keys.inc
index 68a40afea92..20f67a00bc3 100644
--- a/mysql-test/suite/vcol/inc/vcol_keys.inc
+++ b/mysql-test/suite/vcol/inc/vcol_keys.inc
@@ -95,10 +95,10 @@ drop table t1;
if (!$skip_spatial_index_check)
{
--echo # Error "All parts of a SPATIAL index must be NOT NULL"
- --error ER_SPATIAL_CANT_HAVE_NULL
+ --error ER_SPATIAL_MUST_HAVE_GEOM_COL
create table t1 (a int, b int as (a+1) persistent, spatial index (b));
create table t1 (a int, b int as (a+1) persistent);
- --error ER_SPATIAL_CANT_HAVE_NULL
+ --error ER_SPATIAL_MUST_HAVE_GEOM_COL
alter table t1 add spatial index (b);
drop table t1;
}
diff --git a/mysql-test/suite/vcol/inc/vcol_view.inc b/mysql-test/suite/vcol/inc/vcol_view.inc
index 2bf413e2471..64149a7bb31 100644
--- a/mysql-test/suite/vcol/inc/vcol_view.inc
+++ b/mysql-test/suite/vcol/inc/vcol_view.inc
@@ -69,10 +69,14 @@ create table t1 (a int not null,
insert into t1 (a) values (1), (2), (3), (4);
create view v1 as select b+1 from t1 order by 1 desc limit 2;
select * from v1;
+--echo MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
+--echo MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
select * from v1;
+--echo MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
+--echo MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
drop view v1;
drop table t1;
diff --git a/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result b/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result
index b1f96f8f4d9..db16d25000a 100644
--- a/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result
@@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES NULL VIRTUAL
+b int(11) YES NULL PERSISTENT
insert into t1 (a) values (1);
select * from t1;
a b
diff --git a/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result b/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result
index 9fde339cb06..1b4a5060e40 100644
--- a/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result
@@ -114,7 +114,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES NULL VIRTUAL
+b int(11) YES NULL PERSISTENT
insert into t1 (a) values (1);
select * from t1;
a b
diff --git a/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result b/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result
index a2ebc7a8cd8..44fcae7a6e5 100644
--- a/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result
@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3);
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't1' ignored
-Warning 1647 The value specified for computed column 'c' in table 't1' ignored
+Warning 1906 The value specified for computed column 'b' in table 't1' ignored
+Warning 1906 The value specified for computed column 'c' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
@@ -65,8 +65,8 @@ a b c
# against vcols
insert into t1 (a,b) values (1,3), (2,4);
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't1' ignored
-Warning 1647 The value specified for computed column 'b' in table 't1' ignored
+Warning 1906 The value specified for computed column 'b' in table 't1' ignored
+Warning 1906 The value specified for computed column 'b' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
@@ -107,8 +107,8 @@ a b c
create table t2 like t1;
insert into t2 select * from t1;
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't2' ignored
-Warning 1647 The value specified for computed column 'c' in table 't2' ignored
+Warning 1906 The value specified for computed column 'b' in table 't2' ignored
+Warning 1906 The value specified for computed column 'c' in table 't2' ignored
select * from t1;
a b c
2 -2 -2
@@ -123,8 +123,8 @@ a b c
create table t2 like t1;
insert into t2 (a,b) select a,b from t1;
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't2' ignored
-Warning 1647 The value specified for computed column 'b' in table 't2' ignored
+Warning 1906 The value specified for computed column 'b' in table 't2' ignored
+Warning 1906 The value specified for computed column 'b' in table 't2' ignored
select * from t2;
a b c
2 -2 -2
@@ -159,7 +159,7 @@ a b c
2 -2 -2
update t1 set c=3 where a=2;
Warnings:
-Warning 1647 The value specified for computed column 'c' in table 't1' ignored
+Warning 1906 The value specified for computed column 'c' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
@@ -189,7 +189,7 @@ a b c
2 -2 -2
update t1 set c=3 where b=-2;
Warnings:
-Warning 1647 The value specified for computed column 'c' in table 't1' ignored
+Warning 1906 The value specified for computed column 'c' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
diff --git a/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result b/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result
index 161a82171ce..66745862c22 100644
--- a/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result
@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3);
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't1' ignored
-Warning 1647 The value specified for computed column 'c' in table 't1' ignored
+Warning 1906 The value specified for computed column 'b' in table 't1' ignored
+Warning 1906 The value specified for computed column 'c' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
@@ -65,8 +65,8 @@ a b c
# against vcols
insert into t1 (a,b) values (1,3), (2,4);
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't1' ignored
-Warning 1647 The value specified for computed column 'b' in table 't1' ignored
+Warning 1906 The value specified for computed column 'b' in table 't1' ignored
+Warning 1906 The value specified for computed column 'b' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
@@ -107,8 +107,8 @@ a b c
create table t2 like t1;
insert into t2 select * from t1;
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't2' ignored
-Warning 1647 The value specified for computed column 'c' in table 't2' ignored
+Warning 1906 The value specified for computed column 'b' in table 't2' ignored
+Warning 1906 The value specified for computed column 'c' in table 't2' ignored
select * from t1;
a b c
2 -2 -2
@@ -123,8 +123,8 @@ a b c
create table t2 like t1;
insert into t2 (a,b) select a,b from t1;
Warnings:
-Warning 1647 The value specified for computed column 'b' in table 't2' ignored
-Warning 1647 The value specified for computed column 'b' in table 't2' ignored
+Warning 1906 The value specified for computed column 'b' in table 't2' ignored
+Warning 1906 The value specified for computed column 'b' in table 't2' ignored
select * from t2;
a b c
2 -2 -2
@@ -159,7 +159,7 @@ a b c
2 -2 -2
update t1 set c=3 where a=2;
Warnings:
-Warning 1647 The value specified for computed column 'c' in table 't1' ignored
+Warning 1906 The value specified for computed column 'c' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
@@ -189,7 +189,7 @@ a b c
2 -2 -2
update t1 set c=3 where b=-2;
Warnings:
-Warning 1647 The value specified for computed column 'c' in table 't1' ignored
+Warning 1906 The value specified for computed column 'c' in table 't1' ignored
select * from t1;
a b c
1 -1 -1
diff --git a/mysql-test/suite/vcol/r/vcol_keys_innodb.result b/mysql-test/suite/vcol/r/vcol_keys_innodb.result
index 857dcb8423f..5070981f08f 100644
--- a/mysql-test/suite/vcol/r/vcol_keys_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_keys_innodb.result
@@ -19,7 +19,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES UNI NULL VIRTUAL
+b int(11) YES UNI NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2), unique key (b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column
@@ -34,7 +34,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES UNI NULL VIRTUAL
+b int(11) YES UNI NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2));
alter table t1 add unique key (b);
@@ -64,7 +64,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES MUL NULL VIRTUAL
+b int(11) YES MUL NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2) persistent, index (a,b));
show create table t1;
@@ -77,7 +77,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES MUL NULL
-b int(11) YES NULL VIRTUAL
+b int(11) YES NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2));
alter table t1 add index (b);
diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
index af0935affbc..5ea3b625ec1 100644
--- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
@@ -19,7 +19,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES UNI NULL VIRTUAL
+b int(11) YES UNI NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2), unique key (b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column
@@ -34,7 +34,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES UNI NULL VIRTUAL
+b int(11) YES UNI NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2));
alter table t1 add unique key (b);
@@ -64,7 +64,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES NULL
-b int(11) YES MUL NULL VIRTUAL
+b int(11) YES MUL NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2) persistent, index (a,b));
show create table t1;
@@ -77,7 +77,7 @@ t1 CREATE TABLE `t1` (
describe t1;
Field Type Null Key Default Extra
a int(11) YES MUL NULL
-b int(11) YES NULL VIRTUAL
+b int(11) YES NULL PERSISTENT
drop table t1;
create table t1 (a int, b int as (a*2));
alter table t1 add index (b);
@@ -101,10 +101,10 @@ drop table t1;
# SPATIAL INDEX
# Error "All parts of a SPATIAL index must be NOT NULL"
create table t1 (a int, b int as (a+1) persistent, spatial index (b));
-ERROR 42000: All parts of a SPATIAL index must be NOT NULL
+ERROR 42000: A SPATIAL index may only contain a geometrical type column
create table t1 (a int, b int as (a+1) persistent);
alter table t1 add spatial index (b);
-ERROR 42000: All parts of a SPATIAL index must be NOT NULL
+ERROR 42000: A SPATIAL index may only contain a geometrical type column
drop table t1;
# FOREIGN KEY
# Rejected FK options.
diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result
index 4213aecf85d..de4d4dcbb93 100644
--- a/mysql-test/suite/vcol/r/vcol_misc.result
+++ b/mysql-test/suite/vcol/r/vcol_misc.result
@@ -108,10 +108,10 @@ DROP TABLE t1,t2;
CREATE TABLE t1 (p int, a double NOT NULL, v double AS (ROUND(a,p)) VIRTUAL);
INSERT INTO t1 VALUES (0,1,0);
Warnings:
-Warning 1647 The value specified for computed column 'v' in table 't1' ignored
+Warning 1906 The value specified for computed column 'v' in table 't1' ignored
INSERT INTO t1 VALUES (NULL,0,0);
Warnings:
-Warning 1647 The value specified for computed column 'v' in table 't1' ignored
+Warning 1906 The value specified for computed column 'v' in table 't1' ignored
SELECT a, p, v, ROUND(a,p), ROUND(a,p+NULL) FROM t1;
a p v ROUND(a,p) ROUND(a,p+NULL)
1 0 1 1 NULL
@@ -152,3 +152,93 @@ a b c d v
3 30 30 100 101
set join_cache_level=default;
drop table t1, t2;
+create table t1 (a bigint, b bigint as (a > '2'));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) DEFAULT NULL,
+ `b` bigint(20) AS (a > '2') VIRTUAL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 (a) values (1),(3);
+select * from t1;
+a b
+1 0
+3 1
+select * from t1;
+a b
+1 0
+3 1
+drop table t1;
+create table t1 (a bigint, b bigint as (a between 0 and 2));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) DEFAULT NULL,
+ `b` bigint(20) AS (a between 0 and 2) VIRTUAL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 (a) values (1),(3);
+select * from t1;
+a b
+1 1
+3 0
+select * from t1;
+a b
+1 1
+3 0
+drop table t1;
+create table t1 (a char(10), b char(10) as (a between 0 and 2));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) DEFAULT NULL,
+ `b` char(10) AS (a between 0 and 2) VIRTUAL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 (a) values (1),(3);
+select * from t1;
+a b
+1 1
+3 0
+select * from t1;
+a b
+1 1
+3 0
+drop table t1;
+CREATE TABLE `t1` (
+`a` int(11) NOT NULL,
+`b` varchar(32) DEFAULT NULL,
+`c` int(11) AS (a MOD 10) VIRTUAL,
+`d` varchar(5) AS (LEFT(b,5)) PERSISTENT
+) ENGINE=MyISAM;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` varchar(32) DEFAULT NULL,
+ `c` int(11) AS (a MOD 10) VIRTUAL,
+ `d` varchar(5) AS (LEFT(b,5)) PERSISTENT
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+show columns from t1;
+Field Type Null Key Default Extra
+a int(11) NO NULL
+b varchar(32) YES NULL
+c int(11) YES NULL VIRTUAL
+d varchar(5) YES NULL PERSISTENT
+show full columns from t1;
+Field Type Collation Null Key Default Extra Privileges Comment
+a int(11) NULL NO NULL #
+b varchar(32) latin1_swedish_ci YES NULL #
+c int(11) NULL YES NULL VIRTUAL #
+d varchar(5) latin1_swedish_ci YES NULL PERSISTENT #
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
+UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
+Warnings:
+Warning 1906 The value specified for computed column 'd' in table 't1' ignored
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
+Warnings:
+Warning 1906 The value specified for computed column 'd' in table 't1' ignored
+set sql_mode='strict_all_tables';
+UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
+ERROR HY000: The value specified for computed column 'd' in table 't1' ignored
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
+ERROR HY000: The value specified for computed column 'd' in table 't1' ignored
+drop table t1;
diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result
index a54a2f828b5..129022dd7cc 100644
--- a/mysql-test/suite/vcol/r/vcol_select_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result
@@ -98,8 +98,7 @@ a b c
NULL NULL NULL
explain select * from (select a,b,c from t1) as t11;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5
-2 DERIVED t1 ALL NULL NULL NULL NULL 5
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5
###
### Using aggregate functions with/without DISTINCT
###
diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result
index dd169602654..43ec4e90e88 100644
--- a/mysql-test/suite/vcol/r/vcol_select_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result
@@ -98,8 +98,7 @@ a b c
NULL NULL NULL
explain select * from (select a,b,c from t1) as t11;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5
-2 DERIVED t1 ALL NULL NULL NULL NULL 5
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5
###
### Using aggregate functions with/without DISTINCT
###
@@ -173,7 +172,7 @@ a b c
1 -1 -1
explain select * from t3 where a between 1 and 2 order by c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Rowid-ordered scan; Using filesort
+1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol>
select * from t3 where b between -2 and -1 order by a;
a b c
@@ -189,7 +188,7 @@ a b c
2 -2 -2
explain select * from t3 where c between -2 and -1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using where; Rowid-ordered scan; Using filesort
+1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan; Using filesort
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
select * from t3 where b between -2 and -1 order by b;
a b c
diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
index 83f755a2e7f..5983d5e96c1 100644
--- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
@@ -2251,7 +2251,7 @@ t1 CREATE TABLE `t1` (
insert into t1 values ('2003-02-05',default);
insert into t1 values ('2003-02-32',default);
Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+Warning 1265 Data truncated for column 'a' at row 1
select * from t1;
a b
2003-02-05 00:00:00 2003-02-28 00:00:00
@@ -2686,10 +2686,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
insert into t1 values (1,default);
insert into t1 values (-1,default);
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1;
a b
1 1
-1 18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1;
set sql_warnings = 0;
# Convert()
@@ -2703,10 +2708,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
insert into t1 values (1,default);
insert into t1 values (-1,default);
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1;
a b
1 1
-1 18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1;
set sql_warnings = 0;
#
diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
index 844aae38af2..fa84fb046b3 100644
--- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
@@ -2251,7 +2251,7 @@ t1 CREATE TABLE `t1` (
insert into t1 values ('2003-02-05',default);
insert into t1 values ('2003-02-32',default);
Warnings:
-Warning 1264 Out of range value for column 'a' at row 1
+Warning 1265 Data truncated for column 'a' at row 1
select * from t1;
a b
2003-02-05 00:00:00 2003-02-28 00:00:00
@@ -2686,10 +2686,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default);
insert into t1 values (-1,default);
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1;
a b
1 1
-1 18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1;
set sql_warnings = 0;
# Convert()
@@ -2703,10 +2708,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default);
insert into t1 values (-1,default);
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
select * from t1;
a b
1 1
-1 18446744073709551615
+Warnings:
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
+Warning 1105 Cast to unsigned converted negative integer to it's positive complement
drop table t1;
set sql_warnings = 0;
#
diff --git a/mysql-test/suite/vcol/r/vcol_view_innodb.result b/mysql-test/suite/vcol/r/vcol_view_innodb.result
index ae834722606..88681ca305f 100644
--- a/mysql-test/suite/vcol/r/vcol_view_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_view_innodb.result
@@ -63,7 +63,7 @@ b
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a b c
@@ -82,7 +82,7 @@ c
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a b c
@@ -103,9 +103,11 @@ select * from v1;
b+1
0
-1
+MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
+MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
@@ -113,9 +115,11 @@ select * from v1;
c+1
0
-1
+MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
+MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
diff --git a/mysql-test/suite/vcol/r/vcol_view_myisam.result b/mysql-test/suite/vcol/r/vcol_view_myisam.result
index bd5999792ff..72e0bdb16a4 100644
--- a/mysql-test/suite/vcol/r/vcol_view_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_view_myisam.result
@@ -63,7 +63,7 @@ b
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a b c
@@ -82,7 +82,7 @@ c
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a b c
@@ -103,9 +103,11 @@ select * from v1;
b+1
0
-1
+MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
+MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
@@ -113,9 +115,11 @@ select * from v1;
c+1
0
-1
+MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
+MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test
index bd868f46111..a0616d187da 100644
--- a/mysql-test/suite/vcol/t/vcol_misc.test
+++ b/mysql-test/suite/vcol/t/vcol_misc.test
@@ -160,3 +160,49 @@ select * from t1,t2 where t1.b=t2.c and d <= 100;
set join_cache_level=default;
drop table t1, t2;
+
+#
+# Test crashes when using convert_const_item()
+#
+create table t1 (a bigint, b bigint as (a > '2'));
+show create table t1;
+insert into t1 (a) values (1),(3);
+select * from t1;
+select * from t1;
+drop table t1;
+create table t1 (a bigint, b bigint as (a between 0 and 2));
+show create table t1;
+insert into t1 (a) values (1),(3);
+select * from t1;
+select * from t1;
+drop table t1;
+create table t1 (a char(10), b char(10) as (a between 0 and 2));
+show create table t1;
+insert into t1 (a) values (1),(3);
+select * from t1;
+select * from t1;
+drop table t1;
+
+#
+# Test output of show columns
+#
+
+CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` varchar(32) DEFAULT NULL,
+ `c` int(11) AS (a MOD 10) VIRTUAL,
+ `d` varchar(5) AS (LEFT(b,5)) PERSISTENT
+) ENGINE=MyISAM;
+show create table t1;
+show columns from t1;
+--replace_column 8 #
+show full columns from t1;
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
+UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
+set sql_mode='strict_all_tables';
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
+UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
+--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
+INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
+drop table t1;
diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test
index 05f739bfd69..c77967a0cc9 100644
--- a/mysql-test/t/analyse.test
+++ b/mysql-test/t/analyse.test
@@ -1,6 +1,7 @@
#
# Test of procedure analyse
#
+-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1,t2;
@@ -133,3 +134,26 @@ DROP TABLE t1;
--echo End of 5.0 tests
+
+--echo #
+--echo # Bug#11765202: Dbug_violation_helper::~Dbug_violation_helper(): Assertion `!_entered' failed.
+--echo #
+
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a VARCHAR(2) CHARSET UTF8 NOT NULL);
+INSERT INTO t1 VALUES ('e'),('e'),('e-');
+SELECT * FROM t1 PROCEDURE ANALYSE();
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
+--echo #
+
+CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
+CREATE TABLE t2(f2 INT) ENGINE=INNODB;
+INSERT INTO t2 VALUES (1);
+SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
+SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
+DROP TABLE t1, t2;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 8e60d548c2f..b1e2d23b654 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -9,14 +9,60 @@ select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
select ~5, cast(~5 as signed);
explain extended select ~5, cast(~5 as signed);
+select cast(18446744073709551615 as signed);
select cast(5 as unsigned) -6.0;
select cast(NULL as signed), cast(1/0 as signed);
+select cast(1 as double(5,2));
+select cast("5.2222" as double(5,2));
+select cast(12.444 as double(5,2));
+select cast(cast(12.444 as decimal(10,3)) as double(5,2));
+select cast(null as double(5,2));
+select cast(12.444 as double);
+select cast(cast("20:01:01" as time) as datetime);
+select cast(cast("8:46:06.23434" AS time) as decimal(32,10));
+select cast(cast("2011-04-05 8:46:06.23434" AS datetime) as decimal(32,6));
+
+--echo #
+--echo # Check handling of cast with microseconds
+--echo #
+select cast(cast(20010203101112.121314 as double) as datetime);
+select cast(cast(010203101112.12 as double) as datetime);
+select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime);
+select cast(20010203101112.121314 as datetime);
+select cast(110203101112.121314 as datetime);
+select cast(cast(010203101112.12 as double) as datetime);
+
+select cast("2011-02-03 10:11:12.123456" as datetime);
+select cast("2011-02-03 10:11:12.123456" as datetime(0));
+select cast("2011-02-03 10:11:12.123456" as datetime(5));
+select cast("2011-02-03 10:11:12.123456" as datetime(6));
+select cast("2011-02-03 10:11:12" as datetime(6));
+select cast(cast(20010203101112.1 as double) as datetime(1));
+select cast(cast(010203101112.12 as double) as datetime(2));
+select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime(6));
+select cast(20010203101112.121314 as datetime(6));
+select cast(110203101112.121314 as datetime(6));
+select cast(cast(010203101112.12 as double) as datetime(6));
+
+select cast("2011-02-03 10:11:12.123456" as time);
+select cast("2011-02-03 10:11:12.123456" as time(6));
+select cast("10:11:12.123456" as time);
+select cast("10:11:12.123456" as time(0));
+select cast("10:11:12.123456" as time(5));
+select cast("10:11:12.123456" as time(6));
+select cast("10:11:12" as time(6));
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime) as time);
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime) as time(6));
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime(6)) as time);
+select cast(cast("2011-04-05 8:46:06.123456" AS datetime(6)) as time(6));
+
#
# Bug #28250: Run-Time Check Failure #3 - The variable 'value' is being used
# without being def
#
# The following line causes Run-Time Check Failure on
# binaries built with Visual C++ 2005
+#
select cast(NULL as unsigned), cast(1/0 as unsigned);
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
@@ -42,6 +88,44 @@ select cast('a10' as unsigned integer);
select 10+'a';
select 10.0+cast('a' as decimal);
select 10E+0+'a';
+select cast("a" as double(5,2));
+select cast(1000 as decimal(5,2));
+select cast(-1000 as decimal(5,2));
+select cast(1000 as double(5,2));
+select cast(-1000 as double(5,2));
+select cast(010203101112.121314 as datetime);
+select cast(120010203101112.121314 as datetime);
+select cast(cast(1.1 as decimal) as datetime);
+select cast(cast(-1.1 as decimal) as datetime);
+select cast('0' as date);
+select cast('' as date);
+select cast('0' as datetime);
+select cast('' as datetime);
+select cast('0' as time);
+select cast('' as time);
+select cast(NULL as DATE);
+select cast(NULL as DATETIME);
+select cast(NULL as TIME);
+select cast(NULL as BINARY);
+
+#
+# We have to disable warnings for these as the printed double value is
+# not portable
+#
+--disable_warnings
+select cast(cast(120010203101112.121314 as double) as datetime);
+select cast(cast(1.1 as double) as datetime);
+select cast(cast(-1.1 as double) as datetime);
+--enable_warnings
+
+
+#
+# Some EXPLAIN EXTENDED to ensure the print functions are correct
+#
+
+explain extended select cast(10 as double(5,2));
+explain extended select cast(10 as double);
+explain extended select cast(10 as decimal(5,2));
# out-of-range cases
select cast('18446744073709551616' as unsigned);
@@ -52,6 +136,20 @@ select cast('abc' as signed);
select cast('1a' as signed);
select cast('' as signed);
+--error ER_M_BIGGER_THAN_D
+select cast(1 as double(5,6));
+--error ER_M_BIGGER_THAN_D
+select cast(1 as decimal(5,6));
+--error ER_TOO_BIG_PRECISION
+select cast(1 as double(66,6));
+--error ER_TOO_BIG_PRECISION
+select cast(1 as decimal(66,6));
+--error ER_TOO_BIG_SCALE
+select cast(1 as decimal(64,63));
+--error ER_TOO_BIG_SCALE
+select cast(1 as double(64,63));
+
+
#
# Character set conversion
#
@@ -124,8 +222,6 @@ set names binary;
select cast("2001-1-1" as date) = "2001-01-01";
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
select cast("1:2:3" as TIME) = "1:02:03";
-select cast(NULL as DATE);
-select cast(NULL as BINARY);
#
# Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions
@@ -172,6 +268,14 @@ select cast(repeat('1',20) as signed);
select cast(1.0e+300 as signed int);
#
+# Test that we create the correct types with create ... select cast()
+#
+
+create table t1 select cast(1 as unsigned), cast(1 as signed), cast(1 as double(5,2)), cast(1 as decimal(5,3)), cast("A" as binary), cast("A" as char(100)), cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME), cast("1:2:3" as TIME);
+show create table t1;
+drop table t1;
+
+#
# Bugs: #15098: CAST(column double TO signed int), wrong result
#
CREATE TABLE t1 (f1 double);
@@ -284,3 +388,22 @@ DROP TABLE t1;
--echo End of 5.1 tests
+
+select cast("2101-00-01 02:03:04" as datetime);
+select cast(cast("2101-00-01 02:03:04" as datetime) as time);
+SELECT CAST(CAST('20:05:05' AS TIME) as date);
+set sql_mode= TRADITIONAL;
+select cast("2101-00-01 02:03:04" as datetime);
+select cast(cast("2101-00-01 02:03:04" as datetime) as time);
+SELECT CAST(CAST('20:05:05' AS TIME) as date);
+set sql_mode=DEFAULT;
+
+#
+# lp:737458 Casting dates and times into integers works differently
+# in 5.1-micro
+#
+create table t1 (f1 time, f2 date, f3 datetime);
+insert into t1 values ('11:22:33','2011-12-13','2011-12-13 11:22:33');
+select cast(f1 as unsigned), cast(f2 as unsigned), cast(f3 as unsigned) from t1;
+drop table t1;
+
diff --git a/mysql-test/t/crash_commit_before.test b/mysql-test/t/crash_commit_before.test
index e7d8a373647..f99690777c9 100644
--- a/mysql-test/t/crash_commit_before.test
+++ b/mysql-test/t/crash_commit_before.test
@@ -1,6 +1,8 @@
-- source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index b59fa9edb9f..8f39fb0e0b9 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1534,5 +1534,30 @@ drop table t1,t2,t3;
--echo
--echo # -- End of Bug#45829
+#
+--echo # new table creation/renaming blocked if old encoded table present
+#
+let $MYSQLD_DATADIR= `select @@datadir`;
+create table `t-1` (a int) engine=myisam;
+insert into `t-1` values (1);
+show tables;
+flush tables;
+--echo convert table files in mysql 5.0 file name encoding
+--copy_file $MYSQLD_DATADIR/test/t@002d1.MYD $MYSQLD_DATADIR/test/t-1.MYD
+--copy_file $MYSQLD_DATADIR/test/t@002d1.MYI $MYSQLD_DATADIR/test/t-1.MYI
+--copy_file $MYSQLD_DATADIR/test/t@002d1.frm $MYSQLD_DATADIR/test/t-1.frm
+--remove_file $MYSQLD_DATADIR/test/t@002d1.MYD
+--remove_file $MYSQLD_DATADIR/test/t@002d1.MYI
+--remove_file $MYSQLD_DATADIR/test/t@002d1.frm
+show tables;
+--error ER_TABLE_EXISTS_ERROR
+create table `t-1` (a int);
+create table t1 (a int);
+--error ER_TABLE_EXISTS_ERROR
+alter table t1 rename `t-1`;
+--error ER_TABLE_EXISTS_ERROR
+rename table t1 to `t-1`;
+drop table `#mysql50#t-1`, t1;
+
--echo
--echo End of 5.1 tests
diff --git a/mysql-test/t/csv_not_null.test b/mysql-test/t/csv_not_null.test
index 03ed566fb22..bebea53b2f7 100644
--- a/mysql-test/t/csv_not_null.test
+++ b/mysql-test/t/csv_not_null.test
@@ -55,10 +55,8 @@ INSERT INTO t1 VALUES();
SELECT * FROM t1;
-- disable_warnings
-# NOTE - Test disabled due to enum crash for this INSERT
-# See Bug#33717 - INSERT...(default) fails for enum.
-# Crashes CSV tables, loads spaces for MyISAM
-#INSERT INTO t1 VALUES(default,default,default,default,default,default);
+# Bug#33717 - INSERT...(default) fails for enum.
+INSERT INTO t1 VALUES(default,default,default,default,default,default);
-- enable_warnings
SELECT * FROM t1;
diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test
index 1fb656f2a01..3e17ee52164 100644
--- a/mysql-test/t/ctype_cp1250_ch.test
+++ b/mysql-test/t/ctype_cp1250_ch.test
@@ -72,3 +72,13 @@ select a from t1 where a like "abcdefghá";
drop table t1;
# End of 4.1 tests
+
+#
+# Bug #48053 String::c_ptr has a race and/or does an invalid
+# memory reference
+# (triggered by Valgrind tests)
+# (see also ctype_eucjpms.test, ctype_cp1250.test, ctype_cp1251.test)
+#
+--error 1193
+set global LC_MESSAGES=convert((@@global.log_bin_trust_function_creators)
+ using cp1250);
diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test
index 0e3edce825a..dfe97cb28f3 100644
--- a/mysql-test/t/ctype_cp1251.test
+++ b/mysql-test/t/ctype_cp1251.test
@@ -56,6 +56,16 @@ drop table t1;
--source include/ctype_8bit.inc
+#
+# Bug #48053 String::c_ptr has a race and/or does an invalid
+# memory reference
+# (triggered by Valgrind tests)
+# (see also ctype_eucjpms.test, ctype_cp1250.test, ctype_cp1251.test)
+#
+--error 1105
+set global LC_TIME_NAMES=convert((-8388608) using cp1251);
+
+
--echo #
--echo # End of 5.1 tests
--echo #
diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test
index b1f34ec22d4..07eee7709d1 100644
--- a/mysql-test/t/ctype_cp932_binlog_stm.test
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test
@@ -28,6 +28,16 @@ delimiter ;|
--echo End of 5.0 tests
+#
+# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump
+# Note: 364 is a magic position (found experimentally, depends on
+# the log's contents) that caused the server crash.
+
+call mtr.add_suppression("Error in Log_event::read_log_event\\\(\\\): 'Found invalid");
+
+--error 1220
+SHOW BINLOG EVENTS FROM 504;
+
--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932;
INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test
index ec358d94900..165cfba897a 100644
--- a/mysql-test/t/ctype_eucjpms.test
+++ b/mysql-test/t/ctype_eucjpms.test
@@ -381,3 +381,11 @@ select hex(convert(_eucjpms 0xA5FE41 using ucs2));
# the next character, which is a single byte character 0x41.
select hex(convert(_eucjpms 0x8FABF841 using ucs2));
+#
+# Bug #48053 String::c_ptr has a race and/or does an invalid
+# memory reference
+# (triggered by Valgrind tests)
+# (see also ctype_eucjpms.test, ctype_cp1250.test, ctype_cp1251.test)
+#
+--error 1105
+set global LC_TIME_NAMES=convert((convert((0x63) using eucjpms)) using utf8);
diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test
index 0903c3dd7fa..84048761228 100644
--- a/mysql-test/t/ctype_many.test
+++ b/mysql-test/t/ctype_many.test
@@ -211,3 +211,19 @@ SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f;
DROP TABLE t1;
# End of 4.1 tests
+
+
+--echo #
+--echo # Start of 5.1 tests
+--echo #
+
+--echo #
+--echo # Bug#58371 Assertion failed: !s.uses_buffer_owned_by(this) with format string function
+--echo #
+
+SET NAMES latin1;
+DO CONVERT(CAST(SUBSTRING_INDEX(FORMAT(1,'1111'), FORMAT('','Zpq'),1)
+ AS BINARY(0)) USING utf8);
+--echo #
+--echo # End of 5.1 tests
+--echo #
diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test
index 7de94e34dea..854f9c01a2b 100644
--- a/mysql-test/t/ctype_sjis.test
+++ b/mysql-test/t/ctype_sjis.test
@@ -92,4 +92,12 @@ INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
DROP TABLE t1;
+--echo #
+--echo # Bug#11766519 - Bug#59648: MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED.
+--echo #
+# In the below string backslash (0x5C) is a part of a multi-byte
+# character, so it should not be quoted.
+SELECT QUOTE('ƒ\');
+
+
--echo # End of 5.1 tests
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 583334b0c04..8b266fb4748 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -741,6 +741,12 @@ WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
+--echo #
+SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850));
+SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED);
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index 2a5de8ca9ba..55e08e420b1 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -128,12 +128,9 @@ SET datetime_format=default;
# Test of str_to_date
#
-# PS doesn't support fractions of a second
---disable_ps_protocol
select str_to_date(concat('15-01-2001',' 2:59:58.999'),
concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
---enable_ps_protocol
create table t1 (date char(30), format char(30) not null);
insert into t1 values
@@ -169,8 +166,6 @@ insert into t1 values
('15-01-20', '%d-%m-%y'),
('15-2001-1', '%d-%Y-%c');
-# PS doesn't support fractional seconds
---disable_ps_protocol
select date,format,str_to_date(date, format) as str_to_date from t1;
# Use as a string
select date,format,concat('',str_to_date(date, format)) as con from t1;
@@ -217,7 +212,6 @@ select date,format,str_to_date(date, format) as str_to_date from t1;
select date,format,concat(str_to_date(date, format),'') as con from t1;
drop table t1;
---enable_ps_protocol
#
# Test of get_format
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 962cec95add..75368925499 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -315,3 +315,19 @@ WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
DROP TABLE t1;
--echo # End of 5.0 tests
+
+--echo #
+--echo # LP bug #793436: query with a derived table for which optimizer proves
+--echo # that it contains not more than 1 row
+--echo #
+
+CREATE TABLE t1 (a int, KEY (a)) ;
+INSERT INTO t1 VALUES (3), (1);
+CREATE TABLE t2 (a int);
+INSERT INTO t2 VALUES (3);
+
+EXPLAIN
+SELECT * FROM (SELECT DISTINCT * FROM t2) t, t1 WHERE t1.a = t.a;
+SELECT * FROM (SELECT DISTINCT * FROM t2) t, t1 WHERE t1.a = t.a;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test
new file mode 100644
index 00000000000..93c2eb48fcd
--- /dev/null
+++ b/mysql-test/t/derived_view.test
@@ -0,0 +1,237 @@
+--disable_warnings
+drop table if exists t1,t2;
+drop view if exists v1,v2,v3,v4;
+--enable_warnings
+create table t1(f1 int, f11 int);
+create table t2(f2 int, f22 int);
+insert into t1 values(1,1),(2,2),(3,3),(5,5),(9,9),(7,7);
+insert into t1 values(17,17),(13,13),(11,11),(15,15),(19,19);
+insert into t2 values(1,1),(3,3),(2,2),(4,4),(8,8),(6,6);
+insert into t2 values(12,12),(14,14),(10,10),(18,18),(16,16);
+
+--echo Tests:
+
+--echo for merged derived tables
+--echo explain for simple derived
+explain select * from (select * from t1) tt;
+select * from (select * from t1) tt;
+--echo explain for multitable derived
+explain extended select * from (select * from t1 join t2 on f1=f2) tt;
+select * from (select * from t1 join t2 on f1=f2) tt;
+--echo explain for derived with where
+explain extended
+ select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+--echo join of derived
+explain extended
+ select * from (select * from t1 where f1 in (2,3)) tt join
+ (select * from t1 where f1 in (1,2)) aa on tt.f1=aa.f1;
+select * from (select * from t1 where f1 in (2,3)) tt join
+ (select * from t1 where f1 in (1,2)) aa on tt.f1=aa.f1;
+
+flush status;
+explain extended
+ select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+show status like 'Handler_read%';
+flush status;
+select * from (select * from t1 where f1 in (2,3)) tt where f11=2;
+show status like 'Handler_read%';
+
+--echo for merged views
+create view v1 as select * from t1;
+create view v2 as select * from t1 join t2 on f1=f2;
+create view v3 as select * from t1 where f1 in (2,3);
+create view v4 as select * from t2 where f2 in (2,3);
+--echo explain for simple views
+explain extended select * from v1;
+select * from v1;
+--echo explain for multitable views
+explain extended select * from v2;
+select * from v2;
+--echo explain for views with where
+explain extended select * from v3 where f11 in (1,3);
+select * from v3 where f11 in (1,3);
+--echo explain for joined views
+explain extended
+ select * from v3 join v4 on f1=f2;
+select * from v3 join v4 on f1=f2;
+
+flush status;
+explain extended select * from v4 where f2 in (1,3);
+show status like 'Handler_read%';
+flush status;
+select * from v4 where f2 in (1,3);
+show status like 'Handler_read%';
+
+--echo for materialized derived tables
+--echo explain for simple derived
+explain extended select * from (select * from t1 group by f1) tt;
+select * from (select * from t1 having f1=f1) tt;
+--echo explain showing created indexes
+explain extended
+ select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+--echo explain showing late materialization
+flush status;
+explain select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+show status like 'Handler_read%';
+flush status;
+select * from t1 join (select * from t2 group by f2) tt on f1=f2;
+show status like 'Handler_read%';
+
+--echo for materialized views
+drop view v1,v2,v3;
+create view v1 as select * from t1 group by f1;
+create view v2 as select * from t2 group by f2;
+create view v3 as select t1.f1,t1.f11 from t1 join t1 as t11 where t1.f1=t11.f1
+ having t1.f1<100;
+--echo explain for simple derived
+explain extended select * from v1;
+select * from v1;
+--echo explain showing created indexes
+explain extended select * from t1 join v2 on f1=f2;
+select * from t1 join v2 on f1=f2;
+explain extended
+ select * from t1,v3 as v31,v3 where t1.f1=v31.f1 and t1.f1=v3.f1;
+flush status;
+select * from t1,v3 as v31,v3 where t1.f1=v31.f1 and t1.f1=v3.f1;
+show status like 'Handler_read%';
+--echo explain showing late materialization
+flush status;
+explain select * from t1 join v2 on f1=f2;
+show status like 'Handler_read%';
+flush status;
+select * from t1 join v2 on f1=f2;
+show status like 'Handler_read%';
+
+explain extended select * from v1 join v4 on f1=f2;
+select * from v1 join v4 on f1=f2;
+
+--echo merged derived in merged derived
+explain extended select * from (select * from
+ (select * from t1 where f1 < 7) tt where f1 > 2) zz;
+select * from (select * from
+ (select * from t1 where f1 < 7) tt where f1 > 2) zz;
+
+--echo materialized derived in merged derived
+explain extended select * from (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) zz;
+select * from (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) zz;
+
+--echo merged derived in materialized derived
+explain extended select * from (select * from
+ (select * from t1 where f1 < 7) tt where f1 > 2 group by f1) zz;
+select * from (select * from
+ (select * from t1 where f1 < 7) tt where f1 > 2 group by f1) zz;
+
+--echo materialized derived in materialized derived
+explain extended select * from (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) zz;
+select * from (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) zz;
+
+--echo mat in merged derived join mat in merged derived
+explain extended select * from
+ (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) x
+join
+ (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) z
+ on x.f1 = z.f1;
+
+flush status;
+select * from
+ (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) x
+join
+ (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) z
+ on x.f1 = z.f1;
+show status like 'Handler_read%';
+flush status;
+
+--echo merged in merged derived join merged in merged derived
+explain extended select * from
+ (select * from
+ (select * from t1 where f1 < 7 ) tt where f1 > 2 ) x
+join
+ (select * from
+ (select * from t1 where f1 < 7 ) tt where f1 > 2 ) z
+ on x.f1 = z.f1;
+
+select * from
+ (select * from
+ (select * from t1 where f1 < 7 ) tt where f1 > 2 ) x
+join
+ (select * from
+ (select * from t1 where f1 < 7 ) tt where f1 > 2 ) z
+ on x.f1 = z.f1;
+
+--echo materialized in materialized derived join
+--echo materialized in materialized derived
+explain extended select * from
+ (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) x
+join
+ (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) z
+ on x.f1 = z.f1;
+
+select * from
+ (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) x
+join
+ (select * from
+ (select * from t1 where f1 < 7 group by f1) tt where f1 > 2 group by f1) z
+ on x.f1 = z.f1;
+
+--echo merged view in materialized derived
+explain extended
+select * from (select * from v4 group by 1) tt;
+select * from (select * from v4 group by 1) tt;
+
+--echo materialized view in merged derived
+explain extended
+select * from ( select * from v1 where f1 < 7) tt;
+select * from ( select * from v1 where f1 < 7) tt;
+
+--echo merged view in a merged view in a merged derived
+create view v6 as select * from v4 where f2 < 7;
+explain extended select * from (select * from v6) tt;
+select * from (select * from v6) tt;
+
+--echo materialized view in a merged view in a materialized derived
+create view v7 as select * from v1;
+explain extended select * from (select * from v7 group by 1) tt;
+select * from (select * from v7 group by 1) tt;
+
+--echo join of above two
+explain extended select * from v6 join v7 on f2=f1;
+select * from v6 join v7 on f2=f1;
+
+--echo test two keys
+explain select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 xx on tt.f22=xx.f1;
+select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 xx on tt.f22=xx.f1;
+
+
+--echo TODO: Add test with 64 tables mergeable view to test fall back to
+--echo materialization on tables > MAX_TABLES merge
+drop table t1,t2;
+drop view v1,v2,v3,v4,v6,v7;
+
+--echo #
+--echo # LP bug #794909: crash when defining possible keys for
+--echo # a materialized view/derived_table
+--echo #
+
+CREATE TABLE t1 (f1 int) ;
+INSERT INTO t1 VALUES (149), (150), (224), (29);
+
+CREATE TABLE t2 (f1 int, KEY (f1));
+INSERT INTO t2 VALUES (149), (NULL), (224);
+
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+
+EXPLAIN
+SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1;
+SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 2c54131e08a..c4eb6bf829e 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -11,11 +11,6 @@
##############################################################################
kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
-partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings
-main.mysqlhotcopy_myisam : bug#54129 2010-06-04 Horst
-main.mysqlhotcopy_archive: bug#54129 2010-06-04 Horst
-main.events_time_zone : Test is not predictable as it depends on precise timing.
-main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
-main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails
log_tables-big : Bug#48646 2010-11-15 mattiasj report already exists
read_many_rows_innodb : Bug#37635 2010-11-15 mattiasj report already exists
+main.subselect_mat_cost : MWL#89 tests that must be adjusted to the cost model introduced after the code review
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index bf4c23562cf..796732fa097 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -614,3 +614,41 @@ SET @@sort_buffer_size = @old_sort_buffer_size;
SET @@max_heap_table_size = @old_max_heap_table_size;
--echo End of 5.1 tests
+
+#
+# test_if_equality_guarantees_uniqueness() and dates
+#
+create table t1 (a varchar(100));
+insert t1 values ('2010-10-10'), ('20101010');
+select * from t1 where a = DATE('2010-10-10');
+select distinct a from t1 where a = DATE('2010-10-10');
+explain select distinct a from t1 where a = DATE('2010-10-10');
+drop table t1;
+#
+# test_if_equality_guarantees_uniqueness() and different type combinations
+#
+--echo # date = string
+create table t1 (a date);
+insert t1 values ('2010-10-10'), ('20101010');
+explain select distinct a from t1 where a = '2010-10-10';
+drop table t1;
+--echo # double = string
+create table t1 (a double);
+insert t1 values (2), (2);
+explain select distinct a from t1 where a = '2';
+--echo # double = int
+explain select distinct a from t1 where a = 2;
+--echo # string = double
+alter table t1 modify a varchar(100);
+explain select distinct a from t1 where a = 2e0;
+drop table t1;
+
+#
+# lp:731124 Loss of precision on DISTINCT
+#
+create table t1 (f1 varchar(40));
+insert into t1 values ('2010-10-10 00:00:00.0001'),('2010-10-10 00:00:00.0002'),('2010-10-10 00:00:00.0003');
+select time(f1) from t1 ;
+select distinct time(f1) from t1 ;
+drop table t1;
+
diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test
new file mode 100644
index 00000000000..1901a998732
--- /dev/null
+++ b/mysql-test/t/dyncol.test
@@ -0,0 +1,548 @@
+#
+# Dynamic column function test
+#
+
+--echo #
+--echo # column create
+--echo #
+select hex(COLUMN_CREATE(1, NULL AS char character set utf8));
+select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8));
+select hex(COLUMN_CREATE(1, 1212 AS char character set utf8));
+select hex(COLUMN_CREATE(1, 12.12 AS char character set utf8));
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS char character set utf8));
+select hex(COLUMN_CREATE(1, NULL AS unsigned int));
+select hex(COLUMN_CREATE(1, 1212 AS unsigned int));
+select hex(COLUMN_CREATE(1, 7 AS unsigned int));
+select hex(COLUMN_CREATE(1, 8 AS unsigned int));
+select hex(COLUMN_CREATE(1, 127 AS unsigned int));
+select hex(COLUMN_CREATE(1, 128 AS unsigned int));
+select hex(COLUMN_CREATE(1, 12.12 AS unsigned int));
+select hex(COLUMN_CREATE(1, ~0));
+select hex(COLUMN_CREATE(1, -1));
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int));
+select hex(COLUMN_CREATE(1, NULL AS int));
+select hex(COLUMN_CREATE(1, 1212 AS int));
+select hex(COLUMN_CREATE(1, 7 AS int));
+select hex(COLUMN_CREATE(1, 8 AS int));
+select hex(COLUMN_CREATE(1, 127 AS int));
+select hex(COLUMN_CREATE(1, 128 AS int));
+select hex(COLUMN_CREATE(1, 12.12 AS int));
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS int));
+select hex(COLUMN_CREATE(1, NULL AS double));
+select hex(COLUMN_CREATE(1, 1212 AS double));
+select hex(COLUMN_CREATE(1, 12.12 AS double));
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS double));
+select hex(COLUMN_CREATE(1, NULL AS decimal));
+select hex(COLUMN_CREATE(1, 1212 AS decimal));
+select hex(COLUMN_CREATE(1, 7 AS decimal));
+select hex(COLUMN_CREATE(1, 8 AS decimal));
+select hex(COLUMN_CREATE(1, 127 AS decimal));
+select hex(COLUMN_CREATE(1, 128 AS decimal));
+select hex(COLUMN_CREATE(1, 12.12 AS decimal));
+select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS decimal));
+select hex(COLUMN_CREATE(1, NULL AS date));
+select hex(COLUMN_CREATE(1, "2011-04-05" AS date));
+select hex(COLUMN_CREATE(1, NULL AS time));
+select hex(COLUMN_CREATE(1, "0:45:49.000001" AS time));
+select hex(COLUMN_CREATE(1, NULL AS datetime));
+select hex(COLUMN_CREATE(1, "2011-04-05 0:45:49.000001" AS datetime));
+select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
+ 2, 1212 AS unsigned int,
+ 3, 1212 AS int,
+ 4, 12.12 AS double,
+ 4+1, 12.12 AS decimal,
+ 6, "2011-04-05" AS date,
+ 7, "- 0:45:49.000001" AS time,
+ 8, "2011-04-05 0:45:49.000001" AS datetime));
+explain extended
+select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
+ 2, 1212 AS unsigned int,
+ 3, 1212 AS int,
+ 4, 12.12 AS double,
+ 4+1, 12.12 AS decimal,
+ 6, "2011-04-05" AS date,
+ 7, "- 0:45:49.000001" AS time,
+ 8, "2011-04-05 0:45:49.000001" AS datetime));
+select hex(column_create(1, 0.0 AS decimal));
+select hex(column_create(1, 1.0 AS decimal));
+
+--echo #
+--echo # column get uint
+--echo #
+select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
+explain extended
+select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned int);
+explain extended
+select column_get(column_create(1, 1212 AS unsigned int), 1 as unsigned);
+select column_get(column_create(1, 1212 AS decimal), 1 as unsigned int);
+select column_get(column_create(1, 1212 AS double), 1 as unsigned int);
+select column_get(column_create(1, 1212 AS int), 1 as unsigned int);
+select column_get(column_create(1, "1212" AS char), 1 as unsigned int);
+select column_get(column_create(1, "2011-04-05" AS date), 1 as unsigned int);
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as unsigned int);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as unsigned int);
+select column_get(column_create(1, NULL AS unsigned int), 1 as unsigned int);
+--echo # column geint truncation & warnings
+select column_get(column_create(1, -1212 AS int), 1 as unsigned int);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as unsigned int);
+select column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as unsigned int);
+select column_get(column_create(1, -1 AS decimal), 1 as unsigned int);
+--replace_result e+029 e+29
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as unsigned int);
+select column_get(column_create(1, 999.9 AS double), 1 as unsigned int);
+select column_get(column_create(1, -1 AS double), 1 as unsigned int);
+select column_get(column_create(1, "1212III" AS char), 1 as unsigned int);
+
+--echo #
+--echo # column get int
+--echo #
+select column_get(column_create(1, 1212 AS int), 1 as int);
+explain extended
+select column_get(column_create(1, 1212 AS int), 1 as int);
+explain extended
+select column_get(column_create(1, 1212 AS int), 1 as signed int);
+select column_get(column_create(1, -1212 AS int), 1 as int);
+select column_get(column_create(1, 1212 AS decimal), 1 as int);
+select column_get(column_create(1, 1212 AS double), 1 as int);
+select column_get(column_create(1, 1212 AS unsigned int), 1 as int);
+select column_get(column_create(1, "1212" AS char), 1 as int);
+select column_get(column_create(1, "-1212" AS char), 1 as int);
+select column_get(column_create(1, "2011-04-05" AS date), 1 as int);
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as int);
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as int);
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as int);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as int);
+select column_get(column_create(1, NULL AS int), 1 as int);
+--echo #column gett truncation & warnings
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as int);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as int);
+select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as int);
+select column_get(column_create(1, 999.9999999999999999 AS decimal), 1 as int);
+select column_get(column_create(1, 999.9 AS double), 1 as int);
+--replace_result e+029 e+29
+select column_get(column_create(1, -99999999999999999999999999999 AS double), 1 as int);
+select column_get(column_create(1, "-1212III" AS char), 1 as int);
+select column_get(column_create(1, "1212III" AS char), 1 as int);
+select column_get(COLUMN_CREATE(1, ~0), 1 as signed);
+select column_get(COLUMN_CREATE(1, ~0), 1 as unsigned);
+select column_get(COLUMN_CREATE(1, -1), 1 as signed);
+select column_get(COLUMN_CREATE(1, -1), 1 as unsigned);
+
+--echo #
+--echo #column get char
+--echo #
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8);
+explain extended
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset utf8);
+select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8);
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as char charset utf8);
+select column_get(column_create(1, 1212 AS int), 1 as char charset utf8);
+select column_get(column_create(1, -1212 AS int), 1 as char charset utf8);
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as char charset utf8);
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as char charset utf8);
+select column_get(column_create(1, 1212.12 AS decimal), 1 as char charset utf8);
+select column_get(column_create(1, 1212.12 AS double), 1 as char charset utf8);
+select column_get(column_create(1, "2011-04-05" AS date), 1 as char charset utf8);
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as char charset utf8);
+select column_get(column_create(1, "8:46:06.23434" AS time(0)), 1 as char charset utf8);
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as char charset utf8);
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as char charset utf8);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as char charset utf8);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(0)), 1 as char charset utf8);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as char charset utf8);
+select column_get(column_create(1, NULL AS char charset utf8), 1 as char charset utf8);
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary);
+explain extended
+select column_get(column_create(1, "1212" AS char charset utf8), 1 as char charset binary);
+
+--echo #
+--echo # column get real
+--echo #
+select column_get(column_create(1, 1212.12 AS double), 1 as double);
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as double);
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as double(6,2));
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as double);
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as double);
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as double);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal), 1 as double);
+select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as double);
+select column_get(column_create(1, "2011-04-05" AS date), 1 as double);
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as double);
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as double);
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as double);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime(6)), 1 as double);
+# The replace result is needed for windows.
+select round(column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as double(20,6)),3);
+select column_get(column_create(1, NULL AS double), 1 as double);
+
+-- echo # column get real truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as double);
+select column_get(column_create(1, "aa" AS char), 1 as double);
+select column_get(column_create(1, "1223.5555" AS double), 1 as double(5,2));
+select column_get(column_create(1, "1223.5555" AS double), 1 as double(3,2));
+
+--echo #
+--echo # column get decimal
+--echo #
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal);
+explain extended
+select column_get(column_create(1, 1212.12 AS double), 1 as decimal(6,2));
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal(20,0));
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal(32,0));
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal(32,0));
+select column_get(column_create(1, -99999999999999999999999999999 AS decimal), 1 as decimal(40,10));
+select column_get(column_create(1, "2011-04-05" AS date), 1 as decimal(32,6));
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as decimal(32,6));
+select column_get(column_create(1, "8:46:06.23434" AS time(6)), 1 as decimal(32,6));
+select column_get(column_create(1, "-808:46:06.23434" AS time(6)), 1 as decimal(32,6));
+select column_get(column_create(1, "2011-04-05 8:46:06.123456" AS datetime), 1 as decimal(32,6));
+select column_get(column_create(1, "2011-04-05 8:46:06.123456" AS datetime(6)), 1 as decimal(32,6));
+select column_get(column_create(1, "2011-04-05 8:46:06.12345678" AS datetime(6)), 1 as decimal(32,8));
+select column_get(column_create(1, NULL as decimal), 1 as decimal(32,10));
+select column_get(column_create(1, "1223.5555" as decimal(10,5)), 1 as decimal(6,2));
+
+-- echo # column get decimal truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as decimal(32,10));
+select column_get(column_create(1, "aa" AS char), 1 as decimal(32,10));
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as decimal);
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as decimal);
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as decimal);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as decimal);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as decimal);
+select column_get(column_create(1, "1223.5555" as double), 1 as decimal(5,2));
+select column_get(column_create(1, "-1223.5555" as double), 1 as decimal(5,2));
+select column_get(column_create(1, "1223.5555" AS double), 1 as decimal(3,2));
+select column_get(column_create(1, "1223.5555" AS decimal(10,5)), 1 as decimal(3,2));
+select column_get(column_create(1, 0.0 AS decimal,2, 0.0 as decimal), 1 as decimal);
+
+--echo #
+--echo # column get datetime
+--echo #
+select column_get(column_create(1, 20010203101112.121314 as double), 1 as datetime);
+select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as datetime);
+select column_get(column_create(1, 20010203101112 as unsigned int), 1 as datetime);
+select column_get(column_create(1, 20010203101112 as int), 1 as datetime);
+select column_get(column_create(1, "20010203101112" as char), 1 as datetime);
+select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as datetime);
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as datetime);
+select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as datetime);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime(0));
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as datetime(6));
+select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as datetime);
+select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as datetime);
+
+select column_get(column_create(1, 20010203 as unsigned int), 1 as datetime);
+select column_get(column_create(1, 20010203 as int), 1 as datetime);
+select column_get(column_create(1, 20010203), 1 as datetime);
+select column_get(column_create(1, 20010203.0), 1 as datetime);
+select column_get(column_create(1, 20010203.0 as double), 1 as datetime);
+select column_get(column_create(1, "2001-02-03"), 1 as datetime);
+select column_get(column_create(1, "20010203"), 1 as datetime);
+select column_get(column_create(1, 0), 1 as datetime);
+select column_get(column_create(1, "2001021"), 1 as datetime);
+
+select column_get(column_create(1, "8:46:06.23434" AS time), 1 as datetime);
+select column_get(column_create(1, "-808:46:06.23434" AS time), 1 as datetime);
+
+set @@sql_mode="allow_invalid_dates";
+select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as datetime);
+select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as datetime);
+select column_get(column_create(1, "2001-00-02" AS CHAR), 1 as datetime);
+set @@sql_mode="";
+
+-- echo # column get datetime truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as datetime);
+--replace_result e+019 e+19
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as datetime);
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as datetime);
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as datetime);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as datetime);
+--replace_result e+029 e+29
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as datetime);
+select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as datetime);
+select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as datetime);
+select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as datetime);
+select column_get(column_create(1, "20010231"), 1 as datetime);
+select column_get(column_create(1, "0" AS CHAR), 1 as datetime);
+
+
+--echo #
+--echo # column get date
+--echo #
+select column_get(column_create(1, 20010203101112.121314 as double), 1 as date);
+select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as date);
+select column_get(column_create(1, 20010203101112 as unsigned int), 1 as date);
+select column_get(column_create(1, 20010203101112 as int), 1 as date);
+select column_get(column_create(1, "20010203101112" as char), 1 as date);
+select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as date);
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as date);
+select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as date);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as date);
+select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as date);
+select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as date);
+
+select column_get(column_create(1, 20010203 as unsigned int), 1 as date);
+select column_get(column_create(1, 20010203 as int), 1 as date);
+select column_get(column_create(1, 20010203), 1 as date);
+select column_get(column_create(1, 20010203.0), 1 as date);
+select column_get(column_create(1, 20010203.0 as double), 1 as date);
+select column_get(column_create(1, "2001-02-03"), 1 as date);
+select column_get(column_create(1, "20010203"), 1 as date);
+select column_get(column_create(1, 0), 1 as date);
+select column_get(column_create(1, "2001021"), 1 as date);
+
+set @@sql_mode="allow_invalid_dates";
+select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as date);
+select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as date);
+select column_get(column_create(1, "2001-00-02" AS CHAR), 1 as date);
+set @@sql_mode="";
+
+-- echo # column get date truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as date);
+--replace_result e+019 e+19
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as date);
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as date);
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as date);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as date);
+--replace_result e+029 e+29
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as date);
+select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as date);
+select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as date);
+select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as date);
+select column_get(column_create(1, "20010231"), 1 as date);
+select column_get(column_create(1, "0" AS CHAR), 1 as date);
+
+--echo #
+--echo # column get time
+--echo #
+select column_get(column_create(1, 20010203101112.121314 as double), 1 as time);
+select column_get(column_create(1, 20010203101112.121314 as decimal), 1 as time);
+select column_get(column_create(1, 20010203101112 as unsigned int), 1 as time);
+select column_get(column_create(1, 8080102 as unsigned int), 1 as time);
+select column_get(column_create(1, 20010203101112 as int), 1 as time);
+select column_get(column_create(1, -8080102 as int), 1 as time);
+select column_get(column_create(1, "20010203101112" as char), 1 as time);
+select column_get(column_create(1, "2001-02-03 10:11:12" as char), 1 as time);
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time);
+select column_get(column_create(1, "2001-02-03 10:11:12.121314" as char), 1 as time(6));
+select column_get(column_create(1, "2001-02-03 10:11:12.121314"), 1 as time);
+select column_get(column_create(1, "2011-04-05 8:46:06.23434" AS datetime), 1 as time(6));
+select column_get(column_create(1, "2011-00-00 8:46:06.23434" AS CHAR), 1 as time(6));
+select column_get(column_create(1, "2011-00-01 8:46:06.23434" AS CHAR), 1 as time(6));
+select column_get(column_create(1, "830:46:06.23434" AS CHAR), 1 as time(6));
+select column_get(column_create(1, "830:46:06" AS CHAR), 1 as time(6));
+select cast("-830:46:06.23434" AS time(6));
+select 1,cast("-830:46:06.23434" AS time(6));
+select hex(column_create(1, "-830:46:06.23434" AS CHAR));
+select column_get(column_create(1, "-830:46:06.23434" AS CHAR), 1 as time(6));
+select column_get(column_create(1, "0" AS CHAR), 1 as time);
+select column_get(column_create(1, "6" AS CHAR), 1 as time);
+select column_get(column_create(1, "1:6" AS CHAR), 1 as time);
+select column_get(column_create(1, "2:1:6" AS CHAR), 1 as time);
+
+select column_get(column_create(1, 0), 1 as time);
+select column_get(column_create(1, "2001021"), 1 as time);
+
+set @@sql_mode="allow_invalid_dates";
+select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as time);
+set @@sql_mode="";
+
+-- echo # column get date truncation & warnings
+select column_get(column_create(1, "1223.5aa" AS char), 1 as time);
+select column_get(column_create(1, "1223.5aa" AS char), 1 as time(3));
+--replace_result e+019 e+19
+select column_get(column_create(1, 18446744073709551615 AS unsigned int), 1 as time);
+select column_get(column_create(1, 9223372036854775807 AS int), 1 as time);
+select column_get(column_create(1, -9223372036854775808 AS int), 1 as time);
+select column_get(column_create(1, 99999999999999999999999999999 AS decimal(32,10)), 1 as time);
+--replace_result e+029 e+29
+select column_get(column_create(1, 99999999999999999999999999999 AS double), 1 as time);
+select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as time);
+select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as time);
+select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as time);
+select column_get(column_create(1, "2001-02-03"), 1 as time);
+select column_get(column_create(1, "20010203"), 1 as time);
+
+
+-- echo # column add
+select hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer));
+select hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer));
+select hex(column_add(column_create(1, 1212 as integer), 1, NULL as integer));
+select hex(column_add(column_create(1, 1212 as integer), 2, NULL as integer));
+select hex(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer));
+select column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 1 as integer);
+select column_get(column_add(column_create(1, 1212 as integer), 2, 1212 as integer, 1, 11 as integer), 2 as integer);
+select hex(column_add(column_create(1, 1212 as integer), 1, 1212 as integer, 2, 11 as integer));
+select hex(column_add(column_create(1, NULL as integer), 1, 1212 as integer, 2, 11 as integer));
+select hex(column_add(column_create(1, 1212 as integer, 2, 1212 as integer), 1, 11 as integer));
+select hex(column_add(column_create(1, 1), 1, null));
+select column_list(column_add(column_create(1, 1), 1, null));
+select column_list(column_add(column_create(1, 1), 1, ""));
+select hex(column_add("", 1, 1));
+
+-- echo # column delete
+select hex(column_delete(column_create(1, 1212 as integer, 2, 1212 as integer), 1));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 3));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 4));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 1));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 2, 3));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3));
+select hex(column_delete(column_create(1, 1 as integer, 2, 2 as integer, 3, 3 as integer), 1, 2, 3, 10));
+select hex(column_delete(column_create(1, 1), 1));
+select hex(column_delete("", 1));
+
+-- echo # column exists
+select column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 1);
+select column_exists(column_create(1, 1212 as integer, 2, 1212 as integer), 4);
+
+-- echo # column list
+select column_list(column_create(1, 1212 as integer, 2, 1212 as integer));
+select column_list(column_create(1, 1212 as integer));
+select column_list(column_create(1, NULL as integer));
+
+--echo #
+--echo # check error handling
+--echo #
+--error ER_DYN_COL_DATA
+select HEX(COLUMN_CREATE(1, 5, 1, 5));
+--error 1064
+select HEX(COLUMN_CREATE("", 1, 5, 1, 5));
+--error ER_DYN_COL_WRONG_FORMAT
+select COLUMN_LIST("a");
+--error ER_DYN_COL_WRONG_FORMAT
+select column_delete("a", 1);
+select hex(column_delete("", 1));
+--error ER_DYN_COL_DATA
+select hex(column_delete("", -1));
+--error ER_DYN_COL_DATA
+select hex(column_create(-1, 1));
+--error ER_DYN_COL_DATA
+select hex(column_create(65536, 1));
+--error ER_DYN_COL_DATA
+select hex(column_add("", -1, 1));
+--error ER_DYN_COL_DATA
+select hex(column_add("", 65536, 1));
+select hex(column_get("", -1 as int));
+
+--echo #
+--echo # Test with table
+--echo #
+
+# create table with 'str' to hold a set of dynamic columns
+create table t1 (id int primary key, str mediumblob);
+insert into t1 values (1, ''), (2, ''), (3, ''), (4, ''), (5, null);
+
+# Selecting a non existing column
+select id, str, column_get(str, 1 as int) from t1;
+
+# Add some dynamic columns. One and do it with create or add.
+update t1 set str=column_create(1, id, 2, "a") where id < 3;
+update t1 set str=column_add(str, 1, id, 2, "b") where id >= 4;
+
+# Show some data, if it exists
+select id, column_get(str, 1 as int), column_get(str, 2 as char) from t1 where column_exists(str,1) or column_exists(str,2);
+
+# Add data to row 5 and 6
+update t1 set str=column_create(1, id, 10, "test") where id = 5;
+insert into t1 values (6, column_create(10, "test2"));
+
+# Update some of the columns and add a new column 3
+update t1 set str=column_add(str, 2, 'c', 1, column_get(str, 1 as int) + 1, 3, 100) where id > 2;
+
+# Check data
+select id, length(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1;
+
+# You can do anything with the columns, like SUM() or GROUP
+select column_get(str, 2 as char), sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char);
+select column_get(str, 2 as char), sum(column_get(str, 1 as int)) from t1 where column_exists(str, 2) <> 0 group by 1;
+select sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char) order by sum(column_get(str, 1 as int)) desc;
+select sum(column_get(str, 1 as int)) from t1 group by column_get(str, 2 as char) having sum(column_get(str, 1 as int)) > 2;
+select sum(column_get(str, 1 as int)) from t1 where column_get(str, 3 as int) > 50 group by column_get(str, 2 as char);
+
+# Deleting of column
+select id, column_list(str) from t1 where id= 5;
+update t1 set str=column_delete(str, 3, 4, 2) where id= 5;
+
+select id, length(str), column_list(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1;
+
+update t1 set str=column_add(str, 4, 45 as char, 2, 'c') where id= 5;
+select id, length(str), column_list(str), column_get(str, 1 as int), column_get(str, 2 as char), column_get(str, 3 as int) from t1 where id = 5;
+
+# Check which column exists
+select id, length(str), column_list(str), column_exists(str, 4) from t1;
+select sum(column_get(str, 1 as int)), column_list(str) from t1 group by 2;
+select id, hex(str) from t1;
+
+# Check with a bit larger strings
+
+update t1 set str=column_add(str, 4, repeat("a", 100000)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("a", 100000);
+select id from t1 where column_get(str,4 as char(100)) = repeat("a", 100);
+update t1 set str=column_add(str, 4, repeat("b", 10000)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("b", 10000);
+update t1 set str=column_add(str, 4, repeat("c", 100)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("c", 100);
+update t1 set str=column_add(str, 4, repeat("d", 10000)) where id=5;
+select id from t1 where column_get(str,4 as char(100000)) = repeat("d", 10000);
+update t1 set str=column_add(str, 4, repeat("e", 10), 5, repeat("f", 100000)) where id=5;
+select id from t1 where column_get(str,5 as char(100000)) = repeat("f", 100000);
+select id, column_list(str), length(str) from t1 where id=5;
+update t1 set str=column_delete(str, 5) where id=5;
+select id, column_list(str), length(str) from t1 where id=5;
+
+drop table t1;
+
+--echo #
+--echo # LP#778905: Assertion `value->year <= 9999' failed in
+--echo # dynamic_column_date_store
+--echo #
+
+--error ER_DYN_COL_WRONG_FORMAT
+SELECT COLUMN_GET( 'a' , 2 AS DATE );
+--error ER_DYN_COL_WRONG_FORMAT
+SELECT COLUMN_CREATE( 1 , COLUMN_GET( 'a' , 2 AS DATE ) );
+
+--echo #
+--echo # LP#778912: Assertion `field_pos < field_count' failed in
+--echo # Protocol_text::store in maria-5.3-mwl34
+--echo #
+
+CREATE TABLE t1 ( f1 blob );
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 SET f1 = COLUMN_CREATE( 2 , 'cde' );
+SELECT HEX(COLUMN_ADD(f1, 1, 'abc')), COLUMN_LIST(f1) FROM t1;
+
+# Don't print strange characters on screen
+--disable_result_log
+SELECT COLUMN_ADD(f1, 1, 'abc'), COLUMN_LIST(f1) FROM t1;
+--enable_result_log
+DROP TABLE t1;
+
+--echo #
+--echo # Some dynamic strings that caused crashes in the past
+--echo #
+
+set @a=0x0102000200030004000F0D086B74697A6A7176746F6B687563726A746E7A746A666163726C6F7A6B62636B6B756B666779666977617369796F67756C726D62677A72756E63626D78636D7077706A6F736C6D636464696770786B6371637A6A6A6463737A6A676879716462637178646C666E6B6C726A637677696E7271746C616D646368687A6C707869786D666F666261797470616A63797673737A796D74747475666B717573687A79696E7276706F796A6E767361796A6F6D646F6378677A667074746363736A796D67746C786F697873686464616265616A7A6F7168707A6B776B6376737A6B72666C6F666C69636163686F6B666D627166786A71616F;
+--error ER_DYN_COL_WRONG_FORMAT
+select column_add(@a, 3, "a");
+
+--echo #
+--echo # LP#781233 mysqld: decimal.c:1459: decimal_bin_size:
+--echo # Assertion `scale >= 0 && precision > 0 && scale <= precision' ...
+--echo #
+
+set @a=0x00020008000009000C2C010080;
+select COLUMN_GET(@a, 9 AS DECIMAL);
+select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL)));
+select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL(19,0))));
+
+select hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal)));
+select hex(COLUMN_CREATE(0, 0.0 as decimal));
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
index f2a82f40cff..e80d87d4047 100644
--- a/mysql-test/t/events_bugs.test
+++ b/mysql-test/t/events_bugs.test
@@ -1220,6 +1220,21 @@ SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS;
DROP EVENT ev1;
SET GLOBAL server_id = @old_server_id;
+#
+# Bug#11751148: show events shows events in other schema
+#
+
+CREATE DATABASE event_test12;
+USE event_test12;
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+CREATE DATABASE event_test1;
+USE event_test1;
+# Following show events should not show ev1
+SHOW EVENTS;
+DROP DATABASE event_test1;
+DROP DATABASE event_test12;
+
+
###########################################################################
#
# End of tests
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index c6c30b58341..1cfd78143c7 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -158,7 +158,10 @@ SELECT @@session.sql_mode INTO @old_sql_mode;
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
# EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE.
---error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
+# Before moving max/min optimization to optimize phase this statement
+# generated error, but as far as original query do not contain aggregate
+# function user should not see error
+# --error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
EXPLAIN EXTENDED SELECT 1 FROM t1
WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
SHOW WARNINGS;
@@ -265,3 +268,19 @@ DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo End of 5.1 tests.
+
+--echo #
+--echo # Bug#776295: EXPLAIN EXTENDED with always false multiple equality
+--echo # in the WHERE condition of a derived table
+--echo #
+
+CREATE TABLE t1 (a int) ;
+
+CREATE TABLE t2 (a int) ;
+INSERT INTO t2 VALUES (8);
+
+EXPLAIN EXTENDED
+SELECT * FROM ( SELECT t1.a FROM t1,t2 WHERE t2.a = t1.a ) AS t;
+
+DROP TABLE t1,t2;
+
diff --git a/mysql-test/t/func_encrypt_ucs2.test b/mysql-test/t/func_encrypt_ucs2.test
new file mode 100644
index 00000000000..920c7a6ad0d
--- /dev/null
+++ b/mysql-test/t/func_encrypt_ucs2.test
@@ -0,0 +1,12 @@
+-- source include/have_ssl.inc
+-- source include/have_ucs2.inc
+
+--echo #
+--echo # Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
+--echo #
+
+SELECT CHAR_LENGTH(DES_ENCRYPT(0, CHAR('1' USING ucs2)));
+SELECT CONVERT(DES_ENCRYPT(0, CHAR('1' USING ucs2)),UNSIGNED);
+
+SELECT CHAR_LENGTH(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' USING ucs2)));
+SELECT CONVERT(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' using ucs2)), UNSIGNED);
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 6e0a3fe2589..742b0955dca 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1063,7 +1063,8 @@ insert into t1 values
(02,2002,20020101,"2002-01-01 23:59:59"),
(60,2060,20600101,"2060-01-01 11:11:11"),
(70,1970,19700101,"1970-11-11 22:22:22"),
- (NULL,NULL,NULL,NULL);
+ (NULL,NULL,NULL,NULL),
+ (71,1971,19710101,"1971-11-11 22:22:22");
select min(f1),max(f1) from t1;
select min(f2),max(f2) from t1;
select min(f3),max(f3) from t1;
@@ -1117,6 +1118,28 @@ SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa');
--enable_result_log
+
+--echo #
+--echo # Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS
+--echo #
+
+CREATE TABLE t1 (a BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (18446668621106209655);
+SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+--echo #
+
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+--enable_metadata
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+--disable_metadata
+DROP TABLE t1;
+
+
--echo #
--echo End of 5.1 tests
@@ -1141,6 +1164,9 @@ INSERT INTO t1 VALUES (1,'c'),(2,NULL);
INSERT INTO t2 VALUES (3,'m'),(4,NULL);
INSERT INTO t3 VALUES (1,'n');
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
+
--echo
--echo #
--echo # 1) Test that subquery materialization is setup for query with
@@ -1188,10 +1214,6 @@ FROM t2);
--echo # 3) Test that subquery materialization is setup for query with
--echo # premature optimize() exit due to "Select tables optimized away"
--echo #
---echo # NOTE: The result of this query is actually wrong; it should be NULL
---echo # See BUG#47762. Even so, the test case is still needed to test
---echo # that the HAVING subquery does not crash the server
---echo #
SELECT MIN(pk)
FROM t1
WHERE pk=NULL
@@ -1250,6 +1272,8 @@ HAVING ('m') IN (
SELECT v
FROM t2);
+set @@optimizer_switch=@save_optimizer_switch;
+
--echo #
--echo # Cleanup for BUG#46680
--echo #
diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test
index 8142f57c0de..bbe9958685a 100644
--- a/mysql-test/t/func_if.test
+++ b/mysql-test/t/func_if.test
@@ -161,8 +161,9 @@ DROP TABLE t1;
#
CREATE TABLE t1 (c LONGTEXT);
-INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890');
+INSERT INTO t1 VALUES(1), (2), (3), (4), ('1234567890123456789');
+SELECT IF(1, CAST(c AS UNSIGNED), 0) FROM t1;
SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index 6efeb2866e6..08469b37967 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -555,5 +555,11 @@ SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP;
DROP TABLE t1;
--echo #
+--echo # Bug #11766212 59270: NOT IN (YEAR( ... ), ... ) PRODUCES MANY VALGRIND WARNINGS
+--echo #
+
+SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
+
+--echo #
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test
index 1204d04d9a0..f1fe52274b2 100644
--- a/mysql-test/t/func_like.test
+++ b/mysql-test/t/func_like.test
@@ -126,5 +126,10 @@ INSERT INTO t2 VALUES (1), (2), (3);
SELECT 1 FROM t2 JOIN t1 ON 1 LIKE a GROUP BY a;
DROP TABLE t1, t2;
+--echo #
+--echo # Bug#59149 valgrind warnings with "like .. escape .." function
+--echo #
+--error ER_WRONG_ARGUMENTS
+SELECT '' LIKE '1' ESCAPE COUNT(1);
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index c8ea11c7490..9d51a5c94f9 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -324,4 +324,29 @@ CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1
SHOW CREATE TABLE t1;
DROP TABLE t1;
+--echo #
+--echo # Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+--echo #
+
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
+--echo #
+
+SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test
index 1292c475732..5c31cee403a 100644
--- a/mysql-test/t/func_sapdb.test
+++ b/mysql-test/t/func_sapdb.test
@@ -91,8 +91,8 @@ select microsecond("1997-12-31 23:59:59.000001");
create table t1
select makedate(1997,1) as f1,
- addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
- addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
+ addtime(cast("1997-12-31 23:59:59.000001" as datetime(6)), "1 1:1:1.000002") as f2,
+ addtime(cast("23:59:59.999999" as time(6)) , "1 1:1:1.000002") as f3,
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
maketime(10,11,12) as f6,
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index fdcfbcf519e..92c4bae5327 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1369,4 +1369,15 @@ DROP TABLE t1;
SELECT '1' IN ('1', SUBSTRING(-9223372036854775809, 1));
SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3));
+--echo #
+--echo # Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail
+--echo # and other crashes
+--echo #
+CREATE TABLE t1 ( a TEXT );
+SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt';
+SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' );
+LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 6190c2f42fa..2d84202c6aa 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -15,7 +15,12 @@ select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_times
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
sec_to_time(time_to_sec("0:30:47")/6.21);
+select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899);
select sec_to_time(time_to_sec('-838:59:59'));
+select sec_to_time('9001.1'), sec_to_time('1234567890123.123');
+--replace_result e+042 e+42
+select sec_to_time(90011e-1), sec_to_time(1234567890123e30);
+select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999');
select now()-curdate()*1000000-curtime();
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
select strcmp(localtime(),concat(current_date()," ",current_time()));
@@ -27,6 +32,7 @@ select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
select month("2001-02-00"),year("2001-00-00");
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
+select TIME(230322), TIME(230322.33), TIME("230322.33");
# Test of week and yearweek
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
@@ -66,10 +72,10 @@ select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
select dayname("1962-03-03"),dayname("1962-03-03")+0;
select monthname("1972-03-04"),monthname("1972-03-04")+0;
-select time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+select time_format(000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+select time_format(010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+select time_format(131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
+select time_format(010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
@@ -539,6 +545,7 @@ DROP TABLE t1;
# Bug #20927: sec_to_time treats big unsigned as signed
#
# check if SEC_TO_TIME() handles BIGINT UNSIGNED values correctly
+--replace_regex /'1.8446.*e.*19'/'1.84467440737096e+19'/
SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
#
@@ -723,6 +730,7 @@ set time_zone= @@global.time_zone;
#
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
+select str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute;
#
# Bug #21103: DATE column not compared as DATE
@@ -819,6 +827,28 @@ SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
--error ER_PARSE_ERROR
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
+
+--echo #
+--echo # Bug #52315 part 2 : utc_date() crashes when system time > year 2037
+--echo #
+
+--disable_result_log
+--error ER_WRONG_VALUE_FOR_VAR
+SET TIMESTAMP=-147490000; SELECT UTC_TIMESTAMP();
+--error 0,ER_WRONG_VALUE_FOR_VAR
+SET TIMESTAMP=2147483648; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483646; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=2147483647; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=0; SELECT UTC_TIMESTAMP();
+--error ER_WRONG_VALUE_FOR_VAR
+SET TIMESTAMP=-1; SELECT UTC_TIMESTAMP();
+SET TIMESTAMP=1; SELECT UTC_TIMESTAMP();
+--enable_result_log
+
+#reset back the timestamp value
+SET TIMESTAMP=0;
+
+
--echo End of 5.0 tests
#
@@ -859,4 +889,180 @@ INSERT INTO t1 VALUES (''),('');
SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
DROP TABLE t1;
+--echo #
+--echo # Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
+--echo #
+
+SELECT STR_TO_DATE(SPACE(2),'1');
+
+--echo #
+--echo # Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
+--echo #
+
+SET GLOBAL SQL_MODE='';
+DO STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
+SET GLOBAL SQL_MODE=DEFAULT;
+
+--echo #
+--echo # Bug#11766087 59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
+--echo #
+
+SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
+
+--echo #
+--echo # Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+--echo #
+
+--disable_result_log
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+--enable_result_log
+
+--echo #
+--echo # Bug#11766124 59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
+--echo #
+
+SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
+
+--echo #
+--echo # Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
+--echo #
+
+SELECT DATE_FORMAT('0000-00-11', '%W');
+SELECT DATE_FORMAT('0000-00-11', '%a');
+SELECT DATE_FORMAT('0000-00-11', '%w');
+
--echo End of 5.1 tests
+
+select time('10:10:10') > 10;
+select time('10:10:10') > 1010;
+select time('10:10:09') > 101010;
+select time('10:10:10') > 101010;
+select time('10:10:11') > 101010;
+
+select time(' 1 02:03:04') + interval 9 microsecond;
+select time(' 1 02:03:04') - interval 9 microsecond;
+select time('-1 02:03:04') + interval 9 microsecond;
+select time('-1 02:03:04') - interval 9 microsecond;
+select time(' 1 02:03:04') + interval '4:4:4' hour_second;
+select time(' 1 02:03:04') - interval '4:4:4' hour_second;
+select time('-1 02:03:04') + interval '4:4:4' hour_second;
+select time('-1 02:03:04') - interval '4:4:4' hour_second;
+select time(' 1 02:03:04') + interval 2 day;
+select time(' 1 02:03:04') - interval 2 day;
+select time('-1 02:03:04') + interval 2 day;
+select time('-1 02:03:04') - interval 2 day;
+
+select time('10 02:03:04') + interval 30 day;
+select time('10 02:03:04') + interval 1 year;
+
+# specially constructed queries to reach obscure places in the code
+# not touched by the more "normal" queries (and to increase the coverage)
+select cast('131415.123e0' as time);
+select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
+select least(time('1:2:3'), '01:02:04', null) div 1;
+select truncate(least(time('1:2:3'), '01:02:04', null), 6);
+select cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1));
+select unix_timestamp(null);
+select truncate(date('2010-40-10'), 6);
+select extract(month from '2010-40-50');
+select subtime('0000-00-10 10:10:10', '30 10:00:00');
+
+#
+# lp:730637 Valgrind warnings in 5.1-micro
+#
+select cast(str_to_date(NULL, '%H:%i:%s') as time);
+
+create table t1 (f1 datetime, key (f1));
+insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49');
+select * from t1 where f1 > time('-23:00:06');
+drop table t1;
+
+#
+# lp:730627 TIME_to_ulonglong: Assertion `0' failed in 5.1-micro on wrong argument to MAKETIME
+#
+select maketime(20,61,10)+0;
+
+#
+# lp:731103 Assertion `maybe_null && item->null_value' failed with ORDER BY LAST_DAY()
+#
+create table t1 (f2 int not null) ;
+insert into t1 values (0),(0);
+select last_day(f2) from t1;
+select last_day(f2) from t1 where last_day(f2) is null;
+select * from t1 order by last_day (f2);
+drop table t1;
+
+#
+# lp:731815 Crash/valgrind warning Item::send with 5.1-micro
+#
+select convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetime)), 'UTC', 'Europe/Moscow');
+
+#
+# lp:736370 Datetime functions in subquery context cause wrong result and bogus warnings in mysql-5.1-micr
+#
+create table t1 (f1 integer, f2 date);
+insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05'),(6, '2011-05-06');
+select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
+drop table t1;
+
+#
+# lp:736791 Crash in make_truncated_value_warning with LEAST()/GREATEST/COALESCE
+#
+create table t1 (f1 timestamp);
+insert into t1 values ('0000-00-00 00:00:00');
+select least(1, f1) from t1;
+drop table t1;
+
+#
+# lp:737092 Assertion `item->null_value' failed in get_datetime_value in 5.1-micro
+#
+select now() > coalesce(time('21:43:24'), date('2010-05-03'));
+
+#
+# lp:737104 Crash in DTCollation::set in 5.1-micro
+#
+create table t1 (f1 timestamp);
+select * from t1 where f1 > f1 and f1 <=> timestampadd(hour, 9 , '2010-01-01 16:55:35');
+drop table t1;
+
+#
+# lp:737111 Different behavior for TIMESTAMPADD with 0000-00-00 argument in 5.1-micro
+#
+create table t1 (f1 date);
+insert into t1 values ('0000-00-00');
+select timestampadd(week, 1, f1) from t1;
+select timestampadd(week, 1, date("0000-00-00"));
+drop table t1;
+
+#
+# lp:737450 Second Assertion `item->null_value' failed in 5.1-micro
+#
+create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
+insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');
+select least(greatest(f3, f2, f4), f5) from t1;
+drop table t1;
+
+#
+# lp:737474 Wrong result with DAY(COALESCE(NULL)) in 5.1-micro
+#
+select day(coalesce(null));
+
+#
+# lp:738067 Crash in get_datetime_value() in 5.1-micro
+#
+select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
+
+#
+# lp:738091 cast(timestamp() AS time returns NULL for 0000-00-00 00:00:00 in 5.1-micro
+#
+create table t1 (f1 datetime);
+insert into t1 values ('0000-00-00 00:00:00');
+select cast(f1 AS time) from t1;
+drop table t1;
+
+select greatest(cast("0-0-0" as date), cast("10:20:05" as time));
+select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '0000-00-00';
+select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6));
+
+select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
+
diff --git a/mysql-test/t/func_time_hires.test b/mysql-test/t/func_time_hires.test
new file mode 100644
index 00000000000..4dcd51a85ba
--- /dev/null
+++ b/mysql-test/t/func_time_hires.test
@@ -0,0 +1,108 @@
+#
+# Test of timestamp with hires resolution;
+
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01.123456');
+
+--vertical_results
+select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
+select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
+ current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
+ time_to_sec('12:34:56.789');
+select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
+select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
+--horizontal_results
+--error ER_TOO_BIG_PRECISION
+select current_timestamp(7);
+--error ER_TOO_BIG_PRECISION
+select curtime(7);
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
+ sec_to_time(1234567e-2), now(), curtime(0),
+ utc_timestamp(1), utc_time(2), current_time(3),
+ current_timestamp(4), localtime(5), localtimestamp(6),
+ time_to_sec(123456), time_to_sec('12:34:56.789');
+show create table t1;
+--query_vertical select * from t1
+drop table t1;
+
+--query_vertical select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));
+--query_vertical select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));
+
+select sec_to_time(3020399.99999), sec_to_time(3020399.999999), sec_to_time(3020399.9999999);
+select sec_to_time(-3020399.99999), sec_to_time(-3020399.999999), sec_to_time(-3020399.9999999);
+select 20010101000203.000000004 + interval 1 day;
+select 20010101000203.4 + interval 1 day;
+#
+# precision of expressions
+#
+set @a=cast('2011-01-02 12:13:14' as datetime);
+select @a + interval 1 minute;
+select @a + interval 10 microsecond;
+select @a + interval 10 microsecond + interval 999990 microsecond;
+
+#
+# CAST
+#
+set @a='2011-01-02 12:13:14.123456';
+create table t1 select CAST(@a AS DATETIME) as dauto,
+ CAST(@a AS DATETIME(0)) as d0,
+ CAST(@a AS DATETIME(1)) as d1,
+ CAST(@a AS DATETIME(2)) as d2,
+ CAST(@a AS DATETIME(3)) as d3,
+ CAST(@a AS DATETIME(4)) as d4,
+ CAST(@a AS DATETIME(5)) as d5,
+ CAST(@a AS DATETIME(6)) as d6,
+ CAST(@a AS TIME) as tauto,
+ CAST(@a AS TIME(0)) as t0,
+ CAST(@a AS TIME(1)) as t1,
+ CAST(@a AS TIME(2)) as t2,
+ CAST(@a AS TIME(3)) as t3,
+ CAST(@a AS TIME(4)) as t4,
+ CAST(@a AS TIME(5)) as t5,
+ CAST(@a AS TIME(6)) as t6;
+show create table t1;
+--query_vertical select * from t1
+drop table t1;
+explain extended select cast(cast(@a as datetime(4)) as time(0));
+select cast(cast(@a as time(2)) as time(6));
+
+--error ER_TOO_BIG_PRECISION
+select CAST(@a AS DATETIME(7));
+
+#
+# CONVERT_TZ
+#
+SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
+SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
+SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
+SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
+
+#
+# Field::store_time()
+#
+create table t1 (a varchar(200));
+insert t1 values (now(6));
+select * from t1;
+drop table t1;
+
+#
+# lp:736358 Unexpected increased timestamp resolution with UNION
+#
+# timestamp(6) case is fixed:
+create table t1 (f1 timestamp(6));
+insert into t1 values ('2002-07-15 21:00:00');
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+alter table t1 modify f1 timestamp;
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+# but the effect cannot be eliminated completely:
+alter table t1 modify f1 varchar(100);
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+drop table t1;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 416a40630bc..fa6a7dc4675 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -361,7 +361,7 @@ t1 where object_id=85998;
# Expected result is 36.3310176346905, but IA64 returns 36.3310176346904
# due to fused multiply-add instructions.
---replace_result 36.3310176346904 36.3310176346905
+--replace_result 36.3310176346904 36.3310176346905 -114.87787186923326 -114.87787186923313 36.33101763469053 36.33101763469059 36.33101763469043 36.33101763469059
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85984;
@@ -735,6 +735,28 @@ SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000
SET @a=POLYFROMWKB(@a);
+#
+# Bug #57321 crashes and valgrind errors from spatial types
+#
+
+create table t1(a polygon NOT NULL)engine=myisam;
+insert into t1 values (geomfromtext("point(0 1)"));
+insert into t1 values (geomfromtext("point(1 0)"));
+select * from (select polygon(t1.a) as p from t1 order by t1.a) d;
+drop table t1;
+
+
+--echo #
+--echo # Test for bug #59888 "debug assertion when attempt to create spatial index
+--echo # on char > 31 bytes".
+--echo #
+create table t1(a char(32) not null) engine=myisam;
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_SPATIAL_MUST_HAVE_GEOM_COL
+create spatial index i on t1 (a);
+drop table t1;
+
+
--echo End of 5.1 tests
#
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index f021e46f4ae..e17c17f446e 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -1396,6 +1396,183 @@ DROP USER testuser@localhost;
use test;
--echo
+
+--echo #
+--echo # Test for bug #36544 "DROP USER does not remove stored function
+--echo # privileges".
+--echo #
+create database mysqltest1;
+create function mysqltest1.f1() returns int return 0;
+create procedure mysqltest1.p1() begin end;
+--echo #
+--echo # 1) Check that DROP USER properly removes privileges on both
+--echo # stored procedures and functions.
+--echo #
+create user mysqluser1@localhost;
+grant execute on function mysqltest1.f1 to mysqluser1@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser1@localhost;
+
+--echo # Quick test that granted privileges are properly reflected
+--echo # in privilege tables and in in-memory structures.
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con1' as 'mysqluser1@localhost'.
+--connect (bug36544_con1,localhost,mysqluser1,,)
+call mysqltest1.p1();
+select mysqltest1.f1();
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+drop user mysqluser1@localhost;
+
+--echo #
+--echo # Test that dropping of user is properly reflected in
+--echo # both privilege tables and in in-memory structures.
+--echo #
+--echo # Switch to connection 'bug36544_con1'.
+--connection bug36544_con1
+--echo # The connection cold be alive but should not be able to
+--echo # access to any of the stored routines.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--disconnect bug36544_con1
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Now create user with the same name and check that he
+--echo # has not inherited privileges.
+create user mysqluser1@localhost;
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con2' as 'mysqluser1@localhost'.
+--connect (bug36544_con2,localhost,mysqluser1,,)
+--echo # Newly created user should not be able to access any of the routines.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+
+--echo #
+--echo # 2) Check that RENAME USER properly updates privileges on both
+--echo # stored procedures and functions.
+--echo #
+grant execute on function mysqltest1.f1 to mysqluser1@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser1@localhost;
+--echo #
+--echo # Create one more user to make in-memory hashes non-trivial.
+--echo # User names 'mysqluser11' and 'mysqluser10' were selected
+--echo # to trigger bug discovered during code inspection.
+create user mysqluser11@localhost;
+grant execute on function mysqltest1.f1 to mysqluser11@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser11@localhost;
+--echo # Also create a couple of tables to test for another bug
+--echo # discovered during code inspection (again table names were
+--echo # chosen especially to trigger the bug).
+create table mysqltest1.t11 (i int);
+create table mysqltest1.t22 (i int);
+grant select on mysqltest1.t22 to mysqluser1@localhost;
+grant select on mysqltest1.t11 to mysqluser1@localhost;
+
+--echo # Quick test that granted privileges are properly reflected
+--echo # in privilege tables and in in-memory structures.
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Switch to connection 'bug36544_con2'.
+--connection bug36544_con2
+call mysqltest1.p1();
+select mysqltest1.f1();
+select * from mysqltest1.t11;
+select * from mysqltest1.t22;
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+rename user mysqluser1@localhost to mysqluser10@localhost;
+
+--echo #
+--echo # Test that there are no privileges left for mysqluser1.
+--echo #
+--echo # Switch to connection 'bug36544_con2'.
+--connection bug36544_con2
+--echo # The connection cold be alive but should not be able to
+--echo # access to any of the stored routines or tables.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t11;
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t22;
+--disconnect bug36544_con2
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Now create user with the old name and check that he
+--echo # has not inherited privileges.
+create user mysqluser1@localhost;
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con3' as 'mysqluser1@localhost'.
+--connect (bug36544_con3,localhost,mysqluser1,,)
+--echo # Newly created user should not be able to access to any of the
+--echo # stored routines or tables.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t11;
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t22;
+--disconnect bug36544_con3
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Now check that privileges became associated with a new user
+--echo # name - mysqluser10.
+--echo #
+show grants for mysqluser10@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser10' and host='localhost';
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser10' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con4' as 'mysqluser10@localhost'.
+--connect (bug36544_con4,localhost,mysqluser10,,)
+call mysqltest1.p1();
+select mysqltest1.f1();
+select * from mysqltest1.t11;
+select * from mysqltest1.t22;
+--disconnect bug36544_con4
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Clean-up.
+drop user mysqluser1@localhost;
+drop user mysqluser10@localhost;
+drop user mysqluser11@localhost;
+drop database mysqltest1;
+
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 394eb8d7c68..44af2ca27a2 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1264,4 +1264,41 @@ ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;
DROP TABLE t1;
+--echo #
+--echo # Bug#59839: Aggregation followed by subquery yields wrong result
+--echo #
+
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c INT,
+ KEY (a, b)
+);
+
+INSERT INTO t1 VALUES
+ ( 1, 1, 1 ),
+ ( 1, 2, 2 ),
+ ( 1, 3, 3 ),
+ ( 1, 4, 6 ),
+ ( 1, 5, 5 ),
+ ( 1, 9, 13 ),
+
+ ( 2, 1, 6 ),
+ ( 2, 2, 7 ),
+ ( 2, 3, 8 );
+
+EXPLAIN
+SELECT a, AVG(t1.b),
+(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c,
+(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c
+FROM t1 GROUP BY a;
+
+SELECT a, AVG(t1.b),
+(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c,
+(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c
+FROM t1 GROUP BY a;
+
+DROP TABLE t1;
+
+
--echo # End of 5.1 tests
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 8ab7e1c9cb4..1ba06bee942 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -406,11 +406,61 @@ explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c = t1.c )
group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c = t1.c )
+group by a1,a2,b;
+
# the sub-select is unrelated to MIN/MAX
explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c > 'b1' )
group by a1,a2,b;
+select a1,a2,b,min(c),max(c) from t1
+where exists ( select * from t2 where t2.c > 'b1' )
+group by a1,a2,b;
+
+# correlated subselect that doesn't reference the min/max argument
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+ where t2.c in (select c from t3 where t3.c > t1.b) and
+ t2.c > 'b1' )
+group by a1,a2,b;
+
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+ where t2.c in (select c from t3 where t3.c > t1.b) and
+ t2.c > 'b1' )
+group by a1,a2,b;
+
+# correlated subselect that references the min/max argument
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
+group by a1,a2,b;
+
+explain select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+ where t2.c in (select c from t3 where t3.c > t1.c) and
+ t2.c > 'b1' )
+group by a1,a2,b;
+
+select a1,a2,b,c,min(c), max(c) from t1
+where exists ( select * from t2
+ where t2.c in (select c from t3 where t3.c > t1.c) and
+ t2.c > 'b1' )
+group by a1,a2,b;
+
# A,B,C) Predicates referencing mixed classes of attributes
# plans
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index c808e747523..2ed8b40b858 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -564,4 +564,30 @@ HAVING field1 < 7;
DROP TABLE t1,t2;
+--echo #
+--echo # Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
+--echo #
+
+CREATE TABLE t1 (f1 INT, f2 INT);
+INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
+CREATE TABLE t2 (f1 INT, f2 INT);
+
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+
+SELECT t1.f1
+FROM t1
+HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+
+DROP TABLE t1,t2;
+
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/index_intersect.test b/mysql-test/t/index_intersect.test
index 9ea2f5e3101..c2834e685eb 100644
--- a/mysql-test/t/index_intersect.test
+++ b/mysql-test/t/index_intersect.test
@@ -136,7 +136,8 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'B%';
---replace_column 9 #
+--replace_column 7 # 9 #
+--replace_result Population,Country,Name Population,Name,Country
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
diff --git a/mysql-test/t/innodb_mrr.test b/mysql-test/t/innodb_mrr.test
index 7a3dc9f668e..2ae8744bca0 100644
--- a/mysql-test/t/innodb_mrr.test
+++ b/mysql-test/t/innodb_mrr.test
@@ -370,14 +370,14 @@ set join_buffer_size=@my_save_join_buffer_size;
--echo #
create table t1 (pk int primary key, b int, c int default 0, index idx(b)) engine=innodb;
insert into t1(pk,b) values (3, 30), (2, 20), (9, 90), (7, 70), (4, 40), (5, 50), (10, 100), (12, 120);
-set @my_save_optimizer_use_mrr=@@optimizer_use_mrr;
-set optimizer_use_mrr='disable';
+set @bug665669_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=off';
explain select * from t1 where b > 1000;
--echo # The following two must produce indentical results:
select * from t1 where pk < 2 or pk between 3 and 4;
select * from t1 where pk < 2 or pk between 3 and 4;
drop table t1;
-set optimizer_use_mrr = @my_save_optimizer_use_mrr;
+set optimizer_switch = @bug665669_tmp;
--echo #
--echo # Bug#43360 - Server crash with a simple multi-table update
--echo #
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 53eae4fdfaa..ca1bb168728 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -613,5 +613,33 @@ DROP TABLE t1;
let $MYSQLD_DATADIR= `select @@datadir`;
remove_file $MYSQLD_DATADIR/test/tmpp2.txt;
+--echo #
+--echo # Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
+--echo #
+
+CREATE TABLE t1(f1 INT);
+EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
+--disable_warnings
+LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
+--enable_warnings
+
+DROP TABLE t1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t1.dat;
+
+--echo #
+--echo # Bug#11765141 - 58072: LOAD DATA INFILE: LEAKS IO CACHE MEMORY
+--echo # WHEN ERROR OCCURS
+--echo #
+
+--let $file=$MYSQLTEST_VARDIR/tmp/bug11735141.txt
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT '1\n' INTO DUMPFILE '$file'
+
+create table t1(a point);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+--eval LOAD DATA INFILE '$file' INTO TABLE t1
+drop table t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 30f4d4d6c61..fdacb9c57d4 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -245,3 +245,28 @@ UNLOCK TABLES;
DROP TABLE t1,t2;
--echo End of 5.1 tests.
+
+#
+# Test concurrent lock and read locks
+# This gave a warning:
+# Warning at 'read lock with old write lock' for lock: 5:
+# Found lock of type 8 that is write and read locked. Read_no_write_count: 1
+#
+create table t1 (a int) engine=myisam;
+lock tables t1 write concurrent, t1 as t2 read;
+connect (con1,localhost,root,,);
+connection con1;
+lock tables t1 read local;
+unlock tables;
+connection default;
+unlock tables;
+connection con1;
+lock tables t1 read local;
+connection default;
+lock tables t1 write concurrent, t1 as t2 read;
+unlock tables;
+connection con1;
+unlock tables;
+disconnect con1;
+connection default;
+drop table t1;
diff --git a/mysql-test/t/lock_multi_bug38499.test b/mysql-test/t/lock_multi_bug38499.test
index 3d3f084ba5f..b812984e516 100644
--- a/mysql-test/t/lock_multi_bug38499.test
+++ b/mysql-test/t/lock_multi_bug38499.test
@@ -16,7 +16,9 @@ connect (writer,localhost,root,,);
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1( a INT, b INT );
+CREATE TABLE t2( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
--echo # 1. test regular tables
--echo # 1.1. test altering of columns that multiupdate doesn't use
@@ -28,7 +30,7 @@ while ($i) {
--dec $i
--connection writer
- send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
+ send UPDATE t1, (SELECT 1 FROM t2 t1i) d SET a = 0 WHERE 1=0;
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
@@ -41,7 +43,7 @@ while ($i) {
--echo # 1.1.2. PS mode
--connection writer
-PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
+PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t2 t1i) d SET a = 0 WHERE 1=0';
let $i = 100;
while ($i) {
@@ -75,7 +77,7 @@ while ($i) {
UPDATE t1 SET a=b;
--connection writer
---send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
+--send UPDATE t1, (SELECT 1 FROM t2 t1i) d SET a = 0 WHERE 1=0;
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
@@ -100,7 +102,7 @@ while ($i) {
UPDATE t1 SET a=b;
--connection writer
- PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
+ PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t2 t1i) d SET a = 0 WHERE 1=0';
--send EXECUTE stmt
--connection locker
@@ -210,7 +212,7 @@ while ($i) {
}
--enable_query_log
--connection default
-DROP TABLE t1;
+DROP TABLE t1,t2;
# Close connections
diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test
index 17f8abb75f3..1df09524140 100644
--- a/mysql-test/t/lock_sync.test
+++ b/mysql-test/t/lock_sync.test
@@ -862,6 +862,60 @@ disconnect con2;
set @@global.concurrent_insert= @old_concurrent_insert;
+--echo #
+--echo # Bug#11763784 56541: ASSERTION TABLE->DB_STAT FAILED IN
+--echo # SQL_BASE.CC::OPEN_TABLE() DURING I_S Q
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (1), (2);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
+
+connect (con1, localhost, root);
+--echo # Connection con2
+connect (con2, localhost, root);
+SET DEBUG_SYNC= 'before_open_in_get_all_tables SIGNAL is_waits WAIT_FOR is_cont';
+--echo # Sending:
+--send SELECT * FROM information_schema.table_constraints JOIN t1 ON table_name = a
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= 'now WAIT_FOR is_waits';
+--echo # Sending:
+--send DROP TRIGGER t1_bi
+
+--echo # Connection default
+connection default;
+--echo # Wait until DROP TRIGGER is blocked, waiting for t1
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table" AND
+ info = "DROP TRIGGER t1_bi";
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL is_cont';
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping SELECT * FROM information_schema.table_constraints JOIN t1...
+--reap
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping DROP TRIGGER t1_bi
+--reap
+
+--echo # Connection default
+connection default;
+DROP TABLE t1;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
+
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test
index af6c34dec37..01528f3658d 100644
--- a/mysql-test/t/log_tables.test
+++ b/mysql-test/t/log_tables.test
@@ -283,7 +283,7 @@ drop table mysql.slow_log;
use mysql;
CREATE TABLE `general_log` (
- `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
+ `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
@@ -293,11 +293,11 @@ CREATE TABLE `general_log` (
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
CREATE TABLE `slow_log` (
- `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
+ `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
- `query_time` time NOT NULL,
- `lock_time` time NOT NULL,
+ `query_time` time(6) NOT NULL,
+ `lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
@@ -710,10 +710,10 @@ DROP DATABASE IF EXISTS `db_17876`;
CREATE DATABASE db_17876;
CREATE TABLE `db_17876.slow_log_data` (
- `start_time` timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `start_time` timestamp(6) default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`user_host` mediumtext ,
- `query_time` time ,
- `lock_time` time ,
+ `query_time` time(6) ,
+ `lock_time` time(6) ,
`rows_sent` int(11) ,
`rows_examined` int(11) ,
`db` varchar(512) default NULL,
@@ -724,7 +724,7 @@ CREATE TABLE `db_17876.slow_log_data` (
);
CREATE TABLE `db_17876.general_log_data` (
- `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext,
`thread_id` int(11) DEFAULT NULL,
`server_id` int(11) DEFAULT NULL,
@@ -736,7 +736,7 @@ DELIMITER //;
CREATE procedure `db_17876.archiveSlowLog`()
BEGIN
- DECLARE start_time, query_time, lock_time CHAR(20);
+ DECLARE start_time, query_time, lock_time CHAR(28);
DECLARE user_host MEDIUMTEXT;
DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT;
DECLARE dbname MEDIUMTEXT;
@@ -776,7 +776,7 @@ END //
CREATE procedure `db_17876.archiveGeneralLog`()
BEGIN
- DECLARE event_time CHAR(20);
+ DECLARE event_time CHAR(28);
DECLARE user_host, argument MEDIUMTEXT;
DECLARE thread_id, server_id INT;
DECLARE sql_text BLOB;
diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test
index 521df01cc9b..b595d4b1775 100644
--- a/mysql-test/t/lowercase_table2.test
+++ b/mysql-test/t/lowercase_table2.test
@@ -150,3 +150,40 @@ select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES
where TABLE_SCHEMA ='mysqltest_LC2';
use test;
drop database mysqltest_LC2;
+
+
+--echo #
+--echo # Bug #11758687: 50924: object names not resolved correctly
+--echo # on lctn2 systems
+--echo #
+
+CREATE DATABASE BUP_XPFM_COMPAT_DB2;
+
+CREATE TABLE BUP_XPFM_COMPAT_DB2.TABLE2 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.table1 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE bup_xpfm_compat_db2.table3 (c13 INT) DEFAULT CHARSET latin1;
+
+delimiter |;
+#
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.trigger1 AFTER INSERT
+ ON BUP_XPFM_COMPAT_DB2.table1 FOR EACH ROW
+ update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TRIGGER2 AFTER INSERT
+ ON BUP_XPFM_COMPAT_DB2.TABLE2 FOR EACH ROW
+ update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TrigGer3 AFTER INSERT
+ ON BUP_XPFM_COMPAT_DB2.TaBle3 FOR EACH ROW
+ update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+delimiter ;|
+
+SELECT trigger_schema, trigger_name, event_object_table FROM
+INFORMATION_SCHEMA.TRIGGERS
+ WHERE trigger_schema COLLATE utf8_bin = 'BUP_XPFM_COMPAT_DB2'
+ ORDER BY trigger_schema, trigger_name;
+
+DROP DATABASE BUP_XPFM_COMPAT_DB2;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/maria_mrr.test b/mysql-test/t/maria_mrr.test
index f0e0dd1144a..233186fe5bd 100644
--- a/mysql-test/t/maria_mrr.test
+++ b/mysql-test/t/maria_mrr.test
@@ -92,7 +92,6 @@ DROP TABLE t1,t2,t3;
--echo # (works only on Maria because we need 1024-byte long key)
--echo #
-SET SESSION optimizer_use_mrr = 'force';
SET SESSION join_cache_level = 6;
SET SESSION join_buffer_size = 1024;
CREATE TABLE t1 (
diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test
index 9bfb47c53be..115c320003a 100644
--- a/mysql-test/t/metadata.test
+++ b/mysql-test/t/metadata.test
@@ -143,3 +143,11 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.0 tests
+
+--enable_metadata
+
+#
+# lp:740173 5.1-micro reports incorrect Length metadata for TIME expressions
+#
+select cast('01:01:01' as time), cast('01:01:01' as time(2));
+
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 6a5736913b4..58a614e3a11 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -685,6 +685,9 @@ CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
CREATE TABLE t1 (f1 DATE);
INSERT INTO t1 VALUES('2001-01-01');
UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
+CREATE view v1 as SELECT f1() FROM t1;
+UPDATE (SELECT 1 FROM t1 WHERE f1 = (select * from v1)) x, t1 SET f1 = 1;
+DROP VIEW v1;
DROP FUNCTION f1;
DROP TABLE t1;
diff --git a/mysql-test/t/myisam_crash_before_flush_keys.test b/mysql-test/t/myisam_crash_before_flush_keys.test
index 1860ddd27e3..ea41b3559ca 100644
--- a/mysql-test/t/myisam_crash_before_flush_keys.test
+++ b/mysql-test/t/myisam_crash_before_flush_keys.test
@@ -8,6 +8,9 @@
--echo # Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+
let $MYSQLD_DATADIR= `select @@datadir`;
SET GLOBAL delay_key_write=ALL;
CREATE TABLE t1(a INT,
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index 4f634cdda05..d1ae90be864 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -413,6 +413,12 @@ drop table t1;
--echo
--exec $MYSQL --skip-column-names --vertical test -e "select 1 as a"
+#
+# Bug#57450: mysql client enter in an infinite loop if the standard input is a directory
+#
+--error 1
+--exec $MYSQL < .
+
--echo
--echo #
diff --git a/mysql-test/t/mysqladmin.test b/mysql-test/t/mysqladmin.test
index 839ecf00b60..a2b12dbc9b6 100644
--- a/mysql-test/t/mysqladmin.test
+++ b/mysql-test/t/mysqladmin.test
@@ -33,3 +33,15 @@ EOF
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
+
+--echo #
+--echo # Bug#58221 : mysqladmin --sleep=x --count=x keeps looping
+--echo #
+
+--echo # Executing mysqladmin with --sleep=1 and --count=2.
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --sleep=1 --count=2 ping > $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
+--echo # Done.
+--echo # Displaying the output :
+--cat_file $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
+
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index bf371443779..6a73a170d12 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -558,3 +558,23 @@ exec $MYSQL_BINLOG $MYSQLD_DATADIR/$master_binlog | $MYSQL test 2>&1;
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
source include/show_binlog_events.inc;
+#
+# BUG#11766427 BUG#59530: Filter by server id in mysqlbinlog fails
+# This test checks that the format description log event is not
+# filtered out by the --server-id option.
+#
+RESET MASTER;
+USE test;
+CREATE TABLE t1 (a INT);
+--let $old_server_id= `SELECT @@GLOBAL.SERVER_ID`
+SET GLOBAL SERVER_ID = 2;
+DROP TABLE t1;
+--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
+FLUSH LOGS;
+# The following should only create t1, not drop it.
+--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/$master_binlog | $MYSQL
+SHOW TABLES IN test;
+# The following should only drop t1, not create it.
+--exec $MYSQL_BINLOG --server-id=2 $MYSQLD_DATADIR/$master_binlog | $MYSQL
+SHOW TABLES IN test;
+eval SET GLOBAL SERVER_ID = $old_server_id;
diff --git a/mysql-test/t/mysqlbinlog_row_big.test b/mysql-test/t/mysqlbinlog_row_big.test
index 75f3b90269f..ffd1b79af34 100644
--- a/mysql-test/t/mysqlbinlog_row_big.test
+++ b/mysql-test/t/mysqlbinlog_row_big.test
@@ -79,8 +79,8 @@ eval CREATE TABLE t1 (
--echo # Insert some big rows.
--echo #
---echo 256MB
-INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
+--echo 64MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 4194304));
--echo 32MB
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index eaf9d168da0..99537618011 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -6,6 +6,10 @@ call mtr.add_suppression("@003f.frm' \\(errno: 22\\)");
# Binlog is required
--source include/have_log_bin.inc
+# utf8 is required
+let collation=utf8_unicode_ci;
+--source include/have_collation.inc
+
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -2167,6 +2171,38 @@ SELECT LENGTH(a) FROM t2;
DROP TABLE t1, t2;
###########################################################################
+
+--echo #
+--echo # Bug #13618 : mysqldump --xml ommit comment on table field
+--echo #
+
+CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
+--exec $MYSQL_DUMP --compact --skip-create --xml test
+DROP TABLE `comment_table`;
+
+--echo #
+--echo # BUG#11766310 : 59398: MYSQLDUMP 5.1 CAN'T HANDLE A DASH ("-") IN
+--echo # DATABASE NAMES IN ALTER DATABASE
+--echo #
+
+CREATE DATABASE `test-database`;
+USE `test-database`;
+CREATE TABLE `test` (`c1` VARCHAR(10)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DELIMITER |;
+CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END |
+DELIMITER ;|
+
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+
+--exec $MYSQL_DUMP --quote-names --compact test-database
+
+DROP DATABASE `test-database`;
+# Switching back to test database.
+USE `test`;
+
--echo #
--echo # End of 5.1 tests
--echo #
diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test
index 28042f62fe6..757d2813483 100644
--- a/mysql-test/t/mysqlslap.test
+++ b/mysql-test/t/mysqlslap.test
@@ -53,3 +53,18 @@ CREATE PROCEDURE p1() SELECT 1;
--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1
DROP PROCEDURE p1;
+
+
+--echo #
+--echo # Bug #11765157 - 58090: mysqlslap drops schema specified in
+--echo # create_schema if auto-generate-sql also set.
+--echo #
+
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --concurrency=5 --iterations=20 --auto-generate-sql
+--echo # 'bug58090' database should not be present.
+SHOW DATABASES;
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --no-drop --auto-generate-sql
+--echo # 'bug58090' database should be present.
+SHOW DATABASES;
+DROP DATABASE bug58090;
+
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 2e04d96aaab..51d12130b13 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -867,6 +867,12 @@ insert into t1 values ('`select 42`');
let $a= `select * from t1`;
# This should output `select 42`, not evaluate it again to 42
echo $a;
+insert into t1 values ('$dollar');
+# These should also output the string without evaluating it.
+let $a= query_get_value(select * from t1 order by a, a, 1);
+echo $a;
+let $a= query_get_value(select * from t1 order by a, a, 2);
+echo $a;
drop table t1;
--error 1
diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test
index c556445bbc9..714bf2e9c96 100644
--- a/mysql-test/t/not_embedded_server.test
+++ b/mysql-test/t/not_embedded_server.test
@@ -42,4 +42,14 @@ select 1;
SHOW VARIABLES like 'slave_skip_errors';
+--echo #
+--echo # Bug#58026: massive recursion and crash in regular expression handling
+--echo #
+
+--disable_result_log
+--error ER_STACK_OVERRUN_NEED_MORE
+SELECT '1' RLIKE RPAD('1', 10000, '(');
+--enable_result_log
+
+
# End of 5.1 tests
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index e725e107c48..1b7d22cc677 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -1,11 +1,17 @@
#
-# Bug with order by
+# Testing ORDER BY
#
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
+
+#
+# Test old ORDER BY bug
+#
+
CREATE TABLE t1 (
id int(6) DEFAULT '0' NOT NULL,
idservice int(5),
@@ -853,7 +859,6 @@ set session max_sort_length= 2180;
select * from t1 order by b;
drop table t1;
-
--echo #
--echo # Bug #39844: Query Crash Mysql Server 5.0.67
--echo #
@@ -1368,6 +1373,14 @@ SELECT d FROM t3 AS t1, t2 AS t2
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
ORDER BY t2.c LIMIT 1;
+SELECT t1.*,t2.* FROM t1, t2
+WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
+ORDER BY t2.c LIMIT 5;
+
+SELECT t1.*, t2.* FROM t3 AS t1, t2 AS t2
+WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
+ORDER BY t2.c LIMIT 5;
+
DROP TABLE t1,t2,t3;
@@ -1516,4 +1529,21 @@ SELECT * FROM t1 r JOIN t1 s ON r.a = s.a
DROP TABLE t1;
+--echo #
+--echo # Bug #59110: Memory leak of QUICK_SELECT_I allocated memory
+--echo # and
+--echo # Bug #59308: Incorrect result for
+--echo SELECT DISTINCT <col>... ORDER BY <col> DESC
+--echo
+--echo # Use Valgrind to detect #59110!
+--echo #
+
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/parser_precedence.test b/mysql-test/t/parser_precedence.test
index 484c8759779..7b69bc9c6da 100644
--- a/mysql-test/t/parser_precedence.test
+++ b/mysql-test/t/parser_precedence.test
@@ -3,6 +3,8 @@
drop table if exists t1_30237_bool;
--enable_warnings
+set sql_mode=NO_UNSIGNED_SUBTRACTION;
+
create table t1_30237_bool(A boolean, B boolean, C boolean);
insert into t1_30237_bool values
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index e0d420f2558..3c3810b5296 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -15,6 +15,49 @@ drop table if exists t1, t2;
--enable_warnings
--echo #
+--echo # Bug#59297: Can't find record in 'tablename' on update inner join
+--echo #
+
+CREATE TABLE t1 (
+a char(2) NOT NULL,
+b char(2) NOT NULL,
+c int(10) unsigned NOT NULL,
+d varchar(255) DEFAULT NULL,
+e varchar(1000) DEFAULT NULL,
+PRIMARY KEY (a, b, c),
+KEY (a),
+KEY (a, b)
+)
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 20 */;
+
+INSERT INTO t1 (a, b, c, d, e) VALUES
+('07', '03', 343, '1', '07_03_343'),
+('01', '04', 343, '2', '01_04_343'),
+('01', '06', 343, '3', '01_06_343'),
+('01', '07', 343, '4', '01_07_343'),
+('01', '08', 343, '5', '01_08_343'),
+('01', '09', 343, '6', '01_09_343'),
+('03', '03', 343, '7', '03_03_343'),
+('03', '06', 343, '8', '03_06_343'),
+('03', '07', 343, '9', '03_07_343'),
+('04', '03', 343, '10', '04_03_343'),
+('04', '06', 343, '11', '04_06_343'),
+('05', '03', 343, '12', '05_03_343'),
+('11', '03', 343, '13', '11_03_343'),
+('11', '04', 343, '14', '11_04_343')
+;
+
+UPDATE t1 AS A,
+(SELECT '03' AS a, '06' AS b, 343 AS c, 'last' AS d) AS B
+SET A.e = B.d
+WHERE A.a = '03'
+AND A.b = '06'
+AND A.c = 343;
+
+DROP TABLE t1;
+
+--echo #
--echo # Bug#57113: ha_partition::extra(ha_extra_function):
--echo # Assertion `m_extra_cache' failed
CREATE TABLE t1
@@ -2149,3 +2192,22 @@ DROP TABLE t1;
SET GLOBAL myisam_use_mmap=default;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # BUG#598247: partition.test produces valgrind errors in 5.3-based branches
+--echo #
+CREATE TABLE t1 (
+ a INT DEFAULT NULL,
+ b DOUBLE DEFAULT NULL,
+ c INT DEFAULT NULL,
+ KEY idx2(b,a)
+) engine=myisam PARTITION BY HASH(c) PARTITIONS 3;
+
+INSERT INTO t1 VALUES (6,8,9);
+INSERT INTO t1 VALUES (6,8,10);
+
+SELECT 1 FROM t1 JOIN t1 AS t2 USING (a);
+
+drop table t1;
+
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index b222b02252b..7e574fd6a42 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -11,6 +11,21 @@ drop table if exists t1;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
+--echo # Bug#57924: crash when creating partitioned table with
+--echo # multiple columns in the partition key
+--echo #
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, a);
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(A, b);
+DROP TABLE t1;
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
+PARTITION BY KEY(a, b, A);
+
+
+--echo #
--echo # Bug#54483: valgrind errors when making warnings for multiline inserts
--echo # into partition
--echo #
@@ -673,7 +688,6 @@ PARTITION BY HASH (TIME_TO_SEC(a));
CREATE TABLE t1 (a INT)
PARTITION BY HASH (TIME_TO_SEC(a));
-
--echo #
--echo # Bug#49161: Out of memory; restart server and try again (needed 2 bytes)
--echo #
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 0b8928b6038..55ddad701c4 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -3107,3 +3107,15 @@ DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo End of 5.1 tests.
+
+#
+# restoring of the Item tree in BETWEEN with dates
+#
+prepare stmt from "select date('2010-10-10') between '2010-09-09' and ?";
+set @a='2010-11-11';
+execute stmt using @a;
+execute stmt using @a;
+set @a='2010-08-08';
+execute stmt using @a;
+execute stmt using @a;
+
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 24487db826a..0d57a5640bf 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -1255,6 +1255,7 @@ set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size=default;
+set local query_cache_type=default;
#
# Bug#33756 - query cache with concurrent_insert=0 appears broken
@@ -1515,3 +1516,23 @@ SET GLOBAL query_cache_size= default;
--echo End of 5.1 tests
+--echo New query cache switching OFF mechanism test
+set global query_cache_size=1024*1024*20;
+set global query_cache_type=on;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+set global query_cache_size=0;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+set global query_cache_size=1024*1024*20;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+set global query_cache_type=off;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+set global query_cache_type=on;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+set local query_cache_type= on;
+select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
+
+
+--echo restore defaults
+SET GLOBAL query_cache_type= default;
+SET GLOBAL query_cache_size= default;
+SET LOCAL query_cache_type= default;
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index 0ad3d3e8504..7206235e3e2 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -1325,4 +1325,80 @@ SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
DROP TABLE t1;
+--echo #
+--echo # Bug #57030: 'BETWEEN' evaluation is incorrect
+--echo #
+
+# Test some BETWEEN predicates which does *not* follow the
+# 'normal' pattern of <field> BETWEEN <low const> AND <high const>
+
+CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
+CREATE UNIQUE INDEX i4_uq ON t1(i4);
+
+INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
+
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
+
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
+
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
+
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
+
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
+
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
+SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
+
+EXPLAIN
+SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0;
+SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0;
+
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
+SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
+
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
+
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
+SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
+
+EXPLAIN
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
+
+#Should detect the EQ_REF 't2.pk=t1.i4'
+EXPLAIN
+SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
+SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
+
+EXPLAIN
+SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
+SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
+
+#
+# lp:750117 Bogus warning with aggregate and datetime column
+#
+create table t1 (f1 datetime, key (f1));
+insert into t1 values ('2000-03-09 15:56:59'),('2000-05-05 23:24:28'),('2000-06-13 13:12:06');
+select min(f1) from t1 where f1 >= '2006-05-25 07:00:20' and f1 between '2003-11-23 10:00:09' and '2010-01-01 01:01:01' and f1 > '2001-01-01 01:01:01';
+drop table t1;
+
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 3d5ffd185ba..3cebb8fffd0 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3513,6 +3513,7 @@ DROP VIEW v1;
select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT'
and '2007/10/20 00:00:00 GMT';
select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';
+select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/20 00:00:00 GMT-6';
select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
# We have all we need -- and trailing garbage:
@@ -3562,10 +3563,12 @@ select str_to_date('1','%Y-%m-%d') = '1';
select str_to_date('1','%Y-%m-%d') = '1';
select str_to_date('','%Y-%m-%d') = '';
-# these three should work!
-select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';
-select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
+select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and NULL;
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '2001-01-01';
+select str_to_date('2000-01-01','%Y-%m-%d') between '2001-01-01' and NULL;
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and '1000-01-01';
+select str_to_date('2000-01-01','%Y-%m-%d') between NULL and NULL;
#
# Bug #30666: Incorrect order when using range conditions on 2 tables or more
@@ -3893,9 +3896,9 @@ DROP TABLE t1;
# Field_varstring::store
#
-CREATE TABLE A (date_key date);
+CREATE TABLE t1 (date_key date);
-CREATE TABLE C (
+CREATE TABLE t2 (
pk int,
int_nokey int,
int_key int,
@@ -3904,20 +3907,20 @@ CREATE TABLE C (
varchar_key varchar(1)
);
-INSERT INTO C VALUES
+INSERT INTO t2 VALUES
(1,1,1,'0000-00-00',NULL,NULL),
(1,1,1,'0000-00-00',NULL,NULL);
-SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);
+SELECT 1 FROM t2 WHERE pk > ANY (SELECT 1 FROM t2);
-SELECT COUNT(DISTINCT 1) FROM C
- WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;
-SELECT date_nokey FROM C
- WHERE int_key IN (SELECT 1 FROM A)
+SELECT COUNT(DISTINCT 1) FROM t2
+ WHERE date_key = (SELECT 1 FROM t1 WHERE t2.date_key IS NULL) GROUP BY pk;
+SELECT date_nokey FROM t2
+ WHERE int_key IN (SELECT 1 FROM t1)
HAVING date_nokey = '10:41:7'
ORDER BY date_key;
-DROP TABLE A,C;
+DROP TABLE t1,t2;
#
# Bug #42957: no results from
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index d46261f38d2..e5ca35bda32 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -1064,6 +1064,7 @@ set names latin1;
#
--error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND
show columns from `#mysql50#????????`;
+call mtr.add_suppression("Can.t find file: '.\\\\test\\\\\\?{8}.frm'");
#
# SHOW CREATE TRIGGER test.
diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test
index a2755170276..3fe487808b3 100644
--- a/mysql-test/t/sp-destruct.test
+++ b/mysql-test/t/sp-destruct.test
@@ -14,6 +14,7 @@
# Supress warnings written to the log file
call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted");
+call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value in column mysql.proc");
# Backup proc table
let $MYSQLD_DATADIR= `select @@datadir`;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index db8077bbbef..b54845c307f 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -3748,15 +3748,25 @@ begin
return @x;
end|
-set @qcs1 = @@query_cache_size|
-set global query_cache_size = 100000|
+--disable_query_log
+--echo # Set query cache size, if we have query cache
+if (`select @@have_query_cache='YES'`) {
+ set @qcs1 = @@query_cache_size|
+ set global query_cache_size = 100000|
+}
+--enable_query_log
set @x = 1|
insert into t1 values ("qc", 42)|
select bug9902() from t1|
select bug9902() from t1|
select @x|
-set global query_cache_size = @qcs1|
+--echo # Restore the old query cache size
+--disable_query_log
+if (`select @@have_query_cache='YES'`) {
+ set global query_cache_size = @qcs1|
+}
+--enable_query_log
delete from t1|
drop function bug9902|
diff --git a/mysql-test/t/ssl_cipher-master.opt b/mysql-test/t/ssl_cipher-master.opt
new file mode 100644
index 00000000000..9525c238c40
--- /dev/null
+++ b/mysql-test/t/ssl_cipher-master.opt
@@ -0,0 +1 @@
+--ssl-cipher=AES128-SHA
diff --git a/mysql-test/t/ssl_cipher.test b/mysql-test/t/ssl_cipher.test
new file mode 100644
index 00000000000..5346968175c
--- /dev/null
+++ b/mysql-test/t/ssl_cipher.test
@@ -0,0 +1,23 @@
+# Turn on ssl between the client and server
+# and run a number of tests
+
+--echo #
+--echo # BUG#11760210 - SSL_CIPHER_LIST NOT SET OR RETURNED FOR "SHOW STATUS LIKE 'SSL_CIPHER_LIST'"
+--echo #
+
+-- source include/have_ssl.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+connect (ssl_con,localhost,root,,,,,SSL);
+
+# Check Cipher Name and Cipher List
+SHOW STATUS LIKE 'Ssl_cipher';
+SHOW STATUS LIKE 'Ssl_cipher_list';
+
+connection default;
+disconnect ssl_con;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 5779ea97bc2..e4a93453aee 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -367,6 +367,8 @@ INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
--error 1292
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
+--error 1292
+INSERT INTO t1 (col1) VALUES('2004-0-10');
# deactivated because of Bug#8294
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 2015ab83513..3f843cdf534 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -260,6 +260,7 @@ INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
-- error ER_SUBQUERY_NO_1_ROW
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
+show warnings;
drop table t1;
create table t1 (a int);
@@ -322,7 +323,7 @@ insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t1;
select * from t1 where b = (select b from t2 where t1.a = t2.a);
-- error ER_UPDATE_TABLE_USED
-delete from t1 where b = (select b from t1);
+delete from t1 where b in (select b from t1);
-- error ER_SUBQUERY_NO_1_ROW
delete from t1 where b = (select b from t2);
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -2078,7 +2079,7 @@ SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2);
--error ER_SUBQUERY_NO_1_ROW
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1);
-
+--sorted_result
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
@@ -2086,7 +2087,7 @@ SELECT a FROM t1 GROUP BY a
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
-
+--sorted_result
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
@@ -2094,7 +2095,7 @@ SELECT a FROM t1 GROUP BY a
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3;
-
+--sorted_result
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
@@ -2102,7 +2103,7 @@ SELECT a FROM t1
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
-
+--sorted_result
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
@@ -4333,3 +4334,71 @@ EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1);
SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1);
DROP table t1,t2;
+
+--echo #
+--echo # Bug#751350: crash with pushed condition for outer references when
+--echo # there should be none of such conditions
+--echo #
+
+CREATE TABLE t1 (a int, b int) ;
+INSERT INTO t1 VALUES (0,0),(0,0);
+
+EXPLAIN
+SELECT b FROM t1
+ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+ GROUP BY b;
+
+SELECT b FROM t1
+ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
+ GROUP BY b;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #11765713 58705:
+--echo # OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+--echo # CREATED BY OPT_SUM_QUERY
+--echo #
+
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT 1 as foo FROM t1 WHERE a < SOME
+ (SELECT a FROM t1 WHERE a <=>
+ (SELECT a FROM t1)
+ );
+
+SELECT 1 as foo FROM t1 WHERE a < SOME
+ (SELECT a FROM t1 WHERE a <=>
+ (SELECT a FROM t1 where a is null)
+ );
+
+DROP TABLE t1;
+
+--echo #
+--echo # BUG#779885: Crash in eliminate_item_equal with materialization=on in
+--echo # maria-5.3
+--echo #
+
+CREATE TABLE t1 ( f1 int );
+INSERT INTO t1 VALUES (19), (20);
+
+CREATE TABLE t2 ( f10 varchar(32) );
+INSERT INTO t2 VALUES ('c'),('d');
+
+CREATE TABLE t3 ( f10 varchar(32) );
+INSERT INTO t3 VALUES ('a'),('b');
+
+SELECT *
+FROM t1
+WHERE
+( 't' ) IN (
+ SELECT t3.f10
+ FROM t3
+ JOIN t2
+ ON t2.f10 = t3.f10
+);
+DROP TABLE t1,t2,t3;
+
+--echo End of 5.3 tests
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test
index dc625239e84..0c1523a04ca 100644
--- a/mysql-test/t/subselect3.test
+++ b/mysql-test/t/subselect3.test
@@ -683,7 +683,8 @@ SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1;
# The x alias is used below to workaround bug #40674.
# Regression tests for sum function on outer column in subselect from dual:
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 22), ROW(11, 12) IN (SELECT MAX(x), 22) FROM t1;
---echo # 2nd and 3rd columns should be same for x == 11 only
+--echo # 2nd and 3rd columns should be same
+EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1;
DROP TABLE t1;
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index 5cc44ca5557..39561d5114f 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -1,5 +1,8 @@
# General purpose bug fix tests go here : subselect.test too large
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6;
+--enable_warnings
--echo #
--echo # Bug #46791: Assertion failed:(table->key_read==0),function unknown
@@ -216,11 +219,9 @@ CREATE TABLE `t1` (
INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','','');
set @old_optimizer_switch = @@session.optimizer_switch,
- @old_optimizer_use_mrr = @@session.optimizer_use_mrr,
@old_engine_condition_pushdown = @@session.engine_condition_pushdown;
-SET SESSION OPTIMIZER_SWITCH = 'materialization=off,semijoin=off,loosescan=off,firstmatch=off';
-SET SESSION optimizer_use_mrr = 'force';
+SET SESSION OPTIMIZER_SWITCH = 'materialization=off,semijoin=off,loosescan=off,firstmatch=off,mrr=on';
SET SESSION engine_condition_pushdown = 1;
SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN (
@@ -228,7 +229,6 @@ SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G
BY `pk` ;
set @@session.optimizer_switch = @old_optimizer_switch,
- @@session.optimizer_use_mrr = @old_optimizer_use_mrr,
@@session.engine_condition_pushdown = @old_engine_condition_pushdown;
DROP TABLE t1;
@@ -318,7 +318,7 @@ INSERT INTO t3 VALUES ('E4','P5',80);
SET @old_optimizer_switch = @@session.optimizer_switch;
SET @old_join_cache_level = @@session.join_cache_level;
-SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,semijoin=on';
+SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,in_to_exists=off,semijoin=on';
SET SESSION join_cache_level = 1;
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
@@ -528,7 +528,7 @@ INSERT INTO t3 VALUES ('E4','P5',80);
SET @old_optimizer_switch = @@session.optimizer_switch;
SET @old_join_cache_level = @@session.join_cache_level;
-SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,semijoin=on';
+SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,in_to_exists=off,semijoin=on';
SET SESSION join_cache_level = 1;
CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
@@ -661,7 +661,7 @@ CREATE TABLE t2 (f11 varchar(1)) ;
INSERT INTO t2 VALUES ('f'),('d');
SET @old_optimizer_switch = @@session.optimizer_switch;
-SET SESSION optimizer_switch = 'materialization=on';
+SET SESSION optimizer_switch = 'materialization=on,in_to_exists=off,';
EXPLAIN
SELECT * FROM t1
@@ -695,7 +695,7 @@ CREATE TABLE t2 (f3 int, f4 int not null, PRIMARY KEY (f3));
set @save_optimizer_switch=@@optimizer_switch;
-SET @@optimizer_switch = 'materialization=on,semijoin=off';
+SET @@optimizer_switch = 'materialization=on,in_to_exists=off,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2);
@@ -746,7 +746,7 @@ SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2);
-SET @@optimizer_switch = 'materialization=off,semijoin=off';
+SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
EXPLAIN
@@ -803,7 +803,7 @@ INSERT INTO t1 VALUES (3, 4);
INSERT INTO t2 VALUES (5, 6);
INSERT INTO t2 VALUES (7, 8);
-SET @@optimizer_switch = 'materialization=on,semijoin=off';
+SET @@optimizer_switch = 'materialization=on,in_to_exists=off,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
@@ -853,7 +853,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
-SET @@optimizer_switch = 'materialization=off,semijoin=off';
+SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
@@ -934,7 +934,7 @@ INSERT INTO t2 VALUES (1,7,'p');
set @save_optimizer_switch=@@optimizer_switch;
-set @@optimizer_switch='materialization=off,semijoin=off';
+set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
EXPLAIN
SELECT t1.f3, MAX(t1.f2)
@@ -945,7 +945,7 @@ SELECT t1.f3, MAX(t1.f2)
FROM t1, t2
WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
-set @@optimizer_switch='materialization=on,semijoin=off';
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
EXPLAIN
SELECT t1.f3, MAX(t1.f2)
@@ -963,3 +963,455 @@ WHERE (t2.pk = t1.pk) AND t2.pk IN (SELECT f2 FROM t1);
set @@optimizer_switch=@save_optimizer_switch;
drop table t1, t2;
+
+--echo #
+--echo # LP BUG#641203 Query returns rows where no result is expected (impossible WHERE)
+--echo #
+
+CREATE TABLE t1 (c1 varchar(1) DEFAULT NULL);
+CREATE TABLE t2 (c1 varchar(1) DEFAULT NULL);
+INSERT INTO t2 VALUES ('k'), ('d');
+CREATE TABLE t3 (c1 varchar(1) DEFAULT NULL);
+INSERT INTO t3 VALUES ('a'), ('b'), ('c');
+CREATE TABLE t4 (c1 varchar(1) primary key);
+INSERT INTO t4 VALUES ('k'), ('d');
+
+EXPLAIN
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+EXPLAIN
+SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
+EXPLAIN
+SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
+SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
+EXPLAIN
+SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
+SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
+drop table t1, t2, t3, t4;
+
+--echo #
+--echo # LP BUG#675981 Assertion `cache != __null' failed in sub_select_cache()
+--echo # on EXPLAIN
+--echo #
+
+CREATE TABLE t1 (f1 int,f2 int) ;
+INSERT IGNORE INTO t1 VALUES ('2','5'),('2',NULL);
+
+CREATE TABLE t2 (f1 int, f5 int) ;
+INSERT IGNORE INTO t2 VALUES (1,0);
+
+CREATE TABLE t3 (f4 int) ;
+INSERT IGNORE INTO t3 VALUES (0),(0);
+
+set @@optimizer_switch='in_to_exists=on,materialization=off,semijoin=off';
+EXPLAIN
+SELECT * FROM t2
+WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4);
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # LP BUG#680005 Second assertion `cache != __null' failed in
+--echo # sub_select_cache() on EXPLAIN
+--echo #
+
+CREATE TABLE t1 (f1 int,f2 int,f4 int,f6 int,KEY (f4)) ;
+INSERT IGNORE INTO t1 VALUES
+('1','5','1','0'),('2','1','1','0'),('2','2','2','0'),('0',NULL,'0','0'),
+('2','1','2','0'),('2','0','0','0'),('2','2','2','0'),('2','8','2','0'),
+('2','7','2','0'),('2','5','2','0'),('2',NULL,'1','0');
+
+CREATE TABLE t2 (f3 int) ;
+INSERT IGNORE INTO t2 VALUES ('7');
+
+CREATE TABLE t3 (f3 int) ;
+INSERT IGNORE INTO t3 VALUES ('2');
+
+EXPLAIN
+SELECT t1.f4
+FROM t2 JOIN t1 ON t1.f6
+WHERE
+( t1.f2 ) IN (SELECT SUBQUERY2_t1.f3
+ FROM t3 AS SUBQUERY2_t1
+ JOIN
+ (t1 AS SUBQUERY2_t2
+ JOIN
+ t1 AS SUBQUERY2_t3 ON SUBQUERY2_t3.f1)
+ ON SUBQUERY2_t3.f2)
+GROUP BY t1.f4 ORDER BY t1.f1 LIMIT 10;
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # LP BUG#680038 bool close_thread_table(THD*, TABLE**):
+--echo # Assertion `table->key_read == 0' failed in EXPLAIN
+--echo #
+
+CREATE TABLE t1 (f1 int,f3 int,f4 int) ;
+INSERT IGNORE INTO t1 VALUES (NULL,1,0);
+
+CREATE TABLE t2 (f2 int,f4 int,f5 int) ;
+INSERT IGNORE INTO t2 VALUES (8,0,0),(5,0,0);
+
+CREATE TABLE t3 (f4 int,KEY (f4)) ;
+INSERT IGNORE INTO t3 VALUES (0),(0);
+
+set @@optimizer_switch='semijoin=off';
+
+EXPLAIN
+SELECT * FROM t1 WHERE
+(SELECT f2 FROM t2
+ WHERE f4 <= ALL
+ (SELECT SQ1_t1.f4
+ FROM t3 AS SQ1_t1 JOIN t3 AS SQ1_t3 ON SQ1_t3.f4
+ GROUP BY SQ1_t1.f4));
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # BUG#52317: Assertion failing in Field_varstring::store()
+--echo # at field.cc:6833
+--echo #
+
+CREATE TABLE t1 (i INTEGER);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i INTEGER, KEY k(i));
+INSERT INTO t2 VALUES (1), (2);
+
+EXPLAIN
+SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo #
+--echo # LP BUG#680846: Crash in clear_tables() with subqueries
+--echo #
+
+CREATE TABLE t1 (f3 int) ;
+INSERT IGNORE INTO t1 VALUES (0),(0);
+
+CREATE TABLE t2 (f1 int,f3 int,f4 varchar(32)) ;
+INSERT IGNORE INTO t2 VALUES (1,0,'f');
+
+EXPLAIN
+SELECT COUNT(t2.f3),
+ (SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+
+SELECT COUNT(t2.f3),
+ (SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+
+EXPLAIN
+SELECT COUNT(t2.f3),
+ (SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+
+SELECT COUNT(t2.f3),
+ (SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
+FROM t2 JOIN t1 ON t1.f3
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+
+# these queries are like the ones above, but without the ON clause,
+# resulting in a different crash (failed assert)
+EXPLAIN
+SELECT COUNT(t2.f3),
+ (SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+
+SELECT COUNT(t2.f3),
+ (SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+GROUP BY f9;
+
+EXPLAIN
+SELECT COUNT(t2.f3),
+ (SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+
+SELECT COUNT(t2.f3),
+ (SELECT t2.f1 FROM t1 limit 1) AS f9
+FROM t2 JOIN t1
+WHERE ('v') IN (SELECT f4 FROM t2)
+ORDER BY f9;
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#682683 Crash in create_tmp_table called from
+--echo # JOIN::init_execution
+--echo #
+
+CREATE TABLE t2 (f1 int) ;
+INSERT INTO t2 VALUES (1),(2);
+
+CREATE TABLE t1 (f1 int) ;
+
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+
+INSERT INTO t1 VALUES (1),(2);
+
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+--error ER_SUBQUERY_NO_1_ROW
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
+EXPLAIN
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+--error ER_SUBQUERY_NO_1_ROW
+SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#680943 Assertion `!table || (!table->read_set ||
+--echo # bitmap_is_set(table->read_set, field_index))' failed with subquery
+--echo #
+
+CREATE TABLE t1 (f1 int,f3 int) ;
+INSERT IGNORE INTO t1 VALUES ('6','0'),('4','0');
+
+CREATE TABLE t2 (f1 int,f2 int,f3 int) ;
+INSERT IGNORE INTO t2 VALUES ('6','0','0'),('2','0','0');
+
+SELECT f2
+FROM (SELECT * FROM t2) AS alias1
+WHERE (SELECT SQ2_t2.f1
+ FROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3
+ WHERE SQ2_t2.f3 AND alias1.f1)
+ORDER BY f3 ;
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#715062: Wrong result with VIEW + UNION + subquery in maria-5.3-mwl89
+--echo #
+
+create table t1 (f1 int);
+create table t2 (f2 int);
+create table t3 (f3 int);
+insert into t1 values (2);
+insert into t2 values (2);
+insert into t3 values (7);
+
+CREATE VIEW v1 AS SELECT 2 UNION SELECT 2 ;
+CREATE VIEW v2 AS SELECT * from t1 UNION SELECT * from t2 ;
+
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch = 'in_to_exists=off,semijoin=off,materialization=on';
+
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+
+EXPLAIN
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+
+SET @@optimizer_switch = 'in_to_exists=on,semijoin=off,materialization=off';
+
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
+
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+SELECT ( 5 ) IN ( SELECT * FROM v1 );
+
+EXPLAIN
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
+
+EXPLAIN
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
+
+EXPLAIN
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+SELECT ( 5 ) IN ( SELECT * FROM v2 );
+
+set @@optimizer_switch=@save_optimizer_switch;
+
+drop table t1,t2,t3;
+drop view v1,v2;
+
+--echo #
+--echo # LP BUG#715069 Wrong result with GROUP BY inside subquery and materialization=off
+--echo #
+
+CREATE TABLE t0 ( f1 int(11), f2 int(11), f10 varchar(1), PRIMARY KEY (f1)) ;
+INSERT INTO t0 VALUES (8,8,'u'),(10,5,'o');
+
+CREATE TABLE t1 (f1a int, f2a int not null, f3a varchar(3) not null, PRIMARY KEY (f1a)) ;
+INSERT INTO t1 VALUES
+(8,8,'a1a'),
+(10,5,'b1b');
+
+CREATE TABLE t2 (f1b int, f2b int not null, f3b varchar(3) not null, PRIMARY KEY (f1b)) ;
+INSERT INTO t2 VALUES
+(10,5,'d1d');
+
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch = 'materialization=off';
+
+EXPLAIN
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+
+SET @@optimizer_switch = 'materialization=on';
+
+EXPLAIN
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+
+SELECT alias2.f1 , alias2.f2
+FROM t0 AS alias1
+RIGHT JOIN t0 AS alias2 ON alias2.f10
+WHERE ( alias2.f1 , alias2.f2 ) IN ( SELECT f2 , f1 FROM t0 GROUP BY f2 , f1 );
+
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+SELECT * FROM t2 WHERE (f1b, f2b) IN (SELECT f1a, f2a FROM t1 GROUP BY f1a, f2a);
+
+EXPLAIN
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+SELECT * FROM t2 WHERE (f1b) IN (SELECT f1a FROM t1 GROUP BY f1a, f2a);
+
+set @@optimizer_switch=@save_optimizer_switch;
+
+drop table t0,t1,t2;
+
+
+--echo #
+--echo # LP BUG#715759 Wrong result with in_to_exists=on in maria-5.3-mwl89
+--echo #
+
+set @save_optimizer_switch=@@optimizer_switch;
+CREATE TABLE t1 (a1 int, a2 int) ;
+INSERT INTO t1 VALUES (1, 2);
+INSERT INTO t1 VALUES (3, 4);
+
+CREATE TABLE t2 (b1 int, b2 int) ;
+INSERT INTO t2 VALUES (1, 2);
+
+SET @@optimizer_switch = 'in_to_exists=on,materialization=off,semijoin=off';
+
+EXPLAIN SELECT * FROM t1 WHERE a1 IN (SELECT b1 FROM t2 WHERE b1 = b2);
+SELECT * FROM t1 WHERE a1 IN (SELECT b1 FROM t2 WHERE b1 = b2);
+
+set @@optimizer_switch=@save_optimizer_switch;
+drop table t1, t2;
+
+--echo #
+--echo # LP BUG#772309 join_tab_cmp_straight(): Assertion `!jt2->emb_sj_nest' failed in maria-5.3-mwl89 with semijoin
+--echo #
+
+CREATE TABLE t1 ( f2 int) ;
+INSERT INTO t1 VALUES (0),(0);
+
+CREATE TABLE t2 ( f1 int NOT NULL ) ;
+INSERT INTO t2 VALUES (0),(0);
+
+CREATE TABLE t3 ( f1 int NOT NULL , f2 int) ;
+INSERT INTO t3 VALUES (0,0), (0,0);
+
+EXPLAIN SELECT STRAIGHT_JOIN (
+ SELECT f2 FROM t1 WHERE ( f2 ) IN ( SELECT t3.f2 FROM t3 JOIN t2 ON t2.f1 = 1 )
+);
+SELECT STRAIGHT_JOIN (
+ SELECT f2 FROM t1 WHERE ( f2 ) IN ( SELECT t3.f2 FROM t3 JOIN t2 ON t2.f1 = 1 )
+);
+
+drop table t1, t2, t3;
+
+
+--echo #
+--echo # LP BUG#777597 Wrong result with multipart keys, in_to_exists=on, NOT IN in MWL#89
+--echo #
+
+CREATE TABLE t1 ( f4 int);
+INSERT IGNORE INTO t1 VALUES (2),(2);
+
+CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3) );
+INSERT IGNORE INTO t2 VALUES (6, 1), (6, 1);
+
+CREATE TABLE t3 ( f10 int );
+INSERT IGNORE INTO t3 VALUES (1);
+
+SET SESSION optimizer_switch='in_to_exists=on,materialization=off';
+
+EXPLAIN
+SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
+SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
+
+drop table t1,t2,t3;
+
+
+--echo #
+--echo # LP BUG#778413 Third crash in select_describe() in maria-5.3-mwl89
+--echo #
+
+CREATE TABLE t1 ( f11 int) ;
+INSERT INTO t1 VALUES (1),(1);
+
+CREATE TABLE t2 ( f1 int NOT NULL) ;
+INSERT INTO t2 VALUES (20);
+
+CREATE TABLE t3 (f3 int) ;
+INSERT INTO t3 VALUES (2),(2);
+
+EXPLAIN SELECT * FROM t2
+WHERE t2.f1 = (
+ SELECT MAX( f3 ) FROM t3
+ WHERE EXISTS (
+ SELECT DISTINCT f11
+ FROM t1));
+
+drop table t1, t2, t3;
diff --git a/mysql-test/t/subselect_mat.test b/mysql-test/t/subselect_mat.test
index c18585d0478..9d6eb2775ab 100644
--- a/mysql-test/t/subselect_mat.test
+++ b/mysql-test/t/subselect_mat.test
@@ -3,908 +3,12 @@
# (WL#1110: Subquery optimization: materialization)
#
---disable_warnings
-drop table if exists t1, t2, t3, t1i, t2i, t3i;
-drop view if exists v1, v2, v1m, v2m;
---enable_warnings
-
-create table t1 (a1 char(8), a2 char(8));
-create table t2 (b1 char(8), b2 char(8));
-create table t3 (c1 char(8), c2 char(8));
-
-insert into t1 values ('1 - 00', '2 - 00');
-insert into t1 values ('1 - 01', '2 - 01');
-insert into t1 values ('1 - 02', '2 - 02');
-
-insert into t2 values ('1 - 01', '2 - 01');
-insert into t2 values ('1 - 01', '2 - 01');
-insert into t2 values ('1 - 02', '2 - 02');
-insert into t2 values ('1 - 02', '2 - 02');
-insert into t2 values ('1 - 03', '2 - 03');
-
-insert into t3 values ('1 - 01', '2 - 01');
-insert into t3 values ('1 - 02', '2 - 02');
-insert into t3 values ('1 - 03', '2 - 03');
-insert into t3 values ('1 - 04', '2 - 04');
-
-# Indexed columns
-create table t1i (a1 char(8), a2 char(8));
-create table t2i (b1 char(8), b2 char(8));
-create table t3i (c1 char(8), c2 char(8));
-create index it1i1 on t1i (a1);
-create index it1i2 on t1i (a2);
-create index it1i3 on t1i (a1, a2);
-
-create index it2i1 on t2i (b1);
-create index it2i2 on t2i (b2);
-create index it2i3 on t2i (b1, b2);
-
-create index it3i1 on t3i (c1);
-create index it3i2 on t3i (c2);
-create index it3i3 on t3i (c1, c2);
-
-insert into t1i select * from t1;
-insert into t2i select * from t2;
-insert into t3i select * from t3;
# force the use of materialization
-set @@optimizer_switch='semijoin=off';
-
-/******************************************************************************
-* Simple tests.
-******************************************************************************/
-# non-indexed nullable fields
-explain extended
-select * from t1 where a1 in (select b1 from t2 where b1 > '0');
-select * from t1 where a1 in (select b1 from t2 where b1 > '0');
-
-explain extended
-select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
-select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
-
-explain extended
-select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
-select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
-
-explain extended
-select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
-select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
-
-# indexed columns
-explain extended
-select * from t1i where a1 in (select b1 from t2i where b1 > '0');
-select * from t1i where a1 in (select b1 from t2i where b1 > '0');
-
-explain extended
-select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
-select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
-
-explain extended
-select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
-select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
-
-explain extended
-select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
-select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
-
-explain extended
-select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
-select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
-
-# BUG#31639: Wrong plan for uncorrelated subquery when loose scan is applicable.
-explain extended
-select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
-select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
-
-prepare st1 from "explain select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
-execute st1;
-execute st1;
-prepare st2 from "select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
-execute st2;
-execute st2;
-
-explain extended
-select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
-select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
--- error 1235
-select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1);
-
-# test re-optimization/re-execution with different execution methods
-# prepare once, exec with different modes
-set @@optimizer_switch='default,semijoin=off';
-prepare st1 from
-"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
-set @@optimizer_switch='default,materialization=off';
-execute st1;
-set @@optimizer_switch='default,semijoin=off';
-execute st1;
-
-set @@optimizer_switch='default,materialization=off';
-prepare st1 from
-"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
-set @@optimizer_switch='default,semijoin=off';
-execute st1;
-set @@optimizer_switch='default,materialization=off';
-execute st1;
-set @@optimizer_switch='default,semijoin=off';
-
-# materialize the result of ORDER BY
-# non-indexed fields
-explain extended
-select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
-select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
-# indexed fields
-explain extended
-select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
-select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
-
-/******************************************************************************
-* Views, UNIONs, several levels of nesting.
-******************************************************************************/
-# materialize the result of subquery over temp-table view
-
-create algorithm=merge view v1 as
-select b1, c2 from t2, t3 where b2 > c2;
-
-create algorithm=merge view v2 as
-select b1, c2 from t2, t3 group by b2, c2;
-
-create algorithm=temptable view v1m as
-select b1, c2 from t2, t3 where b2 > c2;
-
-create algorithm=temptable view v2m as
-select b1, c2 from t2, t3 group by b2, c2;
-
-select * from v1 where (c2, b1) in (select c2, b1 from v2 where b1 is not null);
-select * from v1 where (c2, b1) in (select distinct c2, b1 from v2 where b1 is not null);
-
-select * from v1m where (c2, b1) in (select c2, b1 from v2m where b1 is not null);
-select * from v1m where (c2, b1) in (select distinct c2, b1 from v2m where b1 is not null);
-
-drop view v1, v2, v1m, v2m;
-
-# nested subqueries, views
-explain extended
-select * from t1
-where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-select * from t1
-where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-
-explain extended
-select * from t1i
-where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
- (a1, a2) in (select c1, c2 from t3i
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-select * from t1i
-where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
- (a1, a2) in (select c1, c2 from t3i
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-
-explain extended
-select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 where c2 LIKE '%02') or
- b2 in (select c2 from t3 where c2 LIKE '%03')) and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 where c2 LIKE '%02') or
- b2 in (select c2 from t3 where c2 LIKE '%03')) and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-
-# as above with correlated innermost subquery
-explain extended
-select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 t3a where c1 = a1) or
- b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
- (a1, a2) in (select c1, c2 from t3 t3c
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 t3a where c1 = a1) or
- b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
- (a1, a2) in (select c1, c2 from t3 t3c
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-
-
-# multiple levels of nesting subqueries, unions
-explain extended
-(select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 where c2 LIKE '%02') or
- b2 in (select c2 from t3 where c2 LIKE '%03')
- group by b1, b2) and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
-UNION
-(select * from t1i
-where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
- (a1, a2) in (select c1, c2 from t3i
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
-
-(select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 where c2 LIKE '%02') or
- b2 in (select c2 from t3 where c2 LIKE '%03')
- group by b1, b2) and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
-UNION
-(select * from t1i
-where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
- (a1, a2) in (select c1, c2 from t3i
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
-
-
-# UNION of subqueries as a subquery (thus it is not computed via materialization)
-explain extended
-select * from t1
-where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-select * from t1
-where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
- (a1, a2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
-# as above, with a join conditon between the outer references
-explain extended
-select * from t1, t3
-where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
- (c1, c2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
- a1 = c1;
-select * from t1, t3
-where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
- (c1, c2) in (select c1, c2 from t3
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
- a1 = c1;
-
-
-/******************************************************************************
-* Negative tests, where materialization should not be applied.
-******************************************************************************/
-# UNION in a subquery
-explain extended
-select * from t3
-where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
-select * from t3
-where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
-
-# correlation
-explain extended
-select * from t1
-where (a1, a2) in (select b1, b2 from t2
- where b2 in (select c2 from t3 t3a where c1 = a1) or
- b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
- (a1, a2) in (select c1, c2 from t3 t3c
- where (c1, c2) in (select b1, b2 from t2i where b2 > '0' or b2 = a2));
-
-# subquery has no tables
-explain extended
-select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
-select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
-explain extended
-select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
-select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
-
-
-/******************************************************************************
-* Subqueries in other uncovered clauses.
-******************************************************************************/
-
-/* SELECT clause */
-select ((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL from t1;
-
-/* GROUP BY clause */
-create table columns (col int key);
-insert into columns values (1), (2);
-
-explain extended
-select * from t1 group by (select col from columns limit 1);
-select * from t1 group by (select col from columns limit 1);
-
-explain extended
-select * from t1 group by (a1 in (select col from columns));
-select * from t1 group by (a1 in (select col from columns));
-
-/* ORDER BY clause */
-explain extended
-select * from t1 order by (select col from columns limit 1);
-select * from t1 order by (select col from columns limit 1);
-
-/******************************************************************************
-* Column types/sizes that affect materialization.
-******************************************************************************/
-
-/*
- Test that BLOBs are not materialized (except when arguments of some functions).
-*/
-# force materialization to be always considered
-set @@optimizer_switch='semijoin=off';
-set @prefix_len = 6;
-
-# BLOB == 16 (small blobs that could be stored in HEAP tables)
-set @blob_len = 16;
-set @suffix_len = @blob_len - @prefix_len;
-
-create table t1_16 (a1 blob(16), a2 blob(16));
-create table t2_16 (b1 blob(16), b2 blob(16));
-create table t3_16 (c1 blob(16), c2 blob(16));
-
-insert into t1_16 values
- (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
-insert into t1_16 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t1_16 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-
-insert into t2_16 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t2_16 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t2_16 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-
-insert into t3_16 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t3_16 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t3_16 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-insert into t3_16 values
- (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
-
-# single value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select b1 from t2_16 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select b1 from t2_16 where b1 > '0');
-
-# row value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_16
-where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_16
-where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
-
-# string function with a blob argument, the return type may be != blob
-explain extended select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
-
-# group_concat with a blob argument - depends on
-# the variable group_concat_max_len, and
-# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-explain extended select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select group_concat(b1) from t2_16 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select group_concat(b1) from t2_16 group by b2);
-
-set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 512)
-
-explain extended select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select group_concat(b1) from t2_16 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_16
-where a1 in (select group_concat(b1) from t2_16 group by b2);
-
-# BLOB column at the second (intermediate) level of nesting
-explain extended
-select * from t1
-where concat(a1,'x') IN
- (select left(a1,8) from t1_16
- where (a1, a2) IN
- (select t2_16.b1, t2_16.b2 from t2_16, t2
- where t2.b2 = substring(t2_16.b2,1,6) and
- t2.b1 IN (select c1 from t3 where c2 > '0')));
-
-
-drop table t1_16, t2_16, t3_16;
-
-
-# BLOB == 512 (CONVERT_IF_BIGGER_TO_BLOB == 512)
-set @blob_len = 512;
-set @suffix_len = @blob_len - @prefix_len;
-
-create table t1_512 (a1 blob(512), a2 blob(512));
-create table t2_512 (b1 blob(512), b2 blob(512));
-create table t3_512 (c1 blob(512), c2 blob(512));
-
-insert into t1_512 values
- (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
-insert into t1_512 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t1_512 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-
-insert into t2_512 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t2_512 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t2_512 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-
-insert into t3_512 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t3_512 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t3_512 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-insert into t3_512 values
- (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
-
-# single value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select b1 from t2_512 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select b1 from t2_512 where b1 > '0');
-
-# row value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_512
-where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_512
-where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
-
-# string function with a blob argument, the return type may be != blob
-explain extended select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
-
-# group_concat with a blob argument - depends on
-# the variable group_concat_max_len, and
-# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-explain extended select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select group_concat(b1) from t2_512 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select group_concat(b1) from t2_512 group by b2);
-
-set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 512)
-
-explain extended select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select group_concat(b1) from t2_512 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_512
-where a1 in (select group_concat(b1) from t2_512 group by b2);
-
-drop table t1_512, t2_512, t3_512;
-
-
-# BLOB == 1024 (group_concat_max_len == 1024)
-set @blob_len = 1024;
-set @suffix_len = @blob_len - @prefix_len;
-
-create table t1_1024 (a1 blob(1024), a2 blob(1024));
-create table t2_1024 (b1 blob(1024), b2 blob(1024));
-create table t3_1024 (c1 blob(1024), c2 blob(1024));
-
-insert into t1_1024 values
- (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
-insert into t1_1024 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t1_1024 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-
-insert into t2_1024 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t2_1024 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t2_1024 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-
-insert into t3_1024 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t3_1024 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t3_1024 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-insert into t3_1024 values
- (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
-
-# single value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select b1 from t2_1024 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select b1 from t2_1024 where b1 > '0');
-
-# row value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_1024
-where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_1024
-where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
-
-# string function with a blob argument, the return type may be != blob
-explain extended select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
-
-# group_concat with a blob argument - depends on
-# the variable group_concat_max_len, and
-# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-explain extended select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select group_concat(b1) from t2_1024 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select group_concat(b1) from t2_1024 group by b2);
-
-set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 1024)
-
-explain extended select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select group_concat(b1) from t2_1024 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_1024
-where a1 in (select group_concat(b1) from t2_1024 group by b2);
-
-drop table t1_1024, t2_1024, t3_1024;
-
-
-# BLOB == 1025
-set @blob_len = 1025;
-set @suffix_len = @blob_len - @prefix_len;
-
-create table t1_1025 (a1 blob(1025), a2 blob(1025));
-create table t2_1025 (b1 blob(1025), b2 blob(1025));
-create table t3_1025 (c1 blob(1025), c2 blob(1025));
-
-insert into t1_1025 values
- (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
-insert into t1_1025 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t1_1025 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-
-insert into t2_1025 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t2_1025 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t2_1025 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-
-insert into t3_1025 values
- (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
-insert into t3_1025 values
- (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
-insert into t3_1025 values
- (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
-insert into t3_1025 values
- (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
-
-# single value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select b1 from t2_1025 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select b1 from t2_1025 where b1 > '0');
-
-# row value transformer
-explain extended select left(a1,7), left(a2,7)
-from t1_1025
-where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_1025
-where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
-
-# string function with a blob argument, the return type may be != blob
-explain extended select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
-
-select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
-
-# group_concat with a blob argument - depends on
-# the variable group_concat_max_len, and
-# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-explain extended select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select group_concat(b1) from t2_1025 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select group_concat(b1) from t2_1025 group by b2);
-
-set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 1025)
-
-explain extended select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select group_concat(b1) from t2_1025 group by b2);
-
-select left(a1,7), left(a2,7)
-from t1_1025
-where a1 in (select group_concat(b1) from t2_1025 group by b2);
-
-drop table t1_1025, t2_1025, t3_1025;
-
-# test for BIT fields
-create table t1bit (a1 bit(3), a2 bit(3));
-create table t2bit (b1 bit(3), b2 bit(3));
-
-insert into t1bit values (b'000', b'100');
-insert into t1bit values (b'001', b'101');
-insert into t1bit values (b'010', b'110');
-
-insert into t2bit values (b'001', b'101');
-insert into t2bit values (b'010', b'110');
-insert into t2bit values (b'110', b'111');
-
-set @@optimizer_switch='semijoin=off';
-
-explain extended select bin(a1), bin(a2)
-from t1bit
-where (a1, a2) in (select b1, b2 from t2bit);
-
-select bin(a1), bin(a2)
-from t1bit
-where (a1, a2) in (select b1, b2 from t2bit);
-
-drop table t1bit, t2bit;
-
-# test mixture of BIT and BLOB
-create table t1bb (a1 bit(3), a2 blob(3));
-create table t2bb (b1 bit(3), b2 blob(3));
-
-insert into t1bb values (b'000', '100');
-insert into t1bb values (b'001', '101');
-insert into t1bb values (b'010', '110');
-
-insert into t2bb values (b'001', '101');
-insert into t2bb values (b'010', '110');
-insert into t2bb values (b'110', '111');
-
-explain extended select bin(a1), a2
-from t1bb
-where (a1, a2) in (select b1, b2 from t2bb);
-
-select bin(a1), a2
-from t1bb
-where (a1, a2) in (select b1, b2 from t2bb);
-
-drop table t1bb, t2bb;
-drop table t1, t2, t3, t1i, t2i, t3i, columns;
-
-/******************************************************************************
-* Test the cache of the left operand of IN.
-******************************************************************************/
-set @@optimizer_switch='semijoin=off';
-
-# Test that default values of Cached_item are not used for comparison
-create table t1 (s1 int);
-create table t2 (s2 int);
-insert into t1 values (5),(1),(0);
-insert into t2 values (0), (1);
-select s2 from t2 where s2 in (select s1 from t1);
-drop table t1, t2;
-
-create table t1 (a int not null, b int not null);
-create table t2 (c int not null, d int not null);
-create table t3 (e int not null);
-
-# the first outer row has no matching inner row
-insert into t1 values (1,10);
-insert into t1 values (1,20);
-insert into t1 values (2,10);
-insert into t1 values (2,20);
-insert into t1 values (2,30);
-insert into t1 values (3,20);
-insert into t1 values (4,40);
-
-insert into t2 values (2,10);
-insert into t2 values (2,20);
-insert into t2 values (2,40);
-insert into t2 values (3,20);
-insert into t2 values (4,10);
-insert into t2 values (5,10);
-
-insert into t3 values (10);
-insert into t3 values (10);
-insert into t3 values (20);
-insert into t3 values (30);
-
-explain extended
-select a from t1 where a in (select c from t2 where d >= 20);
-select a from t1 where a in (select c from t2 where d >= 20);
-
-create index it1a on t1(a);
-
-explain extended
-select a from t1 where a in (select c from t2 where d >= 20);
-select a from t1 where a in (select c from t2 where d >= 20);
-
-# the first outer row has a matching inner row
-insert into t2 values (1,10);
-
-explain extended
-select a from t1 where a in (select c from t2 where d >= 20);
-select a from t1 where a in (select c from t2 where d >= 20);
-
-# cacheing for IN predicates inside a having clause - here the cached
-# items are changed to point to temporary tables.
-explain extended
-select a from t1 group by a having a in (select c from t2 where d >= 20);
-select a from t1 group by a having a in (select c from t2 where d >= 20);
-
-# create an index that can be used for the outer query GROUP BY
-create index iab on t1(a, b);
-explain extended
-select a from t1 group by a having a in (select c from t2 where d >= 20);
-select a from t1 group by a having a in (select c from t2 where d >= 20);
-
-explain extended
-select a from t1 group by a
-having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
-select a from t1 group by a
-having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
-explain extended
-select a from t1
-where a in (select c from t2 where d >= some(select e from t3 where b=e));
-select a from t1
-where a in (select c from t2 where d >= some(select e from t3 where b=e));
-
-drop table t1, t2, t3;
-
-#
-# BUG#36133 "Assertion `exec_method != MATERIALIZATION || (exec_method == MATERIALIZATION &&"
-#
-create table t2 (a int, b int, key(a), key(b));
-insert into t2 values (3,3),(3,3),(3,3);
-select 1 from t2 where
- t2.a > 1
- or
- t2.a = 3 and not t2.a not in (select t2.b from t2);
-drop table t2;
-
-#
-# BUG#37896 Assertion on entry of Item_in_subselect::exec on subquery with AND NOT
-#
-create table t1 (a1 int key);
-create table t2 (b1 int);
-insert into t1 values (5);
-
-# Query with group by, executed via materialization
-explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
-select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
-# Query with group by, executed via IN=>EXISTS
-set @@optimizer_switch='default,materialization=off';
-explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
-select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
-
-# Executed with materialization
-set @@optimizer_switch='default,semijoin=off';
-explain select min(a1) from t1 where 7 in (select b1 from t2);
-select min(a1) from t1 where 7 in (select b1 from t2);
-# Executed with semi-join. Notice, this time we get a different result (NULL).
-# This is the only correct result of all four queries. This difference is
-# filed as BUG#40037.
-set @@optimizer_switch='default,materialization=off';
-explain select min(a1) from t1 where 7 in (select b1 from t2);
-select min(a1) from t1 where 7 in (select b1 from t2);
-drop table t1,t2;
-
-#
-# BUG#36752 "subquery materialization produces wrong results when comparing different types"
-#
-create table t1 (a char(2), b varchar(10));
-insert into t1 values ('a', 'aaa');
-insert into t1 values ('aa', 'aaaa');
-
-set @@optimizer_switch='default,semijoin=off';
-explain select a,b from t1 where b in (select a from t1);
-select a,b from t1 where b in (select a from t1);
-prepare st1 from "select a,b from t1 where b in (select a from t1)";
-execute st1;
-execute st1;
-drop table t1;
-
-#
-# Bug #44303 Assertion failures in Field_new_decimal::store_decimal
-# when executing materialized InsideOut semijoin
-#
-CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM;
-INSERT INTO t1 (f1, f2) VALUES (1, 1.789);
-INSERT INTO t1 (f1, f2) VALUES (13, 1.454);
-INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
-
-CREATE TABLE t2 LIKE t1;
-INSERT INTO t2 VALUES (1, 1.789);
-INSERT INTO t2 VALUES (13, 1.454);
-
-SET @@optimizer_switch='default,semijoin=on,materialization=on';
-EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
-SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
-
-DROP TABLE t1, t2;
-
-#
-# BUG#46548 IN-subqueries return 0 rows with materialization=on
-#
-CREATE TABLE t1 (
- pk int,
- a varchar(1),
- b varchar(4),
- c varchar(4),
- d varchar(4),
- PRIMARY KEY (pk)
-);
-INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
-
-CREATE TABLE t2 LIKE t1;
-INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
-
-SET @@optimizer_switch='default,semijoin=on,materialization=on';
-EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
-SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
-SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
-DROP TABLE t1, t2;
-
---echo #
---echo # BUG#50019: Wrong result for IN-subquery with materialization
---echo #
-create table t1(i int);
-insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
-create table t2(i int);
-insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
-create table t3(i int);
-insert into t3 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
-select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
-set @save_optimizer_switch=@@optimizer_switch;
-set session optimizer_switch='materialization=off';
-select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
-set session optimizer_switch=@save_optimizer_switch;
-drop table t1, t2, t3;
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
+--source t/subselect_sj_mat.test
+set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
#
# Test that the contents of the temp table of a materialized subquery is
# cleaned up between PS re-executions.
@@ -970,8 +74,8 @@ SELECT i FROM t1 LEFT JOIN t2 ON (j) IN (SELECT max(k) FROM t3);
DROP TABLE t1, t2, t3;
--echo #
---echo # LPBUG#609121: RQG: wrong result on aggregate + NOT IN + HAVING and
---echo # partial_match_table_scan=on
+--echo # LPBUG#611622/BUG#52344: Subquery materialization: Assertion
+--echo # if subquery in on-clause of outer join
--echo #
CREATE TABLE t1 (c1 int);
@@ -982,7 +86,7 @@ INSERT INTO t2 VALUES (10);
PREPARE st1 FROM "
SELECT *
-FROM t2 LEFT JOIN (SELECT * FROM t2) t3 ON (8, 4) IN (SELECT c1, c1 FROM t1)";
+FROM t2 LEFT JOIN t2 t3 ON (8, 4) IN (SELECT c1, c1 FROM t1)";
EXECUTE st1;
EXECUTE st1;
@@ -1011,6 +115,36 @@ SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
DROP TABLE t1, t2;
+
+-- echo #
+-- echo # BUG#724228: Wrong result with materialization=on and three aggregates in maria-5.3-mwl90
+-- echo #
+CREATE TABLE t1 ( f2 int(11)) ;
+INSERT IGNORE INTO t1 VALUES ('7'),('9'),('7'),('4'),('2'),('6'),('8'),('5'),('6'),('188'),('2'),('1'),('1'),('0'),('9'),('4');
+
+CREATE TABLE t2 ( f1 int(11), f2 int(11)) ENGINE=MyISAM;
+INSERT IGNORE INTO t2 VALUES ('1','1');
+
+CREATE TABLE t3 ( f1 int(11), f2 int(11), f3 int(11), PRIMARY KEY (f1)) ;
+INSERT IGNORE INTO t3 VALUES ('16','6','1'),('18','3','4'),('19',NULL,'9'),('20','0','6'),('41','2','0'),('42','2','5'),('43','9','6'),('44','7','4'),('45','1','4'),('46','222','238'),('47','3','6'),('48','6','6'),('49',NULL,'1'),('50','5','1');
+
+SET @_save_join_cache_level = @@join_cache_level;
+SET @_save_optimizer_switch = @@optimizer_switch;
+
+SET join_cache_level = 1;
+SET optimizer_switch='materialization=on';
+
+SELECT f1 FROM t3
+WHERE
+ f1 NOT IN (SELECT MAX(f2) FROM t1) AND
+ f3 IN (SELECT MIN(f1) FROM t2) AND
+ f1 IN (SELECT COUNT(f2) FROM t1);
+
+SET @@join_cache_level = @_save_join_cache_level;
+SET @@optimizer_switch = @_save_optimizer_switch;
+
+drop table t1, t2, t3;
+
--echo #
--echo # LPBUG#719198 Ordered_key::cmp_key_with_search_key(rownum_t): Assertion `!compare_pred[i]->null_value'
--echo # failed with subquery on both sides of NOT IN and materialization
@@ -1022,21 +156,23 @@ CREATE TABLE t2 ( f2 int);
INSERT IGNORE INTO t2 VALUES (3),(4);
CREATE TABLE t3 (f3a int, f3b int);
-set session optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off';
+set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,in_to_exists=off';
EXPLAIN
SELECT * FROM t2 WHERE (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
SELECT * FROM t2 WHERE (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
EXPLAIN
+SELECT (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
+SELECT (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
+
+EXPLAIN
SELECT * FROM t2 WHERE (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
SELECT * FROM t2 WHERE (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
-insert into t3 values (1,1),(2,2);
-
EXPLAIN
-SELECT * FROM t2 WHERE (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1);
-SELECT * FROM t2 WHERE (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1);
+SELECT (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
+SELECT (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
drop table t1, t2, t3;
@@ -1051,7 +187,7 @@ CREATE TABLE t2 (f1 int NOT NULL, f2 int, f3 int) ;
INSERT INTO t1 VALUES (60, 3, null), (61, null, 77);
INSERT INTO t2 VALUES (1000,6,2);
-set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off';
+set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,in_to_exists=off';
EXPLAIN
SELECT (f1, f2, f3) NOT IN
diff --git a/mysql-test/t/subselect_mat_cost.test b/mysql-test/t/subselect_mat_cost.test
new file mode 100644
index 00000000000..ced99bccea3
--- /dev/null
+++ b/mysql-test/t/subselect_mat_cost.test
@@ -0,0 +1,204 @@
+#
+# Tets of cost-based choice between the materialization and in-to-exists
+# subquery execution strategies (MWL#89)
+#
+
+--disable_warnings
+drop table if exists t1, t2, t1_1024, t2_1024;
+drop procedure if exists make_t1_indexes;
+drop procedure if exists make_t2_indexes;
+drop procedure if exists remove_t1_indexes;
+drop procedure if exists remove_t2_indexes;
+drop procedure if exists add_materialization_data;
+drop procedure if exists delete_materialization_data;
+drop procedure if exists set_all_columns_not_null;
+drop procedure if exists set_all_columns_nullable;
+--enable_warnings
+
+create table t1 (a1 char(8), a2 char(8), a3 char(8), a4 int);
+insert into t1 values ('1 - 00', '2 - 00', '3 - 00', 0);
+insert into t1 values ('1 - 01', '2 - 01', '3 - 01', 1);
+
+create table t2 (b1 char(8), b2 char(8), b3 char(8), b4 int);
+insert into t2 values ('1 - 01', '2 - 01', '3 - 01', 1);
+insert into t2 values ('1 - 01', '2 - 01', '3 - 02', 2);
+insert into t2 values ('1 - 02', '2 - 02', '3 - 03', 3);
+insert into t2 values ('1 - 02', '2 - 02', '3 - 04', 4);
+insert into t2 values ('1 - 03', '2 - 03', '3 - 05', 5);
+
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+insert into t1_1024 values (concat('1 - 00', repeat('x', 1018)), concat('2 - 00', repeat('x', 1018)));
+insert into t1_1024 values (concat('1 - 01', repeat('x', 1018)), concat('2 - 01', repeat('x', 1018)));
+
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+insert into t2_1024 values (concat('1 - 01', repeat('x', 1018)), concat('2 - 01', repeat('x', 1018)));
+insert into t2_1024 values (concat('1 - 02', repeat('x', 1018)), concat('2 - 02', repeat('x', 1018)));
+insert into t2_1024 values (concat('1 - 03', repeat('x', 1018)), concat('2 - 03', repeat('x', 1018)));
+insert into t2_1024 values (concat('1 - 04', repeat('x', 1018)), concat('2 - 04', repeat('x', 1018)));
+
+delimiter |;
+create procedure make_t1_indexes()
+begin
+ create index it1i1 on t1 (a1);
+ create index it1i2 on t1 (a2);
+ create index it1i3 on t1 (a1, a2);
+ create index it1_1024i1 on t1_1024 (a1(6));
+ create index it1_1024i2 on t1_1024 (a2(6));
+ create index it1_1024i3 on t1_1024 (a1(6), a2(6));
+end|
+
+create procedure make_t2_indexes()
+begin
+ create index it2i1 on t2 (b1);
+ create index it2i2 on t2 (b2);
+ create index it2i3 on t2 (b1, b2);
+ create unique index it2i4 on t2 (b1, b2, b3);
+ create index it2_1024i1 on t2_1024 (b1(6));
+ create index it2_1024i2 on t2_1024 (b2(6));
+ create index it2_1024i3 on t2_1024 (b1(6), b2(6));
+end|
+
+create procedure remove_t1_indexes()
+begin
+ drop index it1i1 on t1;
+ drop index it1i2 on t1;
+ drop index it1i3 on t1;
+ drop index it1_1024i1 on t1_1024;
+ drop index it1_1024i2 on t1_1024;
+ drop index it1_1024i3 on t1_1024;
+end|
+
+create procedure remove_t2_indexes()
+begin
+ drop index it2i1 on t2;
+ drop index it2i2 on t2;
+ drop index it2i3 on t2;
+ drop index it2i4 on t2;
+ drop index it2_1024i1 on t2_1024;
+ drop index it2_1024i2 on t2_1024;
+ drop index it2_1024i3 on t2_1024;
+end|
+
+create procedure add_materialization_data()
+begin
+insert into t1 values ('1 - 03', '2 - 03', '3 - 03', 3);
+insert into t1 values ('1 - 04', '2 - 04', '3 - 04', 4);
+insert into t1 values ('1 - 05', '2 - 05', '3 - 05', 5);
+insert into t1 values ('1 - 06', '2 - 06', '3 - 06', 6);
+insert into t1 values ('1 - 07', '2 - 07', '3 - 07', 7);
+insert into t1_1024 values (concat('1 - 03', repeat('x', 1018)), concat('2 - 03', repeat('x', 1018)));
+end|
+
+create procedure delete_materialization_data()
+begin
+delete from t1 where a1 >= '1 - 03';
+delete from t1_1024 where a1 >= '1 - 03';
+end|
+
+create procedure set_all_columns_not_null()
+begin
+alter table t1 modify a1 char(8) not null, modify a2 char(8) not null, modify a3 char(8) not null;
+alter table t2 modify b1 char(8) not null, modify b2 char(8) not null, modify b3 char(8) not null;
+end|
+
+create procedure set_all_columns_nullable()
+begin
+alter table t1 modify a1 char(8) null, modify a2 char(8) null, modify a3 char(8) null;
+alter table t2 modify b1 char(8) null, modify b2 char(8) null, modify b3 char(8) null;
+end|
+
+delimiter ;|
+-- echo
+
+-- echo /******************************************************************************
+-- echo 1. Both materialization and in-to-exists are ON, make a cost-based choice.
+-- echo ******************************************************************************/
+set @@optimizer_switch='materialization=on,in_to_exists=on';
+-- echo
+-- echo /* 1.1 In-to-exists is cheaper */
+call make_t1_indexes();
+
+-- echo /* 1.1.1 non-indexed table access */
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 1.1.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 1.1.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+-- source include/subselect_mat_cost.inc
+call set_all_columns_nullable();
+
+-- echo
+-- echo /* 1.2 Materialization is cheaper */
+# make materialization cheaper
+call add_materialization_data();
+call remove_t1_indexes();
+
+-- echo /* 1.2.1 non-indexed table access */
+call remove_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 1.2.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 1.2.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+-- source include/subselect_mat_cost.inc
+call set_all_columns_nullable();
+
+
+insert into t1 values ('1 - 02', '2 - 02', '3 - 02', 2);
+
+-- echo /******************************************************************************
+-- echo 2. Materialization is OFF, in-to-exists is ON, materialization is cheaper.
+-- echo ******************************************************************************/
+set @@optimizer_switch='materialization=off,in_to_exists=on';
+
+-- echo /* 2.1 non-indexed table access */
+call remove_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 2.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 2.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+-- source include/subselect_mat_cost.inc
+call set_all_columns_nullable();
+
+
+-- echo /******************************************************************************
+-- echo 3. Materialization is ON, in-to-exists is OFF, in-to-exists is cheaper.
+-- echo ******************************************************************************/
+set @@optimizer_switch='materialization=on,in_to_exists=off';
+# make IN-TO-EXISTS cheaper
+call delete_materialization_data();
+call make_t1_indexes();
+
+-- echo /* 3.1 non-indexed table access */
+call remove_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 3.2 indexed table access, nullabale columns. */
+call make_t2_indexes();
+-- source include/subselect_mat_cost.inc
+
+-- echo /* 3.3 indexed table access, non-nullabale columns. */
+call set_all_columns_not_null();
+-- source include/subselect_mat_cost.inc
+call set_all_columns_nullable();
+
+
+drop procedure make_t1_indexes;
+drop procedure make_t2_indexes;
+drop procedure remove_t1_indexes;
+drop procedure remove_t2_indexes;
+drop procedure add_materialization_data;
+drop procedure delete_materialization_data;
+drop procedure set_all_columns_not_null;
+drop procedure set_all_columns_nullable;
+drop table t1, t2, t1_1024, t2_1024;
diff --git a/mysql-test/t/subselect_mat_cost_bugs.test b/mysql-test/t/subselect_mat_cost_bugs.test
new file mode 100644
index 00000000000..0240c9203b3
--- /dev/null
+++ b/mysql-test/t/subselect_mat_cost_bugs.test
@@ -0,0 +1,328 @@
+#
+# Test cases for bugs related to the implementation of
+# MWL#89 cost-based choice between the materialization and in-to-exists
+#
+
+--echo #
+--echo # LP BUG#643424 valgrind warning in choose_subquery_plan()
+--echo #
+
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ c1 int(11) DEFAULT NULL,
+ c2 int(11) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY c2 (c2));
+
+INSERT INTO t1 VALUES (1,NULL,2);
+INSERT INTO t1 VALUES (2,7,9);
+INSERT INTO t1 VALUES (9,NULL,8);
+
+CREATE TABLE t2 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ c1 int(11) DEFAULT NULL,
+ c2 int(11) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY c2 (c2));
+
+INSERT INTO t2 VALUES (1,1,7);
+
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
+
+SELECT pk FROM t1 WHERE (c2, c1) IN (SELECT c2, c2 FROM t2);
+
+set session optimizer_switch=@save_optimizer_switch;
+
+drop table t1, t2;
+
+
+--echo #
+--echo # LP BUG#652727 Crash in create_ref_for_key()
+--echo #
+
+CREATE TABLE t2 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ c1 int(11) DEFAULT NULL,
+ PRIMARY KEY (pk));
+
+INSERT INTO t2 VALUES (10,7);
+INSERT INTO t2 VALUES (11,1);
+INSERT INTO t2 VALUES (17,NULL);
+
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ c1 int(11) DEFAULT NULL,
+ PRIMARY KEY (pk));
+
+INSERT INTO t1 VALUES (15,1);
+INSERT INTO t1 VALUES (19,NULL);
+
+CREATE TABLE t3 (c2 int(11) DEFAULT NULL, KEY c2 (c2));
+INSERT INTO t3 VALUES (1);
+
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
+
+SELECT c2
+FROM t3
+WHERE (2, 6) IN (SELECT t1.c1, t1.c1 FROM t1 STRAIGHT_JOIN t2 ON t2.pk = t1.pk);
+
+set session optimizer_switch=@save_optimizer_switch;
+drop table t1, t2, t3;
+
+
+--echo #
+--echo # LP BUG#641245 Crash in Item_equal::contains
+--echo #
+
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ c1 int(11) DEFAULT NULL,
+ c2 int(11) DEFAULT NULL,
+ c3 varchar(1) DEFAULT NULL,
+ c4 varchar(1) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY c2 (c2),
+ KEY c3 (c3,c2));
+
+INSERT INTO t1 VALUES (10,7,8,'v','v');
+INSERT INTO t1 VALUES (11,1,9,'r','r');
+INSERT INTO t1 VALUES (12,5,9,'a','a');
+
+create table t1a like t1;
+insert into t1a select * from t1;
+
+create table t1b like t1;
+insert into t1b select * from t1;
+
+CREATE TABLE t2 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ c1 int(11) DEFAULT NULL,
+ c2 int(11) DEFAULT NULL,
+ c3 varchar(1) DEFAULT NULL,
+ c4 varchar(1) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY c2 (c2),
+ KEY c3 (c3,c2));
+
+INSERT INTO t2 VALUES (1,NULL,2,'w','w');
+INSERT INTO t2 VALUES (2,7,9,'m','m');
+
+set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off';
+
+let $query=
+SELECT pk
+FROM t1
+WHERE c1 IN
+ (SELECT t1a.c1
+ FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN
+ t1a ON (t1a.c2 = t1b.pk AND 2)
+ WHERE t1.pk) ;
+eval EXPLAIN EXTENDED $query;
+eval $query;
+
+DROP TABLE t1, t1a, t1b, t2;
+
+--echo #
+--echo # LP BUG#714808 Assertion `outer_lookup_keys <= outer_record_count'
+--echo # failed with materialization
+
+CREATE TABLE t1 ( pk int(11), PRIMARY KEY (pk)) ;
+CREATE TABLE t2 ( f2 int(11)) ;
+CREATE TABLE t3 ( f1 int(11), f3 varchar(1), KEY (f1)) ;
+INSERT INTO t3 VALUES (7,'f');
+
+set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off';
+
+EXPLAIN
+SELECT t1.*
+FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
+WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
+
+SELECT t1.*
+FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
+WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
+
+drop table t1,t2,t3;
+
+--echo #
+--echo # LP BUG#714999 Second crash in select_describe() with nested subqueries
+--echo #
+
+CREATE TABLE t1 ( pk int(11)) ;
+INSERT INTO t1 VALUES (29);
+
+CREATE TABLE t2 ( f1 varchar(1)) ;
+INSERT INTO t2 VALUES ('f'),('d');
+
+CREATE TABLE t3 ( f2 varchar(1)) ;
+
+EXPLAIN SELECT f2 FROM t3 WHERE (
+ SELECT MAX( pk ) FROM t1
+ WHERE EXISTS (
+ SELECT DISTINCT f1
+ FROM t2
+ )
+) IS NULL ;
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # LP BUG#715034 Item_sum_distinct::clear(): Assertion `tree != 0' failed
+--echo #
+
+CREATE TABLE t2 ( f2 int(11)) ;
+
+CREATE TABLE t1 ( f3 int(11), KEY (f3)) ;
+INSERT INTO t1 VALUES (6),(4);
+
+EXPLAIN
+SELECT * FROM (SELECT * FROM t2) AS a2
+WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
+
+insert into t2 values (1),(2);
+EXPLAIN
+SELECT * FROM (SELECT * FROM t2) AS a2
+WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#715027 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
+--echo #
+
+CREATE TABLE t1 ( f1 int(11), PRIMARY KEY (f1)) ;
+INSERT INTO t1 VALUES (28),(29);
+
+CREATE TABLE t2 ( f2 int(11), f3 int(11), f10 varchar(1)) ;
+INSERT INTO t2 VALUES (NULL,6,'f'),(4,2,'d');
+
+EXPLAIN
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+ SELECT t2.f2
+ FROM t2 JOIN t1 ON t1.f1
+ WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+
+SELECT alias2.f2 AS field1
+FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
+WHERE (
+ SELECT t2.f2
+ FROM t2 JOIN t1 ON t1.f1
+ WHERE t1.f1 AND alias2.f10
+)
+ORDER BY field1 ;
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#718578 Yet another Assertion `!table ||
+--echo # (!table->read_set || bitmap_is_set(table->read_set, field_index))'
+
+CREATE TABLE t1 ( f1 int(11), f2 int(11), f3 int(11)) ;
+INSERT IGNORE INTO t1 VALUES (28,5,6),(29,NULL,4);
+
+CREATE TABLE t2 ( f10 varchar(1) );
+INSERT IGNORE INTO t2 VALUES (NULL);
+
+SELECT f1 AS field1
+FROM ( SELECT * FROM t1 ) AS alias1
+WHERE (SELECT t1.f1
+ FROM t2 JOIN t1 ON t1.f2
+ WHERE alias1.f3 AND t1.f3) AND f2
+ORDER BY field1;
+
+drop table t1,t2;
+
+--echo #
+--echo # LP BUG#601124 Bug in eliminate_item_equal
+--echo # leads to crash in Item_func::Item_func
+
+CREATE TABLE t1 ( f1 int(11), f3 varchar(1)) ;
+INSERT INTO t1 VALUES (5,'m'),(NULL,'c');
+
+CREATE TABLE t2 ( f2 int(11), f3 varchar(1)) ;
+INSERT INTO t2 VALUES (6,'f'),(2,'d');
+
+CREATE TABLE t3 ( f2 int(11), f3 varchar(1)) ;
+INSERT INTO t3 VALUES (6,'f'),(2,'d');
+
+SELECT * FROM t3
+WHERE ( f2 ) IN (SELECT t1.f1
+ FROM t1 STRAIGHT_JOIN t2 ON t2.f3 = t1.f3
+ WHERE t2.f3 = 'c');
+drop table t1,t2,t3;
+
+
+--echo #
+--echo # LP BUG#718593 Crash in substitute_for_best_equal_field -> eliminate_item_equal ->
+--echo # Item_field::find_item_equal -> Item_equal::contains
+--echo #
+
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch = 'semijoin=off';
+
+CREATE TABLE t1 ( f3 int(11), f10 varchar(1), f11 varchar(1)) ;
+INSERT IGNORE INTO t1 VALUES (6,'f','f'),(2,'d','d');
+
+CREATE TABLE t2 ( f12 int(11), f13 int(11)) ;
+insert into t2 values (1,2), (3,4);
+
+EXPLAIN
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+ SELECT alias2.f3
+ FROM t1 AS alias1 JOIN t1 AS alias2 ON alias2.f10 = alias1.f11
+ WHERE alias1.f11 OR alias1.f3 = 50 AND alias1.f10
+);
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+ SELECT alias2.f3
+ FROM t1 AS alias1 JOIN t1 AS alias2 ON alias2.f10 = alias1.f11
+ WHERE alias1.f11 OR alias1.f3 = 50 AND alias1.f10
+);
+
+EXPLAIN
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+ SELECT alias2.f3
+ FROM t1 AS alias1, t1 AS alias2
+ WHERE (alias2.f10 = alias1.f11) AND (alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
+SELECT * FROM t2
+WHERE ( f12 ) IN (
+ SELECT alias2.f3
+ FROM t1 AS alias1, t1 AS alias2
+ WHERE (alias2.f10 = alias1.f11) AND (alias1.f11 OR alias1.f3 = 50 AND alias1.f10));
+
+set @@optimizer_switch=@save_optimizer_switch;
+drop table t1, t2;
+
+
+--echo #
+--echo # MWL#89: test introduced after Sergey Petrunia's review - test that
+--echo # keyparts wihtout index prefix are used with the IN-EXISTS strategy.
+--echo #
+
+create table t1 (c1 int);
+insert into t1 values (1), (2), (3);
+
+create table t2 (kp1 int, kp2 int, c2 int, filler char(100));
+insert into t2 values (0,0,0,'filler'),(0,1,1,'filler'),(0,2,2,'filler'),(0,3,3,'filler');
+
+create index key1 on t2 (kp1, kp2);
+create index key2 on t2 (kp1);
+create index key3 on t2 (kp2);
+
+set session optimizer_switch='default';
+
+analyze table t2;
+
+explain
+select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
+select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
+
+drop table t1, t2;
diff --git a/mysql-test/t/subselect_no_opts.test b/mysql-test/t/subselect_no_opts.test
index a26e8dd4c0d..d72deab45bf 100644
--- a/mysql-test/t/subselect_no_opts.test
+++ b/mysql-test/t/subselect_no_opts.test
@@ -1,6 +1,6 @@
#
-# Run subselect.test without semi-join optimization (test materialize)
-#
+# Run subselect.test without semi-join and materialization optimizations
+# (test in-to-exists)
set optimizer_switch='materialization=off,semijoin=off';
--source t/subselect.test
diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test
index acc37a6f9ae..86ea719e8b0 100644
--- a/mysql-test/t/subselect_sj.test
+++ b/mysql-test/t/subselect_sj.test
@@ -311,7 +311,7 @@ FROM t0
WHERE varchar_nokey IN (
SELECT t1 .varchar_key from t1
);
-
+--disable_parsing # wrong duplicate results - LP BUG#702374
SELECT t0.int_key
FROM t0
WHERE t0.varchar_nokey IN (
@@ -325,7 +325,7 @@ WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
);
-
+--enable_parsing
DROP TABLE t0, t1, t2;
--echo # End of bug#46550
@@ -1117,6 +1117,100 @@ WHERE (int_nokey, pk)
DROP TABLE t1, t2, t3;
+--echo #
+--echo # BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
+--echo #
+CREATE TABLE t1 ( t1field integer, primary key (t1field));
+CREATE TABLE t2 ( t2field integer, primary key (t2field));
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t2 VALUES (2),(3),(4);
+explain
+SELECT * FROM t1 A
+WHERE
+ A.t1field IN (SELECT A.t1field FROM t2 B) AND
+ A.t1field IN (SELECT C.t2field FROM t2 C
+ WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
+SELECT * FROM t1 A
+WHERE
+ A.t1field IN (SELECT A.t1field FROM t2 B) AND
+ A.t1field IN (SELECT C.t2field FROM t2 C
+ WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
+drop table t1,t2;
+
+--echo #
+--echo # BUG#787299: Valgrind complains on a join query with two IN subqueries
+--echo #
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+create table t2 as select * from t1;
+select * from t1 A, t1 B
+ where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
+explain
+select * from t1 A, t1 B
+ where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
+drop table t1, t2;
+
+--echo #
+--echo # BUG#784441: Abort on semijoin with a view as the inner table
+--echo #
+
+CREATE TABLE t1 (a int) ;
+INSERT INTO t1 VALUES (1), (1);
+
+CREATE TABLE t2 (a int) ;
+INSERT INTO t2 VALUES (1), (1);
+
+CREATE VIEW v1 AS SELECT 1;
+
+EXPLAIN
+SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
+SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
+--echo #
+--echo # BUG#751439 Assertion `!table->file || table->file->inited == handler::NONE' failed with subquery
+--echo #
+CREATE TABLE t1 ( f10 int, f11 int) ;
+INSERT IGNORE INTO t1 VALUES (0,0),(0,0);
+
+CREATE TABLE t2 ( f11 int);
+INSERT IGNORE INTO t2 VALUES (0),(0);
+
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+
+SELECT alias1.f11 AS field2
+FROM ( t3 AS alias2 JOIN t1 AS alias3 ON alias3.f10 = 1)
+LEFT JOIN ( t2 AS alias1 ) ON alias3.f11 = 1
+WHERE alias2.f11 IN ( SELECT f11 FROM t2 )
+GROUP BY field2 ;
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # BUG#778406 Crash in hp_movelink with Aria engine and subqueries
+--echo #
+CREATE TABLE t4 (f10 varchar(32) , KEY (f10)) ENGINE=Aria;
+INSERT INTO t4 VALUES ('x'),('m'),('c');
+
+CREATE TABLE t1 (f11 int) ENGINE=Aria;
+INSERT INTO t1 VALUES (0),(0),(0);
+
+CREATE TABLE t2 ( f10 int) ENGINE=Aria;
+INSERT INTO t2 VALUES (0),(0),(0);
+
+CREATE TABLE t3 ( f10 int, f11 int) ENGINE=Aria;
+
+SELECT *
+FROM t4
+WHERE f10 IN
+( SELECT t1.f11
+FROM t1
+LEFT JOIN t2 JOIN t3 ON t3.f10 = t2.f10 ON t3.f11 != 0 );
+
+drop table t1,t2,t3,t4;
# The following command must be the last one the file
set @@optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test
index e73e7cfade2..f4573a94407 100644
--- a/mysql-test/t/subselect_sj2.test
+++ b/mysql-test/t/subselect_sj2.test
@@ -229,6 +229,9 @@ INSERT INTO t3 VALUES
('BEL','Dutch',59.2),('BLZ','English',50.8);
--enable_query_log
+# Disable materialization to avoid races between query plans
+set @bug35674_save_optimizer_switch=@@optimizer_switch;
+set optimizer_switch='materialization=off';
EXPLAIN
SELECT Name FROM t2
WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000)
@@ -236,6 +239,7 @@ SELECT Name FROM t2
t2.Code IN (SELECT Country FROM t3
WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000);
+set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3;
@@ -490,6 +494,12 @@ drop table t1, t2;
# Bug#33062: subquery in stored routine cause crash
#
+--disable_warnings
+drop procedure if exists p1;
+drop procedure if exists p2;
+drop procedure if exists p3;
+drop procedure if exists p4;
+--enable_warnings
CREATE TABLE t1(a INT);
CREATE TABLE t2(c INT);
@@ -902,3 +912,30 @@ explain select 1 from t2 where
c1 in (select convert(c6,char(1)) from t2);
drop table t2, t3;
+
+--echo #
+--echo # BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
+--echo #
+
+CREATE TABLE t1 ( f1 int NOT NULL , f10 int) ;
+INSERT IGNORE INTO t1 VALUES (25,0),(29,0);
+
+CREATE TABLE t2 ( f10 int) ENGINE=InnoDB;
+
+CREATE TABLE t3 ( f11 int) ;
+INSERT IGNORE INTO t3 VALUES (0);
+
+SELECT alias1.f10 AS field2
+FROM t2 AS alias1
+JOIN (
+ t3 AS alias2
+ JOIN t1 AS alias3
+ ON alias3.f10
+) ON alias3.f1
+WHERE alias2.f11 IN (
+ SELECT SQ4_alias1.f10
+ FROM t1 AS SQ4_alias1
+ LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10
+)
+GROUP BY field2;
+drop table t1, t2, t3;
diff --git a/mysql-test/t/subselect_sj2_mat.test b/mysql-test/t/subselect_sj2_mat.test
new file mode 100644
index 00000000000..643a287a897
--- /dev/null
+++ b/mysql-test/t/subselect_sj2_mat.test
@@ -0,0 +1,9 @@
+#
+# Run subselect_sj2.test with subquery materialization.
+#
+set optimizer_switch='materialization=on';
+
+--source t/subselect_sj2.test
+
+set optimizer_switch=default;
+select @@optimizer_switch like '%materialization=on%';
diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test
new file mode 100644
index 00000000000..728945be880
--- /dev/null
+++ b/mysql-test/t/subselect_sj_mat.test
@@ -0,0 +1,974 @@
+#
+# Hash semi-join regression tests
+# (WL#1110: Subquery optimization: materialization)
+#
+
+--disable_warnings
+drop table if exists t1, t2, t3, t1i, t2i, t3i;
+drop table if exists columns;
+drop table if exists t1_16, t2_16, t3_16;
+drop view if exists v1, v2, v1m, v2m;
+--enable_warnings
+
+create table t1 (a1 char(8), a2 char(8));
+create table t2 (b1 char(8), b2 char(8));
+create table t3 (c1 char(8), c2 char(8));
+
+insert into t1 values ('1 - 00', '2 - 00');
+insert into t1 values ('1 - 01', '2 - 01');
+insert into t1 values ('1 - 02', '2 - 02');
+
+insert into t2 values ('1 - 01', '2 - 01');
+insert into t2 values ('1 - 01', '2 - 01');
+insert into t2 values ('1 - 02', '2 - 02');
+insert into t2 values ('1 - 02', '2 - 02');
+insert into t2 values ('1 - 03', '2 - 03');
+
+insert into t3 values ('1 - 01', '2 - 01');
+insert into t3 values ('1 - 02', '2 - 02');
+insert into t3 values ('1 - 03', '2 - 03');
+insert into t3 values ('1 - 04', '2 - 04');
+
+# Indexed columns
+create table t1i (a1 char(8), a2 char(8));
+create table t2i (b1 char(8), b2 char(8));
+create table t3i (c1 char(8), c2 char(8));
+create index it1i1 on t1i (a1);
+create index it1i2 on t1i (a2);
+create index it1i3 on t1i (a1, a2);
+
+create index it2i1 on t2i (b1);
+create index it2i2 on t2i (b2);
+create index it2i3 on t2i (b1, b2);
+
+create index it3i1 on t3i (c1);
+create index it3i2 on t3i (c2);
+create index it3i3 on t3i (c1, c2);
+
+insert into t1i select * from t1;
+insert into t2i select * from t2;
+insert into t3i select * from t3;
+
+# force the use of materialization
+set @@optimizer_switch='materialization=on,in_to_exists=off,firstmatch=off';
+
+/******************************************************************************
+* Simple tests.
+******************************************************************************/
+# non-indexed nullable fields
+explain extended
+select * from t1 where a1 in (select b1 from t2 where b1 > '0');
+select * from t1 where a1 in (select b1 from t2 where b1 > '0');
+
+explain extended
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
+
+explain extended
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
+
+explain extended
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
+
+# indexed columns
+--replace_column 7 #
+--replace_regex /it1.*/_it1_idx/ /test.t2i.*/_ref_/ /Using index$// /Using where$//
+explain extended
+select * from t1i where a1 in (select b1 from t2i where b1 > '0');
+select * from t1i where a1 in (select b1 from t2i where b1 > '0');
+
+--replace_column 6 # 8 # 11 #
+explain extended
+select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
+select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
+
+--replace_column 7 #
+--replace_regex /it1.*/_it1_idx/ /test.t2i.*/_ref_/ /Using index$// /Using where$//
+explain extended
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
+
+--replace_column 6 # 7 # 8 # 11 #
+explain extended
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
+select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
+
+--replace_column 6 # 7 # 8 # 11 #
+explain extended
+select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+
+# BUG#31639: Wrong plan for uncorrelated subquery when loose scan is applicable.
+explain extended
+select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
+select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
+
+prepare st1 from "explain select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
+execute st1;
+execute st1;
+prepare st2 from "select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
+execute st2;
+execute st2;
+
+explain extended
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
+-- error 1235
+select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1);
+
+# test re-optimization/re-execution with different execution methods
+# prepare once, exec with different modes
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='default,semijoin=off';
+prepare st1 from
+"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
+set @@optimizer_switch='default,materialization=off';
+execute st1;
+set @@optimizer_switch='default,semijoin=off';
+execute st1;
+
+set @@optimizer_switch='default,materialization=off';
+prepare st1 from
+"select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1)";
+set @@optimizer_switch='default,semijoin=off';
+execute st1;
+set @@optimizer_switch='default,materialization=off';
+execute st1;
+set @@optimizer_switch=@save_optimizer_switch;
+
+# materialize the result of ORDER BY
+# non-indexed fields
+explain extended
+select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
+select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
+# indexed fields
+explain extended
+select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
+select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
+
+/******************************************************************************
+* Views, UNIONs, several levels of nesting.
+******************************************************************************/
+# materialize the result of subquery over temp-table view
+
+create algorithm=merge view v1 as
+select b1, c2 from t2, t3 where b2 > c2;
+
+create algorithm=merge view v2 as
+select b1, c2 from t2, t3 group by b2, c2;
+
+create algorithm=temptable view v1m as
+select b1, c2 from t2, t3 where b2 > c2;
+
+create algorithm=temptable view v2m as
+select b1, c2 from t2, t3 group by b2, c2;
+
+select * from v1 where (c2, b1) in (select c2, b1 from v2 where b1 is not null);
+select * from v1 where (c2, b1) in (select distinct c2, b1 from v2 where b1 is not null);
+
+select * from v1m where (c2, b1) in (select c2, b1 from v2m where b1 is not null);
+select * from v1m where (c2, b1) in (select distinct c2, b1 from v2m where b1 is not null);
+
+drop view v1, v2, v1m, v2m;
+
+# nested subqueries, views
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+select * from t1
+where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+
+--replace_column 6 # 7 # 8 # 11 #
+explain extended
+select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+ (a1, a2) in (select c1, c2 from t3i
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+ (a1, a2) in (select c1, c2 from t3i
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 where c2 LIKE '%02') or
+ b2 in (select c2 from t3 where c2 LIKE '%03')) and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 where c2 LIKE '%02') or
+ b2 in (select c2 from t3 where c2 LIKE '%03')) and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+
+# as above with correlated innermost subquery
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 t3a where c1 = a1) or
+ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
+ (a1, a2) in (select c1, c2 from t3 t3c
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 t3a where c1 = a1) or
+ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
+ (a1, a2) in (select c1, c2 from t3 t3c
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+
+
+# multiple levels of nesting subqueries, unions
+--replace_column 6 # 7 # 8 # 11 #
+explain extended
+(select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 where c2 LIKE '%02') or
+ b2 in (select c2 from t3 where c2 LIKE '%03')
+ group by b1, b2) and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
+UNION
+(select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+ (a1, a2) in (select c1, c2 from t3i
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
+
+(select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 where c2 LIKE '%02') or
+ b2 in (select c2 from t3 where c2 LIKE '%03')
+ group by b1, b2) and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
+UNION
+(select * from t1i
+where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
+ (a1, a2) in (select c1, c2 from t3i
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
+
+
+# UNION of subqueries as a subquery (thus it is not computed via materialization)
+explain extended
+select * from t1
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+select * from t1
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+ (a1, a2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
+# as above, with a join conditon between the outer references
+explain extended
+select * from t1, t3
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+ (c1, c2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
+ a1 = c1;
+select * from t1, t3
+where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
+ (c1, c2) in (select c1, c2 from t3
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
+ a1 = c1;
+
+
+/******************************************************************************
+* Negative tests, where materialization should not be applied.
+******************************************************************************/
+# UNION in a subquery
+explain extended
+select * from t3
+where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
+select * from t3
+where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
+
+# correlation
+explain extended
+select * from t1
+where (a1, a2) in (select b1, b2 from t2
+ where b2 in (select c2 from t3 t3a where c1 = a1) or
+ b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
+ (a1, a2) in (select c1, c2 from t3 t3c
+ where (c1, c2) in (select b1, b2 from t2i where b2 > '0' or b2 = a2));
+
+# subquery has no tables
+explain extended
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
+explain extended
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
+select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
+
+
+/******************************************************************************
+* Subqueries in other uncovered clauses.
+******************************************************************************/
+
+/* SELECT clause */
+select ((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL from t1;
+
+/* GROUP BY clause */
+create table columns (col int key);
+insert into columns values (1), (2);
+
+explain extended
+select * from t1 group by (select col from columns limit 1);
+select * from t1 group by (select col from columns limit 1);
+
+explain extended
+select * from t1 group by (a1 in (select col from columns));
+select * from t1 group by (a1 in (select col from columns));
+
+/* ORDER BY clause */
+explain extended
+select * from t1 order by (select col from columns limit 1);
+select * from t1 order by (select col from columns limit 1);
+
+/******************************************************************************
+* Column types/sizes that affect materialization.
+******************************************************************************/
+
+/*
+ Test that BLOBs are not materialized (except when arguments of some functions).
+*/
+# force materialization to be always considered
+set @prefix_len = 6;
+
+# BLOB == 16 (small blobs that could be stored in HEAP tables)
+set @blob_len = 16;
+set @suffix_len = @blob_len - @prefix_len;
+
+create table t1_16 (a1 blob(16), a2 blob(16));
+create table t2_16 (b1 blob(16), b2 blob(16));
+create table t3_16 (c1 blob(16), c2 blob(16));
+
+insert into t1_16 values
+ (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_16 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_16 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+
+insert into t2_16 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_16 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_16 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+
+insert into t3_16 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_16 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_16 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_16 values
+ (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+
+# single value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select b1 from t2_16 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select b1 from t2_16 where b1 > '0');
+
+# row value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_16
+where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
+
+# string function with a blob argument, the return type may be != blob
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
+
+# group_concat with a blob argument - depends on
+# the variable group_concat_max_len, and
+# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+
+set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 512)
+
+explain extended select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_16
+where a1 in (select group_concat(b1) from t2_16 group by b2);
+
+# BLOB column at the second (intermediate) level of nesting
+explain extended
+select * from t1
+where concat(a1,'x') IN
+ (select left(a1,8) from t1_16
+ where (a1, a2) IN
+ (select t2_16.b1, t2_16.b2 from t2_16, t2
+ where t2.b2 = substring(t2_16.b2,1,6) and
+ t2.b1 IN (select c1 from t3 where c2 > '0')));
+
+
+drop table t1_16, t2_16, t3_16;
+
+
+# BLOB == 512 (CONVERT_IF_BIGGER_TO_BLOB == 512)
+set @blob_len = 512;
+set @suffix_len = @blob_len - @prefix_len;
+
+create table t1_512 (a1 blob(512), a2 blob(512));
+create table t2_512 (b1 blob(512), b2 blob(512));
+create table t3_512 (c1 blob(512), c2 blob(512));
+
+insert into t1_512 values
+ (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_512 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_512 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+
+insert into t2_512 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_512 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_512 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+
+insert into t3_512 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_512 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_512 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_512 values
+ (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+
+# single value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select b1 from t2_512 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select b1 from t2_512 where b1 > '0');
+
+# row value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_512
+where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
+
+# string function with a blob argument, the return type may be != blob
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
+
+# group_concat with a blob argument - depends on
+# the variable group_concat_max_len, and
+# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+
+set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 512)
+
+explain extended select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_512
+where a1 in (select group_concat(b1) from t2_512 group by b2);
+
+drop table t1_512, t2_512, t3_512;
+
+
+# BLOB == 1024 (group_concat_max_len == 1024)
+set @blob_len = 1024;
+set @suffix_len = @blob_len - @prefix_len;
+
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+create table t3_1024 (c1 blob(1024), c2 blob(1024));
+
+insert into t1_1024 values
+ (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1024 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1024 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+
+insert into t2_1024 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1024 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+
+insert into t3_1024 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_1024 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_1024 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_1024 values
+ (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+
+# single value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select b1 from t2_1024 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select b1 from t2_1024 where b1 > '0');
+
+# row value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_1024
+where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
+
+# string function with a blob argument, the return type may be != blob
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
+
+# group_concat with a blob argument - depends on
+# the variable group_concat_max_len, and
+# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+
+set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 1024)
+
+explain extended select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_1024
+where a1 in (select group_concat(b1) from t2_1024 group by b2);
+
+drop table t1_1024, t2_1024, t3_1024;
+
+
+# BLOB == 1025
+set @blob_len = 1025;
+set @suffix_len = @blob_len - @prefix_len;
+
+create table t1_1025 (a1 blob(1025), a2 blob(1025));
+create table t2_1025 (b1 blob(1025), b2 blob(1025));
+create table t3_1025 (c1 blob(1025), c2 blob(1025));
+
+insert into t1_1025 values
+ (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1025 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1025 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+
+insert into t2_1025 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1025 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1025 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+
+insert into t3_1025 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t3_1025 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t3_1025 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+insert into t3_1025 values
+ (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
+
+# single value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select b1 from t2_1025 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select b1 from t2_1025 where b1 > '0');
+
+# row value transformer
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_1025
+where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
+
+# string function with a blob argument, the return type may be != blob
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
+
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
+
+# group_concat with a blob argument - depends on
+# the variable group_concat_max_len, and
+# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+
+set @@group_concat_max_len = 256; # anything < (CONVERT_IF_BIGGER_TO_BLOB = 1025)
+
+explain extended select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+
+select left(a1,7), left(a2,7)
+from t1_1025
+where a1 in (select group_concat(b1) from t2_1025 group by b2);
+
+drop table t1_1025, t2_1025, t3_1025;
+
+# test for BIT fields
+create table t1bit (a1 bit(3), a2 bit(3));
+create table t2bit (b1 bit(3), b2 bit(3));
+
+insert into t1bit values (b'000', b'100');
+insert into t1bit values (b'001', b'101');
+insert into t1bit values (b'010', b'110');
+
+insert into t2bit values (b'001', b'101');
+insert into t2bit values (b'010', b'110');
+insert into t2bit values (b'110', b'111');
+
+explain extended select bin(a1), bin(a2)
+from t1bit
+where (a1, a2) in (select b1, b2 from t2bit);
+
+select bin(a1), bin(a2)
+from t1bit
+where (a1, a2) in (select b1, b2 from t2bit);
+
+drop table t1bit, t2bit;
+
+# test mixture of BIT and BLOB
+create table t1bb (a1 bit(3), a2 blob(3));
+create table t2bb (b1 bit(3), b2 blob(3));
+
+insert into t1bb values (b'000', '100');
+insert into t1bb values (b'001', '101');
+insert into t1bb values (b'010', '110');
+
+insert into t2bb values (b'001', '101');
+insert into t2bb values (b'010', '110');
+insert into t2bb values (b'110', '111');
+
+explain extended select bin(a1), a2
+from t1bb
+where (a1, a2) in (select b1, b2 from t2bb);
+
+select bin(a1), a2
+from t1bb
+where (a1, a2) in (select b1, b2 from t2bb);
+
+drop table t1bb, t2bb;
+drop table t1, t2, t3, t1i, t2i, t3i, columns;
+
+/******************************************************************************
+* Test the cache of the left operand of IN.
+******************************************************************************/
+
+# Test that default values of Cached_item are not used for comparison
+create table t1 (s1 int);
+create table t2 (s2 int);
+insert into t1 values (5),(1),(0);
+insert into t2 values (0), (1);
+select s2 from t2 where s2 in (select s1 from t1);
+drop table t1, t2;
+
+create table t1 (a int not null, b int not null);
+create table t2 (c int not null, d int not null);
+create table t3 (e int not null);
+
+# the first outer row has no matching inner row
+insert into t1 values (1,10);
+insert into t1 values (1,20);
+insert into t1 values (2,10);
+insert into t1 values (2,20);
+insert into t1 values (2,30);
+insert into t1 values (3,20);
+insert into t1 values (4,40);
+
+insert into t2 values (2,10);
+insert into t2 values (2,20);
+insert into t2 values (2,40);
+insert into t2 values (3,20);
+insert into t2 values (4,10);
+insert into t2 values (5,10);
+
+insert into t3 values (10);
+insert into t3 values (10);
+insert into t3 values (20);
+insert into t3 values (30);
+
+explain extended
+select a from t1 where a in (select c from t2 where d >= 20);
+select a from t1 where a in (select c from t2 where d >= 20);
+
+create index it1a on t1(a);
+
+explain extended
+select a from t1 where a in (select c from t2 where d >= 20);
+select a from t1 where a in (select c from t2 where d >= 20);
+
+# the first outer row has a matching inner row
+insert into t2 values (1,10);
+
+explain extended
+select a from t1 where a in (select c from t2 where d >= 20);
+select a from t1 where a in (select c from t2 where d >= 20);
+
+# cacheing for IN predicates inside a having clause - here the cached
+# items are changed to point to temporary tables.
+explain extended
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+
+# create an index that can be used for the outer query GROUP BY
+create index iab on t1(a, b);
+explain extended
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+select a from t1 group by a having a in (select c from t2 where d >= 20);
+
+explain extended
+select a from t1 group by a
+having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
+select a from t1 group by a
+having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
+explain extended
+select a from t1
+where a in (select c from t2 where d >= some(select e from t3 where b=e));
+select a from t1
+where a in (select c from t2 where d >= some(select e from t3 where b=e));
+
+drop table t1, t2, t3;
+
+#
+# BUG#36133 "Assertion `exec_method != MATERIALIZATION || (exec_method == MATERIALIZATION &&"
+#
+create table t2 (a int, b int, key(a), key(b));
+insert into t2 values (3,3),(3,3),(3,3);
+select 1 from t2 where
+ t2.a > 1
+ or
+ t2.a = 3 and not t2.a not in (select t2.b from t2);
+drop table t2;
+
+#
+# BUG#37896 Assertion on entry of Item_in_subselect::exec on subquery with AND NOT
+#
+create table t1 (a1 int key);
+create table t2 (b1 int);
+insert into t1 values (5);
+
+# Query with group by, executed via materialization
+explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+# Query with group by, executed via IN=>EXISTS
+set @save_optimizer_switch=@@optimizer_switch;
+set @@optimizer_switch='default,materialization=off';
+explain select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+select min(a1) from t1 where 7 in (select b1 from t2 group by b1);
+
+# Executed with materialization
+set @@optimizer_switch='default,semijoin=off';
+explain select min(a1) from t1 where 7 in (select b1 from t2);
+select min(a1) from t1 where 7 in (select b1 from t2);
+# Executed with semi-join. Notice, this time we get a different result (NULL).
+# This is the only correct result of all four queries. This difference is
+# filed as BUG#40037.
+set @@optimizer_switch='default,materialization=off';
+-- echo # with MariaDB and MWL#90, this particular case is solved:
+explain select min(a1) from t1 where 7 in (select b1 from t2);
+select min(a1) from t1 where 7 in (select b1 from t2);
+-- echo # but when we go around MWL#90 code, the problem still shows up:
+explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
+select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
+set @@optimizer_switch= @save_optimizer_switch;
+drop table t1,t2;
+
+#
+# BUG#36752 "subquery materialization produces wrong results when comparing different types"
+#
+create table t1 (a char(2), b varchar(10));
+insert into t1 values ('a', 'aaa');
+insert into t1 values ('aa', 'aaaa');
+
+explain select a,b from t1 where b in (select a from t1);
+select a,b from t1 where b in (select a from t1);
+prepare st1 from "select a,b from t1 where b in (select a from t1)";
+execute st1;
+execute st1;
+drop table t1;
+
+#
+# Bug #44303 Assertion failures in Field_new_decimal::store_decimal
+# when executing materialized InsideOut semijoin
+#
+CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM;
+INSERT INTO t1 (f1, f2) VALUES (1, 1.789);
+INSERT INTO t1 (f1, f2) VALUES (13, 1.454);
+INSERT INTO t1 (f1, f2) VALUES (10, 1.668);
+
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1, 1.789);
+INSERT INTO t2 VALUES (13, 1.454);
+
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
+set @@optimizer_switch= @save_optimizer_switch;
+
+DROP TABLE t1, t2;
+
+#
+# BUG#46548 IN-subqueries return 0 rows with materialization=on
+#
+CREATE TABLE t1 (
+ pk int,
+ a varchar(1),
+ b varchar(4),
+ c varchar(4),
+ d varchar(4),
+ PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
+
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
+
+set @save_optimizer_switch=@@optimizer_switch;
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
+DROP TABLE t1, t2;
+set optimizer_switch=@save_optimizer_switch;
+
+--echo #
+--echo # BUG#50019: Wrong result for IN-subquery with materialization
+--echo #
+create table t1(i int);
+insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+create table t2(i int);
+insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+create table t3(i int);
+insert into t3 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
+set @save_optimizer_switch=@@optimizer_switch;
+set session optimizer_switch='materialization=off,in_to_exists=on';
+select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5);
+set session optimizer_switch=@save_optimizer_switch;
+drop table t1, t2, t3;
+
+#
+# Test that the contents of the temp table of a materialized subquery is
+# cleaned up between PS re-executions.
+#
+
+create table t0 (a int);
+insert into t0 values (0),(1),(2);
+create table t1 (a int);
+insert into t1 values (0),(1),(2);
+explain select a, a in (select a from t1) from t0;
+select a, a in (select a from t1) from t0;
+prepare s from 'select a, a in (select a from t1) from t0';
+execute s;
+update t1 set a=123;
+execute s;
+drop table t0, t1;
+set optimizer_switch='firstmatch=on';
+
+--echo #
+--echo # MWL#90, review feedback: check what happens when the subquery
+--echo # looks like candidate for MWL#90 checking at the first glance
+--echo # but then subselect_hash_sj_engine::init_permanent() discovers
+--echo # that it's not possible to perform duplicate removal for the
+--echo # selected datatypes, and so materialization isn't applicable after
+--echo # all.
+--echo #
+set @blob_len = 1024;
+set @suffix_len = @blob_len - @prefix_len;
+
+create table t1_1024 (a1 blob(1024), a2 blob(1024));
+create table t2_1024 (b1 blob(1024), b2 blob(1024));
+
+insert into t1_1024 values
+ (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
+insert into t1_1024 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t1_1024 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+
+insert into t2_1024 values
+ (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
+insert into t2_1024 values
+ (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
+insert into t2_1024 values
+ (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
+
+explain select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1,1,1024), count(*) from t2_1024 where b1 > '0');
+select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1,1,1024), count(*) from t2_1024 where b1 > '0');
+
+drop table t1_1024, t2_1024;
diff --git a/mysql-test/t/subselect_sj_nonmerged.test b/mysql-test/t/subselect_sj_nonmerged.test
new file mode 100644
index 00000000000..5c8fb6db424
--- /dev/null
+++ b/mysql-test/t/subselect_sj_nonmerged.test
@@ -0,0 +1,114 @@
+#
+# Tests for non-merged semi-joins
+#
+--disable_warnings
+drop table if exists t0, t1, t2, t3, t4;
+--enable_warnings
+
+set @save_optimizer_switch=@@optimizer_switch;
+set optimizer_switch='materialization=on';
+
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+
+# Check the case of subquery having agggregates but not having grouping
+
+create table t1 as select * from t0;
+--echo # The following should use full scan on <subquery2> and it must scan 1 row:
+explain select * from t0 where a in (select max(a) from t1);
+select * from t0 where a in (select max(a) from t1);
+
+# Ok, now check the trivial match/no-match/NULL on the left/NULL on the right cases
+insert into t1 values (11);
+select * from t0 where a in (select max(a) from t1);
+delete from t1 where a=11;
+
+insert into t0 values (NULL);
+select * from t0 where a in (select max(a) from t1);
+delete from t0 where a is NULL;
+
+delete from t1;
+select * from t0 where a in (select max(a) from t1);
+
+insert into t0 values (NULL);
+select * from t0 where a in (select max(a) from t1);
+delete from t0 where a is NULL;
+
+drop table t1;
+
+#
+# Try with join subqueries
+#
+
+create table t1 (a int, b int);
+insert into t1 select a,a from t0; # 10 rows
+create table t2 as select * from t1 where a<5; # 5 rows
+create table t3 as select (A.a + 10*B.a) as a from t0 A, t0 B; # 100 rows
+alter table t3 add primary key(a);
+
+--echo # The following should have do a full scan on <subquery2> and scan 5 rows
+--echo # (despite that subquery's join output estimate is 50 rows)
+explain select * from t3 where a in (select max(t2.a) from t1, t2 group by t2.b);
+
+--echo # Compare to this which really will have 50 record combinations:
+explain select * from t3 where a in (select max(t2.a) from t1, t2 group by t2.b, t1.b);
+
+--echo # Outer joins also work:
+explain select * from t3
+where a in (select max(t2.a) from t1 left join t2 on t1.a=t2.a group by t2.b, t1.b);
+
+#
+# Check if joins on the outer side also work
+#
+create table t4 (a int, b int, filler char(20), unique key(a,b));
+insert into t4 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t0 A, t0 B; # 100 rows
+explain select * from t0, t4 where
+ t4.b=t0.a and t4.a in (select max(t2.a) from t1, t2 group by t2.b);
+
+insert into t4 select 100 + (B.a *100 + A.a), 100 + (B.a*100 + A.a), 'filler' from t4 A, t0 B;
+explain select * from t4 where
+ t4.a in (select max(t2.a) from t1, t2 group by t2.b) and
+ t4.b in (select max(t2.a) from t1, t2 group by t2.b);
+
+drop table t1,t2,t3,t4;
+
+drop table t0;
+
+--echo #
+--echo # BUG#780359: Crash with get_fanout_with_deps in maria-5.3-mwl90
+--echo #
+CREATE TABLE t1 (f1 int);
+INSERT INTO t1 VALUES (2),(2);
+
+CREATE TABLE t2 (f3 int);
+INSERT INTO t2 VALUES (2),(2);
+
+SELECT *
+FROM t1
+WHERE ( f1 ) IN (
+ SELECT t2.f3
+ FROM t2
+ WHERE t2.f3 = 97
+ AND t2.f3 = 50
+ GROUP BY 1
+);
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # BUG#727183: WL#90 does not trigger with non-comma joins
+--echo #
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1(a int, key(a));
+insert into t1 select A.a + 10*B.a + 100*C.a from t0 A, t0 B, t0 C;
+
+--echo # The following must use non-merged SJ-Materialization:
+explain select * from t1 X join t0 Y on X.a < Y.a where X.a in (select max(a) from t0);
+
+drop table t0, t1;
+
+set optimizer_switch=@save_optimizer_switch;
+
diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test
index 440fcc8aa8a..08d40bdae0f 100644
--- a/mysql-test/t/system_mysql_db_fix40123.test
+++ b/mysql-test/t/system_mysql_db_fix40123.test
@@ -41,8 +41,8 @@ INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
-CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name varchar(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url varchar(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name varchar(64) not null, parent_category_id smallint unsigned null, url varchar(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test
index 4924c625d57..41e85661fe8 100644
--- a/mysql-test/t/system_mysql_db_fix50030.test
+++ b/mysql-test/t/system_mysql_db_fix50030.test
@@ -39,9 +39,9 @@ INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
-CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
@@ -60,7 +60,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL,
CREATE TABLE proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE TABLE servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test
index d88c4edba93..bed00239081 100644
--- a/mysql-test/t/system_mysql_db_fix50117.test
+++ b/mysql-test/t/system_mysql_db_fix50117.test
@@ -44,9 +44,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
-CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
@@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
diff --git a/mysql-test/t/timezone.test b/mysql-test/t/timezone.test
index 157b18f57fa..a41e806a40e 100644
--- a/mysql-test/t/timezone.test
+++ b/mysql-test/t/timezone.test
@@ -60,4 +60,6 @@ select unix_timestamp('1970-01-01 01:00:00'),
unix_timestamp('2038-01-19 04:14:07'),
unix_timestamp('2038-01-19 04:14:08');
+select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59');
+
# End of 4.1 tests
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 4e097edf73d..c5862699524 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -535,10 +535,10 @@ DROP TABLE b15776;
CREATE TABLE b15776 (a year(-2));
## For timestamp, we silently rewrite widths to 14 or 19.
+--error ER_TOO_BIG_PRECISION
CREATE TABLE b15776 (a timestamp(4294967294));
-DROP TABLE b15776;
+--error ER_TOO_BIG_PRECISION
CREATE TABLE b15776 (a timestamp(4294967295));
-DROP TABLE b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a timestamp(4294967296));
--error ER_PARSE_ERROR
@@ -628,3 +628,11 @@ DROP TABLE t1;
--echo End of 5.1 tests
+#
+# Problem when comparing blobs #778901
+#
+
+CREATE TABLE t1 ( f1 blob, f2 blob );
+INSERT INTO t1 VALUES ('','');
+SELECT f1,f2,"found row" FROM t1 WHERE f1 = f2 ;
+DROP TABLE t1;
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 899f912a5a5..a2639e81aa9 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -267,3 +267,11 @@ DROP TABLE t1;
DROP VIEW v1;
--echo End of 5.1 tests
+
+#
+# lp:737496 Field_temporal::store_TIME_with_warning() in 5.1-micro
+#
+create table t1 (f1 date, key (f1));
+insert t1 values ('2010-10-10 15:foobar');
+drop table t1;
+
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index d4fa6bed186..4e091e14b30 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -137,9 +137,9 @@ DROP TABLE t1;
# Bug 19491 (CAST DATE AS DECIMAL returns incorrect result
#
SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6));
-SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
-SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
-SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
+SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME(6)) AS DECIMAL(20,6));
+SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME(6)) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
+SELECT CAST(CAST('10:11:12.098700' AS TIME(6)) AS DECIMAL(20,6));
#
@@ -432,17 +432,28 @@ set @@sql_mode= @org_mode;
# Bug #42146 - DATETIME fractional seconds parse error
#
# show we trucate microseconds from the right -- special case: leftmost is 0
-SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7));
+SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME(6)) AS DECIMAL(30,7));
# show that we ignore leading zeroes for all other fields
-SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7));
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME(6)) AS DECIMAL(30,7));
# once more with feeling (but no warnings)
-SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7));
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME(6)) AS DECIMAL(30,7));
#
# Bug #38435 - LONG Microseconds cause MySQL to fail a CAST to DATETIME or DATE
#
# show we truncate microseconds from the right
-SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7));
+SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime(6)) AS DECIMAL(30,7));
+
+--echo #
+--echo # Bug#59173: Failure to handle DATE(TIME) values where Year, Month or
+--echo # Day is ZERO
+--echo #
+CREATE TABLE t1 (dt1 DATETIME);
+INSERT INTO t1 (dt1) VALUES ('0000-00-01 00:00:01');
+DELETE FROM t1 WHERE dt1 = '0000-00-01 00:00:01';
+--echo # Should be empty
+SELECT * FROM t1;
+DROP TABLE t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/type_datetime_hires.test b/mysql-test/t/type_datetime_hires.test
new file mode 100644
index 00000000000..74f686d4157
--- /dev/null
+++ b/mysql-test/t/type_datetime_hires.test
@@ -0,0 +1,71 @@
+
+--source include/have_partition.inc
+
+let type=datetime;
+--source include/type_hrtime.inc
+
+#
+# partitioning
+#
+eval CREATE TABLE t1 (
+ taken $type(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
+ id int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (id,taken),
+ KEY taken (taken)
+)
+PARTITION BY RANGE (to_days(taken))
+(
+PARTITION p01 VALUES LESS THAN (732920),
+PARTITION p02 VALUES LESS THAN (732950),
+PARTITION p03 VALUES LESS THAN MAXVALUE);
+
+INSERT INTO t1 VALUES
+('2006-09-27 21:50:01.123456',0),
+('2006-09-27 21:50:01.123456',1),
+('2006-09-27 21:50:01.123456',2),
+('2006-09-28 21:50:01.123456',3),
+('2006-09-29 21:50:01.123456',4),
+('2006-09-29 21:50:01.123456',5),
+('2006-09-30 21:50:01.123456',6),
+('2006-10-01 21:50:01.123456',7),
+('2006-10-02 21:50:01.123456',8),
+('2006-10-02 21:50:01.123456',9);
+
+SELECT id,to_days(taken) FROM t1 order by 2;
+
+eval CREATE TABLE t2 (
+ taken $type(5) NOT NULL DEFAULT '0000-00-00 00:00:00',
+ id int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (id,taken),
+ KEY taken (taken)
+)
+PARTITION BY RANGE (extract(microsecond from taken))
+(
+PARTITION p01 VALUES LESS THAN (123000),
+PARTITION p02 VALUES LESS THAN (500000),
+PARTITION p03 VALUES LESS THAN MAXVALUE);
+
+INSERT INTO t2 VALUES
+('2006-09-27 21:50:01',0),
+('2006-09-27 21:50:01.1',1),
+('2006-09-27 21:50:01.12',2),
+('2006-09-28 21:50:01.123',3),
+('2006-09-29 21:50:01.1234',4),
+('2006-09-29 21:50:01.12345',5),
+('2006-09-30 21:50:01.123456',6),
+('2006-10-01 21:50:01.56',7),
+('2006-10-02 21:50:01.567',8),
+('2006-10-02 21:50:01.5678',9);
+
+select table_name,partition_name,partition_method,partition_expression,partition_description,table_rows from information_schema.partitions where table_name in ('t1', 't2');
+
+drop table t1, t2;
+
+create table t1 (a datetime, b datetime(6));
+insert t1 values ('2010-01-02 03:04:05.678912', '2010-01-02 03:04:05.678912');
+update t1 set b=a;
+select * from t1;
+alter table t1 modify b datetime, modify a datetime(6);
+select * from t1;
+drop table t1;
+
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index 34331b72688..a456f2b9eea 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -100,3 +100,26 @@ SELECT TIMESTAMP(f1,'1') FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
+
+create table t1 (a time);
+insert t1 values (-131415);
+select * from t1;
+drop table t1;
+
+#
+# lp:731229 Different results depending on table access method with TIME column and CURDATE()
+#
+create table t1 (f1 time , f2 varchar(5), key(f1));
+insert into t1 values ('00:20:01','a'),('00:20:03','b');
+select * from t1 force key (f1) where f1 < curdate();
+select * from t1 ignore key (f1) where f1 < curdate();
+drop table t1;
+
+#
+# comparison of time and datetime:
+#
+create table t1(f1 time);
+insert into t1 values ('23:38:57');
+select f1, f1 = '2010-10-11 23:38:57' from t1;
+drop table t1;
+
diff --git a/mysql-test/t/type_time_hires.test b/mysql-test/t/type_time_hires.test
new file mode 100644
index 00000000000..3785a23f1eb
--- /dev/null
+++ b/mysql-test/t/type_time_hires.test
@@ -0,0 +1,12 @@
+
+let type=time;
+--source include/type_hrtime.inc
+
+create table t1 (a time(4) not null, key(a));
+insert into t1 values ('1:2:3.001'),('1:2:3'), ('-00:00:00.6'),('-00:00:00.7'),('-00:00:00.8'),('-00:00:00.9'),('-00:00:01.0'),('-00:00:01.1'),('-00:00:01.000000'),('-00:00:01.100001'),('-00:00:01.000002'),('-00:00:01.090000');
+select * from t1 order by a;
+select * from t1 order by a desc;
+select min(a - interval 1 hour), max(a - interval 1 hour) from t1 where a < 0;
+drop table t1;
+
+select cast(1e-6 as time(6));
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index 602f6f089c2..533a45ba7fe 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -67,17 +67,6 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1;
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
- t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
- t14 timestamp(14));
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-select * from t1;
-drop table t1;
-
#
# Let us check if we properly treat wrong datetimes and produce proper warnings
# (for both strings and numbers)
@@ -298,7 +287,7 @@ drop table t1;
# mode regardless of whether a display width is given.
#
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp(5));
show create table t1;
# restore default mode
set sql_mode='';
@@ -373,4 +362,51 @@ SELECT a FROM t1 WHERE a >= '20000101000000';
DROP TABLE t1;
+--echo #
+--echo # Bug#50774: failed to get the correct resultset when timestamp values
+--echo # are appended with .0
+--echo #
+CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) );
+
+INSERT INTO t1 VALUES( '2010-02-01 09:31:01' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:02' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:03' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:04' );
+
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a;
+SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0';
+SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a;
+
+--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+
+CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) );
+
+INSERT INTO t2 VALUES( '2010-02-01 09:31:01' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:02' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:03' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:04' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:05' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:06' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:07' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:08' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:09' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:10' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:11' );
+
+--echo # The bug would cause the range optimizer's comparison to use an open
+--echo # interval here. This reveals itself only in the number of reads
+--echo # performed.
+FLUSH STATUS;
+--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
+SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
+SHOW STATUS LIKE 'Handler_read_next';
+
+DROP TABLE t1, t2;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/type_timestamp_hires.test b/mysql-test/t/type_timestamp_hires.test
new file mode 100644
index 00000000000..8e1f8586956
--- /dev/null
+++ b/mysql-test/t/type_timestamp_hires.test
@@ -0,0 +1,16 @@
+
+let type=timestamp;
+--source include/type_hrtime.inc
+
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456;
+
+create table t1 (a timestamp(5));
+#
+# CREATE ... DEFAULT NOW(X)
+#
+
+insert t1 values ();
+select * from t1;
+drop table t1;
+
diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test
index 1a9e66478e1..de38306e88f 100644
--- a/mysql-test/t/type_year.test
+++ b/mysql-test/t/type_year.test
@@ -157,6 +157,7 @@ CREATE TABLE t1(c1 YEAR(4));
INSERT INTO t1 VALUES (1901),(2155),(0000);
SELECT * FROM t1;
SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
+SELECT COUNT(*) AS total_rows, MIN(c1+0) AS min_value, MAX(c1+0) FROM t1;
DROP TABLE t1;
--echo #
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index c8d5ea0f8e5..34bb4afc41c 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -1155,5 +1155,13 @@ SELECT * FROM t2 UNION SELECT * FROM t2
DROP TABLE t1,t2;
+#
+# lp:732124 union + limit returns wrong result
+#
+create table t1 (a int);
+insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10);
+--sorted_result
+select a from t1 where false UNION select a from t1 limit 8;
+drop table t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test
index 400ce07b7fd..a8c875ef764 100644
--- a/mysql-test/t/upgrade.test
+++ b/mysql-test/t/upgrade.test
@@ -41,11 +41,9 @@ create table `txu#p#p1` (s1 int);
insert into `txu#p#p1` values (1);
--error 1146
select * from `txu@0023p@0023p1`;
+--error ER_TABLE_EXISTS_ERROR
create table `txu@0023p@0023p1` (s1 int);
-insert into `txu@0023p@0023p1` values (2);
-select * from `txu@0023p@0023p1`;
select * from `txu#p#p1`;
-drop table `txu@0023p@0023p1`;
drop table `txu#p#p1`;
--echo #
diff --git a/mysql-test/t/variables-notembedded.test b/mysql-test/t/variables-notembedded.test
index 7cc068c68c7..b440cfa47b0 100644
--- a/mysql-test/t/variables-notembedded.test
+++ b/mysql-test/t/variables-notembedded.test
@@ -109,3 +109,30 @@ SET @@session.slave_skip_errors= 7;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@global.slave_skip_errors= 7;
#
+
+--echo #
+--echo # Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET
+--echo # ARE NOT BEING HONORED
+--echo #
+
+CREATE TABLE t1 (a MEDIUMTEXT);
+
+SET GLOBAL max_allowed_packet=2048;
+SET GLOBAL net_buffer_length=4096;
+CONNECT (con1,localhost,root,,test);
+SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
+SHOW SESSION VARIABLES LIKE 'net_buffer_length';
+--disable_query_log
+--error ER_NET_PACKET_TOO_LARGE
+INSERT INTO t1 VALUES ('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+--enable_query_log
+
+CONNECTION default;
+DISCONNECT con1;
+SELECT LENGTH(a) FROM t1;
+
+SET GLOBAL max_allowed_packet=default;
+SET GLOBAL net_buffer_length=default;
+DROP TABLE t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index eed5bd54dea..b8fae29fff5 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -785,7 +785,7 @@ SET @@myisam_mmap_size= 500M;
--echo # Bug #52315: utc_date() crashes when system time > year 2037
--echo #
---error 0, ER_UNKNOWN_ERROR
+--error 0, ER_WRONG_VALUE_FOR_VAR
SET TIMESTAMP=2*1024*1024*1024;
--echo #Should not crash
--disable_result_log
@@ -1286,10 +1286,49 @@ SET @@global.max_join_size=0;
SET @@global.key_buffer_size=0;
SET @@global.key_cache_block_size=0;
-# cleanup
+# Restore variables
SET @@global.max_binlog_cache_size=DEFAULT;
SET @@global.max_join_size=DEFAULT;
SET @@global.key_buffer_size=@kbs;
SET @@global.key_cache_block_size=@kcbs;
+#
+# Bug#56976: added new start-up parameter
+#
+select @@max_long_data_size;
+
+--echo #
+--echo # Bug#11766424 59527:
+--echo # Assert in DECIMAL_BIN_SIZE:
+--echo # `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
+--echo # This test also exposed a bug with sql_buffer_result
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED);
+INSERT INTO t1 VALUES (0.2),(0.1);
+set @a=NULL;
+set sql_buffer_result=0;
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= ROUND(f1);
+
+explain SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+
+set sql_buffer_result=1;
+explain SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE f1 = 0);
+SELECT 1 as 'one' FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+
+DROP TABLE t1;
+
+set sql_buffer_result=0;
+
+#
+# Test of CREATE ... CAST
+#
+
+CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 7bd559452f5..626cc506e78 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2782,6 +2782,7 @@ DROP VIEW IF EXISTS v1;
#
# Bug#21261 Wrong access rights was required for an insert to a view
#
+
CREATE DATABASE bug21261DB;
USE bug21261DB;
connect (root,localhost,root,,bug21261DB);
@@ -3941,6 +3942,18 @@ DROP TABLE t1;
CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
DROP VIEW v1;
+--echo #
+--echo # Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------
@@ -4073,3 +4086,51 @@ SELECT * FROM v1 WHERE a > 'JJ' OR a AND a = 'VV';
DROP VIEW v1;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#777745: crash with equality propagation
+--echo # over view fields
+--echo #
+
+CREATE TABLE t1 (a int NOT NULL ) ;
+INSERT INTO t1 VALUES (2), (1);
+
+CREATE TABLE t2 (a int NOT NULL , b int NOT NULL) ;
+INSERT INTO t2 VALUES (2,20),(2,30);
+
+CREATE VIEW v2 AS SELECT * FROM t2;
+
+EXPLAIN
+SELECT * FROM t1,v2
+ WHERE v2.a = t1.a AND v2.a = 2 AND v2.a IS NULL AND t1.a != 0;
+SELECT * FROM t1,v2
+ WHERE v2.a = t1.a AND v2.a = 2 AND v2.a IS NULL AND t1.a != 0;
+
+EXPLAIN
+SELECT * FROM t1,v2
+ WHERE v2.a = t1.a AND v2.a = 2 AND v2.a+1 > 2 AND t1.a != 0;
+SELECT * FROM t1,v2
+ WHERE v2.a = t1.a AND v2.a = 2 AND v2.a+1 > 2 AND t1.a != 0;
+
+DROP VIEW v2;
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#794038: crash with INSERT/UPDATE/DELETE
+--echo # over a non-updatable view
+--echo #
+
+CREATE TABLE t1 (a int);
+CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
+CREATE ALGORITHM = TEMPTABLE VIEW v3 AS SELECT * FROM v2;
+
+-- error ER_NON_INSERTABLE_TABLE
+INSERT INTO v3 VALUES (1);
+-- error ER_NON_UPDATABLE_TABLE
+UPDATE v3 SET a=0;
+-- error ER_NON_UPDATABLE_TABLE
+DELETE FROM v3;
+
+DROP VIEW v1,v2,v3;
+DROP TABLE t1;
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 416f1fef0c5..8db5ca75f1c 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -640,5 +640,15 @@ SELECT UPDATEXML(NULL, (LPAD(0.1111E-15, '2011', 1)), 1);
--error ER_ILLEGAL_VALUE_FOR_TYPE
SELECT EXTRACTVALUE('', LPAD(0.1111E-15, '2011', 1));
+--echo #
+--echo # Bug #44332 my_xml_scan reads behind the end of buffer
+--echo #
+SELECT UPDATEXML(CONVERT(_latin1'<' USING utf8),'1','1');
+SELECT UPDATEXML(CONVERT(_latin1'<!--' USING utf8),'1','1');
+
+--echo #
+--echo # Bug#11766725 (bug#59901): EXTRACTVALUE STILL BROKEN AFTER FIX FOR BUG #44332
+--echo #
+SELECT ExtractValue(CONVERT('<\"', BINARY(10)), 1);
--echo End of 5.1 tests
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index cbf73fa4d8a..685fbf04fde 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -1,3 +1,21 @@
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2009-2011, Monty Program Ab
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#
# Suppress some common (not fatal) errors in system libraries found by valgrind
#
@@ -489,6 +507,16 @@
}
{
+ dlclose memory loss from plugin variant 10
+ Memcheck:Leak
+ fun:calloc
+ obj:/lib*/libdl-*.so
+ fun:dlclose
+ fun:*free_plugin_mem*
+ fun:*plugin_dl_del*
+}
+
+{
dlsym memory loss from plugin on SuSE 11.1 x64
Memcheck:Leak
fun:*alloc
@@ -1115,3 +1143,50 @@
Memcheck:Addr1
fun:buf_buddy_relocate
}
+
+{
+ Bug 59874 Valgrind warning in InnoDB compression code
+ Memcheck:Cond
+ fun:*
+ fun:*
+ fun:deflate
+ fun:btr_store_big_rec_extern_fields_func
+ fun:row_ins_index_entry_low
+ fun:row_ins_index_entry
+ fun:row_ins_index_entry_step
+ fun:row_ins
+ fun:row_ins_step
+ fun:row_insert_for_mysql
+}
+
+{
+ In page0zip.c we have already checked that the memory is initialized before calling deflate()
+ Memcheck:Cond
+ fun:*
+ fun:*
+ fun:deflate
+ fun:page_zip_compress
+ fun:page_cur_insert_rec_zip_reorg
+ fun:page_cur_insert_rec_zip
+ fun:page_cur_tuple_insert
+ fun:btr_cur_optimistic_insert
+ fun:row_ins_index_entry_low
+ fun:row_ins_index_entry
+ fun:row_ins_index_entry_step
+ fun:row_ins
+ fun:row_ins_step
+ fun:row_insert_for_mysql
+}
+
+{
+ Bug 59875 Valgrind warning in buf0buddy.c
+ Memcheck:Addr1
+ fun:mach_read_from_4
+ fun:buf_buddy_relocate
+ fun:buf_buddy_free_low
+ fun:buf_buddy_free
+ fun:buf_LRU_block_remove_hashed_page
+ fun:buf_LRU_invalidate_tablespace
+ fun:fil_delete_tablespace
+ fun:row_drop_table_for_mysql
+}
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 8068318e4c2..c5f90a50a01 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -32,15 +32,15 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chmod.c my_chsize.c
my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c
- my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
- my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
+ my_div.c my_error.c my_file.c my_fopen.c my_fstream.c
+ my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_compare.c my_init.c
my_lib.c my_lock.c my_lockmem.c my_malloc.c my_messnc.c
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
- thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
+ thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c ma_dyncol.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
my_atomic.c my_getncpus.c my_rnd.c
my_uuid.c wqueue.c waiting_threads.c
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 515791be7f1..3c0b9743616 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -27,7 +27,7 @@ libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \
my_open.c my_create.c my_dup.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \
- my_crc32.c \
+ my_crc32.c ma_dyncol.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \
@@ -43,7 +43,8 @@ libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_wcomp.c mf_wfile.c my_gethwaddr.c \
mf_qsort.c mf_qsort2.c mf_sort.c \
ptr_cmp.c mf_radix.c queues.c my_getncpus.c \
- tree.c trie.c list.c hash.c array.c string.c typelib.c \
+ tree.c trie.c list.c hash.c array.c string.c \
+ typelib.c \
my_copy.c my_append.c my_lib.c \
my_delete.c my_rename.c my_redel.c \
my_chsize.c my_clock.c \
@@ -53,8 +54,8 @@ libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_compress.c checksum.c \
my_net.c my_port.c my_sleep.c \
charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
+ rijndael.c my_aes.c sha1.c \
+ my_compare.c my_netware.c my_largepage.c \
my_memmem.c stacktrace.c \
my_windac.c my_access.c base64.c my_libwrap.c \
wqueue.c
diff --git a/mysys/charset.c b/mysys/charset.c
index 7b72f1f5ae3..c7756583b19 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -97,6 +97,9 @@ static my_bool init_state_maps(struct charset_info_st *cs)
state_map[(uchar)'@']= (uchar) MY_LEX_USER_END;
state_map[(uchar) '`']= (uchar) MY_LEX_USER_VARIABLE_DELIMITER;
state_map[(uchar)'"']= (uchar) MY_LEX_STRING_OR_DELIMITER;
+ state_map[(uchar)'-']= (uchar) MY_LEX_MINUS_OR_COMMENT;
+ state_map[(uchar)',']= (uchar) MY_LEX_COMMA;
+ state_map[(uchar)'?']= (uchar) MY_LEX_PLACEHOLDER;
/*
Create a second map to make it faster to find identifiers
diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c
new file mode 100644
index 00000000000..dcb03d7f073
--- /dev/null
+++ b/mysys/ma_dyncol.c
@@ -0,0 +1,2112 @@
+/* Copyright (c) 2011, Monty Program Ab
+ Copyright (c) 2011, Oleksandr Byelkin
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
+
+#include "mysys_priv.h"
+#include <m_string.h>
+#include <ma_dyncol.h>
+
+/*
+ Flag byte bits
+
+ 2 bits which determinate size of offset in the header -1
+*/
+/* mask to get above bits */
+#define DYNCOL_FLG_OFFSET 3
+/* All known flags mask */
+#define DYNCOL_FLG_KNOWN 3
+
+/* dynamic column size reserve */
+#define DYNCOL_SYZERESERVE 80
+
+/* length of fixed string header 1 byte - flags, 2 bytes - columns counter */
+#define FIXED_HEADER_SIZE 3
+
+#define COLUMN_NUMBER_SIZE 2
+
+#define MAX_OFFSET_LENGTH 5
+
+static enum enum_dyncol_func_result
+dynamic_column_time_store(DYNAMIC_COLUMN *str,
+ MYSQL_TIME *value);
+static enum enum_dyncol_func_result
+dynamic_column_date_store(DYNAMIC_COLUMN *str,
+ MYSQL_TIME *value);
+static enum enum_dyncol_func_result
+dynamic_column_time_read_internal(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length);
+static enum enum_dyncol_func_result
+dynamic_column_date_read_internal(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length);
+
+/**
+ Initialize dynamic column string with (make it empty but correct format)
+
+ @param str The string to initialize
+ @param size Amount of preallocated memory for the string.
+
+ @retval FALSE OK
+ @retval TRUE error
+*/
+
+static my_bool dynamic_column_init_str(DYNAMIC_COLUMN *str, size_t size)
+{
+ DBUG_ASSERT(size != 0);
+
+ /*
+ Make string with no fields (empty header)
+ - First \0 is flags
+ - other 2 \0 is number of fields
+ */
+ if (init_dynamic_string(str, NULL,
+ size + FIXED_HEADER_SIZE, DYNCOL_SYZERESERVE))
+ return TRUE;
+ bzero(str->str, FIXED_HEADER_SIZE);
+ str->length= FIXED_HEADER_SIZE;
+ return FALSE;
+}
+
+
+/**
+ Calculate how many bytes needed to store val as variable length integer
+ where first bit indicate continuation of the sequence.
+
+ @param val The value for which we are calculating length
+
+ @return number of bytes
+*/
+
+static size_t dynamic_column_var_uint_bytes(ulonglong val)
+{
+ size_t len= 0;
+ do
+ {
+ len++;
+ val>>= 7;
+ } while (val);
+ return len;
+}
+
+
+/**
+ Stores variable length unsigned integer value to a string
+
+ @param str The string where to append the value
+ @param val The value to put in the string
+
+ @return ER_DYNCOL_* return code
+
+ @notes
+ This is used to store a number together with other data in the same
+ object. (Like decimals, length of string etc)
+ (As we don't know the length of this object, we can't store 0 in 0 bytes)
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_var_uint_store(DYNAMIC_COLUMN *str, ulonglong val)
+{
+ if (dynstr_realloc(str, 10)) /* max what we can use */
+ return ER_DYNCOL_RESOURCE;
+
+ do
+ {
+ ulonglong rest= val >> 7;
+ str->str[str->length++]= ((val & 0x7f) | (rest ? 0x80 : 0x00));
+ val= rest;
+ } while (val);
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Reads variable length unsigned integer value from a string
+
+ @param data The string from which the int should be read
+ @param data_length Max length of data
+ @param len Where to put length of the string read in bytes
+
+ @return value of the unsigned integer read from the string
+
+ In case of error, *len is set to 0
+*/
+
+static ulonglong
+dynamic_column_var_uint_get(uchar *data, size_t data_length,
+ size_t *len)
+{
+ ulonglong val= 0;
+ uint length;
+ uchar *end= data + data_length;
+
+ for (length=0; data < end ; data++)
+ {
+ val+= (((ulonglong)((*data) & 0x7f)) << (length * 7));
+ length++;
+ if (!((*data) & 0x80))
+ {
+ /* End of data */
+ *len= length;
+ return val;
+ }
+ }
+ /* Something was wrong with data */
+ *len= 0; /* Mark error */
+ return 0;
+}
+
+
+/**
+ Calculate how many bytes needed to store val as unsigned.
+
+ @param val The value for which we are calculating length
+
+ @return number of bytes (0-8)
+*/
+
+static size_t dynamic_column_uint_bytes(ulonglong val)
+{
+ size_t len;
+
+ for (len= 0; val ; val>>= 8, len++)
+ ;
+ return len;
+}
+
+
+/**
+ Append the string with given unsigned int value.
+
+ @param str The string where to put the value
+ @param val The value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_uint_store(DYNAMIC_COLUMN *str, ulonglong val)
+{
+ if (dynstr_realloc(str, 8)) /* max what we can use */
+ return ER_DYNCOL_RESOURCE;
+
+ for (; val; val>>= 8)
+ str->str[str->length++]= (char) (val & 0xff);
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Read unsigned int value of given length from the string
+
+ @param store_it_here The structure to store the value
+ @param data The string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_uint_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ ulonglong value= 0;
+ size_t i;
+
+ for (i= 0; i < length; i++)
+ value+= ((ulonglong)data[i]) << (i*8);
+
+ store_it_here->ulong_value= value;
+ return ER_DYNCOL_OK;
+}
+
+/**
+ Calculate how many bytes needed to store val as signed in following encoding:
+ 0 -> 0
+ -1 -> 1
+ 1 -> 2
+ -2 -> 3
+ 2 -> 4
+ ...
+
+ @param val The value for which we are calculating length
+
+ @return number of bytes
+*/
+
+static size_t dynamic_column_sint_bytes(longlong val)
+{
+ return dynamic_column_uint_bytes((val << 1) ^
+ (val < 0 ? ULL(0xffffffffffffffff) : 0));
+}
+
+
+/**
+ Append the string with given signed int value.
+
+ @param str the string where to put the value
+ @param val the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_sint_store(DYNAMIC_COLUMN *str, longlong val)
+{
+ return dynamic_column_uint_store(str,
+ (val << 1) ^
+ (val < 0 ? ULL(0xffffffffffffffff) : 0));
+}
+
+
+/**
+ Read signed int value of given length from the string
+
+ @param store_it_here The structure to store the value
+ @param data The string which should be read
+ @param length The length (in bytes) of the value in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_sint_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ ulonglong val;
+ dynamic_column_uint_read(store_it_here, data, length);
+ val= store_it_here->ulong_value;
+ if (val & 1)
+ val= (val >> 1) ^ ULL(0xffffffffffffffff);
+ else
+ val>>= 1;
+ store_it_here->long_value= (longlong) val;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Calculate how many bytes needed to store the value.
+
+ @param value The value for which we are calculating length
+
+ @return
+ Error: (size_t) ~0
+ ok number of bytes
+*/
+
+static size_t
+dynamic_column_value_len(DYNAMIC_COLUMN_VALUE *value)
+{
+ switch (value->type) {
+ case DYN_COL_NULL:
+ return 0;
+ case DYN_COL_INT:
+ return dynamic_column_sint_bytes(value->long_value);
+ case DYN_COL_UINT:
+ return dynamic_column_uint_bytes(value->ulong_value);
+ case DYN_COL_DOUBLE:
+ return 8;
+ case DYN_COL_STRING:
+ return (dynamic_column_var_uint_bytes(value->charset->number) +
+ value->string_value.length);
+ case DYN_COL_DECIMAL:
+ {
+ int precision= value->decimal_value.intg + value->decimal_value.frac;
+ int scale= value->decimal_value.frac;
+
+ if (precision == 0 || decimal_is_zero(&value->decimal_value))
+ {
+ /* This is here to simplify dynamic_column_decimal_store() */
+ value->decimal_value.intg= value->decimal_value.frac= 0;
+ return 0;
+ }
+ /*
+ Check if legal decimal; This is needed to not get an assert in
+ decimal_bin_size(). However this should be impossible as all
+ decimals entered here should be valid and we have the special check
+ above to handle the unlikely but possible case that decimal_value.intg
+ and decimal.frac is 0.
+ */
+ if (scale < 0 || precision <= 0)
+ {
+ DBUG_ASSERT(0); /* Impossible */
+ return (size_t) ~0;
+ }
+ return (dynamic_column_var_uint_bytes(value->decimal_value.intg) +
+ dynamic_column_var_uint_bytes(value->decimal_value.frac) +
+ decimal_bin_size(precision, scale));
+ }
+ case DYN_COL_DATETIME:
+ /* date+time in bits: 14 + 4 + 5 + 10 + 6 + 6 + 20 + 1 66bits ~= 9 bytes */
+ return 9;
+ case DYN_COL_DATE:
+ /* date in dits: 14 + 4 + 5 = 23bits ~= 3bytes*/
+ return 3;
+ case DYN_COL_TIME:
+ /* time in bits: 10 + 6 + 6 + 20 + 1 = 43bits ~= 6bytes*/
+ return 6;
+ }
+ DBUG_ASSERT(0);
+ return 0;
+}
+
+
+/**
+ Append double value to a string
+
+ @param str the string where to put the value
+ @param val the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_double_store(DYNAMIC_COLUMN *str, double val)
+{
+ if (dynstr_realloc(str, 8))
+ return ER_DYNCOL_RESOURCE;
+ float8store(str->str + str->length, val);
+ str->length+= 8;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Read double value of given length from the string
+
+ @param store_it_here The structure to store the value
+ @param data The string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_double_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ if (length != 8)
+ return ER_DYNCOL_FORMAT;
+ float8get(store_it_here->double_value, data);
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Append the string with given string value.
+
+ @param str the string where to put the value
+ @param val the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_string_store(DYNAMIC_COLUMN *str, LEX_STRING *string,
+ CHARSET_INFO *charset)
+{
+ enum enum_dyncol_func_result rc;
+ if ((rc= dynamic_column_var_uint_store(str, charset->number)))
+ return rc;
+ if (dynstr_append_mem(str, string->str, string->length))
+ return ER_DYNCOL_RESOURCE;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Read string value of given length from the packed string
+
+ @param store_it_here The structure to store the value
+ @param data The packed string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_string_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ size_t len;
+ uint charset_nr= (uint)dynamic_column_var_uint_get(data, length, &len);
+ if (len == 0) /* Wrong packed number */
+ return ER_DYNCOL_FORMAT;
+ store_it_here->charset= get_charset(charset_nr, MYF(MY_WME));
+ if (store_it_here->charset == NULL)
+ return ER_DYNCOL_UNKNOWN_CHARSET;
+ data+= len;
+ store_it_here->string_value.length= (length-= len);
+ store_it_here->string_value.str= (char*) data;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Append the string with given decimal value.
+
+ @param str the string where to put the value
+ @param val the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_decimal_store(DYNAMIC_COLUMN *str,
+ decimal_t *value)
+{
+ uint bin_size;
+ int precision= value->intg + value->frac;
+
+ /* Store decimal zero as empty string */
+ if (precision == 0)
+ return ER_DYNCOL_OK;
+
+ bin_size= decimal_bin_size(precision, value->frac);
+ if (dynstr_realloc(str, bin_size + 20))
+ return ER_DYNCOL_RESOURCE;
+
+ /* The following can't fail as memory is already allocated */
+ (void) dynamic_column_var_uint_store(str, value->intg);
+ (void) dynamic_column_var_uint_store(str, value->frac);
+
+ decimal2bin(value, (uchar *) str->str + str->length,
+ precision, value->frac);
+ str->length+= bin_size;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Prepare the value to be used as decimal.
+
+ @param value The value structure which sould be setup.
+*/
+
+void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value)
+{
+ value->decimal_value.buf= value->decimal_buffer;
+ value->decimal_value.len= DECIMAL_BUFF_LENGTH;
+ /* just to be safe */
+ value->type= DYN_COL_DECIMAL;
+ decimal_make_zero(&value->decimal_value);
+}
+
+
+/**
+ Read decimal value of given length from the string
+
+ @param store_it_here The structure to store the value
+ @param data The string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_decimal_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ size_t intg_len, frac_len;
+ int intg, frac, precision, scale;
+
+ dynamic_column_prepare_decimal(store_it_here);
+ /* Decimals 0.0 is stored as a zero length string */
+ if (length == 0)
+ return ER_DYNCOL_OK; /* value contains zero */
+
+ intg= (int)dynamic_column_var_uint_get(data, length, &intg_len);
+ data+= intg_len;
+ frac= (int)dynamic_column_var_uint_get(data, length - intg_len, &frac_len);
+ data+= frac_len;
+
+ /* Check the size of data is correct */
+ precision= intg + frac;
+ scale= frac;
+ if (scale < 0 || precision <= 0 || scale > precision ||
+ (length - intg_len - frac_len) >
+ (size_t) (DECIMAL_BUFF_LENGTH*sizeof(decimal_digit_t)) ||
+ decimal_bin_size(intg + frac, frac) !=
+ (int) (length - intg_len - frac_len))
+ return ER_DYNCOL_FORMAT;
+
+ if (bin2decimal(data, &store_it_here->decimal_value, precision, scale) !=
+ E_DEC_OK)
+ return ER_DYNCOL_FORMAT;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Append the string with given datetime value.
+
+ @param str the string where to put the value
+ @param value the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_date_time_store(DYNAMIC_COLUMN *str, MYSQL_TIME *value)
+{
+ enum enum_dyncol_func_result rc;
+ /*
+ 0<----year----><mn><day>00000!<-hours--><min-><sec-><---microseconds--->
+ 12345678901234123412345 1123456789012345612345612345678901234567890
+ <123456><123456><123456><123456><123456><123456><123456><123456><123456>
+ */
+ if ((rc= dynamic_column_date_store(str, value)) ||
+ (rc= dynamic_column_time_store(str, value)))
+ return rc;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Read datetime value of given length from the packed string
+
+ @param store_it_here The structure to store the value
+ @param data The packed string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_date_time_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ enum enum_dyncol_func_result rc= ER_DYNCOL_FORMAT;
+ /*
+ 0<----year----><mn><day>00000!<-hours--><min-><sec-><---microseconds--->
+ 12345678901234123412345 1123456789012345612345612345678901234567890
+ <123456><123456><123456><123456><123456><123456><123456><123456><123456>
+ */
+ if (length != 9)
+ goto err;
+ store_it_here->time_value.time_type= MYSQL_TIMESTAMP_DATETIME;
+ if ((rc= dynamic_column_date_read_internal(store_it_here, data, 3)) ||
+ (rc= dynamic_column_time_read_internal(store_it_here, data + 3, 6)))
+ goto err;
+ return ER_DYNCOL_OK;
+
+err:
+ store_it_here->time_value.time_type= MYSQL_TIMESTAMP_ERROR;
+ return rc;
+}
+
+
+/**
+ Append the string with given time value.
+
+ @param str the string where to put the value
+ @param value the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_time_store(DYNAMIC_COLUMN *str, MYSQL_TIME *value)
+{
+ uchar *buf;
+ if (dynstr_realloc(str, 6))
+ return ER_DYNCOL_RESOURCE;
+
+ buf= ((uchar *)str->str) + str->length;
+
+ if (value->time_type == MYSQL_TIMESTAMP_NONE ||
+ value->time_type == MYSQL_TIMESTAMP_ERROR ||
+ value->time_type == MYSQL_TIMESTAMP_DATE)
+ {
+ value->neg= 0;
+ value->second_part= 0;
+ value->hour= 0;
+ value->minute= 0;
+ value->second= 0;
+ }
+ DBUG_ASSERT(value->hour <= 838);
+ DBUG_ASSERT(value->minute <= 59);
+ DBUG_ASSERT(value->second <= 59);
+ DBUG_ASSERT(value->second_part <= 999999);
+ /*
+ 00000!<-hours--><min-><sec-><---microseconds--->
+ 1123456789012345612345612345678901234567890
+ <123456><123456><123456><123456><123456><123456>
+ */
+ buf[0]= (value->second_part & 0xff);
+ buf[1]= ((value->second_part & 0xff00) >> 8);
+ buf[2]= (uchar)(((value->second & 0xf) << 4) |
+ ((value->second_part & 0xf0000) >> 16));
+ buf[3]= ((value->minute << 2) | ((value->second & 0x30) >> 4));
+ buf[4]= (value->hour & 0xff);
+ buf[5]= ((value->neg ? 0x4 : 0) | (value->hour >> 8));
+ str->length+= 6;
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Read time value of given length from the packed string
+
+ @param store_it_here The structure to store the value
+ @param data The packed string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_time_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ store_it_here->time_value.year= store_it_here->time_value.month=
+ store_it_here->time_value.day= 0;
+ store_it_here->time_value.time_type= MYSQL_TIMESTAMP_TIME;
+ return dynamic_column_time_read_internal(store_it_here, data, length);
+}
+
+/**
+ Internal function for reading time part from the string.
+
+ @param store_it_here The structure to store the value
+ @param data The packed string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_time_read_internal(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ if (length != 6)
+ goto err;
+ /*
+ 00000!<-hours--><min-><sec-><---microseconds--->
+ 1123456789012345612345612345678901234567890
+ <123456><123456><123456><123456><123456><123456>
+ */
+ store_it_here->time_value.second_part= (data[0] |
+ (data[1] << 8) |
+ ((data[2] & 0xf) << 16));
+ store_it_here->time_value.second= ((data[2] >> 4) |
+ ((data[3] & 0x3) << 4));
+ store_it_here->time_value.minute= (data[3] >> 2);
+ store_it_here->time_value.hour= (((((uint)data[5]) & 0x3 ) << 8) | data[4]);
+ store_it_here->time_value.neg= ((data[5] & 0x4) ? 1 : 0);
+ if (store_it_here->time_value.second > 59 ||
+ store_it_here->time_value.minute > 59 ||
+ store_it_here->time_value.hour > 838 ||
+ store_it_here->time_value.second_part > 999999)
+ goto err;
+ return ER_DYNCOL_OK;
+
+err:
+ store_it_here->time_value.time_type= MYSQL_TIMESTAMP_ERROR;
+ return ER_DYNCOL_FORMAT;
+}
+
+
+/**
+ Append the string with given date value.
+
+ @param str the string where to put the value
+ @param value the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_date_store(DYNAMIC_COLUMN *str, MYSQL_TIME *value)
+{
+ uchar *buf;
+ if (dynstr_realloc(str, 3))
+ return ER_DYNCOL_RESOURCE;
+
+ buf= ((uchar *)str->str) + str->length;
+ if (value->time_type == MYSQL_TIMESTAMP_NONE ||
+ value->time_type == MYSQL_TIMESTAMP_ERROR ||
+ value->time_type == MYSQL_TIMESTAMP_TIME)
+ value->year= value->month= value->day = 0;
+ DBUG_ASSERT(value->year <= 9999);
+ DBUG_ASSERT(value->month <= 12);
+ DBUG_ASSERT(value->day <= 31);
+ /*
+ 0<----year----><mn><day>
+ 012345678901234123412345
+ <123456><123456><123456>
+ */
+ buf[0]= (value->day |
+ ((value->month & 0x7) << 5));
+ buf[1]= ((value->month >> 3) | ((value->year & 0x7F) << 1));
+ buf[2]= (value->year >> 7);
+ str->length+= 3;
+ return ER_DYNCOL_OK;
+}
+
+
+
+/**
+ Read date value of given length from the packed string
+
+ @param store_it_here The structure to store the value
+ @param data The packed string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_date_read(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data, size_t length)
+{
+ store_it_here->time_value.neg= 0;
+ store_it_here->time_value.second_part= 0;
+ store_it_here->time_value.hour= 0;
+ store_it_here->time_value.minute= 0;
+ store_it_here->time_value.second= 0;
+ store_it_here->time_value.time_type= MYSQL_TIMESTAMP_DATE;
+ return dynamic_column_date_read_internal(store_it_here, data, length);
+}
+
+/**
+ Internal function for reading date part from the string.
+
+ @param store_it_here The structure to store the value
+ @param data The packed string which should be read
+ @param length The length (in bytes) of the value in nthe string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_date_read_internal(DYNAMIC_COLUMN_VALUE *store_it_here,
+ uchar *data,
+ size_t length)
+{
+ if (length != 3)
+ goto err;
+ /*
+ 0<----year----><mn><day>
+ 12345678901234123412345
+ <123456><123456><123456>
+ */
+ store_it_here->time_value.day= (data[0] & 0x1f);
+ store_it_here->time_value.month= (((data[1] & 0x1) << 3) |
+ (data[0] >> 5));
+ store_it_here->time_value.year= ((((uint)data[2]) << 7) |
+ (data[1] >> 1));
+ if (store_it_here->time_value.day > 31 ||
+ store_it_here->time_value.month > 12 ||
+ store_it_here->time_value.year > 9999)
+ goto err;
+ return ER_DYNCOL_OK;
+
+err:
+ store_it_here->time_value.time_type= MYSQL_TIMESTAMP_ERROR;
+ return ER_DYNCOL_FORMAT;
+}
+
+
+/**
+ Append the string with given value.
+
+ @param str the string where to put the value
+ @param value the value to put in the string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+data_store(DYNAMIC_COLUMN *str, DYNAMIC_COLUMN_VALUE *value)
+{
+ switch (value->type) {
+ case DYN_COL_INT:
+ return dynamic_column_sint_store(str, value->long_value);
+ case DYN_COL_UINT:
+ return dynamic_column_uint_store(str, value->ulong_value);
+ case DYN_COL_DOUBLE:
+ return dynamic_column_double_store(str, value->double_value);
+ case DYN_COL_STRING:
+ return dynamic_column_string_store(str, &value->string_value,
+ value->charset);
+ case DYN_COL_DECIMAL:
+ return dynamic_column_decimal_store(str, &value->decimal_value);
+ case DYN_COL_DATETIME:
+ /* date+time in bits: 14 + 4 + 5 + 5 + 6 + 6 40bits = 5 bytes */
+ return dynamic_column_date_time_store(str, &value->time_value);
+ case DYN_COL_DATE:
+ /* date in dits: 14 + 4 + 5 = 23bits ~= 3bytes*/
+ return dynamic_column_date_store(str, &value->time_value);
+ case DYN_COL_TIME:
+ /* time in bits: 5 + 6 + 6 = 17bits ~= 3bytes*/
+ return dynamic_column_time_store(str, &value->time_value);
+ case DYN_COL_NULL:
+ break; /* Impossible */
+ }
+ DBUG_ASSERT(0);
+ return ER_DYNCOL_OK; /* Impossible */
+}
+
+
+/**
+ Calculate length of offset field for given data length
+
+ @param data_length Length of the data segment
+
+ @return number of bytes
+*/
+
+static size_t dynamic_column_offset_bytes(size_t data_length)
+{
+ if (data_length < 0x1f) /* all 1 value is reserved */
+ return 1;
+ if (data_length < 0x1fff) /* all 1 value is reserved */
+ return 2;
+ if (data_length < 0x1fffff) /* all 1 value is reserved */
+ return 3;
+ if (data_length < 0x1fffffff) /* all 1 value is reserved */
+ return 4;
+ return MAX_OFFSET_LENGTH; /* For future */
+}
+
+/**
+ Store offset and type information in the given place
+
+ @param place Beginning of the index entry
+ @param offset_size Size of offset field in bytes
+ @param type Type to be written
+ @param offset Offset to be written
+*/
+
+static void type_and_offset_store(uchar *place, size_t offset_size,
+ DYNAMIC_COLUMN_TYPE type,
+ size_t offset)
+{
+ ulong val = (((ulong) offset) << 3) | (type - 1);
+ DBUG_ASSERT(type != DYN_COL_NULL);
+ DBUG_ASSERT(((type - 1) & (~7)) == 0); /* fit in 3 bits */
+
+ /* Index entry starts with column number; Jump over it */
+ place+= COLUMN_NUMBER_SIZE;
+
+ switch (offset_size) {
+ case 1:
+ DBUG_ASSERT(offset < 0x1f); /* all 1 value is reserved */
+ place[0]= (uchar)val;
+ break;
+ case 2:
+ DBUG_ASSERT(offset < 0x1fff); /* all 1 value is reserved */
+ int2store(place, val);
+ break;
+ case 3:
+ DBUG_ASSERT(offset < 0x1fffff); /* all 1 value is reserved */
+ int3store(place, val);
+ break;
+ case 4:
+ DBUG_ASSERT(offset < 0x1fffffff); /* all 1 value is reserved */
+ int4store(place, val);
+ break;
+ default:
+ DBUG_ASSERT(0); /* impossible */
+ }
+}
+
+
+/**
+ Read offset and type information from index entry
+
+ @param type Where to put type info
+ @param offset Where to put offset info
+ @param place Beginning of the index entry
+ @param offset_size Size of offset field in bytes
+*/
+
+static void type_and_offset_read(DYNAMIC_COLUMN_TYPE *type,
+ size_t *offset,
+ uchar *place, size_t offset_size)
+{
+ ulong val;
+ LINT_INIT(val);
+
+ place+= COLUMN_NUMBER_SIZE; /* skip column number */
+ switch (offset_size) {
+ case 1:
+ val= (ulong)place[0];
+ break;
+ case 2:
+ val= uint2korr(place);
+ break;
+ case 3:
+ val= uint3korr(place);
+ break;
+ case 4:
+ val= uint4korr(place);
+ break;
+ default:
+ DBUG_ASSERT(0); /* impossible */
+ }
+ *type= (val & 0x7) + 1;
+ *offset= val >> 3;
+}
+
+
+/**
+ Comparator function for references on column numbers for qsort
+*/
+
+static int column_sort(const void *a, const void *b)
+{
+ return **((uint **)a) - **((uint **)b);
+}
+
+
+/**
+ Write information to the fixed header
+
+ @param str String where to write the header
+ @param offset_size Size of offset field in bytes
+ @param column_count Number of columns
+*/
+
+static void set_fixed_header(DYNAMIC_COLUMN *str,
+ uint offset_size,
+ uint column_count)
+{
+ DBUG_ASSERT(column_count <= 0xffff);
+ DBUG_ASSERT(offset_size <= 4);
+ str->str[0]= ((str->str[0] & ~DYNCOL_FLG_OFFSET) |
+ (offset_size - 1)); /* size of offset */
+ int2store(str->str + 1, column_count); /* columns number */
+ DBUG_ASSERT((str->str[0] & (~DYNCOL_FLG_KNOWN)) == 0);
+}
+
+/*
+ Calculate entry size (E) and header size (H) by offset size (O) and column
+ count (C).
+*/
+
+#define calc_param(E,H,O,C) do { \
+ (*(E))= (O) + COLUMN_NUMBER_SIZE; \
+ (*(H))= (*(E)) * (C); \
+}while(0);
+
+
+/**
+ Adds columns into the empty string
+
+ @param str String where to write the data
+ @param header_size Size of the header without fixed part
+ @param offset_size Size of offset field in bytes
+ @param column_count Number of columns in the arrays
+ @parem not_null_count Number of non-null columns in the arrays
+ @param data_size Size of the data segment
+ @param column_numbers Array of columns numbers
+ @param values Array of columns values
+ @param new_str True if we need to allocate new string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_new_column_store(DYNAMIC_COLUMN *str,
+ size_t header_size,
+ size_t offset_size,
+ uint column_count,
+ uint not_null_count,
+ size_t data_size,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values,
+ my_bool new_str)
+{
+ uchar *header_end;
+ uint **columns_order;
+ uint i;
+ uint entry_size= COLUMN_NUMBER_SIZE + offset_size;
+ enum enum_dyncol_func_result rc= ER_DYNCOL_RESOURCE;
+
+ if (!(columns_order= malloc(sizeof(uint*)*column_count)))
+ return ER_DYNCOL_RESOURCE;
+ if (new_str)
+ {
+ if (dynamic_column_init_str(str,
+ data_size + header_size + DYNCOL_SYZERESERVE))
+ goto err;
+ }
+ else
+ {
+ str->length= 0;
+ if (dynstr_realloc(str, data_size + header_size + DYNCOL_SYZERESERVE))
+ goto err;
+ bzero(str->str, FIXED_HEADER_SIZE);
+ str->length= FIXED_HEADER_SIZE;
+ }
+
+ /* sort columns for the header */
+ for (i= 0; i < column_count; i++)
+ columns_order[i]= column_numbers + i;
+ qsort(columns_order, (size_t)column_count, sizeof(uint*), &column_sort);
+
+ /*
+ For now we don't allow creating two columns with the same number
+ at the time of create. This can be fixed later to just use the later
+ by comparing the pointers.
+ */
+ for (i= 0; i < column_count - 1; i++)
+ {
+ if (columns_order[i][0] > UINT_MAX16 ||
+ columns_order[i][0] == columns_order[i + 1][0])
+ {
+ rc= ER_DYNCOL_DATA;
+ goto err;
+ }
+ }
+ if (columns_order[i][0] > UINT_MAX16)
+ {
+ rc= ER_DYNCOL_DATA;
+ goto err;
+ }
+
+ DBUG_ASSERT(str->max_length >= str->length + header_size);
+ set_fixed_header(str, offset_size, not_null_count);
+ str->length+= header_size; /* reserve place for header */
+ header_end= (uchar *)str->str + FIXED_HEADER_SIZE;
+ for (i= 0; i < column_count; i++)
+ {
+ uint ord= columns_order[i] - column_numbers;
+ if (values[ord].type != DYN_COL_NULL)
+ {
+ /* Store header first in the str */
+ int2store(header_end, column_numbers[ord]);
+ type_and_offset_store(header_end, offset_size,
+ values[ord].type,
+ str->length - header_size - FIXED_HEADER_SIZE);
+
+ /* Store value in 'str + str->length' and increase str->length */
+ if ((rc= data_store(str, values + ord)))
+ goto err;
+ header_end+= entry_size;
+ }
+ }
+ rc= ER_DYNCOL_OK;
+err:
+ free(columns_order);
+ return rc;
+}
+
+/**
+ Create packed string which contains given columns (internal)
+
+ @param str String where to write the data
+ @param column_count Number of columns in the arrays
+ @param column_numbers Array of columns numbers
+ @param values Array of columns values
+ @param new_str True if we need allocate new string
+
+ @return ER_DYNCOL_* return code
+*/
+
+static enum enum_dyncol_func_result
+dynamic_column_create_many_internal(DYNAMIC_COLUMN *str,
+ uint column_count,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values,
+ my_bool new_str)
+{
+ size_t data_size= 0;
+ size_t header_size, offset_size;
+ uint i;
+ int not_null_column_count= 0;
+
+ if (new_str)
+ {
+ /* to make dynstr_free() working in case of errors */
+ bzero(str, sizeof(DYNAMIC_COLUMN));
+ }
+
+ for (i= 0; i < column_count; i++)
+ {
+ if (values[i].type != DYN_COL_NULL)
+ {
+ size_t tmp;
+ not_null_column_count++;
+ data_size+= (tmp=dynamic_column_value_len(values + i));
+ if (tmp == (size_t) ~0)
+ return ER_DYNCOL_DATA;
+ }
+ }
+
+ /* We can handle data up to 1fffffff = 536870911 bytes now */
+ if ((offset_size= dynamic_column_offset_bytes(data_size)) >=
+ MAX_OFFSET_LENGTH)
+ return ER_DYNCOL_LIMIT;
+
+ /* header entry is column number + offset & type */
+ header_size= not_null_column_count * (offset_size + 2);
+
+ return dynamic_new_column_store(str,
+ header_size, offset_size,
+ column_count,
+ not_null_column_count,
+ data_size,
+ column_numbers, values,
+ new_str);
+}
+
+
+/**
+ Create packed string which contains given columns
+
+ @param str String where to write the data
+ @param column_count Number of columns in the arrays
+ @param column_numbers Array of columns numbers
+ @param values Array of columns values
+
+ @return ER_DYNCOL_* return code
+*/
+
+enum enum_dyncol_func_result
+dynamic_column_create_many(DYNAMIC_COLUMN *str,
+ uint column_count,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values)
+{
+ DBUG_ENTER("dynamic_column_create_many");
+ DBUG_RETURN(dynamic_column_create_many_internal(str, column_count,
+ column_numbers, values,
+ TRUE));
+}
+
+
+/**
+ Create packed string which contains given column
+
+ @param str String where to write the data
+ @param column_number Column number
+ @param value The columns value
+
+ @return ER_DYNCOL_* return code
+*/
+
+enum enum_dyncol_func_result
+dynamic_column_create(DYNAMIC_COLUMN *str, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *value)
+{
+ DBUG_ENTER("dynamic_column_create");
+ DBUG_RETURN(dynamic_column_create_many(str, 1, &column_nr, value));
+}
+
+
+/**
+ Calculate length of data between given two header entries
+
+ @param entry Pointer to the first entry
+ @param entry_next Pointer to the last entry
+ @param header_end Pointer to the header end
+ @param offset_size Size of offset field in bytes
+ @param last_offset Size of the data segment
+
+ @return number of bytes
+*/
+
+static size_t get_length_interval(uchar *entry, uchar *entry_next,
+ uchar *header_end, size_t offset_size,
+ size_t last_offset)
+{
+ size_t offset, offset_next;
+ DYNAMIC_COLUMN_TYPE type, type_next;
+ DBUG_ASSERT(entry < entry_next);
+
+ type_and_offset_read(&type, &offset, entry, offset_size);
+ if (entry_next >= header_end)
+ return (last_offset - offset);
+ type_and_offset_read(&type_next, &offset_next, entry_next, offset_size);
+ return (offset_next - offset);
+}
+
+/*
+ Calculate length of data of one column
+
+
+ @param entry Pointer to the first entry
+ @param header_end Pointer to the header end
+ @param offset_size Size of offset field in bytes
+ @param last_offset Size of the data segment
+
+ @return number of bytes
+*/
+
+static size_t get_length(uchar *entry, uchar *header_end,
+ size_t offset_size,
+ size_t last_offset)
+{
+ return get_length_interval(entry,
+ entry + offset_size + COLUMN_NUMBER_SIZE,
+ header_end, offset_size, last_offset);
+}
+
+
+/**
+ Comparator function for references to header entries for qsort
+*/
+
+static int header_compar(const void *a, const void *b)
+{
+ uint va= uint2korr((uchar*)a), vb= uint2korr((uchar*)b);
+ return (va > vb ? 1 : (va < vb ? -1 : 0));
+}
+
+
+/**
+ Find column and fill information about it
+
+ @param type Returns type of the column
+ @param data Returns a pointer to the data
+ @param length Returns length of the data
+ @param offset_size Size of offset field in bytes
+ @param column_count Number of column in the packed string
+ @param data_end Pointer to the data end
+ @param num Number of the column we want to fetch
+ @param entry_pos NULL or place where to put reference to the entry
+
+ @return 0 ok
+ @return 1 error in data
+*/
+
+static my_bool
+find_column(DYNAMIC_COLUMN_TYPE *type, uchar **data, size_t *length,
+ uchar *header, size_t offset_size, uint column_count,
+ uchar *data_end, uint num, uchar **entry_pos)
+{
+ uchar *entry;
+ size_t offset, total_data, header_size, entry_size;
+ uchar key[2+4];
+
+ if (!entry_pos)
+ entry_pos= &entry;
+
+ calc_param(&entry_size, &header_size, offset_size, column_count);
+
+ if (header + header_size > data_end)
+ return 1;
+
+ int2store(key, num);
+ entry= bsearch(key, header, (size_t)column_count, entry_size,
+ &header_compar);
+ if (!entry)
+ {
+ /* Column not found */
+ *type= DYN_COL_NULL;
+ *entry_pos= NULL;
+ return 0;
+ }
+ type_and_offset_read(type, &offset, entry, offset_size);
+ total_data= data_end - (header + header_size);
+ if (offset > total_data)
+ return 1;
+ *data= header + header_size + offset;
+ *length= get_length(entry, header + header_size, offset_size,
+ total_data);
+ /*
+ Check that the found data is withing the ranges. This can happen if
+ we get data with wrong offsets.
+ */
+ if ((long) *length < 0 || offset + *length > total_data)
+ return 1;
+
+ *entry_pos= entry;
+ return 0;
+}
+
+
+/**
+ Read and check the header of the dynamic string
+
+ @param str Dynamic string
+
+ @retval FALSE OK
+ @retval TRUE error
+
+ Note
+ We don't check for str->length == 0 as all code that calls this
+ already have handled this case.
+*/
+
+static inline my_bool read_fixed_header(DYNAMIC_COLUMN *str,
+ size_t *offset_size,
+ uint *column_count)
+{
+ DBUG_ASSERT(str != NULL && str->length != 0);
+ if ((str->length < FIXED_HEADER_SIZE) ||
+ (str->str[0] & (~DYNCOL_FLG_KNOWN)))
+ return 1; /* Wrong header */
+ *offset_size= (str->str[0] & DYNCOL_FLG_OFFSET) + 1;
+ *column_count= uint2korr(str->str + 1);
+ return 0;
+}
+
+
+/**
+ Get dynamic column value
+
+ @param str The packed string to extract the column
+ @param column_nr Number of column to fetch
+ @param store_it_here Where to store the extracted value
+
+ @return ER_DYNCOL_* return code
+*/
+
+int dynamic_column_get(DYNAMIC_COLUMN *str, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *store_it_here)
+{
+ uchar *data;
+ size_t offset_size, length;
+ uint column_count;
+ enum enum_dyncol_func_result rc= ER_DYNCOL_FORMAT;
+
+ if (str->length == 0)
+ goto null;
+
+ if (read_fixed_header(str, &offset_size, &column_count))
+ goto err;
+
+ if (column_count == 0)
+ goto null;
+
+ if (find_column(&store_it_here->type, &data, &length,
+ (uchar*)str->str + FIXED_HEADER_SIZE,
+ offset_size, column_count, (uchar*)str->str + str->length,
+ column_nr, NULL))
+ goto err;
+
+ switch (store_it_here->type) {
+ case DYN_COL_INT:
+ rc= dynamic_column_sint_read(store_it_here, data, length);
+ break;
+ case DYN_COL_UINT:
+ rc= dynamic_column_uint_read(store_it_here, data, length);
+ break;
+ case DYN_COL_DOUBLE:
+ rc= dynamic_column_double_read(store_it_here, data, length);
+ break;
+ case DYN_COL_STRING:
+ rc= dynamic_column_string_read(store_it_here, data, length);
+ break;
+ case DYN_COL_DECIMAL:
+ rc= dynamic_column_decimal_read(store_it_here, data, length);
+ break;
+ case DYN_COL_DATETIME:
+ rc= dynamic_column_date_time_read(store_it_here, data, length);
+ break;
+ case DYN_COL_DATE:
+ rc= dynamic_column_date_read(store_it_here, data, length);
+ break;
+ case DYN_COL_TIME:
+ rc= dynamic_column_time_read(store_it_here, data, length);
+ break;
+ case DYN_COL_NULL:
+ rc= ER_DYNCOL_OK;
+ break;
+ default:
+ goto err;
+ }
+ return rc;
+
+null:
+ rc= ER_DYNCOL_OK;
+err:
+ store_it_here->type= DYN_COL_NULL;
+ return rc;
+}
+
+/**
+ Delete column with given number from the packed string
+
+ @param str The packed string to delete the column
+ @param column_nr Number of column to delete
+
+ @return ER_DYNCOL_* return code
+*/
+
+int dynamic_column_delete(DYNAMIC_COLUMN *str, uint column_nr)
+{
+ uchar *data, *header_entry, *read, *write;
+ size_t offset_size, new_offset_size, length, entry_size, new_entry_size,
+ header_size, new_header_size, data_size, new_data_size,
+ deleted_entry_offset;
+ uint column_count, i;
+ DYNAMIC_COLUMN_TYPE type;
+
+ if (str->length == 0)
+ return ER_DYNCOL_OK; /* no columns */
+
+ if (read_fixed_header(str, &offset_size, &column_count))
+ return ER_DYNCOL_FORMAT;
+
+ if (column_count == 0)
+ {
+ str->length= 0;
+ return ER_DYNCOL_OK; /* no columns */
+ }
+
+ if (find_column(&type, &data, &length, (uchar*)str->str + FIXED_HEADER_SIZE,
+ offset_size, column_count, (uchar*)str->str + str->length,
+ column_nr, &header_entry))
+ return ER_DYNCOL_FORMAT;
+
+ if (type == DYN_COL_NULL)
+ return ER_DYNCOL_OK; /* no such column */
+
+ if (column_count == 1)
+ {
+ /* delete the only column; Return empty string */
+ str->length= 0;
+ return ER_DYNCOL_OK;
+ }
+
+ /* Calculate entry_size and header_size */
+ calc_param(&entry_size, &header_size, offset_size, column_count);
+ data_size= str->length - FIXED_HEADER_SIZE - header_size;
+
+ new_data_size= data_size - length;
+ if ((new_offset_size= dynamic_column_offset_bytes(new_data_size)) >=
+ MAX_OFFSET_LENGTH)
+ return ER_DYNCOL_LIMIT;
+ DBUG_ASSERT(new_offset_size <= offset_size);
+
+ calc_param(&new_entry_size, &new_header_size,
+ new_offset_size, column_count - 1);
+
+ deleted_entry_offset= ((data - (uchar*) str->str) -
+ header_size - FIXED_HEADER_SIZE);
+
+ /* rewrite header*/
+ set_fixed_header(str, new_offset_size, column_count - 1);
+ for (i= 0, write= read= (uchar *)str->str + FIXED_HEADER_SIZE;
+ i < column_count;
+ i++, read+= entry_size, write+= new_entry_size)
+ {
+ size_t offs;
+ uint nm;
+ DYNAMIC_COLUMN_TYPE tp;
+ if (read == header_entry)
+ {
+#ifndef DBUG_OFF
+ nm= uint2korr(read);
+ type_and_offset_read(&tp, &offs, read,
+ offset_size);
+ DBUG_ASSERT(nm == column_nr);
+ DBUG_ASSERT(offs == deleted_entry_offset);
+#endif
+ write-= new_entry_size; /* do not move writer */
+ continue; /* skip removed field */
+ }
+
+ nm= uint2korr(read),
+ type_and_offset_read(&tp, &offs, read,
+ offset_size);
+
+ if (offs > deleted_entry_offset)
+ offs-= length; /* data stored after removed data */
+
+ int2store(write, nm);
+ type_and_offset_store(write, new_offset_size, tp, offs);
+ }
+
+ /* move data */
+ {
+ size_t first_chunk_len= ((data - (uchar *)str->str) -
+ FIXED_HEADER_SIZE - header_size);
+ size_t second_chunk_len= new_data_size - first_chunk_len;
+ if (first_chunk_len)
+ memmove(str->str + FIXED_HEADER_SIZE + new_header_size,
+ str->str + FIXED_HEADER_SIZE + header_size,
+ first_chunk_len);
+ if (second_chunk_len)
+ memmove(str->str +
+ FIXED_HEADER_SIZE + new_header_size + first_chunk_len,
+ str->str +
+ FIXED_HEADER_SIZE + header_size + first_chunk_len + length,
+ second_chunk_len);
+ }
+
+ /* fix str length */
+ DBUG_ASSERT(str->length >=
+ FIXED_HEADER_SIZE + new_header_size + new_data_size);
+ str->length= FIXED_HEADER_SIZE + new_header_size + new_data_size;
+
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Check existence of the column in the packed string
+
+ @param str The packed string to check the column
+ @param column_nr Number of column to check
+
+ @return ER_DYNCOL_* return code
+*/
+
+enum enum_dyncol_func_result
+dynamic_column_exists(DYNAMIC_COLUMN *str, uint column_nr)
+{
+ uchar *data;
+ size_t offset_size, length;
+ uint column_count;
+ DYNAMIC_COLUMN_TYPE type;
+
+ if (str->length == 0)
+ return ER_DYNCOL_NO; /* no columns */
+
+ if (read_fixed_header(str, &offset_size, &column_count))
+ return ER_DYNCOL_FORMAT;
+
+ if (column_count == 0)
+ return ER_DYNCOL_NO; /* no columns */
+
+ if (find_column(&type, &data, &length, (uchar*)str->str + FIXED_HEADER_SIZE,
+ offset_size, column_count, (uchar*)str->str + str->length,
+ column_nr, NULL))
+ return ER_DYNCOL_FORMAT;
+
+ return (type != DYN_COL_NULL ? ER_DYNCOL_YES : ER_DYNCOL_NO);
+}
+
+
+/**
+ List not-null columns in the packed string
+
+ @param str The packed string
+ @param array_of_uint Where to put reference on created array
+
+ @return ER_DYNCOL_* return code
+*/
+
+enum enum_dyncol_func_result
+dynamic_column_list(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array_of_uint)
+{
+ uchar *read;
+ size_t offset_size, entry_size;
+ uint column_count, i;
+
+ bzero(array_of_uint, sizeof(*array_of_uint)); /* In case of errors */
+ if (str->length == 0)
+ return ER_DYNCOL_OK; /* no columns */
+
+ if (read_fixed_header(str, &offset_size, &column_count))
+ return ER_DYNCOL_FORMAT;
+
+ entry_size= COLUMN_NUMBER_SIZE + offset_size;
+
+ if (entry_size * column_count + FIXED_HEADER_SIZE > str->length)
+ return ER_DYNCOL_FORMAT;
+
+ if (init_dynamic_array(array_of_uint, sizeof(uint),
+ column_count, 0 CALLER_INFO))
+ return ER_DYNCOL_RESOURCE;
+
+ for (i= 0, read= (uchar *)str->str + FIXED_HEADER_SIZE;
+ i < column_count;
+ i++, read+= entry_size)
+ {
+ uint nm= uint2korr(read);
+ /* Insert can't never fail as it's pre-allocated above */
+ (void) insert_dynamic(array_of_uint, (uchar *)&nm);
+ }
+ return ER_DYNCOL_OK;
+}
+
+
+/**
+ Find the place of the column in the header or place where it should be put
+
+ @param num Number of the column
+ @param header Pointer to the header
+ @param entry_size Size of a header entry
+ @param column_count Number of columns in the packed string
+ @param entry Return pointer to the entry or next entry
+
+ @retval TRUE found
+ @retval FALSE pointer set to the next row
+*/
+
+static my_bool
+find_place(uint num, uchar *header, size_t entry_size,
+ uint column_count, uchar **entry)
+{
+ uint mid, start, end, val;
+ int flag;
+ LINT_INIT(flag); /* 100 % safe */
+
+ start= 0;
+ end= column_count -1;
+ mid= 1;
+ while (start != end)
+ {
+ uint val;
+ mid= (start + end) / 2;
+ val= uint2korr(header + mid * entry_size);
+ if ((flag= CMP_NUM(num, val)) <= 0)
+ end= mid;
+ else
+ start= mid + 1;
+ }
+ if (start != mid)
+ {
+ val= uint2korr(header + start * entry_size);
+ flag= CMP_NUM(num, val);
+ }
+ *entry= header + start * entry_size;
+ if (flag > 0)
+ *entry+= entry_size; /* Point at next bigger key */
+ return flag == 0;
+}
+
+
+/*
+ Description of plan of adding/removing/updating a packed string
+*/
+
+typedef enum {PLAN_REPLACE, PLAN_ADD, PLAN_DELETE, PLAN_NOP} PLAN_ACT;
+
+struct st_plan {
+ DYNAMIC_COLUMN_VALUE *val;
+ uint *num;
+ uchar *place;
+ size_t length;
+ int hdelta, ddelta;
+ PLAN_ACT act;
+};
+typedef struct st_plan PLAN;
+
+
+static int plan_sort(const void *a, const void *b)
+{
+ return ((PLAN *)a)->num[0] - ((PLAN *)b)->num[0];
+}
+
+#define DELTA_CHECK(S, D, C) \
+ if ((S) == 0) \
+ (S)= (D); \
+ else if (((S) > 0 && (D) < 0) || \
+ ((S) < 0 && (D) > 0)) \
+ { \
+ (C)= TRUE; \
+ break; \
+ } \
+
+
+/**
+ Update the packed string with the given columns
+
+ @param str String where to write the data
+ @param add_column_count Number of columns in the arrays
+ @param column_numbers Array of columns numbers
+ @param values Array of columns values
+
+ @return ER_DYNCOL_* return code
+*/
+
+enum enum_dyncol_func_result
+dynamic_column_update_many(DYNAMIC_COLUMN *str,
+ uint add_column_count,
+ uint *column_numbers,
+ DYNAMIC_COLUMN_VALUE *values)
+{
+ PLAN *plan;
+ uchar *header_end;
+ long data_delta= 0;
+ uint i, j, k;
+ uint new_column_count, column_count, not_null;
+ enum enum_dyncol_func_result rc;
+ int header_delta, header_delta_sign, data_delta_sign;
+ size_t offset_size, entry_size, header_size, data_size;
+ size_t new_offset_size, new_entry_size, new_header_size, new_data_size;
+ size_t max_offset;
+ my_bool copy;
+
+ if (add_column_count == 0)
+ return ER_DYNCOL_OK;
+
+ /*
+ Get columns in column order. As the data in 'str' is already
+ in column order this allows to replace all columns in one loop.
+ */
+
+ if (!(plan= my_malloc(sizeof(PLAN) * (add_column_count + 1), MYF(0))))
+ return ER_DYNCOL_RESOURCE;
+
+ not_null= add_column_count;
+ for (i= 0; i < add_column_count; i++)
+ {
+ if (column_numbers[i] > UINT_MAX16)
+ {
+ rc= ER_DYNCOL_DATA;
+ goto end;
+ }
+
+ plan[i].val= values + i;
+ plan[i].num= column_numbers + i;
+ if (values[i].type == DYN_COL_NULL)
+ not_null--;
+
+ }
+
+ if (str->length == 0)
+ {
+ /*
+ Just add new columns. If there was no columns to add we return
+ an empty string.
+ */
+ goto create_new_string;
+ }
+
+ /* Check that header is ok */
+ if (read_fixed_header(str, &offset_size, &column_count))
+ {
+ rc= ER_DYNCOL_FORMAT;
+ goto end;
+ }
+ if (column_count == 0)
+ goto create_new_string;
+
+ qsort(plan, (size_t)add_column_count, sizeof(PLAN), &plan_sort);
+
+ new_column_count= column_count;
+ calc_param(&entry_size, &header_size, offset_size, column_count);
+ max_offset= str->length - (FIXED_HEADER_SIZE + header_size);
+ header_end= (uchar*) str->str + FIXED_HEADER_SIZE + header_size;
+
+ if (header_size + FIXED_HEADER_SIZE > str->length)
+ {
+ rc= ER_DYNCOL_FORMAT;
+ goto end;
+ }
+
+ /*
+ Calculate how many columns and data is added/deleted and make a 'plan'
+ for each of them.
+ */
+ header_delta= 0;
+ for (i= 0; i < add_column_count; i++)
+ {
+ uchar *entry;
+
+ /*
+ For now we don't allow creating two columns with the same number
+ at the time of create. This can be fixed later to just use the later
+ by comparing the pointers.
+ */
+ if (i < add_column_count - 1 && plan[i].num[0] == plan[i + 1].num[0])
+ {
+ rc= ER_DYNCOL_DATA;
+ goto end;
+ }
+
+ /* Set common variables for all plans */
+ plan[i].ddelta= data_delta;
+ /* get header delta in entries */
+ plan[i].hdelta= header_delta;
+ plan[i].length= 0; /* Length if NULL */
+
+ if (find_place(plan[i].num[0],
+ (uchar *)str->str + FIXED_HEADER_SIZE,
+ entry_size, column_count, &entry))
+ {
+ size_t entry_data_size;
+
+ /* Data existed; We have to replace or delete it */
+
+ entry_data_size= get_length(entry, header_end,
+ offset_size, max_offset);
+ if ((long) entry_data_size < 0)
+ {
+ rc= ER_DYNCOL_FORMAT;
+ goto end;
+ }
+
+ if (plan[i].val->type == DYN_COL_NULL)
+ {
+ /* Inserting a NULL means delete the old data */
+
+ plan[i].act= PLAN_DELETE; /* Remove old value */
+ header_delta--; /* One row less in header */
+ data_delta-= entry_data_size; /* Less data to store */
+ }
+ else
+ {
+ /* Replace the value */
+
+ plan[i].act= PLAN_REPLACE;
+ /* get data delta in bytes */
+ if ((plan[i].length= dynamic_column_value_len(plan[i].val)) ==
+ (size_t) ~0)
+ {
+ rc= ER_DYNCOL_DATA;
+ goto end;
+ }
+ data_delta+= plan[i].length - entry_data_size;
+ }
+ }
+ else
+ {
+ /* Data did not exists. Add if it it's not NULL */
+
+ if (plan[i].val->type == DYN_COL_NULL)
+ {
+ plan[i].act= PLAN_NOP; /* Mark entry to be skiped */
+ }
+ else
+ {
+ /* Add new value */
+
+ plan[i].act= PLAN_ADD;
+ header_delta++; /* One more row in header */
+ /* get data delta in bytes */
+ if ((plan[i].length= dynamic_column_value_len(plan[i].val)) ==
+ (size_t) ~0)
+ {
+ rc= ER_DYNCOL_DATA;
+ goto end;
+ }
+ data_delta+= plan[i].length;
+ }
+ }
+ plan[i].place= entry;
+ }
+ plan[add_column_count].hdelta= header_delta;
+ plan[add_column_count].ddelta= data_delta;
+ new_column_count= column_count + header_delta;
+
+ /*
+ Check if it is only "increasing" or only "decreasing" plan for (header
+ and data separately).
+ */
+ data_size= str->length - header_size - FIXED_HEADER_SIZE;
+ new_data_size= data_size + data_delta;
+ if ((new_offset_size= dynamic_column_offset_bytes(new_data_size)) >=
+ MAX_OFFSET_LENGTH)
+ {
+ rc= ER_DYNCOL_LIMIT;
+ goto end;
+ }
+
+ /* if (new_offset_size != offset_size) then we have to rewrite header */
+ header_delta_sign= new_offset_size - offset_size;
+ data_delta_sign= 0;
+ copy= FALSE;
+ for (i= 0; i < add_column_count; i++)
+ {
+ /* This is the check for increasing/decreasing */
+ DELTA_CHECK(header_delta_sign, plan[i].hdelta, copy);
+ DELTA_CHECK(data_delta_sign, plan[i].ddelta, copy);
+ }
+
+ calc_param(&new_entry_size, &new_header_size,
+ new_offset_size, new_column_count);
+
+ /*
+ The following code always make a copy. In future we can do a more
+ optimized version when data is only increasing / decreasing.
+ */
+
+ /*if (copy) */
+ {
+ DYNAMIC_COLUMN tmp;
+ uchar *header_base= (uchar *)str->str + FIXED_HEADER_SIZE,
+ *write;
+ if (dynamic_column_init_str(&tmp,
+ (FIXED_HEADER_SIZE + new_header_size +
+ new_data_size + DYNCOL_SYZERESERVE)))
+ {
+ rc= ER_DYNCOL_RESOURCE;
+ goto end;
+ }
+ write= (uchar *)tmp.str + FIXED_HEADER_SIZE;
+ /* Adjust tmp to contain whole the future header */
+ tmp.length= FIXED_HEADER_SIZE + new_header_size;
+ set_fixed_header(&tmp, new_offset_size, new_column_count);
+ data_delta= 0;
+
+ /*
+ Copy data to the new string
+ i= index in array of changes
+ j= index in packed string header index
+ */
+
+ for (i= 0, j= 0; i < add_column_count || j < column_count; i++)
+ {
+ size_t first_offset;
+ uint start= j, end;
+ LINT_INIT(first_offset);
+
+ /*
+ Search in i and j for the next column to add from i and where to
+ add.
+ */
+
+ while (i < add_column_count && plan[i].act == PLAN_NOP)
+ i++; /* skip NOP */
+ if (i == add_column_count)
+ j= end= column_count;
+ else
+ {
+ /*
+ old data portion. We don't need to check that j < column_count
+ as plan[i].place is guaranteed to have a pointer inside the
+ data.
+ */
+ while (header_base + j * entry_size < plan[i].place)
+ j++;
+ end= j;
+ if ((plan[i].act == PLAN_REPLACE || plan[i].act == PLAN_DELETE))
+ j++; /* data at 'j' will be removed */
+ }
+
+ if (plan[i].ddelta == 0 && offset_size == new_offset_size)
+ {
+ uchar *read= header_base + start * entry_size;
+ DYNAMIC_COLUMN_TYPE tp;
+ /*
+ It's safe to copy the header unchanged. This is usually the
+ case for the first header block before any changed data.
+ */
+ if (start < end) /* Avoid memcpy with 0 */
+ {
+ size_t length= entry_size * (end - start);
+ memcpy(write, read, length);
+ write+= length;
+ }
+ /* Read first_offset */
+ type_and_offset_read(&tp, &first_offset, read, offset_size);
+ }
+ else
+ {
+ /*
+ Adjust all headers since last loop.
+ We have to do this as the offset for data has moved
+ */
+ for (k= start; k < end; k++)
+ {
+ uchar *read= header_base + k * entry_size;
+ size_t offs;
+ uint nm;
+ DYNAMIC_COLUMN_TYPE tp;
+
+ nm= uint2korr(read); /* Column nummber */
+ type_and_offset_read(&tp, &offs, read, offset_size);
+ if (k == start)
+ first_offset= offs;
+ else if (offs < first_offset)
+ {
+ dynamic_column_column_free(&tmp);
+ rc= ER_DYNCOL_FORMAT;
+ goto end;
+ }
+
+ offs+= plan[i].ddelta;
+ int2store(write, nm);
+ /* write rest of data at write + COLUMN_NUMBER_SIZE */
+ type_and_offset_store(write, new_offset_size, tp, offs);
+ write+= new_entry_size;
+ }
+ }
+
+ /* copy first the data that was not replaced in original packed data */
+ if (start < end)
+ {
+ /* Add old data last in 'tmp' */
+ size_t data_size=
+ get_length_interval(header_base + start * entry_size,
+ header_base + end * entry_size,
+ header_end, offset_size, max_offset);
+ if ((long) data_size < 0 ||
+ data_size > max_offset - first_offset)
+ {
+ dynamic_column_column_free(&tmp);
+ rc= ER_DYNCOL_FORMAT;
+ goto end;
+ }
+
+ memcpy(tmp.str + tmp.length, (char *)header_end + first_offset,
+ data_size);
+ tmp.length+= data_size;
+ }
+
+ /* new data adding */
+ if (i < add_column_count)
+ {
+ if( plan[i].act == PLAN_ADD || plan[i].act == PLAN_REPLACE)
+ {
+ int2store(write, plan[i].num[0]);
+ type_and_offset_store(write, new_offset_size,
+ plan[i].val[0].type,
+ tmp.length -
+ (FIXED_HEADER_SIZE + new_header_size));
+ write+= new_entry_size;
+ data_store(&tmp, plan[i].val); /* Append new data */
+ }
+ data_delta= plan[i].ddelta;
+ }
+ }
+ dynamic_column_column_free(str);
+ *str= tmp;
+ }
+
+ rc= ER_DYNCOL_OK;
+
+end:
+ my_free(plan, MYF(0));
+ return rc;
+
+create_new_string:
+ /* There is no columns from before, so let's just add the new ones */
+ rc= ER_DYNCOL_OK;
+ if (not_null != 0)
+ rc= dynamic_column_create_many_internal(str, add_column_count,
+ column_numbers, values,
+ str->str == NULL);
+ goto end;
+}
+
+
+/**
+ Update the packed string with the given column
+
+ @param str String where to write the data
+ @param column_number Array of columns number
+ @param values Array of columns values
+
+ @return ER_DYNCOL_* return code
+*/
+
+
+int dynamic_column_update(DYNAMIC_COLUMN *str, uint column_nr,
+ DYNAMIC_COLUMN_VALUE *value)
+{
+ return dynamic_column_update_many(str, 1, &column_nr, value);
+}
diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c
index 9475bebd107..70278e64003 100644
--- a/mysys/mf_getdate.c
+++ b/mysys/mf_getdate.c
@@ -42,7 +42,7 @@ void get_date(register char * to, int flag, time_t date)
struct tm tm_tmp;
#endif
- skr=date ? (time_t) date : my_time(0);
+ skr=date ? date : (time_t) my_time(0);
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
if (flag & GETDATE_GMT)
gmtime_r(&skr,&tm_tmp);
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index c89aec67da8..0e5421ec484 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -1,4 +1,6 @@
/* Copyright (C) 2000 MySQL AB
+ Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (C) 2009- 2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -106,6 +108,7 @@ static inline void bitmap_lock(MY_BITMAP *map __attribute__((unused)))
#endif
}
+
static inline void bitmap_unlock(MY_BITMAP *map __attribute__((unused)))
{
#ifdef THREAD
@@ -285,37 +288,51 @@ void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size)
my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size)
{
- uint prefix_mask= last_byte_mask(prefix_size);
- uchar *m= (uchar*) map->bitmap;
- uchar *end_prefix= m+(prefix_size-1)/8;
- uchar *end;
- DBUG_ASSERT(m && prefix_size <= map->n_bits);
-
- /* Empty prefix is always true */
- if (!prefix_size)
- return 1;
-
- while (m < end_prefix)
- if (*m++ != 0xff)
- return 0;
+ uint prefix_bits= prefix_size % 32;
+ my_bitmap_map *word_ptr= map->bitmap, last_word;
+ my_bitmap_map *end_prefix= word_ptr + prefix_size / 32;
+ DBUG_ASSERT(word_ptr && prefix_size <= map->n_bits);
- end= ((uchar*) map->bitmap) + no_bytes_in_map(map) - 1;
- if (m == end)
- return ((*m & last_byte_mask(map->n_bits)) == prefix_mask);
+ /* 1: Words that should be filled with 1 */
+ for (; word_ptr < end_prefix; word_ptr++)
+ if (*word_ptr != 0xFFFFFFFF)
+ return FALSE;
- if (*m != prefix_mask)
- return 0;
+ last_word= *map->last_word_ptr & ~map->last_word_mask;
- while (++m < end)
- if (*m != 0)
- return 0;
- return ((*m & last_byte_mask(map->n_bits)) == 0);
+ /* 2: Word which contains the end of the prefix (if any) */
+ if (prefix_bits)
+ {
+ if (word_ptr == map->last_word_ptr)
+ return uint4korr((uchar*)&last_word) == (uint32)((1 << prefix_bits) - 1);
+ if (uint4korr((uchar*)word_ptr) != (uint32)((1 << prefix_bits) - 1))
+ return FALSE;
+ word_ptr++;
+ }
+
+ /* 3: Words that should be filled with 0 */
+ for (; word_ptr < map->last_word_ptr; word_ptr++)
+ if (*word_ptr != 0)
+ return FALSE;
+
+ /*
+ We can end up here in two situations:
+ 1) We went through the whole bitmap in step 1. This will happen if the
+ whole bitmap is filled with 1 and prefix_size is a multiple of 32
+ (i.e. the prefix does not end in the middle of a word).
+ In this case word_ptr will be larger than map->last_word_ptr.
+ 2) We have gone through steps 1-3 and just need to check that also
+ the last word is 0.
+ */
+ return word_ptr > map->last_word_ptr || last_word == 0;
}
+
my_bool bitmap_is_set_all(const MY_BITMAP *map)
{
my_bitmap_map *data_ptr= map->bitmap;
my_bitmap_map *end= map->last_word_ptr;
+
for (; data_ptr < end; data_ptr++)
if (*data_ptr != 0xFFFFFFFF)
return FALSE;
@@ -326,8 +343,8 @@ my_bool bitmap_is_set_all(const MY_BITMAP *map)
my_bool bitmap_is_clear_all(const MY_BITMAP *map)
{
my_bitmap_map *data_ptr= map->bitmap;
- my_bitmap_map *end;
- end= map->last_word_ptr;
+ my_bitmap_map *end= map->last_word_ptr;
+
for (; data_ptr < end; data_ptr++)
if (*data_ptr)
return FALSE;
@@ -491,25 +508,28 @@ void bitmap_invert(MY_BITMAP *map)
uint bitmap_bits_set(const MY_BITMAP *map)
-{
- uchar *m= (uchar*)map->bitmap;
- uchar *end= m + no_bytes_in_map(map) - 1;
+{
+ my_bitmap_map *data_ptr= map->bitmap;
+ my_bitmap_map *end= map->last_word_ptr;
uint res= 0;
-
DBUG_ASSERT(map->bitmap);
- while (m < end)
- res+= my_count_bits_ushort(*m++);
- return res + my_count_bits_ushort(*m & last_byte_mask(map->n_bits));
+
+ for (; data_ptr < end; data_ptr++)
+ res+= my_count_bits_uint32(*data_ptr);
+
+ /*Reset last bits to zero*/
+ res+= my_count_bits_uint32(*map->last_word_ptr & ~map->last_word_mask);
+ return res;
}
void bitmap_copy(MY_BITMAP *map, const MY_BITMAP *map2)
{
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
-
DBUG_ASSERT(map->bitmap && map2->bitmap &&
map->n_bits==map2->n_bits);
end= map->last_word_ptr;
+
while (to <= end)
*to++ = *from++;
}
@@ -789,376 +809,4 @@ void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit)
bitmap_flip_bit(map, bitmap_bit);
bitmap_unlock(map);
}
-#endif
-#ifdef MAIN
-
-uint get_rand_bit(uint bitsize)
-{
- return (rand() % bitsize);
-}
-
-my_bool test_set_get_clear_bit(MY_BITMAP *map, uint bitsize)
-{
- uint i, test_bit;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- for (i=0; i < no_loops; i++)
- {
- test_bit= get_rand_bit(bitsize);
- bitmap_set_bit(map, test_bit);
- if (!bitmap_is_set(map, test_bit))
- goto error1;
- bitmap_clear_bit(map, test_bit);
- if (bitmap_is_set(map, test_bit))
- goto error2;
- }
- return FALSE;
-error1:
- printf("Error in set bit, bit %u, bitsize = %u", test_bit, bitsize);
- return TRUE;
-error2:
- printf("Error in clear bit, bit %u, bitsize = %u", test_bit, bitsize);
- return TRUE;
-}
-
-my_bool test_flip_bit(MY_BITMAP *map, uint bitsize)
-{
- uint i, test_bit;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- for (i=0; i < no_loops; i++)
- {
- test_bit= get_rand_bit(bitsize);
- bitmap_flip_bit(map, test_bit);
- if (!bitmap_is_set(map, test_bit))
- goto error1;
- bitmap_flip_bit(map, test_bit);
- if (bitmap_is_set(map, test_bit))
- goto error2;
- }
- return FALSE;
-error1:
- printf("Error in flip bit 1, bit %u, bitsize = %u", test_bit, bitsize);
- return TRUE;
-error2:
- printf("Error in flip bit 2, bit %u, bitsize = %u", test_bit, bitsize);
- return TRUE;
-}
-
-my_bool test_operators(MY_BITMAP *map __attribute__((unused)),
- uint bitsize __attribute__((unused)))
-{
- return FALSE;
-}
-
-my_bool test_get_all_bits(MY_BITMAP *map, uint bitsize)
-{
- uint i;
- bitmap_set_all(map);
- if (!bitmap_is_set_all(map))
- goto error1;
- if (!bitmap_is_prefix(map, bitsize))
- goto error5;
- bitmap_clear_all(map);
- if (!bitmap_is_clear_all(map))
- goto error2;
- if (!bitmap_is_prefix(map, 0))
- goto error6;
- for (i=0; i<bitsize;i++)
- bitmap_set_bit(map, i);
- if (!bitmap_is_set_all(map))
- goto error3;
- for (i=0; i<bitsize;i++)
- bitmap_clear_bit(map, i);
- if (!bitmap_is_clear_all(map))
- goto error4;
- return FALSE;
-error1:
- printf("Error in set_all, bitsize = %u", bitsize);
- return TRUE;
-error2:
- printf("Error in clear_all, bitsize = %u", bitsize);
- return TRUE;
-error3:
- printf("Error in bitmap_is_set_all, bitsize = %u", bitsize);
- return TRUE;
-error4:
- printf("Error in bitmap_is_clear_all, bitsize = %u", bitsize);
- return TRUE;
-error5:
- printf("Error in set_all through set_prefix, bitsize = %u", bitsize);
- return TRUE;
-error6:
- printf("Error in clear_all through set_prefix, bitsize = %u", bitsize);
- return TRUE;
-}
-
-my_bool test_compare_operators(MY_BITMAP *map, uint bitsize)
-{
- uint i, j, test_bit1, test_bit2, test_bit3,test_bit4;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- MY_BITMAP map2_obj, map3_obj;
- MY_BITMAP *map2= &map2_obj, *map3= &map3_obj;
- my_bitmap_map map2buf[1024];
- my_bitmap_map map3buf[1024];
- bitmap_init(&map2_obj, map2buf, bitsize, FALSE);
- bitmap_init(&map3_obj, map3buf, bitsize, FALSE);
- bitmap_clear_all(map2);
- bitmap_clear_all(map3);
- for (i=0; i < no_loops; i++)
- {
- test_bit1=get_rand_bit(bitsize);
- bitmap_set_prefix(map, test_bit1);
- test_bit2=get_rand_bit(bitsize);
- bitmap_set_prefix(map2, test_bit2);
- bitmap_intersect(map, map2);
- test_bit3= test_bit2 < test_bit1 ? test_bit2 : test_bit1;
- bitmap_set_prefix(map3, test_bit3);
- if (!bitmap_cmp(map, map3))
- goto error1;
- bitmap_clear_all(map);
- bitmap_clear_all(map2);
- bitmap_clear_all(map3);
- test_bit1=get_rand_bit(bitsize);
- test_bit2=get_rand_bit(bitsize);
- test_bit3=get_rand_bit(bitsize);
- bitmap_set_prefix(map, test_bit1);
- bitmap_set_prefix(map2, test_bit2);
- test_bit3= test_bit2 > test_bit1 ? test_bit2 : test_bit1;
- bitmap_set_prefix(map3, test_bit3);
- bitmap_union(map, map2);
- if (!bitmap_cmp(map, map3))
- goto error2;
- bitmap_clear_all(map);
- bitmap_clear_all(map2);
- bitmap_clear_all(map3);
- test_bit1=get_rand_bit(bitsize);
- test_bit2=get_rand_bit(bitsize);
- test_bit3=get_rand_bit(bitsize);
- bitmap_set_prefix(map, test_bit1);
- bitmap_set_prefix(map2, test_bit2);
- bitmap_xor(map, map2);
- test_bit3= test_bit2 > test_bit1 ? test_bit2 : test_bit1;
- test_bit4= test_bit2 < test_bit1 ? test_bit2 : test_bit1;
- bitmap_set_prefix(map3, test_bit3);
- for (j=0; j < test_bit4; j++)
- bitmap_clear_bit(map3, j);
- if (!bitmap_cmp(map, map3))
- goto error3;
- bitmap_clear_all(map);
- bitmap_clear_all(map2);
- bitmap_clear_all(map3);
- test_bit1=get_rand_bit(bitsize);
- test_bit2=get_rand_bit(bitsize);
- test_bit3=get_rand_bit(bitsize);
- bitmap_set_prefix(map, test_bit1);
- bitmap_set_prefix(map2, test_bit2);
- bitmap_subtract(map, map2);
- if (test_bit2 < test_bit1)
- {
- bitmap_set_prefix(map3, test_bit1);
- for (j=0; j < test_bit2; j++)
- bitmap_clear_bit(map3, j);
- }
- if (!bitmap_cmp(map, map3))
- goto error4;
- bitmap_clear_all(map);
- bitmap_clear_all(map2);
- bitmap_clear_all(map3);
- test_bit1=get_rand_bit(bitsize);
- bitmap_set_prefix(map, test_bit1);
- bitmap_invert(map);
- bitmap_set_all(map3);
- for (j=0; j < test_bit1; j++)
- bitmap_clear_bit(map3, j);
- if (!bitmap_cmp(map, map3))
- goto error5;
- bitmap_clear_all(map);
- bitmap_clear_all(map3);
- }
- return FALSE;
-error1:
- printf("intersect error bitsize=%u,size1=%u,size2=%u", bitsize,
- test_bit1,test_bit2);
- return TRUE;
-error2:
- printf("union error bitsize=%u,size1=%u,size2=%u", bitsize,
- test_bit1,test_bit2);
- return TRUE;
-error3:
- printf("xor error bitsize=%u,size1=%u,size2=%u", bitsize,
- test_bit1,test_bit2);
- return TRUE;
-error4:
- printf("subtract error bitsize=%u,size1=%u,size2=%u", bitsize,
- test_bit1,test_bit2);
- return TRUE;
-error5:
- printf("invert error bitsize=%u,size=%u", bitsize,
- test_bit1);
- return TRUE;
-}
-
-my_bool test_count_bits_set(MY_BITMAP *map, uint bitsize)
-{
- uint i, bit_count=0, test_bit;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- for (i=0; i < no_loops; i++)
- {
- test_bit=get_rand_bit(bitsize);
- if (!bitmap_is_set(map, test_bit))
- {
- bitmap_set_bit(map, test_bit);
- bit_count++;
- }
- }
- if (bit_count==0 && bitsize > 0)
- goto error1;
- if (bitmap_bits_set(map) != bit_count)
- goto error2;
- return FALSE;
-error1:
- printf("No bits set bitsize = %u", bitsize);
- return TRUE;
-error2:
- printf("Wrong count of bits set, bitsize = %u", bitsize);
- return TRUE;
-}
-
-my_bool test_get_first_bit(MY_BITMAP *map, uint bitsize)
-{
- uint i, test_bit;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- for (i=0; i < no_loops; i++)
- {
- test_bit=get_rand_bit(bitsize);
- bitmap_set_bit(map, test_bit);
- if (bitmap_get_first_set(map) != test_bit)
- goto error1;
- bitmap_set_all(map);
- bitmap_clear_bit(map, test_bit);
- if (bitmap_get_first(map) != test_bit)
- goto error2;
- bitmap_clear_all(map);
- }
- return FALSE;
-error1:
- printf("get_first_set error bitsize=%u,prefix_size=%u",bitsize,test_bit);
- return TRUE;
-error2:
- printf("get_first error bitsize= %u, prefix_size= %u",bitsize,test_bit);
- return TRUE;
-}
-
-my_bool test_get_next_bit(MY_BITMAP *map, uint bitsize)
-{
- uint i, j, test_bit;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- for (i=0; i < no_loops; i++)
- {
- test_bit=get_rand_bit(bitsize);
- for (j=0; j < test_bit; j++)
- bitmap_set_next(map);
- if (!bitmap_is_prefix(map, test_bit))
- goto error1;
- bitmap_clear_all(map);
- }
- return FALSE;
-error1:
- printf("get_next error bitsize= %u, prefix_size= %u", bitsize,test_bit);
- return TRUE;
-}
-
-my_bool test_prefix(MY_BITMAP *map, uint bitsize)
-{
- uint i, j, test_bit;
- uint no_loops= bitsize > 128 ? 128 : bitsize;
- for (i=0; i < no_loops; i++)
- {
- test_bit=get_rand_bit(bitsize);
- bitmap_set_prefix(map, test_bit);
- if (!bitmap_is_prefix(map, test_bit))
- goto error1;
- bitmap_clear_all(map);
- for (j=0; j < test_bit; j++)
- bitmap_set_bit(map, j);
- if (!bitmap_is_prefix(map, test_bit))
- goto error2;
- bitmap_set_all(map);
- for (j=bitsize - 1; ~(j-test_bit); j--)
- bitmap_clear_bit(map, j);
- if (!bitmap_is_prefix(map, test_bit))
- goto error3;
- bitmap_clear_all(map);
- }
- return FALSE;
-error1:
- printf("prefix1 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
- return TRUE;
-error2:
- printf("prefix2 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
- return TRUE;
-error3:
- printf("prefix3 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
- return TRUE;
-}
-
-
-my_bool do_test(uint bitsize)
-{
- MY_BITMAP map;
- my_bitmap_map buf[1024];
- if (bitmap_init(&map, buf, bitsize, FALSE))
- {
- printf("init error for bitsize %d", bitsize);
- goto error;
- }
- if (test_set_get_clear_bit(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_flip_bit(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_operators(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_get_all_bits(&map, bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_compare_operators(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_count_bits_set(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_get_first_bit(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
- if (test_get_next_bit(&map,bitsize))
- goto error;
- if (test_prefix(&map,bitsize))
- goto error;
- return FALSE;
-error:
- printf("\n");
- return TRUE;
-}
-
-int main()
-{
- int i;
- for (i= 1; i < 4096; i++)
- {
- printf("Start test for bitsize=%u\n",i);
- if (do_test(i))
- return -1;
- }
- printf("OK\n");
- return 0;
-}
-
-/*
- In directory mysys:
- make test_bitmap
- will build the bitmap tests and ./test_bitmap will execute it
-*/
-
-#endif
+#endif /* NOT_USED */
diff --git a/mysys/my_handler.c b/mysys/my_compare.c
index 79b0f020a85..19a76593f42 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_compare.c
@@ -1,26 +1,23 @@
/* Copyright (C) 2002-2006 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
+ Copyright (C) 2009-2011 Monty Program Ab
+ Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-#include <m_ctype.h>
+#include "mysys_priv.h"
#include <my_base.h>
-#include <my_handler.h>
-#include <my_sys.h>
-#include "my_handler_errors.h"
+#include "my_compare.h"
int ha_compare_text(CHARSET_INFO *charset_info, const uchar *a, uint a_length,
const uchar *b, uint b_length, my_bool part_key,
@@ -654,6 +651,8 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a)
will ignore calls to register already registered error numbers.
*/
+#include "my_handler_errors.h"
+
void my_handler_error_register(void)
{
/*
diff --git a/mysys/my_gethostbyname.c b/mysys/my_gethostbyname.c
deleted file mode 100644
index 12cf90271dd..00000000000
--- a/mysys/my_gethostbyname.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright (C) 2002, 2004 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
-
-/* Thread safe version of gethostbyname_r() */
-
-#include "mysys_priv.h"
-#if !defined(__WIN__)
-#include <netdb.h>
-#endif
-#include <my_net.h>
-
-/* This file is not needed if my_gethostbyname_r is a macro */
-#if !defined(my_gethostbyname_r)
-
-/*
- Emulate SOLARIS style calls, not because it's better, but just to make the
- usage of getbostbyname_r simpler.
-*/
-
-#if defined(HAVE_GETHOSTBYNAME_R)
-
-#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-
-struct hostent *my_gethostbyname_r(const char *name,
- struct hostent *result, char *buffer,
- int buflen, int *h_errnop)
-{
- struct hostent *hp;
- DBUG_ASSERT((size_t) buflen >= sizeof(*result));
- if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
- return 0;
- return hp;
-}
-
-#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
-
-struct hostent *my_gethostbyname_r(const char *name,
- struct hostent *result, char *buffer,
- int buflen, int *h_errnop)
-{
- if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
- {
- *h_errnop= errno;
- return 0;
- }
- return result;
-}
-
-#else
-
-/* gethostbyname_r with similar interface as gethostbyname() */
-
-struct hostent *my_gethostbyname_r(const char *name,
- struct hostent *result, char *buffer,
- int buflen, int *h_errnop)
-{
- struct hostent *hp;
- DBUG_ASSERT(buflen >= sizeof(struct hostent_data));
- hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
- *h_errnop= errno;
- return hp;
-}
-#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
-
-#else /* !HAVE_GETHOSTBYNAME_R */
-
-#ifdef THREAD
-extern pthread_mutex_t LOCK_gethostbyname_r;
-#endif
-
-/*
- No gethostbyname_r() function exists.
- In this case we have to keep a mutex over the call to ensure that no
- other thread is going to reuse the internal memory.
-
- The user is responsible to call my_gethostbyname_r_free() when he
- is finished with the structure.
-*/
-
-struct hostent *my_gethostbyname_r(const char *name,
- struct hostent *res __attribute__((unused)),
- char *buffer __attribute__((unused)),
- int buflen __attribute__((unused)),
- int *h_errnop)
-{
- struct hostent *hp;
- pthread_mutex_lock(&LOCK_gethostbyname_r);
- hp= gethostbyname(name);
- *h_errnop= h_errno;
- return hp;
-}
-
-void my_gethostbyname_r_free()
-{
- pthread_mutex_unlock(&LOCK_gethostbyname_r);
-}
-
-#endif /* !HAVE_GETHOSTBYNAME_R */
-#endif /* !my_gethostbyname_r */
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c
index 6bffcd65d30..cb063e27c1f 100644
--- a/mysys/my_getsystime.c
+++ b/mysys/my_getsystime.c
@@ -14,224 +14,102 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* get time since epoc in 100 nanosec units */
-/* thus to get the current time we should use the system function
- with the highest possible resolution */
-
-/*
- TODO: in functions my_micro_time() and my_micro_time_and_time() there
- exists some common code that should be merged into a function.
-*/
#include "mysys_priv.h"
#include "my_static.h"
#ifdef __NETWARE__
#include <nks/time.h>
+#elif defined(__WIN__)
+#define OFFSET_TO_EPOC 116444736000000000LL
+static ulonglong query_performance_frequency;
#endif
#ifdef HAVE_LINUX_UNISTD_H
#include <linux/unistd.h>
#endif
+/*
+ return number of nanoseconds since unspecified (but always the same)
+ point in the past
+
+ NOTE:
+ Thus to get the current time we should use the system function
+ with the highest possible resolution
-ulonglong my_getsystime()
+ The value is not anchored to any specific point in time (e.g. epoch) nor
+ is it subject to resetting or drifting by way of adjtime() or settimeofday(),
+ and thus it is *NOT* appropriate for getting the current timestamp. It can be
+ used for calculating time intervals, though.
+*/
+
+ulonglong my_interval_timer()
{
#ifdef HAVE_CLOCK_GETTIME
struct timespec tp;
- clock_gettime(CLOCK_REALTIME, &tp);
- return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100;
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+ return tp.tv_sec*1000000000ULL+tp.tv_nsec;
+#elif defined(HAVE_GETHRTIME)
+ return gethrtime();
#elif defined(__WIN__)
LARGE_INTEGER t_cnt;
if (query_performance_frequency)
{
QueryPerformanceCounter(&t_cnt);
- return ((t_cnt.QuadPart / query_performance_frequency * 10000000) +
- ((t_cnt.QuadPart % query_performance_frequency) * 10000000 /
- query_performance_frequency) + query_performance_offset);
+ return (t_cnt.QuadPart / query_performance_frequency * 1000000000ULL) +
+ ((t_cnt.QuadPart % query_performance_frequency) * 1000000000ULL /
+ query_performance_frequency);
+ }
+ else
+ {
+ ulonglong newtime;
+ GetSystemTimeAsFileTime((FILETIME*)&newtime);
+ return newtime*100ULL;
}
- return 0;
#elif defined(__NETWARE__)
NXTime_t tm;
NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm);
- return (ulonglong)tm/100;
+ return (ulonglong)tm;
#else
/* TODO: check for other possibilities for hi-res timestamping */
struct timeval tv;
gettimeofday(&tv,NULL);
- return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10;
+ return tv.tv_sec*1000000000ULL+tv.tv_usec*1000ULL;
#endif
}
-/*
- Return current time
-
- SYNOPSIS
- my_time()
- flags If MY_WME is set, write error if time call fails
-
-*/
-
-time_t my_time(myf flags __attribute__((unused)))
-{
- time_t t;
-#ifdef HAVE_GETHRTIME
- (void) my_micro_time_and_time(&t);
- return t;
-#else
- /* The following loop is here beacuse time() may fail on some systems */
- while ((t= time(0)) == (time_t) -1)
- {
- if (flags & MY_WME)
- fprintf(stderr, "%s: Warning: time() call failed\n", my_progname);
- }
- return t;
-#endif
-}
-
-
-/*
- Return time in micro seconds
-
- SYNOPSIS
- my_micro_time()
-
- NOTES
- This function is to be used to measure performance in micro seconds.
- As it's not defined whats the start time for the clock, this function
- us only useful to measure time between two moments.
-
- For windows platforms we need the frequency value of the CUP. This is
- initalized in my_init.c through QueryPerformanceFrequency().
-
- If Windows platform doesn't support QueryPerformanceFrequency() we will
- obtain the time via GetClockCount, which only supports milliseconds.
-
- RETURN
- Value in microseconds from some undefined point in time
-*/
-
-ulonglong my_micro_time()
-{
-#if defined(__WIN__)
- ulonglong newtime;
- GetSystemTimeAsFileTime((FILETIME*)&newtime);
- return (newtime/10);
-#elif defined(HAVE_GETHRTIME)
- return gethrtime()/1000;
-#else
- ulonglong newtime;
- struct timeval t;
- /*
- The following loop is here because gettimeofday may fail on some systems
- */
- while (gettimeofday(&t, NULL) != 0)
- {}
- newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
- return newtime;
-#endif /* defined(__WIN__) */
-}
-
-
-/*
- Return time in seconds and timer in microseconds (not different start!)
-
- SYNOPSIS
- my_micro_time_and_time()
- time_arg Will be set to seconds since epoch (00:00:00 UTC,
- January 1, 1970)
-
- NOTES
- This function is to be useful when we need both the time and microtime.
- For example in MySQL this is used to get the query time start of a query
- and to measure the time of a query (for the slow query log)
-
- IMPLEMENTATION
- Value of time is as in time() call.
- Value of microtime is same as my_micro_time(), which may be totally
- unrealated to time()
+/* Return current time in HRTIME_RESOLUTION (microseconds) since epoch */
- RETURN
- Value in microseconds from some undefined point in time
-*/
-
-#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */
-
-ulonglong my_micro_time_and_time(time_t *time_arg)
+my_hrtime_t my_hrtime()
{
+ my_hrtime_t hrtime;
#if defined(__WIN__)
ulonglong newtime;
GetSystemTimeAsFileTime((FILETIME*)&newtime);
- *time_arg= (time_t) ((newtime - OFFSET_TO_EPOCH) / 10000000);
- return (newtime/10);
-#elif defined(HAVE_GETHRTIME)
- /*
- Solaris has a very slow time() call. We optimize this by using the very
- fast gethrtime() call and only calling time() every 1/2 second
- */
- static hrtime_t prev_gethrtime= 0;
- static time_t cur_time= 0;
- hrtime_t cur_gethrtime;
-
- pthread_mutex_lock(&THR_LOCK_time);
- cur_gethrtime= gethrtime();
- /*
- Due to bugs in the Solaris (x86) implementation of gethrtime(),
- the time returned by it might not be monotonic. Don't use the
- cached time(2) value if this is a case.
- */
- if ((prev_gethrtime > cur_gethrtime) ||
- ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS))
- {
- cur_time= time(0);
- prev_gethrtime= cur_gethrtime;
- }
- *time_arg= cur_time;
- pthread_mutex_unlock(&THR_LOCK_time);
- return cur_gethrtime/1000;
+ newtime -= OFFSET_TO_EPOC;
+ hrtime.val= newtime/10;
+#elif defined(HAVE_CLOCK_GETTIME)
+ struct timespec tp;
+ clock_gettime(CLOCK_REALTIME, &tp);
+ hrtime.val= tp.tv_sec*1000000ULL+tp.tv_nsec/1000ULL;
#else
- ulonglong newtime;
struct timeval t;
- /*
- The following loop is here because gettimeofday may fail on some systems
- */
- while (gettimeofday(&t, NULL) != 0)
- {}
- *time_arg= t.tv_sec;
- newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
- return newtime;
-#endif /* defined(__WIN__) */
+ /* The following loop is here because gettimeofday may fail */
+ while (gettimeofday(&t, NULL) != 0) {}
+ hrtime.val= t.tv_sec*1000000ULL + t.tv_usec;
+#endif
+ return hrtime;
}
-/*
- Returns current time
-
- SYNOPSIS
- my_time_possible_from_micro()
- microtime Value from very recent my_micro_time()
-
- NOTES
- This function returns the current time. The microtime argument is only used
- if my_micro_time() uses a function that can safely be converted to the
- current time.
-
- RETURN
- current time
-*/
-
-time_t my_time_possible_from_micro(ulonglong microtime __attribute__((unused)))
+void my_time_init()
{
-#if defined(__WIN__)
- time_t t;
- while ((t= time(0)) == (time_t) -1)
- {}
- return t;
-#elif defined(HAVE_GETHRTIME)
- return my_time(0); /* Cached time */
-#else
- return (time_t) (microtime / 1000000);
-#endif /* defined(__WIN__) */
+#ifdef __WIN__
+ compile_time_assert(sizeof(LARGE_INTEGER) ==
+ sizeof(query_performance_frequency));
+ if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
+ query_performance_frequency= 0;
+#endif
}
diff --git a/mysys/my_handler_errors.h b/mysys/my_handler_errors.h
index 31445cd8671..6213ab188cc 100644
--- a/mysys/my_handler_errors.h
+++ b/mysys/my_handler_errors.h
@@ -1,4 +1,3 @@
-
/*
Errors a handler can give you
*/
@@ -65,5 +64,6 @@ static const char *handler_error_messages[]=
"Read page with wrong checksum",
"Too many active concurrent transactions",
"Row is not visible by the current transaction",
- "Operation was interrupted by end user (probably kill command?)"
+ "Operation was interrupted by end user (probably kill command?)",
+ "Disk full"
};
diff --git a/mysys/my_init.c b/mysys/my_init.c
index e7ab9ba7a1f..356dbe6070f 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -102,6 +102,7 @@ my_bool my_init(void)
DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown"));
if (!home_dir)
{ /* Don't initialize twice */
+ my_time_init();
my_win_init();
if ((home_dir=getenv("HOME")) != 0)
home_dir=intern_filename(home_dir_buff,home_dir);
@@ -258,7 +259,6 @@ void my_debug_put_break_here(void)
#ifdef __WIN__
-
/*
my_parameter_handler
@@ -332,54 +332,6 @@ static void my_win_init(void)
_tzset();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /* The following is used by time functions */
-#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
-#define MS 10000000
- {
- FILETIME ft;
- LARGE_INTEGER li, t_cnt;
- DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
- if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
- query_performance_frequency= 0;
- else
- {
- GetSystemTimeAsFileTime(&ft);
- li.LowPart= ft.dwLowDateTime;
- li.HighPart= ft.dwHighDateTime;
- query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
- QueryPerformanceCounter(&t_cnt);
- query_performance_offset-= (t_cnt.QuadPart /
- query_performance_frequency * MS +
- t_cnt.QuadPart %
- query_performance_frequency * MS /
- query_performance_frequency);
- }
- }
-
{
/*
Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
diff --git a/mysys/my_net.c b/mysys/my_net.c
index 81d977210f8..820abf32386 100644
--- a/mysys/my_net.c
+++ b/mysys/my_net.c
@@ -31,6 +31,8 @@
#include <arpa/inet.h>
#endif
#endif /* !defined(__WIN__) */
+#include "my_net.h"
+
void my_inet_ntoa(struct in_addr in, char *buf)
{
@@ -40,3 +42,93 @@ void my_inet_ntoa(struct in_addr in, char *buf)
strmov(buf,ptr);
pthread_mutex_unlock(&THR_LOCK_net);
}
+
+/* This code is not needed if my_gethostbyname_r is a macro */
+#if !defined(my_gethostbyname_r)
+
+/*
+ Emulate SOLARIS style calls, not because it's better, but just to make the
+ usage of getbostbyname_r simpler.
+*/
+
+#if defined(HAVE_GETHOSTBYNAME_R)
+
+#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
+
+struct hostent *my_gethostbyname_r(const char *name,
+ struct hostent *result, char *buffer,
+ int buflen, int *h_errnop)
+{
+ struct hostent *hp;
+ DBUG_ASSERT((size_t) buflen >= sizeof(*result));
+ if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
+ return 0;
+ return hp;
+}
+
+#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
+
+struct hostent *my_gethostbyname_r(const char *name,
+ struct hostent *result, char *buffer,
+ int buflen, int *h_errnop)
+{
+ if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
+ {
+ *h_errnop= errno;
+ return 0;
+ }
+ return result;
+}
+
+#else
+
+/* gethostbyname_r with similar interface as gethostbyname() */
+
+struct hostent *my_gethostbyname_r(const char *name,
+ struct hostent *result, char *buffer,
+ int buflen, int *h_errnop)
+{
+ struct hostent *hp;
+ DBUG_ASSERT(buflen >= sizeof(struct hostent_data));
+ hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
+ *h_errnop= errno;
+ return hp;
+}
+#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
+
+#else /* !HAVE_GETHOSTBYNAME_R */
+
+#ifdef THREAD
+extern pthread_mutex_t LOCK_gethostbyname_r;
+#endif
+
+/*
+ No gethostbyname_r() function exists.
+ In this case we have to keep a mutex over the call to ensure that no
+ other thread is going to reuse the internal memory.
+
+ The user is responsible to call my_gethostbyname_r_free() when he
+ is finished with the structure.
+*/
+
+struct hostent *
+my_gethostbyname_r(const char *name,
+ struct hostent *result __attribute__((unused)),
+ char *buffer __attribute__((unused)),
+ int buflen __attribute__((unused)),
+ int *h_errnop)
+{
+ struct hostent *hp;
+ pthread_mutex_lock(&LOCK_gethostbyname_r);
+ hp= gethostbyname(name);
+ *h_errnop= h_errno;
+ return hp;
+}
+
+void my_gethostbyname_r_free()
+{
+ pthread_mutex_unlock(&LOCK_gethostbyname_r);
+}
+
+#endif /* !HAVE_GETHOSTBYNAME_R */
+#endif /* !my_gethostbyname_r */
diff --git a/mysys/my_port.c b/mysys/my_port.c
index 9ad333421ca..96dbe10b1bd 100644
--- a/mysys/my_port.c
+++ b/mysys/my_port.c
@@ -29,9 +29,9 @@
integers like '18446744073709551615'. The end result is that the
high bit is simply dropped. (probably bug in gcc optimizations)
Handling the conversion in a sub function seems to work.
-*/
-
+ It doesn't work to make this function inline.
+*/
double my_ulonglong2double(unsigned long long nr)
{
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 08653d03d21..52c8c6aff0e 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -112,11 +112,6 @@ const char *(*proc_info_hook)(void *, const char *, const char *, const char *,
void (*debug_sync_C_callback_ptr)(const char *, size_t);
#endif /* defined(ENABLED_DEBUG_SYNC) */
-#ifdef __WIN__
-/* from my_getsystime.c */
-ulonglong query_performance_frequency, query_performance_offset;
-#endif
-
/* How to disable options */
my_bool NEAR my_disable_locking=0;
my_bool NEAR my_disable_sync=0;
diff --git a/mysys/my_static.h b/mysys/my_static.h
index 90168b099a8..5e853c2a559 100644
--- a/mysys/my_static.h
+++ b/mysys/my_static.h
@@ -66,8 +66,6 @@ extern struct st_irem *sf_malloc_root;
extern struct st_my_file_info my_file_info_default[MY_NFILE];
-extern ulonglong query_performance_frequency, query_performance_offset;
-
#if defined(THREAD) && !defined(__WIN__)
extern sigset_t my_signals; /* signals blocked by mf_brkhant */
#endif
diff --git a/mysys/my_uuid.c b/mysys/my_uuid.c
index e2372391b06..3df2dda2af5 100644
--- a/mysys/my_uuid.c
+++ b/mysys/my_uuid.c
@@ -47,6 +47,7 @@ static my_bool my_uuid_inited= 0;
static struct my_rnd_struct uuid_rand;
static uint nanoseq;
static ulonglong uuid_time= 0;
+static longlong interval_timer_offset;
static uchar uuid_suffix[2+6]; /* clock_seq and node */
#ifdef THREAD
@@ -70,6 +71,8 @@ static void set_clock_seq()
{
uint16 clock_seq= ((uint)(my_rnd(&uuid_rand)*16383)) | UUID_VARIANT;
mi_int2store(uuid_suffix, clock_seq);
+ interval_timer_offset= (my_hrtime().val * 10 - my_interval_timer()/100 +
+ UUID_TIME_OFFSET);
}
@@ -93,7 +96,7 @@ void my_uuid_init(ulong seed1, ulong seed2)
if (my_uuid_inited)
return;
my_uuid_inited= 1;
- now= my_getsystime();
+ now= my_interval_timer()/100 + interval_timer_offset;
nanoseq= 0;
if (my_gethwaddr(mac))
@@ -134,7 +137,7 @@ void my_uuid(uchar *to)
DBUG_ASSERT(my_uuid_inited);
pthread_mutex_lock(&LOCK_uuid_generator);
- tv= my_getsystime() + UUID_TIME_OFFSET + nanoseq;
+ tv= my_interval_timer()/100 + interval_timer_offset + nanoseq;
if (likely(tv > uuid_time))
{
@@ -187,7 +190,7 @@ void my_uuid(uchar *to)
irrelevant in the new numberspace.
*/
set_clock_seq();
- tv= my_getsystime() + UUID_TIME_OFFSET;
+ tv= my_interval_timer()/100 + interval_timer_offset;
nanoseq= 0;
DBUG_PRINT("uuid",("making new numberspace"));
}
@@ -228,7 +231,8 @@ void my_uuid2str(const uchar *guid, char *s)
{
*s++= _dig_vec_lower[guid[i] >>4];
*s++= _dig_vec_lower[guid[i] & 15];
- if(i == 3 || i == 5 || i == 7 || i == 9)
+ /* Set '-' at intervals 3, 5, 7 and 9 */
+ if ((1 << i) & ((1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)))
*s++= '-';
}
}
diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c
index b869b22bdea..e181b24cdef 100644
--- a/mysys/my_wincond.c
+++ b/mysys/my_wincond.c
@@ -77,31 +77,22 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
struct timespec *abstime)
{
int result;
- long timeout;
- union ft64 now;
-
+ DWORD timeout;
+ long long timeout_us;
+ my_hrtime_t now;
+ my_hrtime_t then;
if( abstime != NULL )
{
- GetSystemTimeAsFileTime(&now.ft);
-
- /*
- Calculate time left to abstime
- - subtract start time from current time(values are in 100ns units)
- - convert to millisec by dividing with 10000
- */
- timeout= (long)((abstime->tv.i64 - now.i64) / 10000);
-
- /* Don't allow the timeout to be negative */
- if (timeout < 0)
- timeout= 0L;
-
- /*
- Make sure the calucated timeout does not exceed original timeout
- value which could cause "wait for ever" if system time changes
- */
- if (timeout > abstime->max_timeout_msec)
- timeout= abstime->max_timeout_msec;
-
+ now= my_hrtime();
+ then.val= 1000000ULL*abstime->tv_sec + abstime->tv_nsec/1000;
+ timeout_us= then.val - now.val;
+
+ if (timeout_us < 0)
+ timeout= 0;
+ else if (timeout_us > 1000ULL*INFINITE)
+ timeout= INFINITE;
+ else
+ timeout= (DWORD)(timeout_us/1000);
}
else
{
diff --git a/mysys/string.c b/mysys/string.c
index 10a72b8a295..030178c6667 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -183,3 +183,15 @@ void dynstr_free(DYNAMIC_STRING *str)
str->str=0;
}
}
+
+
+/* Give over the control of the dynamic string to caller */
+
+void dynstr_reassociate(DYNAMIC_STRING *str, char **ptr, size_t *length,
+ size_t *alloc_length)
+{
+ *ptr= str->str;
+ *length= str->length;
+ *alloc_length= str->max_length;
+ str->str=0;
+}
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 2c008a8817a..ac70282c050 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -112,25 +112,37 @@ static inline pthread_cond_t *get_cond(void)
/*
+ Sort locks in priority order
+
+ LOCK_CMP()
+ A First lock
+ B Second lock
+
+ Return:
+ 0 if A >= B
+ 1 if A < B
+
Priority for locks (decides in which order locks are locked)
We want all write locks to be first, followed by read locks.
Locks from MERGE tables has a little lower priority than other
locks, to allow one to release merge tables without having
to unlock and re-lock other locks.
The lower the number, the higher the priority for the lock.
- Read locks should have 4, write locks should have 0.
- UNLOCK is 8, to force these last in thr_merge_locks.
For MERGE tables we add 2 (THR_LOCK_MERGE_PRIV) to the lock priority.
THR_LOCK_LATE_PRIV (1) is used when one locks other tables to be merged
with existing locks. This way we prioritize the original locks over the
new locks.
*/
-static uint lock_priority[(uint)TL_WRITE_ONLY+1] =
-{ 8, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0};
-
-#define LOCK_CMP(A,B) ((uchar*) ((A)->lock) + lock_priority[(uint) (A)->type] + (A)->priority < (uchar*) ((B)->lock) + lock_priority[(uint) (B)->type] + (B)->priority)
+inline int LOCK_CMP(THR_LOCK_DATA *A, THR_LOCK_DATA *B)
+{
+ if (A->lock != B->lock)
+ return A->lock < B->lock;
+ if (A->type != B->type)
+ return A->type > B->type; /* Prioritize read */
+ return A->priority < B->priority;
+}
/*
For the future (now the thread specific cond is alloced by my_pthread.c)
@@ -215,6 +227,7 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
static void check_locks(THR_LOCK *lock, const char *where,
+ enum thr_lock_type type,
my_bool allow_no_locks)
{
uint old_found_errors=found_errors;
@@ -281,6 +294,7 @@ static void check_locks(THR_LOCK *lock, const char *where,
found_errors++;
fprintf(stderr,
"Warning at '%s': Write lock %d waiting while no exclusive read locks\n",where,(int) lock->write_wait.data->type);
+ DBUG_PRINT("warning", ("Warning at '%s': Write lock %d waiting while no exclusive read locks\n",where,(int) lock->write_wait.data->type));
}
}
}
@@ -298,8 +312,10 @@ static void check_locks(THR_LOCK *lock, const char *where,
if (data->type != TL_WRITE_CONCURRENT_INSERT)
{
fprintf(stderr,
- "Warning at '%s': Found TL_WRITE_CONCURRENT_INSERT lock mixed with other write locks\n",
- where);
+ "Warning at '%s': Found TL_WRITE_CONCURRENT_INSERT lock mixed with other write lock: %d\n",
+ where, data->type);
+ DBUG_PRINT("warning", ("Warning at '%s': Found TL_WRITE_CONCURRENT_INSERT lock mixed with other write lock: %d\n",
+ where, data->type));
break;
}
}
@@ -314,26 +330,34 @@ static void check_locks(THR_LOCK *lock, const char *where,
fprintf(stderr,
"Warning at '%s': Found WRITE_ALLOW_WRITE lock waiting for WRITE_ALLOW_WRITE lock\n",
where);
+ DBUG_PRINT("warning", ("Warning at '%s': Found WRITE_ALLOW_WRITE lock waiting for WRITE_ALLOW_WRITE lock\n",
+ where));
+
}
}
if (lock->read.data)
{
- if (!thr_lock_owner_equal(lock->write.data->owner,
- lock->read.data->owner) &&
+ THR_LOCK_DATA *data;
+ for (data=lock->read.data ; data ; data=data->next)
+ {
+ if (!thr_lock_owner_equal(lock->write.data->owner,
+ data->owner) &&
((lock->write.data->type > TL_WRITE_DELAYED &&
lock->write.data->type != TL_WRITE_ONLY) ||
((lock->write.data->type == TL_WRITE_CONCURRENT_INSERT ||
lock->write.data->type == TL_WRITE_ALLOW_WRITE) &&
- lock->read_no_write_count)))
- {
- found_errors++;
- fprintf(stderr,
- "Warning at '%s': Found lock of type %d that is write and read locked\n",
- where, lock->write.data->type);
- DBUG_PRINT("warning",("At '%s': Found lock of type %d that is write and read locked\n",
- where, lock->write.data->type));
-
- }
+ data->type == TL_READ_NO_INSERT)))
+ {
+ found_errors++;
+ fprintf(stderr,
+ "Warning at '%s' for lock: %d: Found lock of type %d that is write and read locked. Read_no_write_count: %d\n",
+ where, (int) type, lock->write.data->type,
+ lock->read_no_write_count);
+ DBUG_PRINT("warning",("At '%s' for lock %d: Found lock of type %d that is write and read locked\n",
+ where, (int) type,
+ lock->write.data->type));
+ }
+ }
}
if (lock->read_wait.data)
{
@@ -359,7 +383,7 @@ static void check_locks(THR_LOCK *lock, const char *where,
}
#else /* EXTRA_DEBUG */
-#define check_locks(A,B,C)
+#define check_locks(A,B,C,D)
#endif
@@ -536,13 +560,14 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
else
wait->last=data->prev;
data->type= TL_UNLOCK; /* No lock */
- check_locks(data->lock, "killed or timed out wait_for_lock", 1);
+ check_locks(data->lock, "killed or timed out wait_for_lock", data->type,
+ 1);
wake_up_waiters(data->lock);
}
else
{
DBUG_PRINT("thr_lock", ("lock aborted"));
- check_locks(data->lock, "aborted wait_for_lock", 0);
+ check_locks(data->lock, "aborted wait_for_lock", data->type, 0);
}
}
else
@@ -551,7 +576,7 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param,
data->type == TL_WRITE_CONCURRENT_INSERT);
- check_locks(data->lock,"got wait_for_lock",0);
+ check_locks(data->lock,"got wait_for_lock", data->type, 0);
}
pthread_mutex_unlock(&data->lock->mutex);
@@ -584,7 +609,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
(long) data, data->owner->info->thread_id,
(long) lock, (int) lock_type));
check_locks(lock,(uint) lock_type <= (uint) TL_READ_NO_INSERT ?
- "enter read_lock" : "enter write_lock",0);
+ "enter read_lock" : "enter write_lock", lock_type, 0);
if ((int) lock_type <= (int) TL_READ_NO_INSERT)
{
/* Request for READ lock */
@@ -613,7 +638,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
lock->read.last= &data->next;
if (lock_type == TL_READ_NO_INSERT)
lock->read_no_write_count++;
- check_locks(lock,"read lock with old write lock",0);
+ check_locks(lock,"read lock with old write lock", lock_type, 0);
if (lock->get_status)
(*lock->get_status)(data->status_param, 0);
statistic_increment(locks_immediate,&THR_LOCK_lock);
@@ -637,7 +662,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
lock->read.last= &data->next;
if (lock_type == TL_READ_NO_INSERT)
lock->read_no_write_count++;
- check_locks(lock,"read lock with no write locks",0);
+ check_locks(lock,"read lock with no write locks", lock_type, 0);
if (lock->get_status)
(*lock->get_status)(data->status_param, 0);
statistic_increment(locks_immediate,&THR_LOCK_lock);
@@ -722,7 +747,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
(*lock->write.last)=data; /* Add to running fifo */
data->prev=lock->write.last;
lock->write.last= &data->next;
- check_locks(lock,"second write lock",0);
+ check_locks(lock,"second write lock", lock_type, 0);
if (lock->get_status)
(*lock->get_status)(data->status_param,
lock_type == TL_WRITE_CONCURRENT_INSERT);
@@ -760,7 +785,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
lock->write.last= &data->next;
if (lock->get_status)
(*lock->get_status)(data->status_param, concurrent_insert);
- check_locks(lock,"only write lock",0);
+ check_locks(lock,"only write lock", lock_type, 0);
statistic_increment(locks_immediate,&THR_LOCK_lock);
goto end;
}
@@ -796,7 +821,7 @@ static inline void free_all_read_locks(THR_LOCK *lock,
{
THR_LOCK_DATA *data=lock->read_wait.data;
- check_locks(lock,"before freeing read locks",1);
+ check_locks(lock,"before freeing read locks", TL_UNLOCK, 1);
/* move all locks from read_wait list to read list */
(*lock->read.last)=data;
@@ -838,7 +863,7 @@ static inline void free_all_read_locks(THR_LOCK *lock,
*lock->read_wait.last=0;
if (!lock->read_wait.data)
lock->write_lock_count=0;
- check_locks(lock,"after giving read locks",0);
+ check_locks(lock,"after giving read locks", TL_UNLOCK, 0);
}
/* Unlock lock and free next thread on same lock */
@@ -851,7 +876,7 @@ void thr_unlock(THR_LOCK_DATA *data, uint unlock_flags)
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx",
(long) data, data->owner->info->thread_id, (long) lock));
pthread_mutex_lock(&lock->mutex);
- check_locks(lock,"start of release lock",0);
+ check_locks(lock,"start of release lock", lock_type, 0);
if (((*data->prev)=data->next)) /* remove from lock-list */
data->next->prev= data->prev;
@@ -885,9 +910,9 @@ void thr_unlock(THR_LOCK_DATA *data, uint unlock_flags)
if (lock_type == TL_READ_NO_INSERT)
lock->read_no_write_count--;
data->type=TL_UNLOCK; /* Mark unlocked */
- check_locks(lock,"after releasing lock",1);
+ check_locks(lock,"after releasing lock", lock_type, 1);
wake_up_waiters(lock);
- check_locks(lock,"end of thr_unlock",1);
+ check_locks(lock,"end of thr_unlock", lock_type, 1);
pthread_mutex_unlock(&lock->mutex);
DBUG_VOID_RETURN;
}
@@ -1012,7 +1037,7 @@ static void wake_up_waiters(THR_LOCK *lock)
free_all_read_locks(lock,0);
}
end:
- check_locks(lock, "after waking up waiters", 0);
+ check_locks(lock, "after waking up waiters", TL_UNLOCK, 0);
DBUG_VOID_RETURN;
}
@@ -1322,7 +1347,7 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
DBUG_ASSERT(old_lock_type == TL_WRITE_ONLY);
DBUG_ASSERT(old_lock_type > new_lock_type);
in_data->type= new_lock_type;
- check_locks(lock,"after downgrading lock",0);
+ check_locks(lock,"after downgrading lock", old_lock_type, 0);
#if TO_BE_REMOVED
switch (old_lock_type)
@@ -1422,7 +1447,8 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
data->prev= lock->write.last;
lock->write.last= &data->next;
data->next= 0;
- check_locks(lock, "Started write lock after downgrade",0);
+ check_locks(lock, "Started write lock after downgrade", new_lock_type,
+ 0);
data->cond= 0;
pthread_cond_signal(cond);
}
@@ -1475,13 +1501,15 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
if (data->type == TL_READ_NO_INSERT)
lock->read_no_write_count++;
- check_locks(lock, "Started read lock after downgrade",0);
+ check_locks(lock, "Started read lock after downgrade", new_lock_type,
+ 0);
data->cond= 0;
pthread_cond_signal(cond);
}
}
}
- check_locks(lock,"after starting waiters after downgrading lock",0);
+ check_locks(lock,"after starting waiters after downgrading lock",
+ new_lock_type, 0);
#endif
pthread_mutex_unlock(&lock->mutex);
DBUG_VOID_RETURN;
@@ -1502,7 +1530,7 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
pthread_mutex_unlock(&lock->mutex);
DBUG_RETURN(data->type == TL_UNLOCK); /* Test if Aborted */
}
- check_locks(lock,"before upgrading lock",0);
+ check_locks(lock,"before upgrading lock", data->type, 0);
/* TODO: Upgrade to TL_WRITE_CONCURRENT_INSERT in some cases */
data->type= new_lock_type; /* Upgrade lock */
@@ -1530,11 +1558,11 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
lock->write_wait.last= &data->next;
data->prev= &lock->write_wait.data;
lock->write_wait.data=data;
- check_locks(lock,"upgrading lock",0);
+ check_locks(lock,"upgrading lock", new_lock_type, 0);
}
else
{
- check_locks(lock,"waiting for lock",0);
+ check_locks(lock,"waiting for lock", new_lock_type, 0);
}
res= wait_for_lock(&lock->write_wait,data,1);
if (res == THR_LOCK_SUCCESS && lock->start_trans)
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index 732929f6d99..6ee79cb8e87 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -479,9 +479,9 @@ void wt_end()
(or even most) of them will never be used for deadlock detection.
@param ds a pointer to deadlock search depth short value
- @param ts a pointer to deadlock timeout short value
+ @param ts a pointer to deadlock timeout short value (microseconds)
@param dl a pointer to deadlock search depth long value
- @param tl a pointer to deadlock timeout long value
+ @param tl a pointer to deadlock timeout long value (microseconds)
@note these are pointers to values, and WT_THD stores them as pointers.
It allows one later to change search depths and timeouts for existing
@@ -1037,8 +1037,9 @@ int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
{
int ret= WT_TIMEOUT;
struct timespec timeout;
- ulonglong before, after, starttime;
+ my_hrtime_t before, after, starttime;
WT_RESOURCE *rc= thd->waiting_for;
+ ulonglong end_wait_time;
DBUG_ENTER("wt_thd_cond_timedwait");
DBUG_PRINT("wt", ("enter: thd=%s, rc=%p", thd->name, rc));
@@ -1050,29 +1051,15 @@ int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
safe_mutex_assert_owner(mutex);
#endif
- before= starttime= my_getsystime();
-
-#ifdef __WIN__
- /*
- only for the sake of Windows we distinguish between
- 'before' and 'starttime':
-
- my_getsystime() returns high-resolution value, that cannot be used for
- waiting (it doesn't follow system clock changes), but is good for time
- intervals.
-
- GetSystemTimeAsFileTime() follows system clock, but is low-resolution
- and will result in lousy intervals.
- */
- GetSystemTimeAsFileTime((PFILETIME)&starttime);
-#endif
+ before= starttime= my_hrtime();
rc_wrlock(rc);
if (rc->owners.elements == 0)
ret= WT_OK;
rc_unlock(rc);
- set_timespec_time_nsec(timeout, starttime, (*thd->timeout_short)*ULL(1000));
+ end_wait_time= starttime.val *1000 + (*thd->timeout_short)*ULL(1000000);
+ set_timespec_time_nsec(timeout, end_wait_time);
if (ret == WT_TIMEOUT && !thd->killed)
ret= pthread_cond_timedwait(&rc->cond, mutex, &timeout);
if (ret == WT_TIMEOUT && !thd->killed)
@@ -1084,15 +1071,16 @@ int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
ret= WT_DEADLOCK;
else if (*thd->timeout_long > *thd->timeout_short)
{
- set_timespec_time_nsec(timeout, starttime, (*thd->timeout_long)*ULL(1000));
+ end_wait_time= starttime.val *1000 + (*thd->timeout_long)*ULL(1000000);
+ set_timespec_time_nsec(timeout, end_wait_time);
if (!thd->killed)
ret= pthread_cond_timedwait(&rc->cond, mutex, &timeout);
}
}
- after= my_getsystime();
+ after= my_hrtime();
if (stop_waiting(thd) == WT_DEADLOCK) /* if we're killed */
ret= WT_DEADLOCK;
- increment_wait_stats(after-before, ret);
+ increment_wait_stats(after.val-before.val, ret);
if (ret == WT_OK)
increment_success_stats();
DBUG_RETURN(ret);
diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c
index f39ff6a78fd..aebdc007d92 100644
--- a/plugin/fulltext/plugin_example.c
+++ b/plugin/fulltext/plugin_example.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006 MySQL AB
+/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -259,7 +259,7 @@ mysql_declare_plugin(ftexample)
MYSQL_FTPARSER_PLUGIN, /* type */
&simple_parser_descriptor, /* descriptor */
"simple_parser", /* name */
- "MySQL AB", /* author */
+ "Sergei Golubchik", /* author */
"Simple Full-Text Parser", /* description */
PLUGIN_LICENSE_GPL,
simple_parser_plugin_init, /* init function (when loaded) */
@@ -270,12 +270,13 @@ mysql_declare_plugin(ftexample)
NULL
}
mysql_declare_plugin_end;
+
maria_declare_plugin(ftexample)
{
MYSQL_FTPARSER_PLUGIN, /* type */
&simple_parser_descriptor, /* descriptor */
"simple_parser", /* name */
- "MySQL AB", /* author */
+ "Sergei Golubchik", /* author */
"Simple Full-Text Parser", /* description */
PLUGIN_LICENSE_GPL,
simple_parser_plugin_init, /* init function (when loaded) */
@@ -287,4 +288,3 @@ maria_declare_plugin(ftexample)
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL /* maturity */
}
maria_declare_plugin_end;
-
diff --git a/plugin/handler_socket/AUTHORS b/plugin/handler_socket/AUTHORS
index 6a66e0ac799..b60fb015eaa 100644
--- a/plugin/handler_socket/AUTHORS
+++ b/plugin/handler_socket/AUTHORS
@@ -17,3 +17,6 @@ Moriyoshi Koizumi (https://github.com/moriyoshi)
takeda-at (https://github.com/takada-at)
- added simple authorization function
+WheresWardy (https://github.com/WheresWardy)
+ - added authentication functions to libhsclient
+
diff --git a/plugin/handler_socket/client/Makefile.am b/plugin/handler_socket/client/Makefile.am
index 6aff3419565..e89727a7023 100644
--- a/plugin/handler_socket/client/Makefile.am
+++ b/plugin/handler_socket/client/Makefile.am
@@ -6,9 +6,19 @@ hsclient_LDFLAGS= -static -L../libhsclient -lhsclient
hsclient_CXXFLAGS= $(AM_INCLUDES)
hstest: hstest.o
- $(CXX) $(CXXFLAGS) $(LFLAGS) hstest.o \
- -L../libhsclient/.libs -lhsclient $(MYSQL_LIB) -o hstest
+ $(CXX) $(CXXFLAGS) $(MY_CXXFLAGS) $(LFLAGS) hstest.o \
+ -L../libhsclient/.libs -lhsclient $(MYSQL_LIB) \
+ -o hstest
hstest.o: hstest.cpp
- $(CXX) $(CXXFLAGS) $(MYSQL_INC) $(AM_INCLUDES) -c hstest.cpp
+ $(CXX) $(CXXFLAGS) $(MY_CXXFLAGS) $(MYSQL_INC) $(AM_INCLUDES) \
+ -c hstest.cpp
+hslongrun: hslongrun.o
+ $(CXX) $(CXXFLAGS) $(MY_CXXFLAGS) $(LFLAGS) hslongrun.o \
+ -L../libhsclient/.libs -lhsclient $(MYSQL_LIB) \
+ -o hslongrun
+
+hslongrun.o: hslongrun.cpp
+ $(CXX) $(CXXFLAGS) $(MY_CXXFLAGS) $(MYSQL_INC) $(AM_INCLUDES) \
+ -c hslongrun.cpp
diff --git a/plugin/handler_socket/client/hslongrun.cpp b/plugin/handler_socket/client/hslongrun.cpp
new file mode 100644
index 00000000000..e82c12b166b
--- /dev/null
+++ b/plugin/handler_socket/client/hslongrun.cpp
@@ -0,0 +1,1041 @@
+
+// vim:sw=2:ai
+
+#include <signal.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <string.h>
+#include <vector>
+#include <map>
+#include <stdlib.h>
+#include <memory>
+#include <errno.h>
+#include <mysql.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "util.hpp"
+#include "auto_ptrcontainer.hpp"
+#include "socket.hpp"
+#include "hstcpcli.hpp"
+#include "string_util.hpp"
+#include "mutex.hpp"
+
+namespace dena {
+
+struct auto_mysql : private noncopyable {
+ auto_mysql() : db(0) {
+ reset();
+ }
+ ~auto_mysql() {
+ if (db) {
+ mysql_close(db);
+ }
+ }
+ void reset() {
+ if (db) {
+ mysql_close(db);
+ }
+ if ((db = mysql_init(0)) == 0) {
+ fatal_exit("failed to initialize mysql client");
+ }
+ }
+ operator MYSQL *() const { return db; }
+ private:
+ MYSQL *db;
+};
+
+struct auto_mysql_res : private noncopyable {
+ auto_mysql_res(MYSQL *db) {
+ res = mysql_store_result(db);
+ }
+ ~auto_mysql_res() {
+ if (res) {
+ mysql_free_result(res);
+ }
+ }
+ operator MYSQL_RES *() const { return res; }
+ private:
+ MYSQL_RES *res;
+};
+
+struct auto_mysql_stmt : private noncopyable {
+ auto_mysql_stmt(MYSQL *db) {
+ stmt = mysql_stmt_init(db);
+ }
+ ~auto_mysql_stmt() {
+ if (stmt) {
+ mysql_stmt_close(stmt);
+ }
+ }
+ operator MYSQL_STMT *() const { return stmt; }
+ private:
+ MYSQL_STMT *stmt;
+};
+
+double
+gettimeofday_double()
+{
+ struct timeval tv = { };
+ if (gettimeofday(&tv, 0) != 0) {
+ fatal_abort("gettimeofday");
+ }
+ return static_cast<double>(tv.tv_usec) / 1000000 + tv.tv_sec;
+}
+
+struct record_value {
+ mutex lock;
+ bool deleted;
+ bool unknown_state;
+ std::string key;
+ std::vector<std::string> values;
+ record_value() : deleted(true), unknown_state(false) { }
+};
+
+struct hs_longrun_shared {
+ config conf;
+ socket_args arg;
+ int verbose;
+ long num_threads;
+ int usleep;
+ volatile mutable int running;
+ auto_ptrcontainer< std::vector<record_value *> > records;
+ hs_longrun_shared() : verbose(0), num_threads(0), usleep(0), running(1) { }
+};
+
+struct thread_base {
+ thread_base() : need_join(false), stack_size(256 * 1024) { }
+ virtual ~thread_base() {
+ join();
+ }
+ virtual void run() = 0;
+ void start() {
+ if (!start_nothrow()) {
+ fatal_abort("thread::start");
+ }
+ }
+ bool start_nothrow() {
+ if (need_join) {
+ return need_join; /* true */
+ }
+ void *const arg = this;
+ pthread_attr_t attr;
+ if (pthread_attr_init(&attr) != 0) {
+ fatal_abort("pthread_attr_init");
+ }
+ if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
+ fatal_abort("pthread_attr_setstacksize");
+ }
+ const int r = pthread_create(&thr, &attr, thread_main, arg);
+ if (pthread_attr_destroy(&attr) != 0) {
+ fatal_abort("pthread_attr_destroy");
+ }
+ if (r != 0) {
+ return need_join; /* false */
+ }
+ need_join = true;
+ return need_join; /* true */
+ }
+ void join() {
+ if (!need_join) {
+ return;
+ }
+ int e = 0;
+ if ((e = pthread_join(thr, 0)) != 0) {
+ fatal_abort("pthread_join");
+ }
+ need_join = false;
+ }
+ private:
+ static void *thread_main(void *arg) {
+ thread_base *p = static_cast<thread_base *>(arg);
+ p->run();
+ return 0;
+ }
+ private:
+ pthread_t thr;
+ bool need_join;
+ size_t stack_size;
+};
+
+struct hs_longrun_stat {
+ unsigned long long verify_error_count;
+ unsigned long long runtime_error_count;
+ unsigned long long unknown_count;
+ unsigned long long success_count;
+ hs_longrun_stat()
+ : verify_error_count(0), runtime_error_count(0),
+ unknown_count(0), success_count(0) { }
+ void add(const hs_longrun_stat& x) {
+ verify_error_count += x.verify_error_count;
+ runtime_error_count += x.runtime_error_count;
+ unknown_count += x.unknown_count;
+ success_count += x.success_count;
+ }
+};
+
+struct hs_longrun_thread_base : public thread_base {
+ struct arg_type {
+ int id;
+ std::string worker_type;
+ char op;
+ int lock_flag;
+ const hs_longrun_shared& sh;
+ arg_type(int id, const std::string& worker_type, char op, int lock_flag,
+ const hs_longrun_shared& sh)
+ : id(id), worker_type(worker_type), op(op), lock_flag(lock_flag),
+ sh(sh) { }
+ };
+ arg_type arg;
+ hs_longrun_stat stat;
+ drand48_data randbuf;
+ unsigned int seed;
+ hs_longrun_thread_base(const arg_type& arg)
+ : arg(arg), seed(0) {
+ seed = time(0) + arg.id + 1;
+ srand48_r(seed, &randbuf);
+ }
+ virtual ~hs_longrun_thread_base() { }
+ virtual void run() = 0;
+ size_t rand_record() {
+ double v = 0;
+ drand48_r(&randbuf, &v);
+ const size_t sz = arg.sh.records.size();
+ size_t r = size_t(v * sz);
+ if (r >= sz) {
+ r = 0;
+ }
+ return r;
+ }
+ int verify_update(const std::string& k, const std::string& v1,
+ const std::string& v2, const std::string& v3, record_value& rec,
+ uint32_t num_rows, bool cur_unknown_state);
+ int verify_read(const std::string& k, uint32_t num_rows, uint32_t num_flds,
+ const std::string rrec[4], record_value& rec);
+ int verify_readnolock(const std::string& k, uint32_t num_rows,
+ uint32_t num_flds, const std::string rrec[4]);
+};
+
+int
+hs_longrun_thread_base::verify_update(const std::string& k,
+ const std::string& v1, const std::string& v2, const std::string& v3,
+ record_value& rec, uint32_t num_rows, bool cur_unknown_state)
+{
+ const bool op_success = num_rows == 1;
+ int ret = 0;
+ if (!rec.unknown_state) {
+ if (!rec.deleted && !op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_update_failure\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ } else if (rec.deleted && op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_update_success\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ }
+ }
+ if (op_success) {
+ rec.values.resize(4);
+ rec.values[0] = k;
+ rec.values[1] = v1;
+ rec.values[2] = v2;
+ rec.values[3] = v3;
+ if (ret == 0 && !rec.unknown_state) {
+ ++stat.success_count;
+ }
+ }
+ rec.unknown_state = cur_unknown_state;
+ if (arg.sh.verbose >= 100 && ret == 0) {
+ fprintf(stderr, "%s %s %s %s %s\n", arg.worker_type.c_str(),
+ k.c_str(), v1.c_str(), v2.c_str(), v3.c_str());
+ }
+ return ret;
+}
+
+int
+hs_longrun_thread_base::verify_read(const std::string& k,
+ uint32_t num_rows, uint32_t num_flds, const std::string rrec[4],
+ record_value& rec)
+{
+ const bool op_success = num_rows != 0;
+ int ret = 0;
+ if (!rec.unknown_state) {
+ if (!rec.deleted && !op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_read_failure\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ } else if (rec.deleted && op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_read_success\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ } else if (num_flds != 4) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_read_fldnum %d\n",
+ arg.worker_type.c_str(), arg.id, k.c_str(),
+ static_cast<int>(num_flds));
+ }
+ ret = 1;
+ } else if (rec.deleted) {
+ /* nothing to verify */
+ } else {
+ int diff = 0;
+ for (size_t i = 0; i < 4; ++i) {
+ if (rec.values[i] == rrec[i]) {
+ /* ok */
+ } else {
+ diff = 1;
+ }
+ }
+ if (diff) {
+ std::string mess;
+ for (size_t i = 0; i < 4; ++i) {
+ const std::string& expected = rec.values[i];
+ const std::string& val = rrec[i];
+ mess += " " + val + "/" + expected;
+ }
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_read_value %s\n",
+ arg.worker_type.c_str(), arg.id, k.c_str(), mess.c_str());
+ }
+ ret = 1;
+ }
+ }
+ }
+ if (arg.sh.verbose >= 100 && ret == 0) {
+ fprintf(stderr, "%s %s\n", arg.worker_type.c_str(), k.c_str());
+ }
+ if (ret == 0 && !rec.unknown_state) {
+ ++stat.success_count;
+ }
+ return ret;
+}
+
+int
+hs_longrun_thread_base::verify_readnolock(const std::string& k,
+ uint32_t num_rows, uint32_t num_flds, const std::string rrec[4])
+{
+ int ret = 0;
+ if (num_rows != 1 || num_flds != 4) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_read_failure\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ }
+ if (arg.sh.verbose >= 100 && ret == 0) {
+ fprintf(stderr, "%s -> %s %s %s %s %s\n", arg.worker_type.c_str(),
+ k.c_str(), rrec[0].c_str(), rrec[1].c_str(), rrec[2].c_str(),
+ rrec[3].c_str());
+ }
+ if (ret == 0) {
+ ++stat.success_count;
+ }
+ return ret;
+}
+
+struct hs_longrun_thread_hs : public hs_longrun_thread_base {
+ hs_longrun_thread_hs(const arg_type& arg)
+ : hs_longrun_thread_base(arg) { }
+ void run();
+ int check_hs_error(const char *mess, record_value *rec);
+ int op_insert(record_value& rec);
+ int op_delete(record_value& rec);
+ int op_update(record_value& rec);
+ int op_read(record_value& rec);
+ int op_readnolock(int k);
+ hstcpcli_ptr cli;
+ socket_args sockargs;
+};
+
+struct lock_guard : noncopyable {
+ lock_guard(mutex& mtx) : mtx(mtx) {
+ mtx.lock();
+ }
+ ~lock_guard() {
+ mtx.unlock();
+ }
+ mutex& mtx;
+};
+
+string_ref
+to_string_ref(const std::string& s)
+{
+ return string_ref(s.data(), s.size());
+}
+
+std::string
+to_string(const string_ref& s)
+{
+ return std::string(s.begin(), s.size());
+}
+
+void
+hs_longrun_thread_hs::run()
+{
+ config c = arg.sh.conf;
+ if (arg.op == 'R' || arg.op == 'N') {
+ c["port"] = to_stdstring(arg.sh.conf.get_int("hsport", 9998));
+ } else {
+ c["port"] = to_stdstring(arg.sh.conf.get_int("hsport_wr", 9999));
+ }
+ sockargs.set(c);
+
+ while (arg.sh.running) {
+ if (cli.get() == 0 || !cli->stable_point()) {
+ cli = hstcpcli_i::create(sockargs);
+ if (check_hs_error("connect", 0) != 0) {
+ cli.reset();
+ continue;
+ }
+ cli->request_buf_open_index(0, "hstestdb", "hstesttbl", "PRIMARY",
+ "k,v1,v2,v3", "k,v1,v2,v3");
+ cli->request_send();
+ if (check_hs_error("openindex_send", 0) != 0) {
+ cli.reset();
+ continue;
+ }
+ size_t num_flds = 0;
+ cli->response_recv(num_flds);
+ if (check_hs_error("openindex_recv", 0) != 0) {
+ cli.reset();
+ continue;
+ }
+ cli->response_buf_remove();
+ }
+ const size_t rec_id = rand_record();
+ if (arg.lock_flag) {
+ record_value& rec = *arg.sh.records[rec_id];
+ lock_guard g(rec.lock);
+ int e = 0;
+ switch (arg.op) {
+ case 'I':
+ e = op_insert(rec);
+ break;
+ case 'D':
+ e = op_delete(rec);
+ break;
+ case 'U':
+ e = op_update(rec);
+ break;
+ case 'R':
+ e = op_read(rec);
+ break;
+ default:
+ break;
+ }
+ } else {
+ int e = 0;
+ switch (arg.op) {
+ case 'N':
+ e = op_readnolock(rec_id);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
+int
+hs_longrun_thread_hs::op_insert(record_value& rec)
+{
+ const std::string k = rec.key;
+ const std::string v1 = "iv1_" + k + "_" + to_stdstring(arg.id);
+ const std::string v2 = "iv2_" + k + "_" + to_stdstring(arg.id);
+ const std::string v3 = "iv3_" + k + "_" + to_stdstring(arg.id);
+ const string_ref op_ref("+", 1);
+ const string_ref op_args[4] = {
+ to_string_ref(k),
+ to_string_ref(v1),
+ to_string_ref(v2),
+ to_string_ref(v3)
+ };
+ cli->request_buf_exec_generic(0, op_ref, op_args, 4, 1, 0,
+ string_ref(), 0, 0, 0, 0);
+ cli->request_send();
+ if (check_hs_error("op_insert_send", &rec) != 0) { return 1; }
+ size_t numflds = 0;
+ cli->response_recv(numflds);
+ if (arg.sh.verbose > 10) {
+ const string_ref *row = cli->get_next_row();
+ fprintf(stderr, "HS op=+ errrcode=%d errmess=[%s]\n", cli->get_error_code(),
+ row ? to_string(row[0]).c_str() : "");
+ }
+ const bool op_success = cli->get_error_code() == 0;
+ int ret = 0;
+ if (!rec.unknown_state) {
+ if (rec.deleted && !op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_insert_failure\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ } else if (!rec.deleted && op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_insert_success\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ }
+ } else {
+ ++stat.unknown_count;
+ }
+ if (op_success) {
+ rec.values.resize(4);
+ rec.values[0] = k;
+ rec.values[1] = v1;
+ rec.values[2] = v2;
+ rec.values[3] = v3;
+ rec.deleted = false;
+ if (arg.sh.verbose >= 100 && ret == 0) {
+ fprintf(stderr, "HS_INSERT %s %s %s %s\n", k.c_str(), v1.c_str(),
+ v2.c_str(), v3.c_str());
+ }
+ if (ret == 0 && !rec.unknown_state) {
+ ++stat.success_count;
+ }
+ rec.unknown_state = false;
+ }
+ cli->response_buf_remove();
+ return ret;
+}
+
+int
+hs_longrun_thread_hs::op_delete(record_value& rec)
+{
+ const std::string k = rec.key;
+ const string_ref op_ref("=", 1);
+ const string_ref op_args[1] = {
+ to_string_ref(k),
+ };
+ const string_ref modop_ref("D", 1);
+ cli->request_buf_exec_generic(0, op_ref, op_args, 1, 1, 0,
+ modop_ref, 0, 0, 0, 0);
+ cli->request_send();
+ if (check_hs_error("op_delete_send", &rec) != 0) { return 1; }
+ size_t numflds = 0;
+ cli->response_recv(numflds);
+ if (check_hs_error("op_delete_recv", &rec) != 0) { return 1; }
+ const string_ref *row = cli->get_next_row();
+ const bool op_success = (numflds > 0 && row != 0 &&
+ to_string(row[0]) == "1");
+ int ret = 0;
+ if (!rec.unknown_state) {
+ if (!rec.deleted && !op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_delete_failure\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ } else if (rec.deleted && op_success) {
+ ++stat.verify_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "VERIFY_ERROR: %s wid=%d k=%s "
+ "unexpected_delete_success\n",
+ arg.worker_type.c_str(), arg.id, k.c_str());
+ }
+ ret = 1;
+ }
+ }
+ cli->response_buf_remove();
+ if (op_success) {
+ rec.deleted = true;
+ if (ret == 0 && !rec.unknown_state) {
+ ++stat.success_count;
+ }
+ rec.unknown_state = false;
+ }
+ if (arg.sh.verbose >= 100 && ret == 0) {
+ fprintf(stderr, "HS_DELETE %s\n", k.c_str());
+ }
+ return ret;
+}
+
+int
+hs_longrun_thread_hs::op_update(record_value& rec)
+{
+ const std::string k = rec.key;
+ const std::string v1 = "uv1_" + k + "_" + to_stdstring(arg.id);
+ const std::string v2 = "uv2_" + k + "_" + to_stdstring(arg.id);
+ const std::string v3 = "uv3_" + k + "_" + to_stdstring(arg.id);
+ const string_ref op_ref("=", 1);
+ const string_ref op_args[1] = {
+ to_string_ref(k),
+ };
+ const string_ref modop_ref("U", 1);
+ const string_ref modop_args[4] = {
+ to_string_ref(k),
+ to_string_ref(v1),
+ to_string_ref(v2),
+ to_string_ref(v3)
+ };
+ cli->request_buf_exec_generic(0, op_ref, op_args, 1, 1, 0,
+ modop_ref, modop_args, 4, 0, 0);
+ cli->request_send();
+ if (check_hs_error("op_update_send", &rec) != 0) { return 1; }
+ size_t numflds = 0;
+ cli->response_recv(numflds);
+ if (check_hs_error("op_update_recv", &rec) != 0) { return 1; }
+ const string_ref *row = cli->get_next_row();
+ uint32_t num_rows = row
+ ? atoi_uint32_nocheck(row[0].begin(), row[0].end()) : 0;
+ cli->response_buf_remove();
+ const bool cur_unknown_state = (num_rows == 1);
+ return verify_update(k, v1, v2, v3, rec, num_rows, cur_unknown_state);
+}
+
+int
+hs_longrun_thread_hs::op_read(record_value& rec)
+{
+ const std::string k = rec.key;
+ const string_ref op_ref("=", 1);
+ const string_ref op_args[1] = {
+ to_string_ref(k),
+ };
+ cli->request_buf_exec_generic(0, op_ref, op_args, 1, 1, 0,
+ string_ref(), 0, 0, 0, 0);
+ cli->request_send();
+ if (check_hs_error("op_read_send", 0) != 0) { return 1; }
+ size_t num_flds = 0;
+ size_t num_rows = 0;
+ cli->response_recv(num_flds);
+ if (check_hs_error("op_read_recv", 0) != 0) { return 1; }
+ const string_ref *row = cli->get_next_row();
+ std::string rrec[4];
+ if (row != 0 && num_flds == 4) {
+ for (int i = 0; i < 4; ++i) {
+ rrec[i] = to_string(row[i]);
+ }
+ ++num_rows;
+ }
+ row = cli->get_next_row();
+ if (row != 0) {
+ ++num_rows;
+ }
+ cli->response_buf_remove();
+ return verify_read(k, num_rows, num_flds, rrec, rec);
+}
+
+int
+hs_longrun_thread_hs::op_readnolock(int key)
+{
+ const std::string k = to_stdstring(key);
+ const string_ref op_ref("=", 1);
+ const string_ref op_args[1] = {
+ to_string_ref(k),
+ };
+ cli->request_buf_exec_generic(0, op_ref, op_args, 1, 1, 0,
+ string_ref(), 0, 0, 0, 0);
+ cli->request_send();
+ if (check_hs_error("op_read_send", 0) != 0) { return 1; }
+ size_t num_flds = 0;
+ size_t num_rows = 0;
+ cli->response_recv(num_flds);
+ if (check_hs_error("op_read_recv", 0) != 0) { return 1; }
+ const string_ref *row = cli->get_next_row();
+ std::string rrec[4];
+ if (row != 0 && num_flds == 4) {
+ for (int i = 0; i < 4; ++i) {
+ rrec[i] = to_string(row[i]);
+ }
+ ++num_rows;
+ }
+ row = cli->get_next_row();
+ if (row != 0) {
+ ++num_rows;
+ }
+ cli->response_buf_remove();
+ return verify_readnolock(k, num_rows, num_flds, rrec);
+}
+
+int
+hs_longrun_thread_hs::check_hs_error(const char *mess, record_value *rec)
+{
+ const int err = cli->get_error_code();
+ if (err == 0) {
+ return 0;
+ }
+ ++stat.runtime_error_count;
+ if (arg.sh.verbose > 0) {
+ const std::string estr = cli->get_error();
+ fprintf(stderr, "RUNTIME_ERROR: op=%c wid=%d %s: %d %s\n",
+ arg.op, arg.id, mess, err, estr.c_str());
+ }
+ if (rec) {
+ rec->unknown_state = true;
+ }
+ return 1;
+}
+
+struct hs_longrun_thread_my : public hs_longrun_thread_base {
+ hs_longrun_thread_my(const arg_type& arg)
+ : hs_longrun_thread_base(arg), connected(false) { }
+ void run();
+ void show_mysql_error(const char *mess, record_value *rec);
+ int op_insert(record_value& rec);
+ int op_delete(record_value& rec);
+ int op_update(record_value& rec);
+ int op_delins(record_value& rec);
+ int op_read(record_value& rec);
+ auto_mysql db;
+ bool connected;
+};
+
+void
+hs_longrun_thread_my::run()
+{
+ const std::string mysql_host = arg.sh.conf.get_str("host", "localhost");
+ const std::string mysql_user = arg.sh.conf.get_str("mysqluser", "root");
+ const std::string mysql_passwd = arg.sh.conf.get_str("mysqlpass", "");
+ const std::string mysql_dbname = "hstestdb";
+
+ while (arg.sh.running) {
+ if (!connected) {
+ if (!mysql_real_connect(db, mysql_host.c_str(), mysql_user.c_str(),
+ mysql_passwd.c_str(), mysql_dbname.c_str(), mysql_port, 0, 0)) {
+ show_mysql_error("mysql_real_connect", 0);
+ continue;
+ }
+ }
+ connected = true;
+ const size_t rec_id = rand_record();
+ record_value& rec = *arg.sh.records[rec_id];
+ lock_guard g(rec.lock);
+ int e = 0;
+ switch (arg.op) {
+ #if 0
+ case 'I':
+ e = op_insert(rec);
+ break;
+ case 'D':
+ e = op_delete(rec);
+ break;
+ case 'U':
+ e = op_update(rec);
+ break;
+ #endif
+ case 'T':
+ e = op_delins(rec);
+ break;
+ case 'R':
+ e = op_read(rec);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+int
+hs_longrun_thread_my::op_delins(record_value& rec)
+{
+ const std::string k = rec.key;
+ const std::string v1 = "div1_" + k + "_" + to_stdstring(arg.id);
+ const std::string v2 = "div2_" + k + "_" + to_stdstring(arg.id);
+ const std::string v3 = "div3_" + k + "_" + to_stdstring(arg.id);
+ int success = 0;
+ bool cur_unknown_state = false;
+ do {
+ char query[1024];
+ #if 1
+ if (mysql_query(db, "begin") != 0) {
+ if (arg.sh.verbose >= 20) {
+ fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), "begin");
+ }
+ break;
+ }
+ #endif
+ cur_unknown_state = true;
+ snprintf(query, 1024,
+ "delete from hstesttbl where k = '%s'", k.c_str());
+ if (mysql_query(db, query) != 0) {
+ if (arg.sh.verbose >= 20) {
+ fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), query);
+ }
+ break;
+ }
+ if (mysql_affected_rows(db) != 1) {
+ if (arg.sh.verbose >= 20) {
+ fprintf(stderr, "mysql: notfound: [%s]\n", query);
+ }
+ break;
+ }
+ snprintf(query, 1024,
+ "insert into hstesttbl values ('%s', '%s', '%s', '%s')",
+ k.c_str(), v1.c_str(), v2.c_str(), v3.c_str());
+ if (mysql_query(db, query) != 0) {
+ if (arg.sh.verbose >= 20) {
+ fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), query);
+ }
+ break;
+ }
+ #if 1
+ if (mysql_query(db, "commit") != 0) {
+ if (arg.sh.verbose >= 20) {
+ fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), "commit");
+ }
+ break;
+ }
+ #endif
+ success = true;
+ cur_unknown_state = false;
+ } while (false);
+ return verify_update(k, v1, v2, v3, rec, (success != 0), cur_unknown_state);
+}
+
+int
+hs_longrun_thread_my::op_read(record_value& rec)
+{
+ const std::string k = rec.key;
+ char query[1024] = { 0 };
+ const int len = snprintf(query, 1024,
+ "select k,v1,v2,v3 from hstesttbl where k='%s'", k.c_str());
+ const int r = mysql_real_query(db, query, len > 0 ? len : 0);
+ if (r != 0) {
+ show_mysql_error(query, 0);
+ return 1;
+ }
+ MYSQL_ROW row = 0;
+ unsigned long *lengths = 0;
+ unsigned int num_rows = 0;
+ unsigned int num_flds = 0;
+ auto_mysql_res res(db);
+ std::string rrec[4];
+ if (res != 0) {
+ num_flds = mysql_num_fields(res);
+ row = mysql_fetch_row(res);
+ if (row != 0) {
+ lengths = mysql_fetch_lengths(res);
+ if (num_flds == 4) {
+ for (int i = 0; i < 4; ++i) {
+ rrec[i] = std::string(row[i], lengths[i]);
+ }
+ }
+ ++num_rows;
+ row = mysql_fetch_row(res);
+ if (row != 0) {
+ ++num_rows;
+ }
+ }
+ }
+ return verify_read(k, num_rows, num_flds, rrec, rec);
+}
+
+void
+hs_longrun_thread_my::show_mysql_error(const char *mess, record_value *rec)
+{
+ ++stat.runtime_error_count;
+ if (arg.sh.verbose > 0) {
+ fprintf(stderr, "RUNTIME_ERROR: op=%c wid=%d [%s]: %s\n",
+ arg.op, arg.id, mess, mysql_error(db));
+ }
+ if (rec) {
+ rec->unknown_state = true;
+ }
+ db.reset();
+ connected = false;
+}
+
+void
+mysql_do(MYSQL *db, const char *query)
+{
+ if (mysql_real_query(db, query, strlen(query)) != 0) {
+ fprintf(stderr, "mysql: e=[%s] q=[%s]\n", mysql_error(db), query);
+ fatal_exit("mysql_do");
+ }
+}
+
+void
+hs_longrun_init_table(const config& conf, int num_prepare,
+ hs_longrun_shared& shared)
+{
+ const std::string mysql_host = conf.get_str("host", "localhost");
+ const std::string mysql_user = conf.get_str("mysqluser", "root");
+ const std::string mysql_passwd = conf.get_str("mysqlpass", "");
+ const std::string mysql_dbname = "";
+ auto_mysql db;
+ if (!mysql_real_connect(db, mysql_host.c_str(), mysql_user.c_str(),
+ mysql_passwd.c_str(), mysql_dbname.c_str(), mysql_port, 0, 0)) {
+ fprintf(stderr, "mysql: error=[%s]\n", mysql_error(db));
+ fatal_exit("hs_longrun_init_table");
+ }
+ mysql_do(db, "drop database if exists hstestdb");
+ mysql_do(db, "create database hstestdb");
+ mysql_do(db, "use hstestdb");
+ mysql_do(db,
+ "create table hstesttbl ("
+ "k int primary key,"
+ "v1 varchar(32) not null,"
+ "v2 varchar(32) not null,"
+ "v3 varchar(32) not null"
+ ") character set utf8 collate utf8_bin engine = innodb");
+ for (int i = 0; i < num_prepare; ++i) {
+ const std::string i_str = to_stdstring(i);
+ const std::string v1 = "pv1_" + i_str;
+ const std::string v2 = "pv2_" + i_str;
+ const std::string v3 = "pv3_" + i_str;
+ char buf[1024];
+ snprintf(buf, 1024, "insert into hstesttbl(k, v1, v2, v3) values"
+ "(%d, '%s', '%s', '%s')", i, v1.c_str(), v2.c_str(), v3.c_str());
+ mysql_do(db, buf);
+ record_value *rec = shared.records[i];
+ rec->key = i_str;
+ rec->values.resize(4);
+ rec->values[0] = i_str;
+ rec->values[1] = v1;
+ rec->values[2] = v2;
+ rec->values[3] = v3;
+ rec->deleted = false;
+ }
+}
+
+int
+hs_longrun_main(int argc, char **argv)
+{
+ hs_longrun_shared shared;
+ parse_args(argc, argv, shared.conf);
+ shared.conf["host"] = shared.conf.get_str("host", "localhost");
+ shared.verbose = shared.conf.get_int("verbose", 1);
+ const int table_size = shared.conf.get_int("table_size", 10000);
+ for (int i = 0; i < table_size; ++i) {
+ std::auto_ptr<record_value> rec(new record_value());
+ rec->key = to_stdstring(i);
+ shared.records.push_back_ptr(rec);
+ }
+ mysql_library_init(0, 0, 0);
+ const int duration = shared.conf.get_int("duration", 10);
+ const int num_hsinsert = shared.conf.get_int("num_hsinsert", 10);
+ const int num_hsdelete = shared.conf.get_int("num_hsdelete", 10);
+ const int num_hsupdate = shared.conf.get_int("num_hsupdate", 10);
+ const int num_hsread = shared.conf.get_int("num_hsread", 10);
+ const int num_myread = shared.conf.get_int("num_myread", 10);
+ const int num_mydelins = shared.conf.get_int("num_mydelins", 10);
+ int num_hsreadnolock = shared.conf.get_int("num_hsreadnolock", 10);
+ const bool always_filled = (num_hsinsert == 0 && num_hsdelete == 0);
+ if (!always_filled) {
+ num_hsreadnolock = 0;
+ }
+ hs_longrun_init_table(shared.conf, always_filled ? table_size : 0,
+ shared);
+ /* create worker threads */
+ static const struct thrtmpl_type {
+ const char *type; char op; int num; int hs; int lock;
+ } thrtmpl[] = {
+ { "hsinsert", 'I', num_hsinsert, 1, 1 },
+ { "hsdelete", 'D', num_hsdelete, 1, 1 },
+ { "hsupdate", 'U', num_hsupdate, 1, 1 },
+ { "hsread", 'R', num_hsread, 1, 1 },
+ { "hsreadnolock", 'N', num_hsreadnolock, 1, 0 },
+ { "myread", 'R', num_myread, 0, 1 },
+ { "mydelins", 'T', num_mydelins, 0, 1 },
+ };
+ typedef auto_ptrcontainer< std::vector<hs_longrun_thread_base *> > thrs_type;
+ thrs_type thrs;
+ for (size_t i = 0; i < sizeof(thrtmpl)/sizeof(thrtmpl[0]); ++i) {
+ const thrtmpl_type& e = thrtmpl[i];
+ for (int j = 0; j < e.num; ++j) {
+ int id = thrs.size();
+ const hs_longrun_thread_hs::arg_type arg(id, e.type, e.op, e.lock,
+ shared);
+ std::auto_ptr<hs_longrun_thread_base> thr;
+ if (e.hs) {
+ thr.reset(new hs_longrun_thread_hs(arg));
+ } else {
+ thr.reset(new hs_longrun_thread_my(arg));
+ }
+ thrs.push_back_ptr(thr);
+ }
+ }
+ shared.num_threads = thrs.size();
+ /* start threads */
+ fprintf(stderr, "START\n");
+ shared.running = 1;
+ for (size_t i = 0; i < thrs.size(); ++i) {
+ thrs[i]->start();
+ }
+ /* wait */
+ sleep(duration);
+ /* stop thread */
+ shared.running = 0;
+ for (size_t i = 0; i < thrs.size(); ++i) {
+ thrs[i]->join();
+ }
+ fprintf(stderr, "DONE\n");
+ /* summary */
+ typedef std::map<std::string, hs_longrun_stat> stat_map;
+ stat_map sm;
+ for (size_t i = 0; i < thrs.size(); ++i) {
+ hs_longrun_thread_base *const thr = thrs[i];
+ const std::string wt = thr->arg.worker_type;
+ hs_longrun_stat& v = sm[wt];
+ v.add(thr->stat);
+ }
+ hs_longrun_stat total;
+ for (stat_map::const_iterator i = sm.begin(); i != sm.end(); ++i) {
+ if (i->second.verify_error_count != 0) {
+ fprintf(stderr, "%s verify_error %llu\n", i->first.c_str(),
+ i->second.verify_error_count);
+ }
+ if (i->second.runtime_error_count) {
+ fprintf(stderr, "%s runtime_error %llu\n", i->first.c_str(),
+ i->second.runtime_error_count);
+ }
+ if (i->second.unknown_count) {
+ fprintf(stderr, "%s unknown %llu\n", i->first.c_str(),
+ i->second.unknown_count);
+ }
+ fprintf(stderr, "%s success %llu\n", i->first.c_str(),
+ i->second.success_count);
+ total.add(i->second);
+ }
+ if (total.verify_error_count != 0) {
+ fprintf(stderr, "TOTAL verify_error %llu\n", total.verify_error_count);
+ }
+ if (total.runtime_error_count != 0) {
+ fprintf(stderr, "TOTAL runtime_error %llu\n", total.runtime_error_count);
+ }
+ if (total.unknown_count != 0) {
+ fprintf(stderr, "TOTAL unknown %llu\n", total.unknown_count);
+ }
+ fprintf(stderr, "TOTAL success %llu\n", total.success_count);
+ mysql_library_end();
+ return 0;
+}
+
+};
+
+int
+main(int argc, char **argv)
+{
+ return dena::hs_longrun_main(argc, argv);
+}
+
diff --git a/plugin/handler_socket/client/hstest.cpp b/plugin/handler_socket/client/hstest.cpp
index c766488cbdf..b5551fed81c 100644
--- a/plugin/handler_socket/client/hstest.cpp
+++ b/plugin/handler_socket/client/hstest.cpp
@@ -92,7 +92,7 @@ namespace {
double
gettimeofday_double()
{
- struct timeval tv = { };
+ struct timeval tv;
if (gettimeofday(&tv, 0) != 0) {
fatal_abort("gettimeofday");
}
@@ -552,7 +552,8 @@ hstest_thread::test_9(int test_num)
"moreflds_prefix", "column0123456789_");
const int use_handler = arg.sh.conf.get_int("handler", 0);
const int sched_flag = arg.sh.conf.get_int("sched", 0);
- const int ssps = arg.sh.conf.get_int("ssps", 0);
+ const int use_in = arg.sh.conf.get_int("in", 0);
+ const int ssps = use_in ? 0 : arg.sh.conf.get_int("ssps", 0);
std::string flds = "v";
for (int i = 0; i < moreflds; ++i) {
char buf[1024];
@@ -561,6 +562,7 @@ hstest_thread::test_9(int test_num)
}
int connected = 0;
std::auto_ptr<auto_mysql_stmt> stmt;
+ string_buffer wbuf;
for (int i = 0; i < num; ++i) {
const double tm1 = gettimeofday_double();
const int flags = 0;
@@ -623,6 +625,20 @@ hstest_thread::test_9(int test_num)
// TODO: moreflds
} else if (ssps) {
//
+ } else if (use_in) {
+ wbuf.clear();
+ char *p = wbuf.make_space(1024);
+ int len = snprintf(p, 1024, "select %s from hstest_table1 where k in ('%d'", flds.c_str(), k);
+ wbuf.space_wrote(len);
+ for (int j = 1; j < use_in; ++j) {
+ /* generate more key */
+ drand48_r(&randbuf, &kf);
+ k = int(kf * tablesize);
+ p = wbuf.make_space(1024);
+ int len = snprintf(p, 1024, ", '%d'", k);
+ wbuf.space_wrote(len);
+ }
+ wbuf.append_literal(")");
} else {
buf_query_len = snprintf(buf_query, sizeof(buf_query),
"select %s from hstest_table1 where k = '%d'", flds.c_str(), k);
@@ -651,6 +667,8 @@ hstest_thread::test_9(int test_num)
}
r = mysql_stmt_execute(*stmt);
// fprintf(stderr, "stmt exec\n");
+ } else if (use_in) {
+ r = mysql_real_query(db, wbuf.begin(), wbuf.size());
} else {
r = mysql_real_query(db, buf_query, buf_query_len);
// fprintf(stderr, "real query\n");
@@ -694,7 +712,7 @@ hstest_thread::test_9(int test_num)
num_flds = mysql_num_fields(res);
MYSQL_ROW row = 0;
while ((row = mysql_fetch_row(res)) != 0) {
- got_data = 1;
+ got_data += 1;
unsigned long *const lengths = mysql_fetch_lengths(res);
if (verbose >= 2) {
for (unsigned int i = 0; i < num_flds; ++i) {
@@ -706,7 +724,10 @@ hstest_thread::test_9(int test_num)
}
}
} else {
- got_data = 1;
+ MYSQL_ROW row = 0;
+ while ((row = mysql_fetch_row(res)) != 0) {
+ got_data += 1;
+ }
}
} else {
if (mysql_field_count(db) == 0) {
@@ -730,7 +751,7 @@ hstest_thread::test_9(int test_num)
if (err == 0) {
++io_success_count;
if (num_affected_rows > 0 || got_data > 0) {
- ++op_success_count;
+ op_success_count += got_data;
} else {
if (verbose >= 1) {
fprintf(stderr, "k=%d numaff=%u gotdata=%d\n",
@@ -779,6 +800,7 @@ hstest_thread::test_10(int test_num)
const std::string table = arg.sh.conf.get_str("table", "hstest_table1");
const std::string index = arg.sh.conf.get_str("index", "PRIMARY");
const std::string field = arg.sh.conf.get_str("field", "v");
+ const int use_in = arg.sh.conf.get_int("in", 0);
const std::string moreflds_prefix = arg.sh.conf.get_str(
"moreflds_prefix", "column0123456789_");
const int dump = arg.sh.dump;
@@ -789,8 +811,8 @@ hstest_thread::test_10(int test_num)
snprintf(sbuf, sizeof(sbuf), ",%s%d", moreflds_prefix.c_str(), i);
moreflds_str += std::string(sbuf);
}
- char wbuf[16384], rbuf[16384];
- int wbuflen = 0;
+ string_buffer wbuf;
+ char rbuf[16384];
for (size_t i = 0; i < arg.sh.loop; ++i) {
int len = 0, rlen = 0, wlen = 0;
#if 0
@@ -801,15 +823,18 @@ hstest_thread::test_10(int test_num)
fprintf(stderr, "connect: %d %s\n", errno, strerror(errno));
return;
}
- len = snprintf(wbuf, sizeof(wbuf),
+ char *wp = wbuf.make_space(1024);
+ len = snprintf(wp, 1024,
"P\t1\t%s\t%s\tPRIMARY\t%s%s\n", dbname.c_str(), table.c_str(),
field.c_str(), moreflds_str.c_str());
/* pst_num, db, table, index, retflds */
- wlen = write(fd.get(), wbuf, len);
+ wbuf.space_wrote(len);
+ wlen = write(fd.get(), wbuf.begin(), len);
if (len != wlen) {
fprintf(stderr, "write: %d %d\n", len, wlen);
return;
}
+ wbuf.clear();
rlen = read(fd.get(), rbuf, sizeof(rbuf));
if (rlen <= 0 || rbuf[rlen - 1] != '\n') {
fprintf(stderr, "read: rlen=%d errno=%d\n", rlen, errno);
@@ -824,7 +849,6 @@ hstest_thread::test_10(int test_num)
const double tm1 = gettimeofday_double();
for (size_t j = 0; j < arg.sh.pipe; ++j) {
int k = 0, v = 0;
- wbuflen = 0;
{
while (true) {
double kf = 0, vf = 0;
@@ -832,19 +856,6 @@ hstest_thread::test_10(int test_num)
drand48_r(&randbuf, &vf);
k = int(kf * tablesize) + firstkey;
v = int(vf * tablesize) + firstkey;
- // k = rand_r(&seed);
- // v = rand_r(&seed); /* unused */
- #if 0
- if (tablesize != 0) {
- k &= tablesize;
- }
- #endif
- if (op == 'G') {
- wbuflen = snprintf(wbuf, sizeof(wbuf), "1\t=\t1\t%d\n", k);
- } else if (op == 'U') {
- wbuflen = snprintf(wbuf, sizeof(wbuf),
- "1\t=\t1\t%d\t1\t0\tU\t%d_%d%s\n", k, v, k, suffix.c_str());
- }
if (k - firstkey < arg.sh.keygen_size) {
volatile char *const ptr = arg.sh.keygen + (k - firstkey);
// int oldv = __sync_fetch_and_or(ptr, 1);
@@ -864,15 +875,42 @@ hstest_thread::test_10(int test_num)
continue;
}
}
+ size_t len = 0;
+ if (op == 'G') {
+ if (use_in) {
+ char *wp = wbuf.make_space(1024);
+ len = snprintf(wp, 1024, "1\t=\t1\t\t%d\t0\t@\t0\t%d\t%d",
+ use_in, use_in, k);
+ wbuf.space_wrote(len);
+ for (int j = 1; j < use_in; ++j) {
+ drand48_r(&randbuf, &kf);
+ k = int(kf * tablesize) + firstkey;
+ char *wp = wbuf.make_space(1024);
+ len = snprintf(wp, 1024, "\t%d", k);
+ wbuf.space_wrote(len);
+ }
+ wbuf.append_literal("\n");
+ } else {
+ char *wp = wbuf.make_space(1024);
+ len = snprintf(wp, 1024, "1\t=\t1\t%d\n", k);
+ wbuf.space_wrote(len);
+ }
+ } else if (op == 'U') {
+ char *wp = wbuf.make_space(1024);
+ len = snprintf(wp, 1024,
+ "1\t=\t1\t%d\t1\t0\tU\t%d_%d%s\n", k, v, k, suffix.c_str());
+ wbuf.space_wrote(len);
+ }
break;
}
}
- wlen = write(fd.get(), wbuf, wbuflen);
- if (wlen != wbuflen) {
- fprintf(stderr, "write: %d %d\n", wbuflen, wlen);
- return;
- }
}
+ wlen = write(fd.get(), wbuf.begin(), wbuf.size());
+ if ((size_t) wlen != wbuf.size()) {
+ fprintf(stderr, "write: %d %d\n", (int)wbuf.size(), wlen);
+ return;
+ }
+ wbuf.clear();
size_t read_cnt = 0;
size_t read_pos = 0;
while (read_cnt < arg.sh.pipe) {
@@ -922,7 +960,7 @@ hstest_thread::test_10(int test_num)
++op_success_count;
arg.sh.increment_count();
if (arg.sh.dump && arg.sh.pipe == 1) {
- fwrite(wbuf, wbuflen, 1, stderr);
+ fwrite(wbuf.begin(), wbuf.size(), 1, stderr);
}
}
}
diff --git a/plugin/handler_socket/configure.ac b/plugin/handler_socket/configure.ac
index 36e85d24cab..4395fcf1994 100644
--- a/plugin/handler_socket/configure.ac
+++ b/plugin/handler_socket/configure.ac
@@ -13,6 +13,12 @@ AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LIBTOOL
+ac_mysql_debug=
+AC_ARG_ENABLE(mysql-debug,
+ [AS_HELP_STRING([--enable-mysql-debug], [specify whether MySQL is build with DBUG_ON])],[ac_mysql_debug="$enableval"],[ac_mysql_debug=no])
+AC_MSG_CHECKING([if --enable-mysql-debug is specified])
+AC_MSG_RESULT($ac_mysql_debug)
+
AC_DEFUN([CONFIG_OPTION_MYSQL],[
AC_MSG_CHECKING([mysql source])
@@ -66,8 +72,12 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
fi
MYSQL_CFLAGS_ADD=`"$ac_mysql_config" --cflags`
- MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD -DFORCE_DBUG_OFF"
- # FIXME
+ MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD"
+ if test "$ac_mysql_debug" = "yes"; then
+ MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_ON -DENABLED_DEBUG_SYNC"
+ else
+ MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_OFF"
+ fi
AC_SUBST(MYSQL_CFLAGS)
MYSQL_BIN_VERSION=`"$ac_mysql_config" --version`
diff --git a/plugin/handler_socket/docs-en/configuration-options.en.txt b/plugin/handler_socket/docs-en/configuration-options.en.txt
index f0c0be32f07..60fb6d85f3c 100644
--- a/plugin/handler_socket/docs-en/configuration-options.en.txt
+++ b/plugin/handler_socket/docs-en/configuration-options.en.txt
@@ -80,8 +80,20 @@ handlersocket_accept_balance (default = 0, min = 0, max = 10000)
handlersocket_wrlock_timeout (default = 12, min = 0, max = 3600)
Specify the lock timeout in seconds. When a write request is
- performed, handlersocket locks an advisory lock named
+ performed, handlersocket acquires an advisory lock named
'handlersocket_wr'. This option sets the timeout for the
locking.
+-----------------------------------------------------------------
+handlersocket_plain_secret (default = '')
+
+ When this option is specified, a plain-text authentication is
+ enabled for the listener for read requests. This option
+ specifies the secret key for the authentication.
+
+-----------------------------------------------------------------
+handlersocket_plain_secret_wr (default = '')
+
+ This option specifies the secret key for the listener for write
+ requests.
diff --git a/plugin/handler_socket/docs-en/protocol.en.txt b/plugin/handler_socket/docs-en/protocol.en.txt
index ee00ab352d8..afde231df7d 100644
--- a/plugin/handler_socket/docs-en/protocol.en.txt
+++ b/plugin/handler_socket/docs-en/protocol.en.txt
@@ -11,7 +11,7 @@ Basic syntax
distinguish NULL from an empty string, as most DBMs does so.
- NULL is expressed as a single NUL(0x00).
- An encoded string is a string with the following encoding rules.
- - Characters in the range [0x10 - 0xff] are not encoded.
+ - Characters in the range [0x10 - 0xff] are encoded as itselves.
- A character in the range [0x00 - 0x0f] is prefixed by 0x01 and
shifted by 0x40. For example, 0x03 is encoded as 0x01 0x43.
- Note that a string can be empty. A continuation of 0x09 0x09 means that
@@ -33,12 +33,14 @@ Request and Response
The 'open_index' request has the following syntax.
- P <indexid> <dbname> <tablename> <indexname> <columns>
+ P <indexid> <dbname> <tablename> <indexname> <columns> [<fcolumns>]
- <indexid> is a number in decimal.
- <dbname>, <tablename>, and <indexname> are strings. To open the primary
key, use PRIMARY as <indexname>.
- <columns> is a comma-separated list of column names.
+- <fcolumns> is a comma-separated list of column names. This parameter is
+ optional.
Once an 'open_index' request is issued, the HandlerSocket plugin opens the
specified index and keep it open until the client connection is closed. Each
@@ -51,8 +53,20 @@ For efficiency, keep <indexid> small as far as possible.
Getting data
The 'find' request has the following syntax.
+
+ <indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...]
- <indexid> <op> <vlen> <v1> ... <vn> <limit> <offset>
+LIM is a sequence of the following parameters.
+
+ <limit> <offset>
+
+IN is a sequence of the following parameters.
+
+ @ <icol> <ivlen> <iv1> ... <ivn>
+
+FILETER is a sequence of the following parameters.
+
+ <ftyp> <fop> <fcol> <fval>
- <indexid> is a number. This number must be an <indexid> specified by a
'open_index' request executed previously on the same connection.
@@ -60,30 +74,53 @@ The 'find' request has the following syntax.
HandlerSocket supports '=', '>', '>=', '<', and '<='.
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
must be smaller than or equal to the number of index columns specified by
- specified by the corresponding 'open_index' request.
+ the <columns> parameter of the corresponding 'open_index' request.
- <v1> ... <vn> specify the index column values to fetch.
-- <limit> and <offset> are numbers. These parameters can be omitted. When
- omitted, it works as if 1 and 0 are specified.
+- LIM is optional. <limit> and <offset> are numbers. When omitted, it works
+ as if 1 and 0 are specified. These parameter works like LIMIT of SQL.
+ These values don't include the number of records skipped by a filter.
+- IN is optional. It works like WHERE ... IN syntax of SQL. <icol> must be
+ smaller than or equal to the number of index columns specified by the
+ <columns> parameter of the corresponding 'open_index' request. If IN is
+ specified in a find request, the <icol>-th parameter value of <v1> ...
+ <vn> is ignored.
+ smaller than or equal to the number of index columns specified by the
+- FILTERs are optional. A FILTER specifies a filter. <ftyp> is either 'F'
+ (filter) or 'W' (while). <fop> specifies the comparison operation to use.
+ <fcol> must be smaller than or equal to the number of columns specified by
+ the <fcolumns> parameter of the corresponding 'open_index' request.
+ Multiple filters can be specified, and work as the logical AND of them.
+ The difference of 'F' and 'W' is that, when a record does not meet the
+ specified condition, 'F' simply skips the record, and 'W' stops the loop.
----------------------------------------------------------------------------
Updating/Deleting data
The 'find_modify' request has the following syntax.
- <indexid> <op> <vlen> <v1> ... <vn> <limit> <offset> <mop> <m1> ... <mk>
+ <indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...] MOD
+
+MOD is a sequence of the following parameters.
+
+ <mop> <m1> ... <mk>
-- <mop> is either 'U' (update) or 'D' (delete).
+- <mop> is 'U' (update), '+' (increment), '-' (decrement), 'D' (delete),
+ 'U?', '+?', '-?', or 'D?'. If the '?' suffix is specified, it returns
+ the contents of the records before modification (as if it's a 'find'
+ request), instead of the number of modified records.
- <m1> ... <mk> specifies the column values to set. The length of <m1> ...
<mk> must be smaller than or equal to the length of <columns> specified by
the corresponding 'open_index' request. If <mop> is 'D', these parameters
- are ignored.
+ are ignored. If <mop> is '+' or '-', values must be numeric. If <mop> is
+ '-' and it attempts to change column values from negative to positive or
+ positive to negative, it is not modified.
----------------------------------------------------------------------------
Inserting data
The 'insert' request has the following syntax.
- <indexid> '+' <vlen> <v1> ... <vn>
+ <indexid> + <vlen> <v1> ... <vn>
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
must be smaller than or equal to the length of <columns> specified by the
@@ -92,6 +129,19 @@ The 'insert' request has the following syntax.
<columns>, the default values for each column are set.
----------------------------------------------------------------------------
+Authentication
+
+The 'auth' request has the following syntax.
+
+ A <atyp> <akey>
+
+- <atyp> must be '1'
+- An 'auth' request succeeds iff <akey> is the correct secret specified by
+ the 'handlersocket_plain_secret' or 'handlersocket_plain_secret_rw'.
+- If an authentication is enabled for a listener, any other requests on a
+ connection fail before an 'auth' request succeeded on the connection.
+
+----------------------------------------------------------------------------
Response syntax
HandlerSocket returns a response of the following syntax for each request.
diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp
index e4616b382ab..f63f011d9b1 100644
--- a/plugin/handler_socket/handlersocket/database.cpp
+++ b/plugin/handler_socket/handlersocket/database.cpp
@@ -23,6 +23,7 @@
#define DBG_FLD(x)
#define DBG_FILTER(x)
#define DBG_REFCNT(x)
+#define DBG_KEYLEN(x)
#define DBG_DELETED
/* status variables */
@@ -140,10 +141,8 @@ struct dbcontext : public dbcontext_i, private noncopyable {
virtual void close_tables_if();
virtual void table_addref(size_t tbl_id);
virtual void table_release(size_t tbl_id);
- virtual void cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
- const char *tbl, const char *idx, const char *retflds,
- const char *filflds);
- virtual void cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args);
+ virtual void cmd_open(dbcallback_i& cb, const cmd_open_args& args);
+ virtual void cmd_exec(dbcallback_i& cb, const cmd_exec_args& args);
virtual void set_statistics(size_t num_conns, size_t num_active);
private:
int set_thread_message(const char *fmt, ...)
@@ -184,11 +183,6 @@ struct dbcontext : public dbcontext_i, private noncopyable {
std::vector<char> info_message_buf;
table_vec_type table_vec;
table_map_type table_map;
- #if MYSQL_VERSION_ID >= 50505
- MDL_request *mdl_request;
- #else
- void *mdl_request;
- #endif
};
database::database(const config& c)
@@ -227,7 +221,7 @@ database_i::create(const config& conf)
dbcontext::dbcontext(volatile database *d, bool for_write)
: dbref(d), for_write_flag(for_write), thd(0), lock(0), lock_failed(false),
user_level_lock_timeout(0), user_level_lock_locked(false),
- commit_error(false), mdl_request(0)
+ commit_error(false)
{
info_message_buf.resize(8192);
user_level_lock_timeout = d->get_conf().get_int("wrlock_timeout", 12);
@@ -274,6 +268,8 @@ wait_server_to_start(THD *thd, volatile int& shutdown_flag)
}; // namespace
+#define DENA_THR_OFFSETOF(fld) ((char *)(&thd->fld) - (char *)thd)
+
void
dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
{
@@ -282,9 +278,17 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
my_thread_init();
thd = new THD;
thd->thread_stack = (char *)stack_bottom;
- DBG_THR(const size_t of = (char *)(&thd->thread_stack) - (char *)thd);
- DBG_THR(fprintf(stderr, "thread_stack = %p sz=%zu of=%zu\n",
- thd->thread_stack, sizeof(THD), of));
+ DBG_THR(fprintf(stderr,
+ "thread_stack = %p sizeof(THD)=%zu sizeof(mtx)=%zu "
+ "O: %zu %zu %zu %zu %zu %zu %zu\n",
+ thd->thread_stack, sizeof(THD), sizeof(LOCK_thread_count),
+ DENA_THR_OFFSETOF(mdl_context),
+ DENA_THR_OFFSETOF(net),
+ DENA_THR_OFFSETOF(LOCK_thd_data),
+ DENA_THR_OFFSETOF(mysys_var),
+ DENA_THR_OFFSETOF(stmt_arena),
+ DENA_THR_OFFSETOF(limit_found_rows),
+ DENA_THR_OFFSETOF(locked_tables_list)));
thd->store_globals();
thd->system_thread = static_cast<enum_thread_type>(1<<30UL);
memset(&thd->net, 0, sizeof(thd->net));
@@ -317,15 +321,6 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
set_thread_message("hs:listening");
DBG_THR(fprintf(stderr, "HNDSOCK x1 %p\n", thd));
- #if MYSQL_VERSION_ID >= 50508
- mdl_request = new(thd->mem_root) MDL_request;
- mdl_request->init(MDL_key::TABLE, "", "",
- for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_STATEMENT);
- #elif MYSQL_VERSION_ID >= 50505
- mdl_request = MDL_request::create(MDL_key::TABLE, "", "",
- for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, thd->mem_root);
- #endif
-
lex_start(thd);
user_lock.reset(new expr_user_lock(thd, user_level_lock_timeout));
@@ -389,7 +384,7 @@ dbcontext::lock_tables_if()
}
if (lock == 0) {
const size_t num_max = table_vec.size();
- TABLE *tables[num_max ? num_max : 1]; /* GNU */
+ TABLE **const tables = DENA_ALLOCA_ALLOCATE(TABLE *, num_max + 1);
size_t num_open = 0;
for (size_t i = 0; i < num_max; ++i) {
if (table_vec[i].refcount > 0) {
@@ -420,6 +415,7 @@ dbcontext::lock_tables_if()
thd->current_stmt_binlog_row_based = 1;
#endif
}
+ DENA_ALLOCA_FREE(tables);
}
DBG_LOCK(fprintf(stderr, "HNDSOCK tblnum=%d\n", (int)tblnum));
}
@@ -428,14 +424,17 @@ void
dbcontext::unlock_tables_if()
{
if (lock != 0) {
- DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK unlock tables\n"));
+ DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK unlock tables %p %p\n",
+ thd, thd->lock));
if (for_write_flag) {
for (size_t i = 0; i < table_vec.size(); ++i) {
if (table_vec[i].modified) {
- query_cache_invalidate3(thd, table_vec[i].table, 0);
- /* invalidate immediately */
+ query_cache_invalidate3(thd, table_vec[i].table, 1);
+ table_vec[i].table->file->ha_release_auto_increment();
}
}
+ }
+ {
bool suc = true;
#if MYSQL_VERSION_ID >= 50505
suc = (trans_commit_stmt(thd) == 0);
@@ -476,9 +475,12 @@ void
dbcontext::close_tables_if()
{
unlock_tables_if();
+ DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK close tables\n"));
+ close_thread_tables(thd);
+ #if MYSQL_VERSION_ID >= 50505
+ thd->mdl_context.release_transactional_locks();
+ #endif
if (!table_vec.empty()) {
- DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK close tables\n"));
- close_thread_tables(thd);
statistic_increment(close_tables_count, &LOCK_status);
table_vec.clear();
table_map.clear();
@@ -544,7 +546,6 @@ dbcontext::dump_record(dbcallback_i& cb, TABLE *const table,
Field *const fld = table->field[fn];
if (fld->is_null()) {
/* null */
- cb.dbcb_resp_entry(0, 0);
fprintf(stderr, "NULL");
} else {
fld->val_str(&rwpstr, &rwpstr);
@@ -621,9 +622,6 @@ dbcontext::modify_record(dbcallback_i& cb, TABLE *const table,
if ((pval < 0 && nval > 0) || (pval > 0 && nval < 0)) {
break; /* don't modify */
}
- if ((pval < 0) != (nval < 0)) {
- nval = 0; /* crip */
- }
}
fld->store(nval, false);
}
@@ -649,7 +647,7 @@ dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst,
}
lock_tables_if();
if (lock == 0) {
- return cb.dbcb_resp_short(2, "lock_tables");
+ return cb.dbcb_resp_short(1, "lock_tables");
}
if (pst.get_table_id() >= table_vec.size()) {
return cb.dbcb_resp_short(2, "tblnum");
@@ -659,20 +657,30 @@ dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst,
uchar *const buf = table->record[0];
empty_record(table);
memset(buf, 0, table->s->null_bytes); /* clear null flags */
- Field **fld = table->field;
- size_t i = 0;
- for (; *fld && i < fvalslen; ++fld, ++i) {
+ const prep_stmt::fields_type& rf = pst.get_ret_fields();
+ const size_t n = rf.size();
+ for (size_t i = 0; i < n; ++i) {
+ uint32_t fn = rf[i];
+ Field *const fld = table->field[fn];
if (fvals[i].begin() == 0) {
- (*fld)->set_null();
+ fld->set_null();
} else {
- (*fld)->store(fvals[i].begin(), fvals[i].size(), &my_charset_bin);
+ fld->store(fvals[i].begin(), fvals[i].size(), &my_charset_bin);
}
}
table->next_number_field = table->found_next_number_field;
+ /* FIXME: test */
const int r = hnd->ha_write_row(buf);
+ const ulonglong insert_id = table->file->insert_id_for_cur_row;
table->next_number_field = 0;
table_vec[pst.get_table_id()].modified = true;
- return cb.dbcb_resp_short(r != 0 ? 1 : 0, "");
+ if (r == 0 && table->found_next_number_field != 0) {
+ return cb.dbcb_resp_short_num64(0, insert_id);
+ }
+ if (r != 0) {
+ return cb.dbcb_resp_short_num(1, r);
+ }
+ return cb.dbcb_resp_short(0, "");
}
void
@@ -685,6 +693,35 @@ dbcontext::cmd_sql_internal(dbcallback_i& cb, const prep_stmt& pst,
return cb.dbcb_resp_short(2, "notimpl");
}
+static size_t
+prepare_keybuf(const cmd_exec_args& args, uchar *key_buf, TABLE *table,
+ KEY& kinfo, size_t invalues_index)
+{
+ size_t kplen_sum = 0;
+ DBG_KEY(fprintf(stderr, "SLOW\n"));
+ for (size_t i = 0; i < args.kvalslen; ++i) {
+ const KEY_PART_INFO & kpt = kinfo.key_part[i];
+ string_ref kval = args.kvals[i];
+ if (args.invalues_keypart >= 0 &&
+ static_cast<size_t>(args.invalues_keypart) == i) {
+ kval = args.invalues[invalues_index];
+ }
+ if (kval.begin() == 0) {
+ kpt.field->set_null();
+ } else {
+ kpt.field->set_notnull();
+ }
+ kpt.field->store(kval.begin(), kval.size(), &my_charset_bin);
+ kplen_sum += kpt.store_length;
+ DBG_KEYLEN(fprintf(stderr, "l=%u sl=%zu\n", kpt.length,
+ kpt.store_length));
+ }
+ key_copy(key_buf, table->record[0], &kinfo, kplen_sum);
+ DBG_KEYLEN(fprintf(stderr, "sum=%zu flen=%u\n", kplen_sum,
+ kinfo.key_length));
+ return kplen_sum;
+}
+
void
dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
ha_rkey_function find_flag, const cmd_exec_args& args)
@@ -714,7 +751,7 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
}
lock_tables_if();
if (lock == 0) {
- return cb.dbcb_resp_short(2, "lock_tables");
+ return cb.dbcb_resp_short(1, "lock_tables");
}
if (pst.get_table_id() >= table_vec.size()) {
return cb.dbcb_resp_short(2, "tblnum");
@@ -728,30 +765,15 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
if (args.kvalslen > kinfo.key_parts) {
return cb.dbcb_resp_short(2, "kpnum");
}
- uchar key_buf[kinfo.key_length]; /* GNU */
- size_t kplen_sum = 0;
- {
- DBG_KEY(fprintf(stderr, "SLOW\n"));
- for (size_t i = 0; i < args.kvalslen; ++i) {
- const KEY_PART_INFO & kpt = kinfo.key_part[i];
- const string_ref& kval = args.kvals[i];
- if (kval.begin() == 0) {
- kpt.field->set_null();
- } else {
- kpt.field->set_notnull();
- }
- kpt.field->store(kval.begin(), kval.size(), &my_charset_bin);
- kplen_sum += kpt.length;
- }
- key_copy(key_buf, table->record[0], &kinfo, kplen_sum);
- }
+ uchar *const key_buf = DENA_ALLOCA_ALLOCATE(uchar, kinfo.key_length);
+ size_t invalues_idx = 0;
+ size_t kplen_sum = prepare_keybuf(args, key_buf, table, kinfo, invalues_idx);
/* filters */
uchar *filter_buf = 0;
if (args.filters != 0) {
const size_t filter_buf_len = calc_filter_buf_size(table, pst,
args.filters);
- filter_buf = reinterpret_cast<uchar *>(alloca(filter_buf_len));
- /* FIXME: TEST */
+ filter_buf = DENA_ALLOCA_ALLOCATE(uchar, filter_buf_len);
if (!fill_filter_buf(table, pst, args.filters, filter_buf,
filter_buf_len)) {
return cb.dbcb_resp_short(2, "filterblob");
@@ -765,9 +787,6 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
}
hnd->ha_index_or_rnd_end();
hnd->ha_index_init(pst.get_idxnum(), 1);
- #if 0
- statistic_increment(index_exec_count, &LOCK_status);
- #endif
if (need_resp_record) {
cb.dbcb_resp_begin(pst.get_ret_fields().size());
}
@@ -775,8 +794,17 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
uint32_t skip = args.skip;
size_t modified_count = 0;
int r = 0;
- for (uint32_t i = 0; i < limit + skip; ++i) {
- if (i == 0) {
+ bool is_first = true;
+ for (uint32_t cnt = 0; cnt < limit + skip;) {
+ if (is_first) {
+ is_first = false;
+ const key_part_map kpm = (1U << args.kvalslen) - 1;
+ r = hnd->ha_index_read_map(table->record[0], key_buf, kpm, find_flag);
+ } else if (args.invalues_keypart >= 0) {
+ if (++invalues_idx >= args.invalueslen) {
+ break;
+ }
+ kplen_sum = prepare_keybuf(args, key_buf, table, kinfo, invalues_idx);
const key_part_map kpm = (1U << args.kvalslen) - 1;
r = hnd->ha_index_read_map(table->record[0], key_buf, kpm, find_flag);
} else {
@@ -814,12 +842,17 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
} else if (skip > 0) {
--skip;
} else {
+ /* hit */
if (need_resp_record) {
resp_record(cb, table, pst);
}
if (mod_op != 0) {
r = modify_record(cb, table, pst, args, mod_op, modified_count);
}
+ ++cnt;
+ }
+ if (args.invalues_keypart >= 0 && r == HA_ERR_KEY_NOT_FOUND) {
+ continue;
}
if (r != 0 && r != HA_ERR_RECORD_DELETED) {
break;
@@ -833,7 +866,7 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
/* revert dbcb_resp_begin() and dbcb_resp_entry() */
cb.dbcb_resp_cancel();
}
- cb.dbcb_resp_short_num(2, r);
+ cb.dbcb_resp_short_num(1, r);
} else {
/* succeeded */
if (need_resp_record) {
@@ -842,6 +875,8 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
cb.dbcb_resp_short_num(0, modified_count);
}
}
+ DENA_ALLOCA_FREE(filter_buf);
+ DENA_ALLOCA_FREE(key_buf);
}
size_t
@@ -856,6 +891,9 @@ dbcontext::calc_filter_buf_size(TABLE *table, const prep_stmt& pst,
const uint32_t fn = pst.get_filter_fields()[f->ff_offset];
filter_buf_len += table->field[fn]->pack_length();
}
+ ++filter_buf_len;
+ /* Field_medium::cmp() calls uint3korr(), which may read 4 bytes.
+ Allocate 1 more byte for safety. */
return filter_buf_len;
}
@@ -954,11 +992,11 @@ dbcontext::check_filter(dbcallback_i& cb, TABLE *table, const prep_stmt& pst,
}
void
-dbcontext::cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
- const char *tbl, const char *idx, const char *retflds, const char *filflds)
+dbcontext::cmd_open(dbcallback_i& cb, const cmd_open_args& arg)
{
unlock_tables_if();
- const table_name_type k = std::make_pair(std::string(dbn), std::string(tbl));
+ const table_name_type k = std::make_pair(std::string(arg.dbn),
+ std::string(arg.tbl));
const table_map_type::const_iterator iter = table_map.find(k);
uint32_t tblnum = 0;
if (iter != table_map.end()) {
@@ -971,23 +1009,24 @@ dbcontext::cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
bool refresh = true;
const thr_lock_type lock_type = for_write_flag ? TL_WRITE : TL_READ;
#if MYSQL_VERSION_ID >= 50505
- tables.init_one_table(dbn, strlen(dbn), tbl, strlen(tbl), tbl,
- lock_type);
- tables.mdl_request = mdl_request;
- Open_table_context ot_act(thd, MYSQL_OPEN_REOPEN);
+ tables.init_one_table(arg.dbn, strlen(arg.dbn), arg.tbl, strlen(arg.tbl),
+ arg.tbl, lock_type);
+ tables.mdl_request.init(MDL_key::TABLE, arg.dbn, arg.tbl,
+ for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_TRANSACTION);
+ Open_table_context ot_act(thd, 0);
if (!open_table(thd, &tables, thd->mem_root, &ot_act)) {
table = tables.table;
}
#else
- tables.init_one_table(dbn, tbl, lock_type);
+ tables.init_one_table(arg.dbn, arg.tbl, lock_type);
table = open_table(thd, &tables, thd->mem_root, &refresh,
OPEN_VIEW_NO_PARSE);
#endif
if (table == 0) {
- DENA_VERBOSE(10, fprintf(stderr,
+ DENA_VERBOSE(20, fprintf(stderr,
"HNDSOCK failed to open %p [%s] [%s] [%d]\n",
- thd, dbn, tbl, static_cast<int>(refresh)));
- return cb.dbcb_resp_short(2, "open_table");
+ thd, arg.dbn, arg.tbl, static_cast<int>(refresh)));
+ return cb.dbcb_resp_short(1, "open_table");
}
statistic_increment(open_tables_count, &LOCK_status);
table->reginfo.lock_type = lock_type;
@@ -999,15 +1038,16 @@ dbcontext::cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
table_map[k] = tblnum;
}
size_t idxnum = static_cast<size_t>(-1);
- if (idx[0] >= '0' && idx[0] <= '9') {
+ if (arg.idx[0] >= '0' && arg.idx[0] <= '9') {
/* numeric */
TABLE *const table = table_vec[tblnum].table;
- idxnum = atoi(idx);
+ idxnum = atoi(arg.idx);
if (idxnum >= table->s->keys) {
return cb.dbcb_resp_short(2, "idxnum");
}
} else {
- const char *const idx_name_to_open = idx[0] == '\0' ? "PRIMARY" : idx;
+ const char *const idx_name_to_open =
+ arg.idx[0] == '\0' ? "PRIMARY" : arg.idx;
TABLE *const table = table_vec[tblnum].table;
for (uint i = 0; i < table->s->keys; ++i) {
KEY& kinfo = table->key_info[i];
@@ -1022,14 +1062,14 @@ dbcontext::cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
}
prep_stmt::fields_type rf;
prep_stmt::fields_type ff;
- if (!parse_fields(table_vec[tblnum].table, retflds, rf)) {
+ if (!parse_fields(table_vec[tblnum].table, arg.retflds, rf)) {
return cb.dbcb_resp_short(2, "fld");
}
- if (!parse_fields(table_vec[tblnum].table, filflds, ff)) {
+ if (!parse_fields(table_vec[tblnum].table, arg.filflds, ff)) {
return cb.dbcb_resp_short(2, "fld");
}
prep_stmt p(this, tblnum, idxnum, rf, ff);
- cb.dbcb_set_prep_stmt(pst_id, p);
+ cb.dbcb_set_prep_stmt(arg.pst_id, p);
return cb.dbcb_resp_short(0, "");
}
@@ -1070,7 +1110,7 @@ enum db_write_op {
};
void
-dbcontext::cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
+dbcontext::cmd_exec(dbcallback_i& cb, const cmd_exec_args& args)
{
const prep_stmt& p = *args.pst;
if (p.get_table_id() == static_cast<size_t>(-1)) {
@@ -1096,7 +1136,7 @@ dbcontext::cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
wrop = db_write_op_sql;
break;
default:
- return cb.dbcb_resp_short(1, "op");
+ return cb.dbcb_resp_short(2, "op");
}
} else if (args.op.size() == 2 && args.op.begin()[1] == '=') {
switch (args.op.begin()[0]) {
@@ -1107,10 +1147,10 @@ dbcontext::cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
find_flag = HA_READ_KEY_OR_PREV;
break;
default:
- return cb.dbcb_resp_short(1, "op");
+ return cb.dbcb_resp_short(2, "op");
}
} else {
- return cb.dbcb_resp_short(1, "op");
+ return cb.dbcb_resp_short(2, "op");
}
if (args.kvalslen <= 0) {
return cb.dbcb_resp_short(2, "klen");
@@ -1128,7 +1168,6 @@ dbcontext::cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
void
dbcontext::set_statistics(size_t num_conns, size_t num_active)
{
- thd_proc_info(thd, &info_message_buf[0]);
if (for_write_flag) {
set_thread_message("handlersocket: mode=wr, %zu conns, %zu active",
num_conns, num_active);
@@ -1136,6 +1175,12 @@ dbcontext::set_statistics(size_t num_conns, size_t num_active)
set_thread_message("handlersocket: mode=rd, %zu conns, %zu active",
num_conns, num_active);
}
+ /*
+ Don't set message buf if it's already in use. This saves slow call to
+ thd_proc_info() (if profiling is enabled)
+ */
+ if (thd->proc_info != &info_message_buf[0])
+ thd_proc_info(thd, &info_message_buf[0]);
}
};
diff --git a/plugin/handler_socket/handlersocket/database.hpp b/plugin/handler_socket/handlersocket/database.hpp
index 5fc3fe737b5..a4aee0874c7 100644
--- a/plugin/handler_socket/handlersocket/database.hpp
+++ b/plugin/handler_socket/handlersocket/database.hpp
@@ -62,6 +62,7 @@ struct dbcallback_i {
virtual const prep_stmt *dbcb_get_prep_stmt(size_t pst_id) const = 0;
virtual void dbcb_resp_short(uint32_t code, const char *msg) = 0;
virtual void dbcb_resp_short_num(uint32_t code, uint32_t value) = 0;
+ virtual void dbcb_resp_short_num64(uint32_t code, uint64_t value) = 0;
virtual void dbcb_resp_begin(size_t num_flds) = 0;
virtual void dbcb_resp_entry(const char *fld, size_t fldlen) = 0;
virtual void dbcb_resp_end() = 0;
@@ -81,6 +82,17 @@ struct record_filter {
record_filter() : filter_type(record_filter_type_skip), ff_offset(0) { }
};
+struct cmd_open_args {
+ size_t pst_id;
+ const char *dbn;
+ const char *tbl;
+ const char *idx;
+ const char *retflds;
+ const char *filflds;
+ cmd_open_args() : pst_id(0), dbn(0), tbl(0), idx(0), retflds(0),
+ filflds(0) { }
+};
+
struct cmd_exec_args {
const prep_stmt *pst;
string_ref op;
@@ -91,8 +103,11 @@ struct cmd_exec_args {
string_ref mod_op;
const string_ref *uvals; /* size must be pst->retfieelds.size() */
const record_filter *filters;
+ int invalues_keypart;
+ const string_ref *invalues;
+ size_t invalueslen;
cmd_exec_args() : pst(0), kvals(0), kvalslen(0), limit(0), skip(0),
- uvals(0), filters(0) { }
+ uvals(0), filters(0), invalues_keypart(-1), invalues(0), invalueslen(0) { }
};
struct dbcontext_i {
@@ -108,11 +123,8 @@ struct dbcontext_i {
virtual void close_tables_if() = 0;
virtual void table_addref(size_t tbl_id) = 0; /* TODO: hide */
virtual void table_release(size_t tbl_id) = 0; /* TODO: hide */
- virtual void cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
- const char *tbl, const char *idx, const char *retflds,
- const char *filflds) = 0;
- virtual void cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
- = 0;
+ virtual void cmd_open(dbcallback_i& cb, const cmd_open_args& args) = 0;
+ virtual void cmd_exec(dbcallback_i& cb, const cmd_exec_args& args) = 0;
virtual void set_statistics(size_t num_conns, size_t num_active) = 0;
};
diff --git a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
index ac01b611aa6..fa42f2b0914 100644
--- a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
+++ b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
@@ -6,6 +6,7 @@
* See COPYRIGHT.txt for details.
*/
+#include <my_config.h>
#include <netinet/in.h>
#include <errno.h>
#include <poll.h>
@@ -17,6 +18,9 @@
#if __linux__
#include <sys/epoll.h>
#endif
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
#include "hstcpsvr_worker.hpp"
#include "string_buffer.hpp"
@@ -27,6 +31,7 @@
#define DBG_FD(x)
#define DBG_TR(x)
#define DBG_EP(x)
+#define DBG_MULTI(x)
/* TODO */
#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(MSG_NOSIGNAL)
@@ -40,13 +45,15 @@ struct dbconnstate {
string_buffer writebuf;
std::vector<prep_stmt> prep_stmts;
size_t resp_begin_pos;
+ size_t find_nl_pos;
void reset() {
readbuf.clear();
writebuf.clear();
prep_stmts.clear();
resp_begin_pos = 0;
+ find_nl_pos = 0;
}
- dbconnstate() : resp_begin_pos(0) { }
+ dbconnstate() : resp_begin_pos(0), find_nl_pos(0) { }
};
struct hstcpsvr_conn;
@@ -78,6 +85,7 @@ struct hstcpsvr_conn : public dbcallback_i {
virtual const prep_stmt *dbcb_get_prep_stmt(size_t pst_id) const;
virtual void dbcb_resp_short(uint32_t code, const char *msg);
virtual void dbcb_resp_short_num(uint32_t code, uint32_t value);
+ virtual void dbcb_resp_short_num64(uint32_t code, uint64_t value);
virtual void dbcb_resp_begin(size_t num_flds);
virtual void dbcb_resp_entry(const char *fld, size_t fldlen);
virtual void dbcb_resp_end();
@@ -206,6 +214,15 @@ hstcpsvr_conn::dbcb_resp_short_num(uint32_t code, uint32_t value)
}
void
+hstcpsvr_conn::dbcb_resp_short_num64(uint32_t code, uint64_t value)
+{
+ write_ui32(cstate.writebuf, code);
+ cstate.writebuf.append_literal("\t1\t");
+ write_ui64(cstate.writebuf, value);
+ cstate.writebuf.append_literal("\n");
+}
+
+void
hstcpsvr_conn::dbcb_resp_begin(size_t num_flds)
{
cstate.resp_begin_pos = cstate.writebuf.size();
@@ -256,6 +273,7 @@ struct hstcpsvr_worker : public hstcpsvr_worker_i, private noncopyable {
#endif
bool accept_enabled;
int accept_balance;
+ std::vector<string_ref> invalues_work;
std::vector<record_filter> filters_work;
private:
int run_one_nb();
@@ -385,6 +403,7 @@ hstcpsvr_worker::run_one_nb()
vshared.shutdown = 1;
} else if (ch == '/') {
conn.cstate.readbuf.clear();
+ conn.cstate.find_nl_pos = 0;
conn.cstate.writebuf.clear();
conn.read_finished = true;
conn.write_finished = true;
@@ -533,6 +552,7 @@ hstcpsvr_worker::run_one_ep()
vshared.shutdown = 1;
} else if (ch == '/') {
conn->cstate.readbuf.clear();
+ conn->cstate.find_nl_pos = 0;
conn->cstate.writebuf.clear();
conn->read_finished = true;
conn->write_finished = true;
@@ -641,19 +661,24 @@ hstcpsvr_worker::run_one_ep()
void
hstcpsvr_worker::execute_lines(hstcpsvr_conn& conn)
{
+ DBG_MULTI(int cnt = 0);
dbconnstate& cstate = conn.cstate;
char *buf_end = cstate.readbuf.end();
char *line_begin = cstate.readbuf.begin();
+ char *find_pos = line_begin + cstate.find_nl_pos;
while (true) {
- char *const nl = memchr_char(line_begin, '\n', buf_end - line_begin);
+ char *const nl = memchr_char(find_pos, '\n', buf_end - find_pos);
if (nl == 0) {
break;
}
char *const lf = (line_begin != nl && nl[-1] == '\r') ? nl - 1 : nl;
+ DBG_MULTI(cnt++);
execute_line(line_begin, lf, conn);
- line_begin = nl + 1;
+ find_pos = line_begin = nl + 1;
}
cstate.readbuf.erase_front(line_begin - cstate.readbuf.begin());
+ cstate.find_nl_pos = cstate.readbuf.size();
+ DBG_MULTI(fprintf(stderr, "cnt=%d\n", cnt));
}
void
@@ -721,8 +746,14 @@ hstcpsvr_worker::do_open_index(char *start, char *finish, hstcpsvr_conn& conn)
idxname_end[0] = 0;
retflds_end[0] = 0;
filflds_end[0] = 0;
- return dbctx->cmd_open_index(conn, pst_id, dbname_begin, tblname_begin,
- idxname_begin, retflds_begin, filflds_begin);
+ cmd_open_args args;
+ args.pst_id = pst_id;
+ args.dbn = dbname_begin;
+ args.tbl = tblname_begin;
+ args.idx = idxname_begin;
+ args.retflds = retflds_begin;
+ args.filflds = filflds_begin;
+ return dbctx->cmd_open(conn, args);
}
void
@@ -741,7 +772,8 @@ hstcpsvr_worker::do_exec_on_index(char *cmd_begin, char *cmd_end, char *start,
args.op = string_ref(op_begin, op_end);
skip_one(start, finish);
const uint32_t fldnum = read_ui32(start, finish);
- string_ref flds[fldnum]; /* GNU */
+ string_ref *const flds = DENA_ALLOCA_ALLOCATE(string_ref, fldnum);
+ auto_alloca_free<string_ref> flds_autofree(flds);
args.kvals = flds;
args.kvalslen = fldnum;
for (size_t i = 0; i < fldnum; ++i) {
@@ -765,10 +797,39 @@ hstcpsvr_worker::do_exec_on_index(char *cmd_begin, char *cmd_end, char *start,
args.skip = read_ui32(start, finish);
if (start == finish) {
/* simple query */
- return dbctx->cmd_exec_on_index(conn, args);
+ return dbctx->cmd_exec(conn, args);
}
- /* has filters or modops */
+ /* has more options */
skip_one(start, finish);
+ /* in-clause */
+ if (start[0] == '@') {
+ read_token(start, finish); /* '@' */
+ skip_one(start, finish);
+ args.invalues_keypart = read_ui32(start, finish);
+ skip_one(start, finish);
+ args.invalueslen = read_ui32(start, finish);
+ if (args.invalueslen <= 0) {
+ return conn.dbcb_resp_short(2, "invalueslen");
+ }
+ if (invalues_work.size() < args.invalueslen) {
+ invalues_work.resize(args.invalueslen);
+ }
+ args.invalues = &invalues_work[0];
+ for (uint32_t i = 0; i < args.invalueslen; ++i) {
+ skip_one(start, finish);
+ char *const invalue_begin = start;
+ read_token(start, finish);
+ char *const invalue_end = start;
+ char *wp = invalue_begin;
+ unescape_string(wp, invalue_begin, invalue_end);
+ invalues_work[i] = string_ref(invalue_begin, wp - invalue_begin);
+ }
+ skip_one(start, finish);
+ }
+ if (start == finish) {
+ /* no more options */
+ return dbctx->cmd_exec(conn, args);
+ }
/* filters */
size_t filters_count = 0;
while (start != finish && (start[0] == 'W' || start[0] == 'F')) {
@@ -823,7 +884,7 @@ hstcpsvr_worker::do_exec_on_index(char *cmd_begin, char *cmd_end, char *start,
}
if (start == finish) {
/* no modops */
- return dbctx->cmd_exec_on_index(conn, args);
+ return dbctx->cmd_exec(conn, args);
}
/* has modops */
char *const mod_op_begin = start;
@@ -831,7 +892,8 @@ hstcpsvr_worker::do_exec_on_index(char *cmd_begin, char *cmd_end, char *start,
char *const mod_op_end = start;
args.mod_op = string_ref(mod_op_begin, mod_op_end);
const size_t num_uvals = args.pst->get_ret_fields().size();
- string_ref uflds[num_uvals]; /* GNU */
+ string_ref *const uflds = DENA_ALLOCA_ALLOCATE(string_ref, num_uvals);
+ auto_alloca_free<string_ref> uflds_autofree(uflds);
for (size_t i = 0; i < num_uvals; ++i) {
skip_one(start, finish);
char *const f_begin = start;
@@ -848,7 +910,7 @@ hstcpsvr_worker::do_exec_on_index(char *cmd_begin, char *cmd_end, char *start,
}
}
args.uvals = uflds;
- return dbctx->cmd_exec_on_index(conn, args);
+ return dbctx->cmd_exec(conn, args);
}
void
@@ -871,7 +933,7 @@ hstcpsvr_worker::do_authorization(char *start, char *finish,
char *wp = key_begin;
unescape_string(wp, key_begin, key_end);
if (authtype_len != 1 || authtype_begin[0] != '1') {
- return conn.dbcb_resp_short(2, "authtype");
+ return conn.dbcb_resp_short(3, "authtype");
}
if (cshared.plain_secret.size() == key_len &&
memcmp(cshared.plain_secret.data(), key_begin, key_len) == 0) {
diff --git a/plugin/handler_socket/handlersocket/mysql_incl.hpp b/plugin/handler_socket/handlersocket/mysql_incl.hpp
index c7b3fce0d1d..d8dba709f28 100644
--- a/plugin/handler_socket/handlersocket/mysql_incl.hpp
+++ b/plugin/handler_socket/handlersocket/mysql_incl.hpp
@@ -17,6 +17,7 @@
#define MYSQL_SERVER 1
#include <my_config.h>
+
#include <mysql_version.h>
#if MYSQL_VERSION_ID >= 50505
diff --git a/plugin/handler_socket/libhsclient/Makefile.am b/plugin/handler_socket/libhsclient/Makefile.am
index d6409ef42ee..343b41860b3 100644
--- a/plugin/handler_socket/libhsclient/Makefile.am
+++ b/plugin/handler_socket/libhsclient/Makefile.am
@@ -8,6 +8,5 @@ inst_HEADERS = allocator.hpp config.hpp mutex.hpp string_util.hpp \
lib_LTLIBRARIES = libhsclient.la
libhsclient_la_SOURCES = config.cpp escape.cpp fatal.cpp hstcpcli.cpp \
socket.cpp string_util.cpp
-#libhsclient_la_LDFLAGS = -static
libhsclient_la_CFLAGS = $(AM_CFLAGS)
libhsclient_la_CXXFLAGS = $(AM_CXXFLAGS)
diff --git a/plugin/handler_socket/libhsclient/allocator.hpp b/plugin/handler_socket/libhsclient/allocator.hpp
index d7cd33ffad3..82ff51f00e7 100644
--- a/plugin/handler_socket/libhsclient/allocator.hpp
+++ b/plugin/handler_socket/libhsclient/allocator.hpp
@@ -33,5 +33,32 @@ typedef std::allocator<int> allocator_type;
typedef std::allocator<int> allocator_type;
#endif
+#if 1
+#define DENA_ALLOCA_ALLOCATE(typ, len) \
+ static_cast<typ *>(alloca((len) * sizeof(typ)))
+#define DENA_ALLOCA_FREE(x)
+#else
+#define DENA_ALLOCA_ALLOCATE(typ, len) \
+ static_cast<typ *>(malloc((len) * sizeof(typ)))
+#define DENA_ALLOCA_FREE(x) free(x)
+#endif
+
+namespace dena {
+
+template <typename T> struct auto_alloca_free {
+ auto_alloca_free(T *value) : value(value) { }
+ ~auto_alloca_free() {
+ /* no-op if alloca() is used */
+ DENA_ALLOCA_FREE(value);
+ }
+ private:
+ auto_alloca_free(const auto_alloca_free&);
+ auto_alloca_free& operator =(const auto_alloca_free&);
+ private:
+ T *value;
+};
+
+};
+
#endif
diff --git a/plugin/handler_socket/libhsclient/auto_addrinfo.hpp b/plugin/handler_socket/libhsclient/auto_addrinfo.hpp
index 5be3d02c75d..c3ab64e8127 100644
--- a/plugin/handler_socket/libhsclient/auto_addrinfo.hpp
+++ b/plugin/handler_socket/libhsclient/auto_addrinfo.hpp
@@ -12,7 +12,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
-#include <string.h>
+
#include "util.hpp"
namespace dena {
@@ -33,7 +33,6 @@ struct auto_addrinfo : private noncopyable {
int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) {
reset();
addrinfo hints;
- memset(&hints, 0, sizeof(hints));
hints.ai_flags = flags;
hints.ai_family = family;
hints.ai_socktype = socktype;
diff --git a/plugin/handler_socket/libhsclient/escape.cpp b/plugin/handler_socket/libhsclient/escape.cpp
index 8bbe3ca8c27..d4df8ae8dd7 100644
--- a/plugin/handler_socket/libhsclient/escape.cpp
+++ b/plugin/handler_socket/libhsclient/escape.cpp
@@ -106,8 +106,18 @@ read_ui32(char *& start, char *finish)
void
write_ui32(string_buffer& buf, uint32_t v)
{
- char *wp = buf.make_space(32);
- int len = snprintf(wp, 32, "%u", v);
+ char *wp = buf.make_space(12);
+ int len = snprintf(wp, 12, "%u", v);
+ if (len > 0) {
+ buf.space_wrote(len);
+ }
+}
+
+void
+write_ui64(string_buffer& buf, uint64_t v)
+{
+ char *wp = buf.make_space(22);
+ int len = snprintf(wp, 22, "%llu", static_cast<unsigned long long>(v));
if (len > 0) {
buf.space_wrote(len);
}
diff --git a/plugin/handler_socket/libhsclient/escape.hpp b/plugin/handler_socket/libhsclient/escape.hpp
index 9e2207f6c69..b928defeff6 100644
--- a/plugin/handler_socket/libhsclient/escape.hpp
+++ b/plugin/handler_socket/libhsclient/escape.hpp
@@ -25,6 +25,7 @@ bool unescape_string(string_buffer& ar, const char *start, const char *finish);
uint32_t read_ui32(char *& start, char *finish);
void write_ui32(string_buffer& buf, uint32_t v);
+void write_ui64(string_buffer& buf, uint64_t v);
inline bool
is_null_expression(const char *start, const char *finish)
diff --git a/plugin/handler_socket/libhsclient/hstcpcli.cpp b/plugin/handler_socket/libhsclient/hstcpcli.cpp
index 3753346aae7..c0cb5fb1e97 100644
--- a/plugin/handler_socket/libhsclient/hstcpcli.cpp
+++ b/plugin/handler_socket/libhsclient/hstcpcli.cpp
@@ -31,21 +31,12 @@ struct hstcpcli : public hstcpcli_i, private noncopyable {
virtual bool stable_point();
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds, const char *filflds);
- #if 0
- virtual void request_buf_find(size_t pst_id, const string_ref& op,
- const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip);
- virtual void request_buf_insert(size_t pst_id, const string_ref *fvs,
- size_t fvslen);
- virtual void request_buf_update(size_t pst_id, const string_ref& op,
- const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip,
- const string_ref *mvs, size_t mvslen);
- virtual void request_buf_delete(size_t pst_id, const string_ref& op,
- const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip);
- #endif
+ virtual void request_buf_auth(const char *secret, const char *typ);
virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
- const hstcpcli_filter *fils, size_t filslen);
+ const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
+ const string_ref *invalues, size_t invalueslen);
virtual int request_send();
virtual int response_recv(size_t& num_flds_r);
virtual const string_ref *get_next_row();
@@ -196,6 +187,27 @@ hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
++num_req_bufd;
}
+void
+hstcpcli::request_buf_auth(const char *secret, const char *typ)
+{
+ if (num_req_sent > 0 || num_req_rcvd > 0) {
+ close();
+ set_error(-1, "request_buf_auth: protocol out of sync");
+ return;
+ }
+ if (typ == 0) {
+ typ = "1";
+ }
+ const string_ref typ_ref(typ, strlen(typ));
+ const string_ref secret_ref(secret, strlen(secret));
+ writebuf.append_literal("A\t");
+ writebuf.append(typ_ref.begin(), typ_ref.end());
+ writebuf.append_literal("\t");
+ writebuf.append(secret_ref.begin(), secret_ref.end());
+ writebuf.append_literal("\n");
+ ++num_req_bufd;
+}
+
namespace {
void
@@ -218,7 +230,8 @@ void
hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
- const hstcpcli_filter *fils, size_t filslen)
+ const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
+ const string_ref *invalues, size_t invalueslen)
{
if (num_req_sent > 0 || num_req_rcvd > 0) {
close();
@@ -234,13 +247,26 @@ hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref& kv = kvs[i];
append_delim_value(writebuf, kv.begin(), kv.end());
}
- if (limit != 0 || skip != 0 || mod_op.size() != 0 || filslen != 0) {
+ if (limit != 0 || skip != 0 || invalues_keypart >= 0 ||
+ mod_op.size() != 0 || filslen != 0) {
+ /* has more option */
writebuf.append_literal("\t");
append_uint32(writebuf, limit); // FIXME size_t ?
- if (skip != 0 || mod_op.size() != 0 || filslen != 0) {
+ if (skip != 0 || invalues_keypart >= 0 ||
+ mod_op.size() != 0 || filslen != 0) {
writebuf.append_literal("\t");
append_uint32(writebuf, skip); // FIXME size_t ?
}
+ if (invalues_keypart >= 0) {
+ writebuf.append_literal("\t@\t");
+ append_uint32(writebuf, invalues_keypart);
+ writebuf.append_literal("\t");
+ append_uint32(writebuf, invalueslen);
+ for (size_t i = 0; i < invalueslen; ++i) {
+ const string_ref& s = invalues[i];
+ append_delim_value(writebuf, s.begin(), s.end());
+ }
+ }
for (size_t i = 0; i < filslen; ++i) {
const hstcpcli_filter& f = fils[i];
writebuf.append_literal("\t");
@@ -264,44 +290,6 @@ hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op,
++num_req_bufd;
}
-#if 0
-void
-hstcpcli::request_buf_find(size_t pst_id, const string_ref& op,
- const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip)
-{
- return request_buf_exec_generic(pst_id, op, kvs, kvslen, limit, skip,
- 0, 0, 0);
-}
-
-void
-hstcpcli::request_buf_insert(size_t pst_id, const string_ref *fvs,
- size_t fvslen)
-{
- const string_ref insert_op("+", 1);
- return request_buf_exec_generic(pst_id, insert_op, fvs, fvslen,
- 0, 0, string_ref(), 0, 0);
-}
-
-void
-hstcpcli::request_buf_update(size_t pst_id, const string_ref& op,
- const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip,
- const string_ref *mvs, size_t mvslen)
-{
- const string_ref modop_update("U", 1);
- return request_buf_exec_generic(pst_id, op, kvs, kvslen, limit, skip,
- modop_update, mvs, mvslen);
-}
-
-void
-hstcpcli::request_buf_delete(size_t pst_id, const string_ref& op,
- const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip)
-{
- const string_ref modop_delete("D", 1);
- return request_buf_exec_generic(pst_id, op, kvs, kvslen, limit, skip,
- modop_delete, 0, 0);
-}
-#endif
-
int
hstcpcli::request_send()
{
diff --git a/plugin/handler_socket/libhsclient/hstcpcli.hpp b/plugin/handler_socket/libhsclient/hstcpcli.hpp
index b852576d509..11dec8ebb0b 100644
--- a/plugin/handler_socket/libhsclient/hstcpcli.hpp
+++ b/plugin/handler_socket/libhsclient/hstcpcli.hpp
@@ -37,13 +37,16 @@ struct hstcpcli_i {
virtual void close() = 0;
virtual int reconnect() = 0;
virtual bool stable_point() = 0;
+ virtual void request_buf_auth(const char *secret, const char *typ) = 0;
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds,
const char *filflds = 0) = 0;
virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip,
const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
- const hstcpcli_filter *fils = 0, size_t filslen = 0) = 0;
+ const hstcpcli_filter *fils = 0, size_t filslen = 0,
+ int invalues_keypart = -1, const string_ref *invalues = 0,
+ size_t invalueslen = 0) = 0; // FIXME: too long
virtual int request_send() = 0;
virtual int response_recv(size_t& num_flds_r) = 0;
virtual const string_ref *get_next_row() = 0;
diff --git a/plugin/handler_socket/libhsclient/string_buffer.hpp b/plugin/handler_socket/libhsclient/string_buffer.hpp
index c013f45f54f..708c0df30a4 100644
--- a/plugin/handler_socket/libhsclient/string_buffer.hpp
+++ b/plugin/handler_socket/libhsclient/string_buffer.hpp
@@ -84,7 +84,7 @@ struct string_buffer : private noncopyable {
}
void space_wrote(size_t len) {
len = std::min(len, alloc_size - end_offset);
- end_offset = std::min(end_offset + len, alloc_size);
+ end_offset += len;
}
template <size_t N>
void append_literal(const char (& str)[N]) {
diff --git a/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs b/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs
index 7d9ee4929ae..39f11e2780e 100644
--- a/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs
+++ b/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs
@@ -109,7 +109,7 @@ hv_to_strmap(HV *hv, std::map<std::string, std::string>& m_r)
static void
strrefarr_push_back(std::vector<dena::string_ref>& a_r, SV *sv)
{
- if (sv == 0 || SvTYPE(sv) == SVt_NULL) {
+ if (sv == 0 || SvTYPE(sv) == SVt_NULL) { /* !SvPOK()? */
DBG(fprintf(stderr, "strrefarr_push_back: null\n"));
return a_r.push_back(dena::string_ref());
}
@@ -135,7 +135,7 @@ av_to_strrefarr(AV *av, std::vector<dena::string_ref>& a_r)
static dena::string_ref
sv_get_string_ref(SV *sv)
{
- if (sv == 0) {
+ if (sv == 0 || SvTYPE(sv) == SVt_NULL) { /* !SvPOK()? */
return dena::string_ref();
}
STRLEN vlen = 0;
@@ -190,7 +190,8 @@ set_process_verbose_level(const std::map<std::string, std::string>& m)
static AV *
execute_internal(SV *obj, int id, const char *op, AV *keys, int limit,
- int skip, const char *modop, AV *modvals, AV *filters)
+ int skip, const char *modop, AV *modvals, AV *filters, int invalues_keypart,
+ AV *invalues)
{
AV *retval = (AV *)&PL_sv_undef;
dena::hstcpcli_i *const ptr =
@@ -198,6 +199,7 @@ execute_internal(SV *obj, int id, const char *op, AV *keys, int limit,
do {
std::vector<dena::string_ref> keyarr, mvarr;
std::vector<dena::hstcpcli_filter> farr;
+ std::vector<dena::string_ref> ivs;
av_to_strrefarr(keys, keyarr);
dena::string_ref modop_ref;
if (modop != 0) {
@@ -207,9 +209,13 @@ execute_internal(SV *obj, int id, const char *op, AV *keys, int limit,
if (filters != 0) {
av_to_filters(filters, farr);
}
+ if (invalues_keypart >= 0 && invalues != 0) {
+ av_to_strrefarr(invalues, ivs);
+ }
ptr->request_buf_exec_generic(id, dena::string_ref(op, strlen(op)),
&keyarr[0], keyarr.size(), limit, skip, modop_ref, &mvarr[0],
- mvarr.size(), &farr[0], farr.size());
+ mvarr.size(), &farr[0], farr.size(), invalues_keypart, &ivs[0],
+ ivs.size());
AV *const av = newAV();
retval = av;
if (ptr->request_send() != 0) {
@@ -258,8 +264,10 @@ struct execute_arg {
const char *modop;
AV *modvals;
AV *filters;
+ int invalues_keypart;
+ AV *invalues;
execute_arg() : id(0), op(0), keys(0), limit(0), skip(0), modop(0),
- modvals(0), filters(0) { }
+ modvals(0), filters(0), invalues_keypart(-1), invalues(0) { }
};
static AV *
@@ -271,6 +279,7 @@ execute_multi_internal(SV *obj, const execute_arg *args, size_t num_args)
for (size_t i = 0; i < num_args; ++i) {
std::vector<dena::string_ref> keyarr, mvarr;
std::vector<dena::hstcpcli_filter> farr;
+ std::vector<dena::string_ref> ivs;
const execute_arg& arg = args[i];
av_to_strrefarr(arg.keys, keyarr);
dena::string_ref modop_ref;
@@ -281,10 +290,13 @@ execute_multi_internal(SV *obj, const execute_arg *args, size_t num_args)
if (arg.filters != 0) {
av_to_filters(arg.filters, farr);
}
+ if (arg.invalues_keypart >= 0 && arg.invalues != 0) {
+ av_to_strrefarr(arg.invalues, ivs);
+ }
ptr->request_buf_exec_generic(arg.id,
dena::string_ref(arg.op, strlen(arg.op)), &keyarr[0], keyarr.size(),
arg.limit, arg.skip, modop_ref, &mvarr[0], mvarr.size(), &farr[0],
- farr.size());
+ farr.size(), arg.invalues_keypart, &ivs[0], ivs.size());
}
AV *const retval = newAV();
/* sends the requests */
@@ -420,6 +432,34 @@ OUTPUT:
RETVAL
int
+auth(obj, key, typ = 0)
+ SV *obj
+ const char *key
+ const char *typ
+CODE:
+ RETVAL = 0;
+ dena::hstcpcli_i *const ptr =
+ reinterpret_cast<dena::hstcpcli_i *>(SvIV(SvRV(obj)));
+ do {
+ ptr->request_buf_auth(key, typ);
+ if (ptr->request_send() != 0) {
+ break;
+ }
+ size_t nflds = 0;
+ ptr->response_recv(nflds);
+ const int e = ptr->get_error_code();
+ DBG(fprintf(stderr, "errcode=%d\n", ptr->get_error_code()));
+ if (e >= 0) {
+ ptr->response_buf_remove();
+ }
+ DBG(fprintf(stderr, "errcode=%d\n", ptr->get_error_code()));
+ } while (0);
+ RETVAL = ptr->get_error_code();
+OUTPUT:
+ RETVAL
+
+
+int
open_index(obj, id, db, table, index, fields, ffields = 0)
SV *obj
int id
@@ -452,7 +492,7 @@ OUTPUT:
RETVAL
AV *
-execute_single(obj, id, op, keys, limit, skip, mop = 0, mvs = 0, fils = 0)
+execute_single(obj, id, op, keys, limit, skip, mop = 0, mvs = 0, fils = 0, ivkeypart = -1, ivs = 0)
SV *obj
int id
const char *op
@@ -462,12 +502,15 @@ execute_single(obj, id, op, keys, limit, skip, mop = 0, mvs = 0, fils = 0)
SV *mop
SV *mvs
SV *fils
+ int ivkeypart
+ SV *ivs
CODE:
const char *const mop_str = sv_get_strval(mop);
AV *const mvs_av = sv_get_arrval(mvs);
AV *const fils_av = sv_get_arrval(fils);
+ AV *const ivs_av = sv_get_arrval(ivs);
RETVAL = execute_internal(obj, id, op, keys, limit, skip, mop_str, mvs_av,
- fils_av);
+ fils_av, ivkeypart, ivs_av);
sv_2mortal((SV *)RETVAL);
OUTPUT:
RETVAL
@@ -500,9 +543,11 @@ CODE:
ag.modop = arr_get_strval(avtarget, argmax, 5);
ag.modvals = arr_get_arrval(avtarget, argmax, 6);
ag.filters = arr_get_arrval(avtarget, argmax, 7);
- DBG(fprintf(stderr, "execute_multi3 %d: %d %s %p %d %d %s %p %p\n",
+ ag.invalues_keypart = arr_get_intval(avtarget, argmax, 8, -1);
+ ag.invalues = arr_get_arrval(avtarget, argmax, 9);
+ DBG(fprintf(stderr, "execute_multi3 %d: %d %s %p %d %d %s %p %p %d %p\n",
i, ag.id, ag.op, ag.keys, ag.limit, ag.skip, ag.modop, ag.modvals,
- ag.filters));
+ ag.filters, ag.invalues_keypart, ag.invalues));
}
RETVAL = execute_multi_internal(obj, args, cmdsmax + 1);
sv_2mortal((SV *)RETVAL);
@@ -510,7 +555,7 @@ OUTPUT:
RETVAL
AV *
-execute_find(obj, id, op, keys, limit, skip, mop = 0, mvs = 0, fils = 0)
+execute_find(obj, id, op, keys, limit, skip, mop = 0, mvs = 0, fils = 0, ivkeypart = -1, ivs = 0)
SV *obj
int id
const char *op
@@ -520,18 +565,21 @@ execute_find(obj, id, op, keys, limit, skip, mop = 0, mvs = 0, fils = 0)
SV *mop
SV *mvs
SV *fils
+ int ivkeypart
+ SV *ivs
CODE:
const char *const mop_str = sv_get_strval(mop);
AV *const mvs_av = sv_get_arrval(mvs);
AV *const fils_av = sv_get_arrval(fils);
+ AV *const ivs_av = sv_get_arrval(ivs);
RETVAL = execute_internal(obj, id, op, keys, limit, skip, mop_str, mvs_av,
- fils_av);
+ fils_av, ivkeypart, ivs_av);
sv_2mortal((SV *)RETVAL);
OUTPUT:
RETVAL
AV *
-execute_update(obj, id, op, keys, limit, skip, modvals, fils = 0)
+execute_update(obj, id, op, keys, limit, skip, modvals, fils = 0, ivkeypart = -1, ivs = 0)
SV *obj
int id
const char *op
@@ -540,16 +588,19 @@ execute_update(obj, id, op, keys, limit, skip, modvals, fils = 0)
int skip
AV *modvals
SV *fils
+ int ivkeypart
+ SV *ivs
CODE:
AV *const fils_av = sv_get_arrval(fils);
+ AV *const ivs_av = sv_get_arrval(ivs);
RETVAL = execute_internal(obj, id, op, keys, limit, skip, "U",
- modvals, fils_av);
+ modvals, fils_av, ivkeypart, ivs_av);
sv_2mortal((SV *)RETVAL);
OUTPUT:
RETVAL
AV *
-execute_delete(obj, id, op, keys, limit, skip, fils = 0)
+execute_delete(obj, id, op, keys, limit, skip, fils = 0, ivkeypart = -1, ivs = 0)
SV *obj
int id
const char *op
@@ -557,9 +608,13 @@ execute_delete(obj, id, op, keys, limit, skip, fils = 0)
int limit
int skip
SV *fils
+ int ivkeypart
+ SV *ivs
CODE:
AV *const fils_av = sv_get_arrval(fils);
- RETVAL = execute_internal(obj, id, op, keys, limit, skip, "D", 0, fils_av);
+ AV *const ivs_av = sv_get_arrval(ivs);
+ RETVAL = execute_internal(obj, id, op, keys, limit, skip, "D", 0, fils_av,
+ ivkeypart, ivs_av);
sv_2mortal((SV *)RETVAL);
OUTPUT:
RETVAL
@@ -570,7 +625,7 @@ execute_insert(obj, id, fvals)
int id
AV *fvals
CODE:
- RETVAL = execute_internal(obj, id, "+", fvals, 0, 0, 0, 0, 0);
+ RETVAL = execute_internal(obj, id, "+", fvals, 0, 0, 0, 0, 0, -1, 0);
sv_2mortal((SV *)RETVAL);
OUTPUT:
RETVAL
diff --git a/plugin/handler_socket/perl-Net-HandlerSocket/MANIFEST b/plugin/handler_socket/perl-Net-HandlerSocket/MANIFEST
index 5df64094269..874fadb5e19 100644
--- a/plugin/handler_socket/perl-Net-HandlerSocket/MANIFEST
+++ b/plugin/handler_socket/perl-Net-HandlerSocket/MANIFEST
@@ -5,4 +5,4 @@ MANIFEST
ppport.h
README
t/HandlerSocket.t
-lib/HandlerSocket.pm
+lib/Net/HandlerSocket.pm
diff --git a/plugin/handler_socket/regtest/common/hstest.pm b/plugin/handler_socket/regtest/common/hstest.pm
index 35cc75aad2f..348242b027f 100644
--- a/plugin/handler_socket/regtest/common/hstest.pm
+++ b/plugin/handler_socket/regtest/common/hstest.pm
@@ -21,6 +21,7 @@ sub init_conf {
$conf{user} = get_conf_env("MYSQLUSER", "root");
$conf{pass} = get_conf_env("MYSQLPASS", "");
$conf{hsport} = get_conf_env("HSPORT", 9998);
+ $conf{hspass} = get_conf_env("HSPASS", undef);
}
sub get_dbi_connection {
@@ -52,6 +53,9 @@ sub get_hs_connection {
$port ||= $conf{hsport};
my $hsargs = { 'host' => $host, 'port' => $port };
my $conn = new Net::HandlerSocket($hsargs);
+ if (defined($conn) && defined($conf{hspass})) {
+ $conn->auth($conf{hspass});
+ }
return $conn;
}
diff --git a/plugin/handler_socket/regtest/test_01_lib/run.sh b/plugin/handler_socket/regtest/test_01_lib/run.sh
index 07b6c37b80c..8514612832f 100755
--- a/plugin/handler_socket/regtest/test_01_lib/run.sh
+++ b/plugin/handler_socket/regtest/test_01_lib/run.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-TESTS="01 02 03 04 05 06 07 08 09 10 11 12 13";
+TESTS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23";
source ../common/compat.sh
diff --git a/plugin/handler_socket/regtest/test_01_lib/test13.expected b/plugin/handler_socket/regtest/test_01_lib/test13.expected
index 5c47447a746..3330382ebf6 100644
--- a/plugin/handler_socket/regtest/test_01_lib/test13.expected
+++ b/plugin/handler_socket/regtest/test_01_lib/test13.expected
@@ -1,4 +1,44 @@
HSINSERT
+11 v1hs_0
+12 v1hs_1
+13 v1hs_2
+14 v1hs_3
+15 v1hs_4
+16 v1hs_5
+17 v1hs_6
+18 v1hs_7
+19 v1hs_8
+20 v1hs_9
+21 v1hs3_0
+22 v1hs3_0
+23 v1hs3_0
+24 v1hs3_1
+25 v1hs3_1
+26 v1hs3_1
+27 v1hs3_2
+28 v1hs3_2
+29 v1hs3_2
+30 v1hs3_3
+31 v1hs3_3
+32 v1hs3_3
+33 v1hs3_4
+34 v1hs3_4
+35 v1hs3_4
+36 v1hs3_5
+37 v1hs3_5
+38 v1hs3_5
+39 v1hs3_6
+40 v1hs3_6
+41 v1hs3_6
+42 v1hs3_7
+43 v1hs3_7
+44 v1hs3_7
+45 v1hs3_8
+46 v1hs3_8
+47 v1hs3_8
+48 v1hs3_9
+49 v1hs3_9
+50 v1hs3_9
DUMP_TABLE
1 v1sql_0 v2sql_0
2 v1sql_1 v2sql_1
diff --git a/plugin/handler_socket/regtest/test_01_lib/test13.pl b/plugin/handler_socket/regtest/test_01_lib/test13.pl
index 5b1440853b2..1e1104d2a07 100644
--- a/plugin/handler_socket/regtest/test_01_lib/test13.pl
+++ b/plugin/handler_socket/regtest/test_01_lib/test13.pl
@@ -47,6 +47,9 @@ for (my $i = 0; $i < $tablesize; ++$i) {
if ($err != 0) {
my $err_str = $r->[1];
print "$err $err_str\n";
+ } else {
+ my $id = $r->[1];
+ print "$id $v1\n";
}
}
# make sure that it works even when inserts are pipelined. these requests
@@ -63,8 +66,11 @@ for (my $i = 0; $i < $tablesize; ++$i) {
for (my $i = 0; $i < 3; ++$i) {
my $err = $r->[$i]->[0];
if ($err != 0) {
- my $err_str = $r->[1];
+ my $err_str = $r->[$i]->[1];
print "$err $err_str\n";
+ } else {
+ my $id = $r->[$i]->[1];
+ print "$id $v1\n";
}
}
}
diff --git a/plugin/handler_socket/regtest/test_01_lib/test14.expected b/plugin/handler_socket/regtest/test_01_lib/test14.expected
new file mode 100644
index 00000000000..00149dd9ac9
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test14.expected
@@ -0,0 +1,144 @@
+DUMP_TABLE
+0
+1 0 A
+2 01 AB
+3 012 ABC
+4 0123 ABCD
+5 01234 ABCDE
+6 012345 ABCDEF
+7 0123456 ABCDEFG
+8 01234567 ABCDEFGH
+9 012345678 ABCDEFGHI
+10 0123456789 ABCDEFGHIJ
+11 01234567890 ABCDEFGHIJA
+12 012345678901 ABCDEFGHIJAB
+13 0123456789012 ABCDEFGHIJABC
+14 01234567890123 ABCDEFGHIJABCD
+15 012345678901234 ABCDEFGHIJABCDE
+16 0123456789012345 ABCDEFGHIJABCDEF
+17 01234567890123456 ABCDEFGHIJABCDEFG
+18 012345678901234567 ABCDEFGHIJABCDEFGH
+19 0123456789012345678 ABCDEFGHIJABCDEFGHI
+20 01234567890123456789 ABCDEFGHIJABCDEFGHIJ
+21 012345678901234567890 ABCDEFGHIJABCDEFGHIJA
+22 0123456789012345678901 ABCDEFGHIJABCDEFGHIJAB
+23 01234567890123456789012 ABCDEFGHIJABCDEFGHIJABC
+24 012345678901234567890123 ABCDEFGHIJABCDEFGHIJABCD
+25 0123456789012345678901234 ABCDEFGHIJABCDEFGHIJABCDE
+26 01234567890123456789012345 ABCDEFGHIJABCDEFGHIJABCDEF
+27 012345678901234567890123456 ABCDEFGHIJABCDEFGHIJABCDEFG
+28 0123456789012345678901234567 ABCDEFGHIJABCDEFGHIJABCDEFGH
+29 01234567890123456789012345678 ABCDEFGHIJABCDEFGHIJABCDEFGHI
+30 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+31 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+32 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+33 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+34 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+35 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+36 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+37 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+38 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+39 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+40 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+41 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+42 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+43 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+44 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+45 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+46 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+47 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+48 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+49 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+PK 0
+I1 0
+I2 0
+PK 1 0 A
+I1 1 0 A
+I2 1 0 A
+PK 2 01 AB
+I1 2 01 AB
+I2 2 01 AB
+PK 3 012 ABC
+I1 3 012 ABC
+I2 3 012 ABC
+PK 4 0123 ABCD
+I1 4 0123 ABCD
+I2 4 0123 ABCD
+PK 5 01234 ABCDE
+I1 5 01234 ABCDE
+I2 5 01234 ABCDE
+PK 6 012345 ABCDEF
+I1 6 012345 ABCDEF
+I2 6 012345 ABCDEF
+PK 7 0123456 ABCDEFG
+I1 7 0123456 ABCDEFG
+I2 7 0123456 ABCDEFG
+PK 8 01234567 ABCDEFGH
+I1 8 01234567 ABCDEFGH
+I2 8 01234567 ABCDEFGH
+PK 9 012345678 ABCDEFGHI
+I1 9 012345678 ABCDEFGHI
+I2 9 012345678 ABCDEFGHI
+PK 10 0123456789 ABCDEFGHIJ
+I1 10 0123456789 ABCDEFGHIJ
+I2 10 0123456789 ABCDEFGHIJ
+PK 11 01234567890 ABCDEFGHIJA
+I1 11 01234567890 ABCDEFGHIJA
+I2 11 01234567890 ABCDEFGHIJA
+PK 12 012345678901 ABCDEFGHIJAB
+I1 12 012345678901 ABCDEFGHIJAB
+I2 12 012345678901 ABCDEFGHIJAB
+PK 13 0123456789012 ABCDEFGHIJABC
+I1 13 0123456789012 ABCDEFGHIJABC
+I2 13 0123456789012 ABCDEFGHIJABC
+PK 14 01234567890123 ABCDEFGHIJABCD
+I1 14 01234567890123 ABCDEFGHIJABCD
+I2 14 01234567890123 ABCDEFGHIJABCD
+PK 15 012345678901234 ABCDEFGHIJABCDE
+I1 15 012345678901234 ABCDEFGHIJABCDE
+I2 15 012345678901234 ABCDEFGHIJABCDE
+PK 16 0123456789012345 ABCDEFGHIJABCDEF
+I1 16 0123456789012345 ABCDEFGHIJABCDEF
+I2 16 0123456789012345 ABCDEFGHIJABCDEF
+PK 17 01234567890123456 ABCDEFGHIJABCDEFG
+I1 17 01234567890123456 ABCDEFGHIJABCDEFG
+I2 17 01234567890123456 ABCDEFGHIJABCDEFG
+PK 18 012345678901234567 ABCDEFGHIJABCDEFGH
+I1 18 012345678901234567 ABCDEFGHIJABCDEFGH
+I2 18 012345678901234567 ABCDEFGHIJABCDEFGH
+PK 19 0123456789012345678 ABCDEFGHIJABCDEFGHI
+I1 19 0123456789012345678 ABCDEFGHIJABCDEFGHI
+I2 19 0123456789012345678 ABCDEFGHIJABCDEFGHI
+PK 20 01234567890123456789 ABCDEFGHIJABCDEFGHIJ
+I1 20 01234567890123456789 ABCDEFGHIJABCDEFGHIJ
+I2 20 01234567890123456789 ABCDEFGHIJABCDEFGHIJ
+PK 21 012345678901234567890 ABCDEFGHIJABCDEFGHIJA
+I1 21 012345678901234567890 ABCDEFGHIJABCDEFGHIJA
+I2 21 012345678901234567890 ABCDEFGHIJABCDEFGHIJA
+PK 22 0123456789012345678901 ABCDEFGHIJABCDEFGHIJAB
+I1 22 0123456789012345678901 ABCDEFGHIJABCDEFGHIJAB
+I2 22 0123456789012345678901 ABCDEFGHIJABCDEFGHIJAB
+PK 23 01234567890123456789012 ABCDEFGHIJABCDEFGHIJABC
+I1 23 01234567890123456789012 ABCDEFGHIJABCDEFGHIJABC
+I2 23 01234567890123456789012 ABCDEFGHIJABCDEFGHIJABC
+PK 24 012345678901234567890123 ABCDEFGHIJABCDEFGHIJABCD
+I1 24 012345678901234567890123 ABCDEFGHIJABCDEFGHIJABCD
+I2 24 012345678901234567890123 ABCDEFGHIJABCDEFGHIJABCD
+PK 25 0123456789012345678901234 ABCDEFGHIJABCDEFGHIJABCDE
+I1 25 0123456789012345678901234 ABCDEFGHIJABCDEFGHIJABCDE
+I2 25 0123456789012345678901234 ABCDEFGHIJABCDEFGHIJABCDE
+PK 26 01234567890123456789012345 ABCDEFGHIJABCDEFGHIJABCDEF
+I1 26 01234567890123456789012345 ABCDEFGHIJABCDEFGHIJABCDEF
+I2 26 01234567890123456789012345 ABCDEFGHIJABCDEFGHIJABCDEF
+PK 27 012345678901234567890123456 ABCDEFGHIJABCDEFGHIJABCDEFG
+I1 27 012345678901234567890123456 ABCDEFGHIJABCDEFGHIJABCDEFG
+I2 27 012345678901234567890123456 ABCDEFGHIJABCDEFGHIJABCDEFG
+PK 28 0123456789012345678901234567 ABCDEFGHIJABCDEFGHIJABCDEFGH
+I1 28 0123456789012345678901234567 ABCDEFGHIJABCDEFGHIJABCDEFGH
+I2 28 0123456789012345678901234567 ABCDEFGHIJABCDEFGHIJABCDEFGH
+PK 29 01234567890123456789012345678 ABCDEFGHIJABCDEFGHIJABCDEFGHI
+I1 29 01234567890123456789012345678 ABCDEFGHIJABCDEFGHIJABCDEFGHI
+I2 29 01234567890123456789012345678 ABCDEFGHIJABCDEFGHIJABCDEFGHI
+PK 30 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+I1 30 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
+I2 30 012345678901234567890123456789 ABCDEFGHIJABCDEFGHIJABCDEFGHIJ
diff --git a/plugin/handler_socket/regtest/test_01_lib/test14.pl b/plugin/handler_socket/regtest/test_01_lib/test14.pl
new file mode 100644
index 00000000000..68ce87bdd63
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test14.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for bugfix: commit/c88efe637f6a184b55d2bd8d060bda3e556572d8
+# (some trailing bytes were dropped for varlen or nullable key fields)
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $table = 'hstesttbl';
+my $tablesize = 50;
+$dbh->do(
+ "create table $table (" .
+ "k int primary key, " .
+ "v1 varchar(30), " .
+ "v2 varchar(30), " .
+ "index i1(v1), index i2(v2, v1)) " .
+ "engine = myisam default charset = binary");
+srand(999);
+
+my %valmap = ();
+
+my $sth = $dbh->prepare("insert into $table values (?,?,?)");
+for (my $i = 0; $i < $tablesize; ++$i) {
+ my $k = $i;
+ my ($s1, $s2) = ("", "");
+ for (my $j = 0; $j < $i; ++$j) {
+ $s1 .= chr(48 + $j % 10);
+ $s2 .= chr(65 + $j % 10);
+ }
+ my $v1 = $s1;
+ my $v2 = $s2;
+ $sth->execute($k, $v1, $v2);
+ $valmap{$k} = [ $v1, $v2 ];
+}
+
+dump_table();
+
+my $hs = hstest::get_hs_connection(undef, 9999);
+my $dbname = $hstest::conf{dbname};
+$hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
+$hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
+$hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
+
+for (my $i = 0; $i <= 30; ++$i) {
+ my ($v1, $v2) = @{$valmap{$i}};
+ my ($rk, $rv1, $rv2);
+ my $r = $hs->execute_single(1, '=', [ $i ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "PK $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(2, '=', [ $v1 ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I1 $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(3, '=', [ $v2, $v1 ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I2 $rk $rv1 $rv2\n";
+}
+
+sub dump_table {
+ print "DUMP_TABLE\n";
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
+ for my $row (@$aref) {
+ my ($k, $v1, $v2) = @$row;
+ $v1 = "[null]" if !defined($v1);
+ $v2 = "[null]" if !defined($v2);
+ print "$k $v1 $v2\n";
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
+ }
+}
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test15.expected b/plugin/handler_socket/regtest/test_01_lib/test15.expected
new file mode 100644
index 00000000000..ea15afef5d8
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test15.expected
@@ -0,0 +1,764 @@
+TYPE TINYINT
+DUMP_TABLE_BEGIN
+-128 s-128 -128
+-42 s-42 -42
+-14 s-14 -14
+-4 s-4 -4
+-1 s-1 -1
+0 s0 0
+1 s1 1
+4 s4 4
+14 s14 14
+42 s42 42
+127 s127 127
+DUMP_TABLE_END
+PK[-128] -128 s-128 -128
+I1[s-128] -128 s-128 -128
+I2[-128, s-128] -128 s-128 -128
+I2p[-128] -128 s-128 -128
+PK[-42] -42 s-42 -42
+I1[s-42] -42 s-42 -42
+I2[-42, s-42] -42 s-42 -42
+I2p[-42] -42 s-42 -42
+PK[-14] -14 s-14 -14
+I1[s-14] -14 s-14 -14
+I2[-14, s-14] -14 s-14 -14
+I2p[-14] -14 s-14 -14
+PK[-4] -4 s-4 -4
+I1[s-4] -4 s-4 -4
+I2[-4, s-4] -4 s-4 -4
+I2p[-4] -4 s-4 -4
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[4] 4 s4 4
+I1[s4] 4 s4 4
+I2[4, s4] 4 s4 4
+I2p[4] 4 s4 4
+PK[14] 14 s14 14
+I1[s14] 14 s14 14
+I2[14, s14] 14 s14 14
+I2p[14] 14 s14 14
+PK[42] 42 s42 42
+I1[s42] 42 s42 42
+I2[42, s42] 42 s42 42
+I2p[42] 42 s42 42
+PK[127] 127 s127 127
+I1[s127] 127 s127 127
+I2[127, s127] 127 s127 127
+I2p[127] 127 s127 127
+
+TYPE TINYINT UNSIGNED
+DUMP_TABLE_BEGIN
+0 s0 0
+1 s1 1
+3 s3 3
+9 s9 9
+28 s28 28
+85 s85 85
+255 s255 255
+DUMP_TABLE_END
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[3] 3 s3 3
+I1[s3] 3 s3 3
+I2[3, s3] 3 s3 3
+I2p[3] 3 s3 3
+PK[9] 9 s9 9
+I1[s9] 9 s9 9
+I2[9, s9] 9 s9 9
+I2p[9] 9 s9 9
+PK[28] 28 s28 28
+I1[s28] 28 s28 28
+I2[28, s28] 28 s28 28
+I2p[28] 28 s28 28
+PK[85] 85 s85 85
+I1[s85] 85 s85 85
+I2[85, s85] 85 s85 85
+I2p[85] 85 s85 85
+PK[255] 255 s255 255
+I1[s255] 255 s255 255
+I2[255, s255] 255 s255 255
+I2p[255] 255 s255 255
+
+TYPE SMALLINT
+DUMP_TABLE_BEGIN
+-32768 s-32768 -32768
+-10922 s-10922 -10922
+-3640 s-3640 -3640
+-1213 s-1213 -1213
+-404 s-404 -404
+-134 s-134 -134
+-1 s-1 -1
+0 s0 0
+1 s1 1
+134 s134 134
+404 s404 404
+1213 s1213 1213
+3640 s3640 3640
+10922 s10922 10922
+32767 s32768 32767
+DUMP_TABLE_END
+PK[-32768] -32768 s-32768 -32768
+I1[s-32768] -32768 s-32768 -32768
+I2[-32768, s-32768] -32768 s-32768 -32768
+I2p[-32768] -32768 s-32768 -32768
+PK[-10922] -10922 s-10922 -10922
+I1[s-10922] -10922 s-10922 -10922
+I2[-10922, s-10922] -10922 s-10922 -10922
+I2p[-10922] -10922 s-10922 -10922
+PK[-3640] -3640 s-3640 -3640
+I1[s-3640] -3640 s-3640 -3640
+I2[-3640, s-3640] -3640 s-3640 -3640
+I2p[-3640] -3640 s-3640 -3640
+PK[-1213] -1213 s-1213 -1213
+I1[s-1213] -1213 s-1213 -1213
+I2[-1213, s-1213] -1213 s-1213 -1213
+I2p[-1213] -1213 s-1213 -1213
+PK[-404] -404 s-404 -404
+I1[s-404] -404 s-404 -404
+I2[-404, s-404] -404 s-404 -404
+I2p[-404] -404 s-404 -404
+PK[-134] -134 s-134 -134
+I1[s-134] -134 s-134 -134
+I2[-134, s-134] -134 s-134 -134
+I2p[-134] -134 s-134 -134
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[134] 134 s134 134
+I1[s134] 134 s134 134
+I2[134, s134] 134 s134 134
+I2p[134] 134 s134 134
+PK[404] 404 s404 404
+I1[s404] 404 s404 404
+I2[404, s404] 404 s404 404
+I2p[404] 404 s404 404
+PK[1213] 1213 s1213 1213
+I1[s1213] 1213 s1213 1213
+I2[1213, s1213] 1213 s1213 1213
+I2p[1213] 1213 s1213 1213
+PK[3640] 3640 s3640 3640
+I1[s3640] 3640 s3640 3640
+I2[3640, s3640] 3640 s3640 3640
+I2p[3640] 3640 s3640 3640
+PK[10922] 10922 s10922 10922
+I1[s10922] 10922 s10922 10922
+I2[10922, s10922] 10922 s10922 10922
+I2p[10922] 10922 s10922 10922
+PK[32768] 32767 s32768 32767
+I1[s32768] 32767 s32768 32767
+I2[32768, s32768] 32767 s32768 32767
+I2p[32768] 32767 s32768 32767
+
+TYPE SMALLINT UNSIGNED
+DUMP_TABLE_BEGIN
+0 s0 0
+1 s1 1
+269 s269 269
+809 s809 809
+2427 s2427 2427
+7281 s7281 7281
+21845 s21845 21845
+65535 s65535 65535
+DUMP_TABLE_END
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[269] 269 s269 269
+I1[s269] 269 s269 269
+I2[269, s269] 269 s269 269
+I2p[269] 269 s269 269
+PK[809] 809 s809 809
+I1[s809] 809 s809 809
+I2[809, s809] 809 s809 809
+I2p[809] 809 s809 809
+PK[2427] 2427 s2427 2427
+I1[s2427] 2427 s2427 2427
+I2[2427, s2427] 2427 s2427 2427
+I2p[2427] 2427 s2427 2427
+PK[7281] 7281 s7281 7281
+I1[s7281] 7281 s7281 7281
+I2[7281, s7281] 7281 s7281 7281
+I2p[7281] 7281 s7281 7281
+PK[21845] 21845 s21845 21845
+I1[s21845] 21845 s21845 21845
+I2[21845, s21845] 21845 s21845 21845
+I2p[21845] 21845 s21845 21845
+PK[65535] 65535 s65535 65535
+I1[s65535] 65535 s65535 65535
+I2[65535, s65535] 65535 s65535 65535
+I2p[65535] 65535 s65535 65535
+
+TYPE MEDIUMINT
+DUMP_TABLE_BEGIN
+-8388608 s-8388608 -8388608
+-2796202 s-2796202 -2796202
+-932067 s-932067 -932067
+-310689 s-310689 -310689
+-103563 s-103563 -103563
+-34521 s-34521 -34521
+-1 s-1 -1
+0 s0 0
+1 s1 1
+34521 s34521 34521
+103563 s103563 103563
+310689 s310689 310689
+932067 s932067 932067
+2796202 s2796202 2796202
+8388607 s8388607 8388607
+DUMP_TABLE_END
+PK[-8388608] -8388608 s-8388608 -8388608
+I1[s-8388608] -8388608 s-8388608 -8388608
+I2[-8388608, s-8388608] -8388608 s-8388608 -8388608
+I2p[-8388608] -8388608 s-8388608 -8388608
+PK[-2796202] -2796202 s-2796202 -2796202
+I1[s-2796202] -2796202 s-2796202 -2796202
+I2[-2796202, s-2796202] -2796202 s-2796202 -2796202
+I2p[-2796202] -2796202 s-2796202 -2796202
+PK[-932067] -932067 s-932067 -932067
+I1[s-932067] -932067 s-932067 -932067
+I2[-932067, s-932067] -932067 s-932067 -932067
+I2p[-932067] -932067 s-932067 -932067
+PK[-310689] -310689 s-310689 -310689
+I1[s-310689] -310689 s-310689 -310689
+I2[-310689, s-310689] -310689 s-310689 -310689
+I2p[-310689] -310689 s-310689 -310689
+PK[-103563] -103563 s-103563 -103563
+I1[s-103563] -103563 s-103563 -103563
+I2[-103563, s-103563] -103563 s-103563 -103563
+I2p[-103563] -103563 s-103563 -103563
+PK[-34521] -34521 s-34521 -34521
+I1[s-34521] -34521 s-34521 -34521
+I2[-34521, s-34521] -34521 s-34521 -34521
+I2p[-34521] -34521 s-34521 -34521
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[34521] 34521 s34521 34521
+I1[s34521] 34521 s34521 34521
+I2[34521, s34521] 34521 s34521 34521
+I2p[34521] 34521 s34521 34521
+PK[103563] 103563 s103563 103563
+I1[s103563] 103563 s103563 103563
+I2[103563, s103563] 103563 s103563 103563
+I2p[103563] 103563 s103563 103563
+PK[310689] 310689 s310689 310689
+I1[s310689] 310689 s310689 310689
+I2[310689, s310689] 310689 s310689 310689
+I2p[310689] 310689 s310689 310689
+PK[932067] 932067 s932067 932067
+I1[s932067] 932067 s932067 932067
+I2[932067, s932067] 932067 s932067 932067
+I2p[932067] 932067 s932067 932067
+PK[2796202] 2796202 s2796202 2796202
+I1[s2796202] 2796202 s2796202 2796202
+I2[2796202, s2796202] 2796202 s2796202 2796202
+I2p[2796202] 2796202 s2796202 2796202
+PK[8388607] 8388607 s8388607 8388607
+I1[s8388607] 8388607 s8388607 8388607
+I2[8388607, s8388607] 8388607 s8388607 8388607
+I2p[8388607] 8388607 s8388607 8388607
+
+TYPE MEDIUMINT UNSIGNED
+DUMP_TABLE_BEGIN
+0 s0 0
+1 s1 1
+69042 s69042 69042
+207126 s207126 207126
+621378 s621378 621378
+1864135 s1864135 1864135
+5592405 s5592405 5592405
+16777215 s16777215 16777215
+DUMP_TABLE_END
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[69042] 69042 s69042 69042
+I1[s69042] 69042 s69042 69042
+I2[69042, s69042] 69042 s69042 69042
+I2p[69042] 69042 s69042 69042
+PK[207126] 207126 s207126 207126
+I1[s207126] 207126 s207126 207126
+I2[207126, s207126] 207126 s207126 207126
+I2p[207126] 207126 s207126 207126
+PK[621378] 621378 s621378 621378
+I1[s621378] 621378 s621378 621378
+I2[621378, s621378] 621378 s621378 621378
+I2p[621378] 621378 s621378 621378
+PK[1864135] 1864135 s1864135 1864135
+I1[s1864135] 1864135 s1864135 1864135
+I2[1864135, s1864135] 1864135 s1864135 1864135
+I2p[1864135] 1864135 s1864135 1864135
+PK[5592405] 5592405 s5592405 5592405
+I1[s5592405] 5592405 s5592405 5592405
+I2[5592405, s5592405] 5592405 s5592405 5592405
+I2p[5592405] 5592405 s5592405 5592405
+PK[16777215] 16777215 s16777215 16777215
+I1[s16777215] 16777215 s16777215 16777215
+I2[16777215, s16777215] 16777215 s16777215 16777215
+I2p[16777215] 16777215 s16777215 16777215
+
+TYPE INT
+DUMP_TABLE_BEGIN
+-2147483648 s-2147483648 -2147483648
+-715827882 s-715827882 -715827882
+-238609294 s-238609294 -238609294
+-79536431 s-79536431 -79536431
+-26512143 s-26512143 -26512143
+-8837381 s-8837381 -8837381
+-1 s-1 -1
+0 s0 0
+1 s1 1
+8837381 s8837381 8837381
+26512143 s26512143 26512143
+79536431 s79536431 79536431
+238609294 s238609294 238609294
+715827882 s715827882 715827882
+2147483647 s2147483647 2147483647
+DUMP_TABLE_END
+PK[-2147483648] -2147483648 s-2147483648 -2147483648
+I1[s-2147483648] -2147483648 s-2147483648 -2147483648
+I2[-2147483648, s-2147483648] -2147483648 s-2147483648 -2147483648
+I2p[-2147483648] -2147483648 s-2147483648 -2147483648
+PK[-715827882] -715827882 s-715827882 -715827882
+I1[s-715827882] -715827882 s-715827882 -715827882
+I2[-715827882, s-715827882] -715827882 s-715827882 -715827882
+I2p[-715827882] -715827882 s-715827882 -715827882
+PK[-238609294] -238609294 s-238609294 -238609294
+I1[s-238609294] -238609294 s-238609294 -238609294
+I2[-238609294, s-238609294] -238609294 s-238609294 -238609294
+I2p[-238609294] -238609294 s-238609294 -238609294
+PK[-79536431] -79536431 s-79536431 -79536431
+I1[s-79536431] -79536431 s-79536431 -79536431
+I2[-79536431, s-79536431] -79536431 s-79536431 -79536431
+I2p[-79536431] -79536431 s-79536431 -79536431
+PK[-26512143] -26512143 s-26512143 -26512143
+I1[s-26512143] -26512143 s-26512143 -26512143
+I2[-26512143, s-26512143] -26512143 s-26512143 -26512143
+I2p[-26512143] -26512143 s-26512143 -26512143
+PK[-8837381] -8837381 s-8837381 -8837381
+I1[s-8837381] -8837381 s-8837381 -8837381
+I2[-8837381, s-8837381] -8837381 s-8837381 -8837381
+I2p[-8837381] -8837381 s-8837381 -8837381
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[8837381] 8837381 s8837381 8837381
+I1[s8837381] 8837381 s8837381 8837381
+I2[8837381, s8837381] 8837381 s8837381 8837381
+I2p[8837381] 8837381 s8837381 8837381
+PK[26512143] 26512143 s26512143 26512143
+I1[s26512143] 26512143 s26512143 26512143
+I2[26512143, s26512143] 26512143 s26512143 26512143
+I2p[26512143] 26512143 s26512143 26512143
+PK[79536431] 79536431 s79536431 79536431
+I1[s79536431] 79536431 s79536431 79536431
+I2[79536431, s79536431] 79536431 s79536431 79536431
+I2p[79536431] 79536431 s79536431 79536431
+PK[238609294] 238609294 s238609294 238609294
+I1[s238609294] 238609294 s238609294 238609294
+I2[238609294, s238609294] 238609294 s238609294 238609294
+I2p[238609294] 238609294 s238609294 238609294
+PK[715827882] 715827882 s715827882 715827882
+I1[s715827882] 715827882 s715827882 715827882
+I2[715827882, s715827882] 715827882 s715827882 715827882
+I2p[715827882] 715827882 s715827882 715827882
+PK[2147483647] 2147483647 s2147483647 2147483647
+I1[s2147483647] 2147483647 s2147483647 2147483647
+I2[2147483647, s2147483647] 2147483647 s2147483647 2147483647
+I2p[2147483647] 2147483647 s2147483647 2147483647
+
+TYPE INT UNSIGNED
+DUMP_TABLE_BEGIN
+0 s0 0
+1 s1 1
+17674762 s17674762 17674762
+53024287 s53024287 53024287
+159072862 s159072862 159072862
+477218588 s477218588 477218588
+1431655765 s1431655765 1431655765
+4294967295 s4294967295 4294967295
+DUMP_TABLE_END
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[17674762] 17674762 s17674762 17674762
+I1[s17674762] 17674762 s17674762 17674762
+I2[17674762, s17674762] 17674762 s17674762 17674762
+I2p[17674762] 17674762 s17674762 17674762
+PK[53024287] 53024287 s53024287 53024287
+I1[s53024287] 53024287 s53024287 53024287
+I2[53024287, s53024287] 53024287 s53024287 53024287
+I2p[53024287] 53024287 s53024287 53024287
+PK[159072862] 159072862 s159072862 159072862
+I1[s159072862] 159072862 s159072862 159072862
+I2[159072862, s159072862] 159072862 s159072862 159072862
+I2p[159072862] 159072862 s159072862 159072862
+PK[477218588] 477218588 s477218588 477218588
+I1[s477218588] 477218588 s477218588 477218588
+I2[477218588, s477218588] 477218588 s477218588 477218588
+I2p[477218588] 477218588 s477218588 477218588
+PK[1431655765] 1431655765 s1431655765 1431655765
+I1[s1431655765] 1431655765 s1431655765 1431655765
+I2[1431655765, s1431655765] 1431655765 s1431655765 1431655765
+I2p[1431655765] 1431655765 s1431655765 1431655765
+PK[4294967295] 4294967295 s4294967295 4294967295
+I1[s4294967295] 4294967295 s4294967295 4294967295
+I2[4294967295, s4294967295] 4294967295 s4294967295 4294967295
+I2p[4294967295] 4294967295 s4294967295 4294967295
+
+TYPE BIGINT
+DUMP_TABLE_BEGIN
+-9223372036854775808 s-9223372036854775808 -9223372036854775808
+-3074457345618258602 s-3074457345618258602 -3074457345618258602
+-1024819115206086200 s-1024819115206086200 -1024819115206086200
+-341606371735362066 s-341606371735362066 -341606371735362066
+-113868790578454022 s-113868790578454022 -113868790578454022
+-37956263526151340 s-37956263526151340 -37956263526151340
+-1 s-1 -1
+0 s0 0
+1 s1 1
+37956263526151340 s37956263526151340 37956263526151340
+113868790578454022 s113868790578454022 113868790578454022
+341606371735362066 s341606371735362066 341606371735362066
+1024819115206086200 s1024819115206086200 1024819115206086200
+3074457345618258602 s3074457345618258602 3074457345618258602
+9223372036854775807 s9223372036854775807 9223372036854775807
+DUMP_TABLE_END
+PK[-9223372036854775808] -9223372036854775808 s-9223372036854775808 -9223372036854775808
+I1[s-9223372036854775808] -9223372036854775808 s-9223372036854775808 -9223372036854775808
+I2[-9223372036854775808, s-9223372036854775808] -9223372036854775808 s-9223372036854775808 -9223372036854775808
+I2p[-9223372036854775808] -9223372036854775808 s-9223372036854775808 -9223372036854775808
+PK[-3074457345618258602] -3074457345618258602 s-3074457345618258602 -3074457345618258602
+I1[s-3074457345618258602] -3074457345618258602 s-3074457345618258602 -3074457345618258602
+I2[-3074457345618258602, s-3074457345618258602] -3074457345618258602 s-3074457345618258602 -3074457345618258602
+I2p[-3074457345618258602] -3074457345618258602 s-3074457345618258602 -3074457345618258602
+PK[-1024819115206086200] -1024819115206086200 s-1024819115206086200 -1024819115206086200
+I1[s-1024819115206086200] -1024819115206086200 s-1024819115206086200 -1024819115206086200
+I2[-1024819115206086200, s-1024819115206086200] -1024819115206086200 s-1024819115206086200 -1024819115206086200
+I2p[-1024819115206086200] -1024819115206086200 s-1024819115206086200 -1024819115206086200
+PK[-341606371735362066] -341606371735362066 s-341606371735362066 -341606371735362066
+I1[s-341606371735362066] -341606371735362066 s-341606371735362066 -341606371735362066
+I2[-341606371735362066, s-341606371735362066] -341606371735362066 s-341606371735362066 -341606371735362066
+I2p[-341606371735362066] -341606371735362066 s-341606371735362066 -341606371735362066
+PK[-113868790578454022] -113868790578454022 s-113868790578454022 -113868790578454022
+I1[s-113868790578454022] -113868790578454022 s-113868790578454022 -113868790578454022
+I2[-113868790578454022, s-113868790578454022] -113868790578454022 s-113868790578454022 -113868790578454022
+I2p[-113868790578454022] -113868790578454022 s-113868790578454022 -113868790578454022
+PK[-37956263526151340] -37956263526151340 s-37956263526151340 -37956263526151340
+I1[s-37956263526151340] -37956263526151340 s-37956263526151340 -37956263526151340
+I2[-37956263526151340, s-37956263526151340] -37956263526151340 s-37956263526151340 -37956263526151340
+I2p[-37956263526151340] -37956263526151340 s-37956263526151340 -37956263526151340
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[37956263526151340] 37956263526151340 s37956263526151340 37956263526151340
+I1[s37956263526151340] 37956263526151340 s37956263526151340 37956263526151340
+I2[37956263526151340, s37956263526151340] 37956263526151340 s37956263526151340 37956263526151340
+I2p[37956263526151340] 37956263526151340 s37956263526151340 37956263526151340
+PK[113868790578454022] 113868790578454022 s113868790578454022 113868790578454022
+I1[s113868790578454022] 113868790578454022 s113868790578454022 113868790578454022
+I2[113868790578454022, s113868790578454022] 113868790578454022 s113868790578454022 113868790578454022
+I2p[113868790578454022] 113868790578454022 s113868790578454022 113868790578454022
+PK[341606371735362066] 341606371735362066 s341606371735362066 341606371735362066
+I1[s341606371735362066] 341606371735362066 s341606371735362066 341606371735362066
+I2[341606371735362066, s341606371735362066] 341606371735362066 s341606371735362066 341606371735362066
+I2p[341606371735362066] 341606371735362066 s341606371735362066 341606371735362066
+PK[1024819115206086200] 1024819115206086200 s1024819115206086200 1024819115206086200
+I1[s1024819115206086200] 1024819115206086200 s1024819115206086200 1024819115206086200
+I2[1024819115206086200, s1024819115206086200] 1024819115206086200 s1024819115206086200 1024819115206086200
+I2p[1024819115206086200] 1024819115206086200 s1024819115206086200 1024819115206086200
+PK[3074457345618258602] 3074457345618258602 s3074457345618258602 3074457345618258602
+I1[s3074457345618258602] 3074457345618258602 s3074457345618258602 3074457345618258602
+I2[3074457345618258602, s3074457345618258602] 3074457345618258602 s3074457345618258602 3074457345618258602
+I2p[3074457345618258602] 3074457345618258602 s3074457345618258602 3074457345618258602
+PK[9223372036854775807] 9223372036854775807 s9223372036854775807 9223372036854775807
+I1[s9223372036854775807] 9223372036854775807 s9223372036854775807 9223372036854775807
+I2[9223372036854775807, s9223372036854775807] 9223372036854775807 s9223372036854775807 9223372036854775807
+I2p[9223372036854775807] 9223372036854775807 s9223372036854775807 9223372036854775807
+
+TYPE BIGINT UNSIGNED
+DUMP_TABLE_BEGIN
+0 s0 0
+1 s1 1
+75912527052302681 s75912527052302681 75912527052302681
+227737581156908044 s227737581156908044 227737581156908044
+683212743470724133 s683212743470724133 683212743470724133
+2049638230412172401 s2049638230412172401 2049638230412172401
+6148914691236517205 s6148914691236517205 6148914691236517205
+18446744073709551615 s18446744073709551615 18446744073709551615
+DUMP_TABLE_END
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[75912527052302681] 75912527052302681 s75912527052302681 75912527052302681
+I1[s75912527052302681] 75912527052302681 s75912527052302681 75912527052302681
+I2[75912527052302681, s75912527052302681] 75912527052302681 s75912527052302681 75912527052302681
+I2p[75912527052302681] 75912527052302681 s75912527052302681 75912527052302681
+PK[227737581156908044] 227737581156908044 s227737581156908044 227737581156908044
+I1[s227737581156908044] 227737581156908044 s227737581156908044 227737581156908044
+I2[227737581156908044, s227737581156908044] 227737581156908044 s227737581156908044 227737581156908044
+I2p[227737581156908044] 227737581156908044 s227737581156908044 227737581156908044
+PK[683212743470724133] 683212743470724133 s683212743470724133 683212743470724133
+I1[s683212743470724133] 683212743470724133 s683212743470724133 683212743470724133
+I2[683212743470724133, s683212743470724133] 683212743470724133 s683212743470724133 683212743470724133
+I2p[683212743470724133] 683212743470724133 s683212743470724133 683212743470724133
+PK[2049638230412172401] 2049638230412172401 s2049638230412172401 2049638230412172401
+I1[s2049638230412172401] 2049638230412172401 s2049638230412172401 2049638230412172401
+I2[2049638230412172401, s2049638230412172401] 2049638230412172401 s2049638230412172401 2049638230412172401
+I2p[2049638230412172401] 2049638230412172401 s2049638230412172401 2049638230412172401
+PK[6148914691236517205] 6148914691236517205 s6148914691236517205 6148914691236517205
+I1[s6148914691236517205] 6148914691236517205 s6148914691236517205 6148914691236517205
+I2[6148914691236517205, s6148914691236517205] 6148914691236517205 s6148914691236517205 6148914691236517205
+I2p[6148914691236517205] 6148914691236517205 s6148914691236517205 6148914691236517205
+PK[18446744073709551615] 18446744073709551615 s18446744073709551615 18446744073709551615
+I1[s18446744073709551615] 18446744073709551615 s18446744073709551615 18446744073709551615
+I2[18446744073709551615, s18446744073709551615] 18446744073709551615 s18446744073709551615 18446744073709551615
+I2p[18446744073709551615] 18446744073709551615 s18446744073709551615 18446744073709551615
+
+TYPE FLOAT
+DUMP_TABLE_BEGIN
+-32768 s-32768 -32768
+-10922 s-10922 -10922
+-3640 s-3640 -3640
+-1213 s-1213 -1213
+-404 s-404 -404
+-134 s-134 -134
+-1 s-1 -1
+0 s0 0
+1 s1 1
+134 s134 134
+404 s404 404
+1213 s1213 1213
+3640 s3640 3640
+10922 s10922 10922
+32768 s32768 32768
+DUMP_TABLE_END
+PK[-32768] -32768 s-32768 -32768
+I1[s-32768] -32768 s-32768 -32768
+I2[-32768, s-32768] -32768 s-32768 -32768
+I2p[-32768] -32768 s-32768 -32768
+PK[-10922] -10922 s-10922 -10922
+I1[s-10922] -10922 s-10922 -10922
+I2[-10922, s-10922] -10922 s-10922 -10922
+I2p[-10922] -10922 s-10922 -10922
+PK[-3640] -3640 s-3640 -3640
+I1[s-3640] -3640 s-3640 -3640
+I2[-3640, s-3640] -3640 s-3640 -3640
+I2p[-3640] -3640 s-3640 -3640
+PK[-1213] -1213 s-1213 -1213
+I1[s-1213] -1213 s-1213 -1213
+I2[-1213, s-1213] -1213 s-1213 -1213
+I2p[-1213] -1213 s-1213 -1213
+PK[-404] -404 s-404 -404
+I1[s-404] -404 s-404 -404
+I2[-404, s-404] -404 s-404 -404
+I2p[-404] -404 s-404 -404
+PK[-134] -134 s-134 -134
+I1[s-134] -134 s-134 -134
+I2[-134, s-134] -134 s-134 -134
+I2p[-134] -134 s-134 -134
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[134] 134 s134 134
+I1[s134] 134 s134 134
+I2[134, s134] 134 s134 134
+I2p[134] 134 s134 134
+PK[404] 404 s404 404
+I1[s404] 404 s404 404
+I2[404, s404] 404 s404 404
+I2p[404] 404 s404 404
+PK[1213] 1213 s1213 1213
+I1[s1213] 1213 s1213 1213
+I2[1213, s1213] 1213 s1213 1213
+I2p[1213] 1213 s1213 1213
+PK[3640] 3640 s3640 3640
+I1[s3640] 3640 s3640 3640
+I2[3640, s3640] 3640 s3640 3640
+I2p[3640] 3640 s3640 3640
+PK[10922] 10922 s10922 10922
+I1[s10922] 10922 s10922 10922
+I2[10922, s10922] 10922 s10922 10922
+I2p[10922] 10922 s10922 10922
+PK[32768] 32768 s32768 32768
+I1[s32768] 32768 s32768 32768
+I2[32768, s32768] 32768 s32768 32768
+I2p[32768] 32768 s32768 32768
+
+TYPE DOUBLE
+DUMP_TABLE_BEGIN
+-2147483648 s-2147483648 -2147483648
+-715827882 s-715827882 -715827882
+-238609294 s-238609294 -238609294
+-79536431 s-79536431 -79536431
+-26512143 s-26512143 -26512143
+-8837381 s-8837381 -8837381
+-1 s-1 -1
+0 s0 0
+1 s1 1
+8837381 s8837381 8837381
+26512143 s26512143 26512143
+79536431 s79536431 79536431
+238609294 s238609294 238609294
+715827882 s715827882 715827882
+2147483647 s2147483647 2147483647
+DUMP_TABLE_END
+PK[-2147483648] -2147483648 s-2147483648 -2147483648
+I1[s-2147483648] -2147483648 s-2147483648 -2147483648
+I2[-2147483648, s-2147483648] -2147483648 s-2147483648 -2147483648
+I2p[-2147483648] -2147483648 s-2147483648 -2147483648
+PK[-715827882] -715827882 s-715827882 -715827882
+I1[s-715827882] -715827882 s-715827882 -715827882
+I2[-715827882, s-715827882] -715827882 s-715827882 -715827882
+I2p[-715827882] -715827882 s-715827882 -715827882
+PK[-238609294] -238609294 s-238609294 -238609294
+I1[s-238609294] -238609294 s-238609294 -238609294
+I2[-238609294, s-238609294] -238609294 s-238609294 -238609294
+I2p[-238609294] -238609294 s-238609294 -238609294
+PK[-79536431] -79536431 s-79536431 -79536431
+I1[s-79536431] -79536431 s-79536431 -79536431
+I2[-79536431, s-79536431] -79536431 s-79536431 -79536431
+I2p[-79536431] -79536431 s-79536431 -79536431
+PK[-26512143] -26512143 s-26512143 -26512143
+I1[s-26512143] -26512143 s-26512143 -26512143
+I2[-26512143, s-26512143] -26512143 s-26512143 -26512143
+I2p[-26512143] -26512143 s-26512143 -26512143
+PK[-8837381] -8837381 s-8837381 -8837381
+I1[s-8837381] -8837381 s-8837381 -8837381
+I2[-8837381, s-8837381] -8837381 s-8837381 -8837381
+I2p[-8837381] -8837381 s-8837381 -8837381
+PK[-1] -1 s-1 -1
+I1[s-1] -1 s-1 -1
+I2[-1, s-1] -1 s-1 -1
+I2p[-1] -1 s-1 -1
+PK[0] 0 s0 0
+I1[s0] 0 s0 0
+I2[0, s0] 0 s0 0
+I2p[0] 0 s0 0
+PK[1] 1 s1 1
+I1[s1] 1 s1 1
+I2[1, s1] 1 s1 1
+I2p[1] 1 s1 1
+PK[8837381] 8837381 s8837381 8837381
+I1[s8837381] 8837381 s8837381 8837381
+I2[8837381, s8837381] 8837381 s8837381 8837381
+I2p[8837381] 8837381 s8837381 8837381
+PK[26512143] 26512143 s26512143 26512143
+I1[s26512143] 26512143 s26512143 26512143
+I2[26512143, s26512143] 26512143 s26512143 26512143
+I2p[26512143] 26512143 s26512143 26512143
+PK[79536431] 79536431 s79536431 79536431
+I1[s79536431] 79536431 s79536431 79536431
+I2[79536431, s79536431] 79536431 s79536431 79536431
+I2p[79536431] 79536431 s79536431 79536431
+PK[238609294] 238609294 s238609294 238609294
+I1[s238609294] 238609294 s238609294 238609294
+I2[238609294, s238609294] 238609294 s238609294 238609294
+I2p[238609294] 238609294 s238609294 238609294
+PK[715827882] 715827882 s715827882 715827882
+I1[s715827882] 715827882 s715827882 715827882
+I2[715827882, s715827882] 715827882 s715827882 715827882
+I2p[715827882] 715827882 s715827882 715827882
+PK[2147483647] 2147483647 s2147483647 2147483647
+I1[s2147483647] 2147483647 s2147483647 2147483647
+I2[2147483647, s2147483647] 2147483647 s2147483647 2147483647
+I2p[2147483647] 2147483647 s2147483647 2147483647
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test15.pl b/plugin/handler_socket/regtest/test_01_lib/test15.pl
new file mode 100644
index 00000000000..4c56d355708
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test15.pl
@@ -0,0 +1,114 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for various numeric types
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use bigint;
+use hstest;
+
+my $numeric_types = [
+ [ 'TINYINT', -128, 127 ],
+ [ 'TINYINT UNSIGNED', 0, 255 ],
+ [ 'SMALLINT', -32768, 32768 ],
+ [ 'SMALLINT UNSIGNED', 0, 65535 ],
+ [ 'MEDIUMINT', -8388608, 8388607 ],
+ [ 'MEDIUMINT UNSIGNED', 0, 16777215 ],
+ [ 'INT', -2147483648, 2147483647 ],
+ [ 'INT UNSIGNED', 0, 4294967295 ],
+ [ 'BIGINT', -9223372036854775808, 9223372036854775807 ],
+ [ 'BIGINT UNSIGNED', 0, 18446744073709551615 ],
+ [ 'FLOAT', -32768, 32768 ],
+ [ 'DOUBLE', -2147483648, 2147483647 ],
+];
+
+my $table = 'hstesttbl';
+my $dbh;
+for my $rec (@$numeric_types) {
+ my ($typ, $minval, $maxval) = @$rec;
+ my @vals = ();
+ push(@vals, 0);
+ push(@vals, 1);
+ push(@vals, $maxval);
+ if ($minval != 0) {
+ push(@vals, -1);
+ push(@vals, $minval);
+ }
+ my $v1 = $minval;
+ my $v2 = $maxval;
+ for (my $i = 0; $i < 5; ++$i) {
+ $v1 /= 3;
+ $v2 /= 3;
+ if ($v1 != 0) {
+ push(@vals, int($v1));
+ }
+ push(@vals, int($v2));
+ }
+ @vals = sort { $a <=> $b } @vals;
+ print("TYPE $typ\n");
+ test_one($typ, \@vals);
+ print("\n");
+}
+
+sub test_one {
+ my ($typ, $values) = @_;
+ $dbh = hstest::init_testdb();
+ $dbh->do(
+ "create table $table (" .
+ "k $typ primary key, " .
+ "v1 varchar(512), " .
+ "v2 $typ, " .
+ "index i1(v1), index i2(v2, v1)) " .
+ "engine = myisam default charset = binary");
+ my $hs = hstest::get_hs_connection(undef, 9999);
+ my $dbname = $hstest::conf{dbname};
+ $hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
+ $hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
+ $hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
+ for my $k (@$values) {
+ my $kstr = 's' . $k;
+ $hs->execute_single(1, '+', [ $k, $kstr, $k ], 0, 0);
+ }
+ dump_table();
+ for my $k (@$values) {
+ my $kstr = 's' . $k;
+ my ($rk, $rv1, $rv2);
+ my $r;
+ $r = $hs->execute_single(1, '=', [ $k ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "PK[$k] $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(2, '=', [ $kstr ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I1[$kstr] $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(3, '=', [ $k, $kstr ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I2[$k, $kstr] $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(3, '=', [ $k ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I2p[$k] $rk $rv1 $rv2\n";
+ }
+}
+
+sub dump_table {
+ print "DUMP_TABLE_BEGIN\n";
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
+ for my $row (@$aref) {
+ my ($k, $v1, $v2) = @$row;
+ $v1 = "[null]" if !defined($v1);
+ $v2 = "[null]" if !defined($v2);
+ print "$k $v1 $v2\n";
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
+ }
+ print "DUMP_TABLE_END\n";
+}
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test16.expected b/plugin/handler_socket/regtest/test_01_lib/test16.expected
new file mode 100644
index 00000000000..b708b95cdf3
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test16.expected
@@ -0,0 +1,66 @@
+TYPE DATE
+DUMP_TABLE_BEGIN
+0000-00-00 s0000-00-00 0000-00-00
+2011-01-01 s2011-01-01 2011-01-01
+9999-12-31 s9999-12-31 9999-12-31
+DUMP_TABLE_END
+PK[0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
+I1[s0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
+I2[0000-00-00, s0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
+I2p[0000-00-00] 0000-00-00 s0000-00-00 0000-00-00
+PK[2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
+I1[s2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
+I2[2011-01-01, s2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
+I2p[2011-01-01] 2011-01-01 s2011-01-01 2011-01-01
+PK[9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
+I1[s9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
+I2[9999-12-31, s9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
+I2p[9999-12-31] 9999-12-31 s9999-12-31 9999-12-31
+
+TYPE DATETIME
+DUMP_TABLE_BEGIN
+0000-00-00 00:00:00 s0 0000-00-00 00:00:00
+2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
+DUMP_TABLE_END
+PK[0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
+I1[s0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
+I2[0, s0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
+I2p[0] 0000-00-00 00:00:00 s0 0000-00-00 00:00:00
+PK[2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
+I1[s2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
+I2[2011-01-01 18:30:25, s2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
+I2p[2011-01-01 18:30:25] 2011-01-01 18:30:25 s2011-01-01 18:30:25 2011-01-01 18:30:25
+
+TYPE TIME
+DUMP_TABLE_BEGIN
+00:00:00 s0 00:00:00
+18:30:25 s18:30:25 18:30:25
+DUMP_TABLE_END
+PK[0] 00:00:00 s0 00:00:00
+I1[s0] 00:00:00 s0 00:00:00
+I2[0, s0] 00:00:00 s0 00:00:00
+I2p[0] 00:00:00 s0 00:00:00
+PK[18:30:25] 18:30:25 s18:30:25 18:30:25
+I1[s18:30:25] 18:30:25 s18:30:25 18:30:25
+I2[18:30:25, s18:30:25] 18:30:25 s18:30:25 18:30:25
+I2p[18:30:25] 18:30:25 s18:30:25 18:30:25
+
+TYPE YEAR(4)
+DUMP_TABLE_BEGIN
+1901 s1901 1901
+2011 s2011 2011
+2155 s2155 2155
+DUMP_TABLE_END
+PK[1901] 1901 s1901 1901
+I1[s1901] 1901 s1901 1901
+I2[1901, s1901] 1901 s1901 1901
+I2p[1901] 1901 s1901 1901
+PK[2011] 2011 s2011 2011
+I1[s2011] 2011 s2011 2011
+I2[2011, s2011] 2011 s2011 2011
+I2p[2011] 2011 s2011 2011
+PK[2155] 2155 s2155 2155
+I1[s2155] 2155 s2155 2155
+I2[2155, s2155] 2155 s2155 2155
+I2p[2155] 2155 s2155 2155
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test16.pl b/plugin/handler_socket/regtest/test_01_lib/test16.pl
new file mode 100644
index 00000000000..6db8c576d7a
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test16.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for date/datetime types
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use bigint;
+use hstest;
+
+my $datetime_types = [
+ [ 'DATE', '0000-00-00', '2011-01-01', '9999-12-31' ],
+ [ 'DATETIME', 0, '2011-01-01 18:30:25' ],
+ [ 'TIME', 0, '18:30:25' ],
+ [ 'YEAR(4)', 1901, 2011, 2155 ],
+ # [ 'TIMESTAMP', 0, 999999999 ], # DOES NOT WORK YET
+];
+
+my $table = 'hstesttbl';
+my $dbh;
+for my $rec (@$datetime_types) {
+ my ($typ, @vals) = @$rec;
+ print("TYPE $typ\n");
+ test_one($typ, \@vals);
+ print("\n");
+}
+
+sub test_one {
+ my ($typ, $values) = @_;
+ $dbh = hstest::init_testdb();
+ $dbh->do(
+ "create table $table (" .
+ "k $typ primary key, " .
+ "v1 varchar(512), " .
+ "v2 $typ, " .
+ "index i1(v1), index i2(v2, v1)) " .
+ "engine = myisam default charset = binary");
+ my $hs = hstest::get_hs_connection(undef, 9999);
+ my $dbname = $hstest::conf{dbname};
+ $hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
+ $hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
+ $hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
+ for my $k (@$values) {
+ my $kstr = 's' . $k;
+ $hs->execute_single(1, '+', [ $k, $kstr, $k ], 0, 0);
+ }
+ dump_table();
+ for my $k (@$values) {
+ my $kstr = 's' . $k;
+ my ($rk, $rv1, $rv2);
+ my $r;
+ $r = $hs->execute_single(1, '=', [ $k ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "PK[$k] $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(2, '=', [ $kstr ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I1[$kstr] $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(3, '=', [ $k, $kstr ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I2[$k, $kstr] $rk $rv1 $rv2\n";
+ $r = $hs->execute_single(3, '=', [ $k ], 1, 0);
+ shift(@$r);
+ ($rk, $rv1, $rv2) = @$r;
+ print "I2p[$k] $rk $rv1 $rv2\n";
+ }
+}
+
+sub dump_table {
+ print "DUMP_TABLE_BEGIN\n";
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
+ for my $row (@$aref) {
+ my ($k, $v1, $v2) = @$row;
+ $v1 = "[null]" if !defined($v1);
+ $v2 = "[null]" if !defined($v2);
+ print "$k $v1 $v2\n";
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
+ }
+ print "DUMP_TABLE_END\n";
+}
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test17.expected b/plugin/handler_socket/regtest/test_01_lib/test17.expected
new file mode 100644
index 00000000000..77176d31722
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test17.expected
Binary files differ
diff --git a/plugin/handler_socket/regtest/test_01_lib/test17.pl b/plugin/handler_socket/regtest/test_01_lib/test17.pl
new file mode 100644
index 00000000000..b7861b880f5
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test17.pl
@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for string types
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use bigint;
+use hstest;
+
+my $string_types = [
+ [ 'CHAR(10)', undef, 1, 2, 5, 10 ],
+ [ 'VARCHAR(10)', undef, 1, 2, 5, 10 ],
+ [ 'BINARY(10)', undef, 1, 2, 5, 10 ],
+ [ 'VARBINARY(10)', undef, 1, 2, 5, 10 ],
+ [ 'CHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
+ [ 'VARCHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
+ [ 'VARCHAR(511)', undef, 1, 2, 5, 10, 100, 200, 511 ],
+ [ 'LONGTEXT', 500, 1, 2, 5, 10, 100, 200, 511 ],
+ [ 'LONGBLOB', 500, 1, 2, 5, 10, 100, 200, 511 ],
+# [ 'VARCHAR(4096)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095 ],
+# [ 'VARCHAR(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
+# [ 'VARBINARY(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
+];
+
+my $table = 'hstesttbl';
+my $dbh;
+for my $rec (@$string_types) {
+ my ($typ, $keylen, @vs) = @$rec;
+ my @vals = ();
+ for my $len (@vs) {
+ my $s = '';
+ my @arr = ();
+ srand(999);
+ # print "$len 1\n";
+ for (my $i = 0; $i < $len; ++$i) {
+ my $v = int(rand(10));
+ $arr[$i] = chr(65 + $v);
+ }
+ # print "2\n";
+ push(@vals, join('', @arr));
+ }
+ print("TYPE $typ\n");
+ test_one($typ, $keylen, \@vals);
+ print("\n");
+}
+
+sub test_one {
+ my ($typ, $keylen, $values) = @_;
+ my $keylen_str = '';
+ if (defined($keylen)) {
+ $keylen_str = "($keylen)";
+ }
+ $dbh = hstest::init_testdb();
+ $dbh->do(
+ "create table $table (" .
+ "k $typ, " .
+ "v1 varchar(2047), " .
+ "v2 $typ, " .
+ "primary key(k$keylen_str), " .
+ "index i1(v1), index i2(v2$keylen_str, v1(300))) " .
+ "engine = myisam default charset = latin1");
+ my $hs = hstest::get_hs_connection(undef, 9999);
+ my $dbname = $hstest::conf{dbname};
+ $hs->open_index(1, $dbname, $table, '', 'k,v1,v2');
+ $hs->open_index(2, $dbname, $table, 'i1', 'k,v1,v2');
+ $hs->open_index(3, $dbname, $table, 'i2', 'k,v1,v2');
+ for my $k (@$values) {
+ my $kstr = 's' . $k;
+ $hs->execute_single(1, '+', [ $k, $kstr, $k ], 0, 0);
+ }
+ # dump_table();
+ for my $k (@$values) {
+ my $kstr = 's' . $k;
+ my ($rk, $rv1, $rv2);
+ my $r;
+ $r = $hs->execute_single(1, '=', [ $k ], 1, 0);
+ shift(@$r);
+ check_value("$typ:PK", @$r);
+ $r = $hs->execute_single(2, '=', [ $kstr ], 1, 0);
+ shift(@$r);
+ check_value("$typ:I1", @$r);
+ $r = $hs->execute_single(3, '=', [ $k, $kstr ], 1, 0);
+ shift(@$r);
+ check_value("$typ:I2", @$r);
+ $r = $hs->execute_single(3, '=', [ $k ], 1, 0);
+ shift(@$r);
+ check_value("$typ:I2p", @$r);
+ }
+}
+
+sub check_value {
+ my ($mess, $rk, $rv1, $rv2) = @_;
+ $rk ||= '';
+ $rv1 ||= '';
+ $rv2 ||= '';
+ if ($rv2 ne $rk) {
+ print "$mess: V2 NE\n$rk\n$rv2\n";
+ return;
+ }
+ if ($rv1 ne 's' . $rk) {
+ print "$mess: V1 NE\n$rk\n$rv1\n";
+ return;
+ }
+ print "$mess: EQ\n";
+}
+
+sub dump_table {
+ print "DUMP_TABLE_BEGIN\n";
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
+ for my $row (@$aref) {
+ my ($k, $v1, $v2) = @$row;
+ $v1 = "[null]" if !defined($v1);
+ $v2 = "[null]" if !defined($v2);
+ print "$k $v1 $v2\n";
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
+ }
+ print "DUMP_TABLE_END\n";
+}
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test18.expected b/plugin/handler_socket/regtest/test_01_lib/test18.expected
new file mode 100644
index 00000000000..9e09341cae9
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test18.expected
@@ -0,0 +1,22 @@
+HSINSERT
+1 v1hs_0
+2 v1hs_1
+3 v1hs_2
+4 v1hs_3
+5 v1hs_4
+6 v1hs_5
+7 v1hs_6
+8 v1hs_7
+9 v1hs_8
+10 v1hs_9
+DUMP_TABLE
+1 v1hs_0
+2 v1hs_1
+3 v1hs_2
+4 v1hs_3
+5 v1hs_4
+6 v1hs_5
+7 v1hs_6
+8 v1hs_7
+9 v1hs_8
+10 v1hs_9
diff --git a/plugin/handler_socket/regtest/test_01_lib/test18.pl b/plugin/handler_socket/regtest/test_01_lib/test18.pl
new file mode 100644
index 00000000000..87047bc9cba
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test18.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# tests that columns to be inserted are specified by open_index
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $table = 'hstesttbl';
+my $tablesize = 10;
+$dbh->do(
+ "create table $table (" .
+ "k int primary key auto_increment, " .
+ "v1 varchar(30), " .
+ "v2 varchar(30)) " .
+ "engine = myisam default charset = binary");
+srand(999);
+
+my %valmap = ();
+
+print "HSINSERT\n";
+my $hs = hstest::get_hs_connection(undef, 9999);
+my $dbname = $hstest::conf{dbname};
+$hs->open_index(1, $dbname, $table, '', 'v1');
+# inserts with auto_increment
+for (my $i = 0; $i < $tablesize; ++$i) {
+ my $k = 0;
+ my $v1 = "v1hs_" . $i;
+ my $v2 = "v2hs_" . $i;
+ my $r = $hs->execute_insert(1, [ $v1 ]);
+ my $err = $r->[0];
+ if ($err != 0) {
+ my $err_str = $r->[1];
+ print "$err $err_str\n";
+ } else {
+ my $id = $r->[1];
+ print "$id $v1\n";
+ }
+}
+
+undef $hs;
+
+dump_table();
+
+sub dump_table {
+ print "DUMP_TABLE\n";
+ my $aref = $dbh->selectall_arrayref("select k,v1,v2 from $table order by k");
+ for my $row (@$aref) {
+ my ($k, $v1, $v2) = @$row;
+ $v1 = "[null]" if !defined($v1);
+ $v2 = "[null]" if !defined($v2);
+ print "$k $v1 $v2\n";
+ # print "MISMATCH\n" if ($valmap{$k} ne $v);
+ }
+}
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test19.expected b/plugin/handler_socket/regtest/test_01_lib/test19.expected
new file mode 100644
index 00000000000..1c37b403d6a
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test19.expected
@@ -0,0 +1,14894 @@
+
+TINYINT -------------------------------------------------
+
+FILTER(TINYINT) NO FILTER
+code=0 rows=30
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = -128
+code=0 rows=3
+[0][0][0][-128]
+[1][0][1][-128]
+[2][0][2][-128]
+
+FILTER(TINYINT) v2 != -128
+code=0 rows=27
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= -128
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < -128
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > -128
+code=0 rows=24
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= -128
+code=0 rows=6
+[0][0][0][-128]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = -42
+code=0 rows=3
+[0][1][0][-42]
+[1][1][1][-42]
+[2][1][2][-42]
+
+FILTER(TINYINT) v2 != -42
+code=0 rows=27
+[0][0][0][-128]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= -42
+code=0 rows=24
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < -42
+code=0 rows=6
+[0][0][0][-128]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > -42
+code=0 rows=21
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= -42
+code=0 rows=9
+[0][0][0][-128]
+[0][1][0][-42]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = -14
+code=0 rows=3
+[0][2][0][-14]
+[1][2][1][-14]
+[2][2][2][-14]
+
+FILTER(TINYINT) v2 != -14
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= -14
+code=0 rows=21
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < -14
+code=0 rows=9
+[0][0][0][-128]
+[0][1][0][-42]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > -14
+code=0 rows=18
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= -14
+code=0 rows=12
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = -4
+code=0 rows=3
+[0][3][0][-4]
+[1][3][1][-4]
+[2][3][2][-4]
+
+FILTER(TINYINT) v2 != -4
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= -4
+code=0 rows=18
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < -4
+code=0 rows=12
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > -4
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= -4
+code=0 rows=15
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(TINYINT) v2 != 0
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < 0
+code=0 rows=15
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > 0
+code=0 rows=12
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= 0
+code=0 rows=18
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = 4
+code=0 rows=3
+[0][5][0][4]
+[1][5][1][4]
+[2][5][2][4]
+
+FILTER(TINYINT) v2 != 4
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= 4
+code=0 rows=12
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < 4
+code=0 rows=18
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > 4
+code=0 rows=9
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= 4
+code=0 rows=21
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = 14
+code=0 rows=3
+[0][6][0][14]
+[1][6][1][14]
+[2][6][2][14]
+
+FILTER(TINYINT) v2 != 14
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= 14
+code=0 rows=9
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < 14
+code=0 rows=21
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > 14
+code=0 rows=6
+[0][7][0][42]
+[0][8][0][127]
+[1][7][1][42]
+[1][8][1][127]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= 14
+code=0 rows=24
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = 42
+code=0 rows=3
+[0][7][0][42]
+[1][7][1][42]
+[2][7][2][42]
+
+FILTER(TINYINT) v2 != 42
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= 42
+code=0 rows=6
+[0][7][0][42]
+[0][8][0][127]
+[1][7][1][42]
+[1][8][1][127]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < 42
+code=0 rows=24
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > 42
+code=0 rows=3
+[0][8][0][127]
+[1][8][1][127]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= 42
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = 127
+code=0 rows=3
+[0][8][0][127]
+[1][8][1][127]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 != 127
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 >= 127
+code=0 rows=3
+[0][8][0][127]
+[1][8][1][127]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 < 127
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 > 127
+code=0 rows=0
+
+FILTER(TINYINT) v2 <= 127
+code=0 rows=30
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 != NULL
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 >= NULL
+code=0 rows=30
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[0][9][0][NULL]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[1][9][1][NULL]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+[2][9][2][NULL]
+
+FILTER(TINYINT) v2 < NULL
+code=0 rows=0
+
+FILTER(TINYINT) v2 > NULL
+code=0 rows=27
+[0][0][0][-128]
+[0][1][0][-42]
+[0][2][0][-14]
+[0][3][0][-4]
+[0][4][0][0]
+[0][5][0][4]
+[0][6][0][14]
+[0][7][0][42]
+[0][8][0][127]
+[1][0][1][-128]
+[1][1][1][-42]
+[1][2][1][-14]
+[1][3][1][-4]
+[1][4][1][0]
+[1][5][1][4]
+[1][6][1][14]
+[1][7][1][42]
+[1][8][1][127]
+[2][0][2][-128]
+[2][1][2][-42]
+[2][2][2][-14]
+[2][3][2][-4]
+[2][4][2][0]
+[2][5][2][4]
+[2][6][2][14]
+[2][7][2][42]
+[2][8][2][127]
+
+FILTER(TINYINT) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+TINYINT UNSIGNED -------------------------------------------------
+
+FILTER(TINYINT UNSIGNED) NO FILTER
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 = 0
+code=0 rows=3
+[0][0][0][0]
+[1][0][1][0]
+[2][0][2][0]
+
+FILTER(TINYINT UNSIGNED) v2 != 0
+code=0 rows=15
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 >= 0
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 < 0
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 > 0
+code=0 rows=12
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 <= 0
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 = 9
+code=0 rows=3
+[0][1][0][9]
+[1][1][1][9]
+[2][1][2][9]
+
+FILTER(TINYINT UNSIGNED) v2 != 9
+code=0 rows=15
+[0][0][0][0]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 >= 9
+code=0 rows=12
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 < 9
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 > 9
+code=0 rows=9
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 <= 9
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][9]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 = 28
+code=0 rows=3
+[0][2][0][28]
+[1][2][1][28]
+[2][2][2][28]
+
+FILTER(TINYINT UNSIGNED) v2 != 28
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][3][0][85]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][3][1][85]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][3][2][85]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 >= 28
+code=0 rows=9
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 < 28
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][9]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 > 28
+code=0 rows=6
+[0][3][0][85]
+[0][4][0][255]
+[1][3][1][85]
+[1][4][1][255]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 <= 28
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 = 85
+code=0 rows=3
+[0][3][0][85]
+[1][3][1][85]
+[2][3][2][85]
+
+FILTER(TINYINT UNSIGNED) v2 != 85
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 >= 85
+code=0 rows=6
+[0][3][0][85]
+[0][4][0][255]
+[1][3][1][85]
+[1][4][1][255]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 < 85
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 > 85
+code=0 rows=3
+[0][4][0][255]
+[1][4][1][255]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 <= 85
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 = 255
+code=0 rows=3
+[0][4][0][255]
+[1][4][1][255]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 != 255
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 >= 255
+code=0 rows=3
+[0][4][0][255]
+[1][4][1][255]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 < 255
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 > 255
+code=0 rows=0
+
+FILTER(TINYINT UNSIGNED) v2 <= 255
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 = NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 != NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 >= NULL
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+[2][5][2][NULL]
+
+FILTER(TINYINT UNSIGNED) v2 < NULL
+code=0 rows=0
+
+FILTER(TINYINT UNSIGNED) v2 > NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][9]
+[0][2][0][28]
+[0][3][0][85]
+[0][4][0][255]
+[1][0][1][0]
+[1][1][1][9]
+[1][2][1][28]
+[1][3][1][85]
+[1][4][1][255]
+[2][0][2][0]
+[2][1][2][9]
+[2][2][2][28]
+[2][3][2][85]
+[2][4][2][255]
+
+FILTER(TINYINT UNSIGNED) v2 <= NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+
+SMALLINT -------------------------------------------------
+
+FILTER(SMALLINT) NO FILTER
+code=0 rows=30
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = -32768
+code=0 rows=3
+[0][0][0][-32768]
+[1][0][1][-32768]
+[2][0][2][-32768]
+
+FILTER(SMALLINT) v2 != -32768
+code=0 rows=27
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= -32768
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < -32768
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > -32768
+code=0 rows=24
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= -32768
+code=0 rows=6
+[0][0][0][-32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = -10922
+code=0 rows=3
+[0][1][0][-10922]
+[1][1][1][-10922]
+[2][1][2][-10922]
+
+FILTER(SMALLINT) v2 != -10922
+code=0 rows=27
+[0][0][0][-32768]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= -10922
+code=0 rows=24
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < -10922
+code=0 rows=6
+[0][0][0][-32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > -10922
+code=0 rows=21
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= -10922
+code=0 rows=9
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = -3640
+code=0 rows=3
+[0][2][0][-3640]
+[1][2][1][-3640]
+[2][2][2][-3640]
+
+FILTER(SMALLINT) v2 != -3640
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= -3640
+code=0 rows=21
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < -3640
+code=0 rows=9
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > -3640
+code=0 rows=18
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= -3640
+code=0 rows=12
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = -1213
+code=0 rows=3
+[0][3][0][-1213]
+[1][3][1][-1213]
+[2][3][2][-1213]
+
+FILTER(SMALLINT) v2 != -1213
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= -1213
+code=0 rows=18
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < -1213
+code=0 rows=12
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > -1213
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= -1213
+code=0 rows=15
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(SMALLINT) v2 != 0
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < 0
+code=0 rows=15
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > 0
+code=0 rows=12
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= 0
+code=0 rows=18
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = 1213
+code=0 rows=3
+[0][5][0][1213]
+[1][5][1][1213]
+[2][5][2][1213]
+
+FILTER(SMALLINT) v2 != 1213
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= 1213
+code=0 rows=12
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < 1213
+code=0 rows=18
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > 1213
+code=0 rows=9
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= 1213
+code=0 rows=21
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = 3640
+code=0 rows=3
+[0][6][0][3640]
+[1][6][1][3640]
+[2][6][2][3640]
+
+FILTER(SMALLINT) v2 != 3640
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= 3640
+code=0 rows=9
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < 3640
+code=0 rows=21
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > 3640
+code=0 rows=6
+[0][7][0][10922]
+[0][8][0][32767]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= 3640
+code=0 rows=24
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = 10922
+code=0 rows=3
+[0][7][0][10922]
+[1][7][1][10922]
+[2][7][2][10922]
+
+FILTER(SMALLINT) v2 != 10922
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= 10922
+code=0 rows=6
+[0][7][0][10922]
+[0][8][0][32767]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < 10922
+code=0 rows=24
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > 10922
+code=0 rows=3
+[0][8][0][32767]
+[1][8][1][32767]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= 10922
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = 32768
+code=0 rows=3
+[0][8][0][32767]
+[1][8][1][32767]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 != 32768
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 >= 32768
+code=0 rows=3
+[0][8][0][32767]
+[1][8][1][32767]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 < 32768
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 > 32768
+code=0 rows=0
+
+FILTER(SMALLINT) v2 <= 32768
+code=0 rows=30
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 != NULL
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 >= NULL
+code=0 rows=30
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+[2][9][2][NULL]
+
+FILTER(SMALLINT) v2 < NULL
+code=0 rows=0
+
+FILTER(SMALLINT) v2 > NULL
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32767]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32767]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32767]
+
+FILTER(SMALLINT) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+SMALLINT UNSIGNED -------------------------------------------------
+
+FILTER(SMALLINT UNSIGNED) NO FILTER
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 = 0
+code=0 rows=3
+[0][0][0][0]
+[1][0][1][0]
+[2][0][2][0]
+
+FILTER(SMALLINT UNSIGNED) v2 != 0
+code=0 rows=15
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 >= 0
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 < 0
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 > 0
+code=0 rows=12
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 <= 0
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 = 2427
+code=0 rows=3
+[0][1][0][2427]
+[1][1][1][2427]
+[2][1][2][2427]
+
+FILTER(SMALLINT UNSIGNED) v2 != 2427
+code=0 rows=15
+[0][0][0][0]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 >= 2427
+code=0 rows=12
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 < 2427
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 > 2427
+code=0 rows=9
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 <= 2427
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][2427]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 = 7281
+code=0 rows=3
+[0][2][0][7281]
+[1][2][1][7281]
+[2][2][2][7281]
+
+FILTER(SMALLINT UNSIGNED) v2 != 7281
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][3][0][21845]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][3][1][21845]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][3][2][21845]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 >= 7281
+code=0 rows=9
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 < 7281
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][2427]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 > 7281
+code=0 rows=6
+[0][3][0][21845]
+[0][4][0][65535]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 <= 7281
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 = 21845
+code=0 rows=3
+[0][3][0][21845]
+[1][3][1][21845]
+[2][3][2][21845]
+
+FILTER(SMALLINT UNSIGNED) v2 != 21845
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 >= 21845
+code=0 rows=6
+[0][3][0][21845]
+[0][4][0][65535]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 < 21845
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 > 21845
+code=0 rows=3
+[0][4][0][65535]
+[1][4][1][65535]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 <= 21845
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 = 65535
+code=0 rows=3
+[0][4][0][65535]
+[1][4][1][65535]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 != 65535
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 >= 65535
+code=0 rows=3
+[0][4][0][65535]
+[1][4][1][65535]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 < 65535
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 > 65535
+code=0 rows=0
+
+FILTER(SMALLINT UNSIGNED) v2 <= 65535
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 = NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 != NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 >= NULL
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+[2][5][2][NULL]
+
+FILTER(SMALLINT UNSIGNED) v2 < NULL
+code=0 rows=0
+
+FILTER(SMALLINT UNSIGNED) v2 > NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][2427]
+[0][2][0][7281]
+[0][3][0][21845]
+[0][4][0][65535]
+[1][0][1][0]
+[1][1][1][2427]
+[1][2][1][7281]
+[1][3][1][21845]
+[1][4][1][65535]
+[2][0][2][0]
+[2][1][2][2427]
+[2][2][2][7281]
+[2][3][2][21845]
+[2][4][2][65535]
+
+FILTER(SMALLINT UNSIGNED) v2 <= NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+
+MEDIUMINT -------------------------------------------------
+
+FILTER(MEDIUMINT) NO FILTER
+code=0 rows=30
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = -8388608
+code=0 rows=3
+[0][0][0][-8388608]
+[1][0][1][-8388608]
+[2][0][2][-8388608]
+
+FILTER(MEDIUMINT) v2 != -8388608
+code=0 rows=27
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= -8388608
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < -8388608
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > -8388608
+code=0 rows=24
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= -8388608
+code=0 rows=6
+[0][0][0][-8388608]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = -2796202
+code=0 rows=3
+[0][1][0][-2796202]
+[1][1][1][-2796202]
+[2][1][2][-2796202]
+
+FILTER(MEDIUMINT) v2 != -2796202
+code=0 rows=27
+[0][0][0][-8388608]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= -2796202
+code=0 rows=24
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < -2796202
+code=0 rows=6
+[0][0][0][-8388608]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > -2796202
+code=0 rows=21
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= -2796202
+code=0 rows=9
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = -932067
+code=0 rows=3
+[0][2][0][-932067]
+[1][2][1][-932067]
+[2][2][2][-932067]
+
+FILTER(MEDIUMINT) v2 != -932067
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= -932067
+code=0 rows=21
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < -932067
+code=0 rows=9
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > -932067
+code=0 rows=18
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= -932067
+code=0 rows=12
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = -310689
+code=0 rows=3
+[0][3][0][-310689]
+[1][3][1][-310689]
+[2][3][2][-310689]
+
+FILTER(MEDIUMINT) v2 != -310689
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= -310689
+code=0 rows=18
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < -310689
+code=0 rows=12
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > -310689
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= -310689
+code=0 rows=15
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(MEDIUMINT) v2 != 0
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < 0
+code=0 rows=15
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > 0
+code=0 rows=12
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= 0
+code=0 rows=18
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = 310689
+code=0 rows=3
+[0][5][0][310689]
+[1][5][1][310689]
+[2][5][2][310689]
+
+FILTER(MEDIUMINT) v2 != 310689
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= 310689
+code=0 rows=12
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < 310689
+code=0 rows=18
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > 310689
+code=0 rows=9
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= 310689
+code=0 rows=21
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = 932067
+code=0 rows=3
+[0][6][0][932067]
+[1][6][1][932067]
+[2][6][2][932067]
+
+FILTER(MEDIUMINT) v2 != 932067
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= 932067
+code=0 rows=9
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < 932067
+code=0 rows=21
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > 932067
+code=0 rows=6
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= 932067
+code=0 rows=24
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = 2796202
+code=0 rows=3
+[0][7][0][2796202]
+[1][7][1][2796202]
+[2][7][2][2796202]
+
+FILTER(MEDIUMINT) v2 != 2796202
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= 2796202
+code=0 rows=6
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < 2796202
+code=0 rows=24
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > 2796202
+code=0 rows=3
+[0][8][0][8388607]
+[1][8][1][8388607]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= 2796202
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = 8388607
+code=0 rows=3
+[0][8][0][8388607]
+[1][8][1][8388607]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 != 8388607
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 >= 8388607
+code=0 rows=3
+[0][8][0][8388607]
+[1][8][1][8388607]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 < 8388607
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 > 8388607
+code=0 rows=0
+
+FILTER(MEDIUMINT) v2 <= 8388607
+code=0 rows=30
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 != NULL
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 >= NULL
+code=0 rows=30
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[0][9][0][NULL]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[1][9][1][NULL]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+[2][9][2][NULL]
+
+FILTER(MEDIUMINT) v2 < NULL
+code=0 rows=0
+
+FILTER(MEDIUMINT) v2 > NULL
+code=0 rows=27
+[0][0][0][-8388608]
+[0][1][0][-2796202]
+[0][2][0][-932067]
+[0][3][0][-310689]
+[0][4][0][0]
+[0][5][0][310689]
+[0][6][0][932067]
+[0][7][0][2796202]
+[0][8][0][8388607]
+[1][0][1][-8388608]
+[1][1][1][-2796202]
+[1][2][1][-932067]
+[1][3][1][-310689]
+[1][4][1][0]
+[1][5][1][310689]
+[1][6][1][932067]
+[1][7][1][2796202]
+[1][8][1][8388607]
+[2][0][2][-8388608]
+[2][1][2][-2796202]
+[2][2][2][-932067]
+[2][3][2][-310689]
+[2][4][2][0]
+[2][5][2][310689]
+[2][6][2][932067]
+[2][7][2][2796202]
+[2][8][2][8388607]
+
+FILTER(MEDIUMINT) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+MEDIUMINT UNSIGNED -------------------------------------------------
+
+FILTER(MEDIUMINT UNSIGNED) NO FILTER
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 = 0
+code=0 rows=3
+[0][0][0][0]
+[1][0][1][0]
+[2][0][2][0]
+
+FILTER(MEDIUMINT UNSIGNED) v2 != 0
+code=0 rows=15
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 >= 0
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 < 0
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 > 0
+code=0 rows=12
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 <= 0
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 = 621378
+code=0 rows=3
+[0][1][0][621378]
+[1][1][1][621378]
+[2][1][2][621378]
+
+FILTER(MEDIUMINT UNSIGNED) v2 != 621378
+code=0 rows=15
+[0][0][0][0]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 >= 621378
+code=0 rows=12
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 < 621378
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 > 621378
+code=0 rows=9
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 <= 621378
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][621378]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 = 1864135
+code=0 rows=3
+[0][2][0][1864135]
+[1][2][1][1864135]
+[2][2][2][1864135]
+
+FILTER(MEDIUMINT UNSIGNED) v2 != 1864135
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][3][2][5592405]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 >= 1864135
+code=0 rows=9
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 < 1864135
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][621378]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 > 1864135
+code=0 rows=6
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 <= 1864135
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 = 5592405
+code=0 rows=3
+[0][3][0][5592405]
+[1][3][1][5592405]
+[2][3][2][5592405]
+
+FILTER(MEDIUMINT UNSIGNED) v2 != 5592405
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 >= 5592405
+code=0 rows=6
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 < 5592405
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 > 5592405
+code=0 rows=3
+[0][4][0][16777215]
+[1][4][1][16777215]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 <= 5592405
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 = 16777215
+code=0 rows=3
+[0][4][0][16777215]
+[1][4][1][16777215]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 != 16777215
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 >= 16777215
+code=0 rows=3
+[0][4][0][16777215]
+[1][4][1][16777215]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 < 16777215
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 > 16777215
+code=0 rows=0
+
+FILTER(MEDIUMINT UNSIGNED) v2 <= 16777215
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 = NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 != NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 >= NULL
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+[2][5][2][NULL]
+
+FILTER(MEDIUMINT UNSIGNED) v2 < NULL
+code=0 rows=0
+
+FILTER(MEDIUMINT UNSIGNED) v2 > NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][621378]
+[0][2][0][1864135]
+[0][3][0][5592405]
+[0][4][0][16777215]
+[1][0][1][0]
+[1][1][1][621378]
+[1][2][1][1864135]
+[1][3][1][5592405]
+[1][4][1][16777215]
+[2][0][2][0]
+[2][1][2][621378]
+[2][2][2][1864135]
+[2][3][2][5592405]
+[2][4][2][16777215]
+
+FILTER(MEDIUMINT UNSIGNED) v2 <= NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+
+INT -------------------------------------------------
+
+FILTER(INT) NO FILTER
+code=0 rows=30
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = -2147483648
+code=0 rows=3
+[0][0][0][-2147483648]
+[1][0][1][-2147483648]
+[2][0][2][-2147483648]
+
+FILTER(INT) v2 != -2147483648
+code=0 rows=27
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= -2147483648
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < -2147483648
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > -2147483648
+code=0 rows=24
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= -2147483648
+code=0 rows=6
+[0][0][0][-2147483648]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = -715827882
+code=0 rows=3
+[0][1][0][-715827882]
+[1][1][1][-715827882]
+[2][1][2][-715827882]
+
+FILTER(INT) v2 != -715827882
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= -715827882
+code=0 rows=24
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < -715827882
+code=0 rows=6
+[0][0][0][-2147483648]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > -715827882
+code=0 rows=21
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= -715827882
+code=0 rows=9
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = -238609294
+code=0 rows=3
+[0][2][0][-238609294]
+[1][2][1][-238609294]
+[2][2][2][-238609294]
+
+FILTER(INT) v2 != -238609294
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= -238609294
+code=0 rows=21
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < -238609294
+code=0 rows=9
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > -238609294
+code=0 rows=18
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= -238609294
+code=0 rows=12
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = -79536431
+code=0 rows=3
+[0][3][0][-79536431]
+[1][3][1][-79536431]
+[2][3][2][-79536431]
+
+FILTER(INT) v2 != -79536431
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= -79536431
+code=0 rows=18
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < -79536431
+code=0 rows=12
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > -79536431
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= -79536431
+code=0 rows=15
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(INT) v2 != 0
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < 0
+code=0 rows=15
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > 0
+code=0 rows=12
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= 0
+code=0 rows=18
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = 79536431
+code=0 rows=3
+[0][5][0][79536431]
+[1][5][1][79536431]
+[2][5][2][79536431]
+
+FILTER(INT) v2 != 79536431
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= 79536431
+code=0 rows=12
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < 79536431
+code=0 rows=18
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > 79536431
+code=0 rows=9
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= 79536431
+code=0 rows=21
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = 238609294
+code=0 rows=3
+[0][6][0][238609294]
+[1][6][1][238609294]
+[2][6][2][238609294]
+
+FILTER(INT) v2 != 238609294
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= 238609294
+code=0 rows=9
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < 238609294
+code=0 rows=21
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > 238609294
+code=0 rows=6
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= 238609294
+code=0 rows=24
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = 715827882
+code=0 rows=3
+[0][7][0][715827882]
+[1][7][1][715827882]
+[2][7][2][715827882]
+
+FILTER(INT) v2 != 715827882
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= 715827882
+code=0 rows=6
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < 715827882
+code=0 rows=24
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > 715827882
+code=0 rows=3
+[0][8][0][2147483647]
+[1][8][1][2147483647]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= 715827882
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = 2147483647
+code=0 rows=3
+[0][8][0][2147483647]
+[1][8][1][2147483647]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 != 2147483647
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][9][2][NULL]
+
+FILTER(INT) v2 >= 2147483647
+code=0 rows=3
+[0][8][0][2147483647]
+[1][8][1][2147483647]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 < 2147483647
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][9][2][NULL]
+
+FILTER(INT) v2 > 2147483647
+code=0 rows=0
+
+FILTER(INT) v2 <= 2147483647
+code=0 rows=30
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(INT) v2 != NULL
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 >= NULL
+code=0 rows=30
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(INT) v2 < NULL
+code=0 rows=0
+
+FILTER(INT) v2 > NULL
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(INT) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+INT UNSIGNED -------------------------------------------------
+
+FILTER(INT UNSIGNED) NO FILTER
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 = 0
+code=0 rows=3
+[0][0][0][0]
+[1][0][1][0]
+[2][0][2][0]
+
+FILTER(INT UNSIGNED) v2 != 0
+code=0 rows=15
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 >= 0
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 < 0
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 > 0
+code=0 rows=12
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 <= 0
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 = 159072862
+code=0 rows=3
+[0][1][0][159072862]
+[1][1][1][159072862]
+[2][1][2][159072862]
+
+FILTER(INT UNSIGNED) v2 != 159072862
+code=0 rows=15
+[0][0][0][0]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 >= 159072862
+code=0 rows=12
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 < 159072862
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 > 159072862
+code=0 rows=9
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 <= 159072862
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][159072862]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 = 477218588
+code=0 rows=3
+[0][2][0][477218588]
+[1][2][1][477218588]
+[2][2][2][477218588]
+
+FILTER(INT UNSIGNED) v2 != 477218588
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 >= 477218588
+code=0 rows=9
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 < 477218588
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][159072862]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 > 477218588
+code=0 rows=6
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 <= 477218588
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 = 1431655765
+code=0 rows=3
+[0][3][0][1431655765]
+[1][3][1][1431655765]
+[2][3][2][1431655765]
+
+FILTER(INT UNSIGNED) v2 != 1431655765
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 >= 1431655765
+code=0 rows=6
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 < 1431655765
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 > 1431655765
+code=0 rows=3
+[0][4][0][4294967295]
+[1][4][1][4294967295]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 <= 1431655765
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 = 4294967295
+code=0 rows=3
+[0][4][0][4294967295]
+[1][4][1][4294967295]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 != 4294967295
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 >= 4294967295
+code=0 rows=3
+[0][4][0][4294967295]
+[1][4][1][4294967295]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 < 4294967295
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 > 4294967295
+code=0 rows=0
+
+FILTER(INT UNSIGNED) v2 <= 4294967295
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 = NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 != NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 >= NULL
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+[2][5][2][NULL]
+
+FILTER(INT UNSIGNED) v2 < NULL
+code=0 rows=0
+
+FILTER(INT UNSIGNED) v2 > NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][159072862]
+[0][2][0][477218588]
+[0][3][0][1431655765]
+[0][4][0][4294967295]
+[1][0][1][0]
+[1][1][1][159072862]
+[1][2][1][477218588]
+[1][3][1][1431655765]
+[1][4][1][4294967295]
+[2][0][2][0]
+[2][1][2][159072862]
+[2][2][2][477218588]
+[2][3][2][1431655765]
+[2][4][2][4294967295]
+
+FILTER(INT UNSIGNED) v2 <= NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+
+BIGINT -------------------------------------------------
+
+FILTER(BIGINT) NO FILTER
+code=0 rows=30
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = -9223372036854775808
+code=0 rows=3
+[0][0][0][-9223372036854775808]
+[1][0][1][-9223372036854775808]
+[2][0][2][-9223372036854775808]
+
+FILTER(BIGINT) v2 != -9223372036854775808
+code=0 rows=27
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= -9223372036854775808
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < -9223372036854775808
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > -9223372036854775808
+code=0 rows=24
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= -9223372036854775808
+code=0 rows=6
+[0][0][0][-9223372036854775808]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = -3074457345618258602
+code=0 rows=3
+[0][1][0][-3074457345618258602]
+[1][1][1][-3074457345618258602]
+[2][1][2][-3074457345618258602]
+
+FILTER(BIGINT) v2 != -3074457345618258602
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= -3074457345618258602
+code=0 rows=24
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < -3074457345618258602
+code=0 rows=6
+[0][0][0][-9223372036854775808]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > -3074457345618258602
+code=0 rows=21
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= -3074457345618258602
+code=0 rows=9
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = -1024819115206086200
+code=0 rows=3
+[0][2][0][-1024819115206086200]
+[1][2][1][-1024819115206086200]
+[2][2][2][-1024819115206086200]
+
+FILTER(BIGINT) v2 != -1024819115206086200
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= -1024819115206086200
+code=0 rows=21
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < -1024819115206086200
+code=0 rows=9
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > -1024819115206086200
+code=0 rows=18
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= -1024819115206086200
+code=0 rows=12
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = -341606371735362066
+code=0 rows=3
+[0][3][0][-341606371735362066]
+[1][3][1][-341606371735362066]
+[2][3][2][-341606371735362066]
+
+FILTER(BIGINT) v2 != -341606371735362066
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= -341606371735362066
+code=0 rows=18
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < -341606371735362066
+code=0 rows=12
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > -341606371735362066
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= -341606371735362066
+code=0 rows=15
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(BIGINT) v2 != 0
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < 0
+code=0 rows=15
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > 0
+code=0 rows=12
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= 0
+code=0 rows=18
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = 341606371735362066
+code=0 rows=3
+[0][5][0][341606371735362066]
+[1][5][1][341606371735362066]
+[2][5][2][341606371735362066]
+
+FILTER(BIGINT) v2 != 341606371735362066
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= 341606371735362066
+code=0 rows=12
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < 341606371735362066
+code=0 rows=18
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > 341606371735362066
+code=0 rows=9
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= 341606371735362066
+code=0 rows=21
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = 1024819115206086200
+code=0 rows=3
+[0][6][0][1024819115206086200]
+[1][6][1][1024819115206086200]
+[2][6][2][1024819115206086200]
+
+FILTER(BIGINT) v2 != 1024819115206086200
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= 1024819115206086200
+code=0 rows=9
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < 1024819115206086200
+code=0 rows=21
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > 1024819115206086200
+code=0 rows=6
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= 1024819115206086200
+code=0 rows=24
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = 3074457345618258602
+code=0 rows=3
+[0][7][0][3074457345618258602]
+[1][7][1][3074457345618258602]
+[2][7][2][3074457345618258602]
+
+FILTER(BIGINT) v2 != 3074457345618258602
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= 3074457345618258602
+code=0 rows=6
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < 3074457345618258602
+code=0 rows=24
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > 3074457345618258602
+code=0 rows=3
+[0][8][0][9223372036854775807]
+[1][8][1][9223372036854775807]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= 3074457345618258602
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = 9223372036854775807
+code=0 rows=3
+[0][8][0][9223372036854775807]
+[1][8][1][9223372036854775807]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 != 9223372036854775807
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 >= 9223372036854775807
+code=0 rows=3
+[0][8][0][9223372036854775807]
+[1][8][1][9223372036854775807]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 < 9223372036854775807
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 > 9223372036854775807
+code=0 rows=0
+
+FILTER(BIGINT) v2 <= 9223372036854775807
+code=0 rows=30
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 != NULL
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 >= NULL
+code=0 rows=30
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[0][9][0][NULL]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[1][9][1][NULL]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+[2][9][2][NULL]
+
+FILTER(BIGINT) v2 < NULL
+code=0 rows=0
+
+FILTER(BIGINT) v2 > NULL
+code=0 rows=27
+[0][0][0][-9223372036854775808]
+[0][1][0][-3074457345618258602]
+[0][2][0][-1024819115206086200]
+[0][3][0][-341606371735362066]
+[0][4][0][0]
+[0][5][0][341606371735362066]
+[0][6][0][1024819115206086200]
+[0][7][0][3074457345618258602]
+[0][8][0][9223372036854775807]
+[1][0][1][-9223372036854775808]
+[1][1][1][-3074457345618258602]
+[1][2][1][-1024819115206086200]
+[1][3][1][-341606371735362066]
+[1][4][1][0]
+[1][5][1][341606371735362066]
+[1][6][1][1024819115206086200]
+[1][7][1][3074457345618258602]
+[1][8][1][9223372036854775807]
+[2][0][2][-9223372036854775808]
+[2][1][2][-3074457345618258602]
+[2][2][2][-1024819115206086200]
+[2][3][2][-341606371735362066]
+[2][4][2][0]
+[2][5][2][341606371735362066]
+[2][6][2][1024819115206086200]
+[2][7][2][3074457345618258602]
+[2][8][2][9223372036854775807]
+
+FILTER(BIGINT) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+BIGINT UNSIGNED -------------------------------------------------
+
+FILTER(BIGINT UNSIGNED) NO FILTER
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 = 0
+code=0 rows=3
+[0][0][0][0]
+[1][0][1][0]
+[2][0][2][0]
+
+FILTER(BIGINT UNSIGNED) v2 != 0
+code=0 rows=15
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 >= 0
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 < 0
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 > 0
+code=0 rows=12
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 <= 0
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 = 683212743470724133
+code=0 rows=3
+[0][1][0][683212743470724133]
+[1][1][1][683212743470724133]
+[2][1][2][683212743470724133]
+
+FILTER(BIGINT UNSIGNED) v2 != 683212743470724133
+code=0 rows=15
+[0][0][0][0]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 >= 683212743470724133
+code=0 rows=12
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 < 683212743470724133
+code=0 rows=6
+[0][0][0][0]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 > 683212743470724133
+code=0 rows=9
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 <= 683212743470724133
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 = 2049638230412172401
+code=0 rows=3
+[0][2][0][2049638230412172401]
+[1][2][1][2049638230412172401]
+[2][2][2][2049638230412172401]
+
+FILTER(BIGINT UNSIGNED) v2 != 2049638230412172401
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 >= 2049638230412172401
+code=0 rows=9
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 < 2049638230412172401
+code=0 rows=9
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 > 2049638230412172401
+code=0 rows=6
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 <= 2049638230412172401
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 = 6148914691236517205
+code=0 rows=3
+[0][3][0][6148914691236517205]
+[1][3][1][6148914691236517205]
+[2][3][2][6148914691236517205]
+
+FILTER(BIGINT UNSIGNED) v2 != 6148914691236517205
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 >= 6148914691236517205
+code=0 rows=6
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 < 6148914691236517205
+code=0 rows=12
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 > 6148914691236517205
+code=0 rows=3
+[0][4][0][18446744073709551615]
+[1][4][1][18446744073709551615]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 <= 6148914691236517205
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 = 18446744073709551615
+code=0 rows=3
+[0][4][0][18446744073709551615]
+[1][4][1][18446744073709551615]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 != 18446744073709551615
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 >= 18446744073709551615
+code=0 rows=3
+[0][4][0][18446744073709551615]
+[1][4][1][18446744073709551615]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 < 18446744073709551615
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 > 18446744073709551615
+code=0 rows=0
+
+FILTER(BIGINT UNSIGNED) v2 <= 18446744073709551615
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 = NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 != NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 >= NULL
+code=0 rows=18
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[0][5][0][NULL]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[1][5][1][NULL]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+[2][5][2][NULL]
+
+FILTER(BIGINT UNSIGNED) v2 < NULL
+code=0 rows=0
+
+FILTER(BIGINT UNSIGNED) v2 > NULL
+code=0 rows=15
+[0][0][0][0]
+[0][1][0][683212743470724133]
+[0][2][0][2049638230412172401]
+[0][3][0][6148914691236517205]
+[0][4][0][18446744073709551615]
+[1][0][1][0]
+[1][1][1][683212743470724133]
+[1][2][1][2049638230412172401]
+[1][3][1][6148914691236517205]
+[1][4][1][18446744073709551615]
+[2][0][2][0]
+[2][1][2][683212743470724133]
+[2][2][2][2049638230412172401]
+[2][3][2][6148914691236517205]
+[2][4][2][18446744073709551615]
+
+FILTER(BIGINT UNSIGNED) v2 <= NULL
+code=0 rows=3
+[0][5][0][NULL]
+[1][5][1][NULL]
+[2][5][2][NULL]
+
+
+FLOAT -------------------------------------------------
+
+FILTER(FLOAT) NO FILTER
+code=0 rows=30
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = -32768
+code=0 rows=3
+[0][0][0][-32768]
+[1][0][1][-32768]
+[2][0][2][-32768]
+
+FILTER(FLOAT) v2 != -32768
+code=0 rows=27
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= -32768
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < -32768
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > -32768
+code=0 rows=24
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= -32768
+code=0 rows=6
+[0][0][0][-32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = -10922
+code=0 rows=3
+[0][1][0][-10922]
+[1][1][1][-10922]
+[2][1][2][-10922]
+
+FILTER(FLOAT) v2 != -10922
+code=0 rows=27
+[0][0][0][-32768]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= -10922
+code=0 rows=24
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < -10922
+code=0 rows=6
+[0][0][0][-32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > -10922
+code=0 rows=21
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= -10922
+code=0 rows=9
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = -3640
+code=0 rows=3
+[0][2][0][-3640]
+[1][2][1][-3640]
+[2][2][2][-3640]
+
+FILTER(FLOAT) v2 != -3640
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= -3640
+code=0 rows=21
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < -3640
+code=0 rows=9
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > -3640
+code=0 rows=18
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= -3640
+code=0 rows=12
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = -1213
+code=0 rows=3
+[0][3][0][-1213]
+[1][3][1][-1213]
+[2][3][2][-1213]
+
+FILTER(FLOAT) v2 != -1213
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= -1213
+code=0 rows=18
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < -1213
+code=0 rows=12
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > -1213
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= -1213
+code=0 rows=15
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(FLOAT) v2 != 0
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < 0
+code=0 rows=15
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > 0
+code=0 rows=12
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= 0
+code=0 rows=18
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = 1213
+code=0 rows=3
+[0][5][0][1213]
+[1][5][1][1213]
+[2][5][2][1213]
+
+FILTER(FLOAT) v2 != 1213
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= 1213
+code=0 rows=12
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < 1213
+code=0 rows=18
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > 1213
+code=0 rows=9
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= 1213
+code=0 rows=21
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = 3640
+code=0 rows=3
+[0][6][0][3640]
+[1][6][1][3640]
+[2][6][2][3640]
+
+FILTER(FLOAT) v2 != 3640
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= 3640
+code=0 rows=9
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < 3640
+code=0 rows=21
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > 3640
+code=0 rows=6
+[0][7][0][10922]
+[0][8][0][32768]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= 3640
+code=0 rows=24
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = 10922
+code=0 rows=3
+[0][7][0][10922]
+[1][7][1][10922]
+[2][7][2][10922]
+
+FILTER(FLOAT) v2 != 10922
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= 10922
+code=0 rows=6
+[0][7][0][10922]
+[0][8][0][32768]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < 10922
+code=0 rows=24
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > 10922
+code=0 rows=3
+[0][8][0][32768]
+[1][8][1][32768]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= 10922
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = 32768
+code=0 rows=3
+[0][8][0][32768]
+[1][8][1][32768]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 != 32768
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 >= 32768
+code=0 rows=3
+[0][8][0][32768]
+[1][8][1][32768]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 < 32768
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 > 32768
+code=0 rows=0
+
+FILTER(FLOAT) v2 <= 32768
+code=0 rows=30
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 != NULL
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 >= NULL
+code=0 rows=30
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[0][9][0][NULL]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[1][9][1][NULL]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+[2][9][2][NULL]
+
+FILTER(FLOAT) v2 < NULL
+code=0 rows=0
+
+FILTER(FLOAT) v2 > NULL
+code=0 rows=27
+[0][0][0][-32768]
+[0][1][0][-10922]
+[0][2][0][-3640]
+[0][3][0][-1213]
+[0][4][0][0]
+[0][5][0][1213]
+[0][6][0][3640]
+[0][7][0][10922]
+[0][8][0][32768]
+[1][0][1][-32768]
+[1][1][1][-10922]
+[1][2][1][-3640]
+[1][3][1][-1213]
+[1][4][1][0]
+[1][5][1][1213]
+[1][6][1][3640]
+[1][7][1][10922]
+[1][8][1][32768]
+[2][0][2][-32768]
+[2][1][2][-10922]
+[2][2][2][-3640]
+[2][3][2][-1213]
+[2][4][2][0]
+[2][5][2][1213]
+[2][6][2][3640]
+[2][7][2][10922]
+[2][8][2][32768]
+
+FILTER(FLOAT) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+DOUBLE -------------------------------------------------
+
+FILTER(DOUBLE) NO FILTER
+code=0 rows=30
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = -2147483648
+code=0 rows=3
+[0][0][0][-2147483648]
+[1][0][1][-2147483648]
+[2][0][2][-2147483648]
+
+FILTER(DOUBLE) v2 != -2147483648
+code=0 rows=27
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= -2147483648
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < -2147483648
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > -2147483648
+code=0 rows=24
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= -2147483648
+code=0 rows=6
+[0][0][0][-2147483648]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = -715827882
+code=0 rows=3
+[0][1][0][-715827882]
+[1][1][1][-715827882]
+[2][1][2][-715827882]
+
+FILTER(DOUBLE) v2 != -715827882
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= -715827882
+code=0 rows=24
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < -715827882
+code=0 rows=6
+[0][0][0][-2147483648]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > -715827882
+code=0 rows=21
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= -715827882
+code=0 rows=9
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = -238609294
+code=0 rows=3
+[0][2][0][-238609294]
+[1][2][1][-238609294]
+[2][2][2][-238609294]
+
+FILTER(DOUBLE) v2 != -238609294
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= -238609294
+code=0 rows=21
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < -238609294
+code=0 rows=9
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > -238609294
+code=0 rows=18
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= -238609294
+code=0 rows=12
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = -79536431
+code=0 rows=3
+[0][3][0][-79536431]
+[1][3][1][-79536431]
+[2][3][2][-79536431]
+
+FILTER(DOUBLE) v2 != -79536431
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= -79536431
+code=0 rows=18
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < -79536431
+code=0 rows=12
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > -79536431
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= -79536431
+code=0 rows=15
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = 0
+code=0 rows=3
+[0][4][0][0]
+[1][4][1][0]
+[2][4][2][0]
+
+FILTER(DOUBLE) v2 != 0
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= 0
+code=0 rows=15
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < 0
+code=0 rows=15
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > 0
+code=0 rows=12
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= 0
+code=0 rows=18
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = 79536431
+code=0 rows=3
+[0][5][0][79536431]
+[1][5][1][79536431]
+[2][5][2][79536431]
+
+FILTER(DOUBLE) v2 != 79536431
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= 79536431
+code=0 rows=12
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < 79536431
+code=0 rows=18
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > 79536431
+code=0 rows=9
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= 79536431
+code=0 rows=21
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = 238609294
+code=0 rows=3
+[0][6][0][238609294]
+[1][6][1][238609294]
+[2][6][2][238609294]
+
+FILTER(DOUBLE) v2 != 238609294
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= 238609294
+code=0 rows=9
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < 238609294
+code=0 rows=21
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > 238609294
+code=0 rows=6
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= 238609294
+code=0 rows=24
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = 715827882
+code=0 rows=3
+[0][7][0][715827882]
+[1][7][1][715827882]
+[2][7][2][715827882]
+
+FILTER(DOUBLE) v2 != 715827882
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= 715827882
+code=0 rows=6
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < 715827882
+code=0 rows=24
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > 715827882
+code=0 rows=3
+[0][8][0][2147483647]
+[1][8][1][2147483647]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= 715827882
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = 2147483647
+code=0 rows=3
+[0][8][0][2147483647]
+[1][8][1][2147483647]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 != 2147483647
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 >= 2147483647
+code=0 rows=3
+[0][8][0][2147483647]
+[1][8][1][2147483647]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 < 2147483647
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 > 2147483647
+code=0 rows=0
+
+FILTER(DOUBLE) v2 <= 2147483647
+code=0 rows=30
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 = NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 != NULL
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 >= NULL
+code=0 rows=30
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[0][9][0][NULL]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[1][9][1][NULL]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+[2][9][2][NULL]
+
+FILTER(DOUBLE) v2 < NULL
+code=0 rows=0
+
+FILTER(DOUBLE) v2 > NULL
+code=0 rows=27
+[0][0][0][-2147483648]
+[0][1][0][-715827882]
+[0][2][0][-238609294]
+[0][3][0][-79536431]
+[0][4][0][0]
+[0][5][0][79536431]
+[0][6][0][238609294]
+[0][7][0][715827882]
+[0][8][0][2147483647]
+[1][0][1][-2147483648]
+[1][1][1][-715827882]
+[1][2][1][-238609294]
+[1][3][1][-79536431]
+[1][4][1][0]
+[1][5][1][79536431]
+[1][6][1][238609294]
+[1][7][1][715827882]
+[1][8][1][2147483647]
+[2][0][2][-2147483648]
+[2][1][2][-715827882]
+[2][2][2][-238609294]
+[2][3][2][-79536431]
+[2][4][2][0]
+[2][5][2][79536431]
+[2][6][2][238609294]
+[2][7][2][715827882]
+[2][8][2][2147483647]
+
+FILTER(DOUBLE) v2 <= NULL
+code=0 rows=3
+[0][9][0][NULL]
+[1][9][1][NULL]
+[2][9][2][NULL]
+
+
+DATE -------------------------------------------------
+
+FILTER(DATE) NO FILTER
+code=0 rows=12
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 = 0000-00-00
+code=0 rows=3
+[0][0][0][0000-00-00]
+[1][0][1][0000-00-00]
+[2][0][2][0000-00-00]
+
+FILTER(DATE) v2 != 0000-00-00
+code=0 rows=9
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[0][3][0][NULL]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[1][3][1][NULL]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 >= 0000-00-00
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 < 0000-00-00
+code=0 rows=3
+[0][3][0][NULL]
+[1][3][1][NULL]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 > 0000-00-00
+code=0 rows=6
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 <= 0000-00-00
+code=0 rows=6
+[0][0][0][0000-00-00]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 = 2011-01-01
+code=0 rows=3
+[0][1][0][2011-01-01]
+[1][1][1][2011-01-01]
+[2][1][2][2011-01-01]
+
+FILTER(DATE) v2 != 2011-01-01
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][2][0][9999-12-31]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][2][1][9999-12-31]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][2][2][9999-12-31]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 >= 2011-01-01
+code=0 rows=6
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 < 2011-01-01
+code=0 rows=6
+[0][0][0][0000-00-00]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 > 2011-01-01
+code=0 rows=3
+[0][2][0][9999-12-31]
+[1][2][1][9999-12-31]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 <= 2011-01-01
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 = 9999-12-31
+code=0 rows=3
+[0][2][0][9999-12-31]
+[1][2][1][9999-12-31]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 != 9999-12-31
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 >= 9999-12-31
+code=0 rows=3
+[0][2][0][9999-12-31]
+[1][2][1][9999-12-31]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 < 9999-12-31
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 > 9999-12-31
+code=0 rows=0
+
+FILTER(DATE) v2 <= 9999-12-31
+code=0 rows=12
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 = NULL
+code=0 rows=3
+[0][3][0][NULL]
+[1][3][1][NULL]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 != NULL
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 >= NULL
+code=0 rows=12
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[0][3][0][NULL]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[1][3][1][NULL]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+[2][3][2][NULL]
+
+FILTER(DATE) v2 < NULL
+code=0 rows=0
+
+FILTER(DATE) v2 > NULL
+code=0 rows=9
+[0][0][0][0000-00-00]
+[0][1][0][2011-01-01]
+[0][2][0][9999-12-31]
+[1][0][1][0000-00-00]
+[1][1][1][2011-01-01]
+[1][2][1][9999-12-31]
+[2][0][2][0000-00-00]
+[2][1][2][2011-01-01]
+[2][2][2][9999-12-31]
+
+FILTER(DATE) v2 <= NULL
+code=0 rows=3
+[0][3][0][NULL]
+[1][3][1][NULL]
+[2][3][2][NULL]
+
+
+DATETIME -------------------------------------------------
+
+FILTER(DATETIME) NO FILTER
+code=0 rows=9
+[0][0][0][0000-00-00 00:00:00]
+[0][1][0][2011-01-01 18:30:25]
+[0][2][0][NULL]
+[1][0][1][0000-00-00 00:00:00]
+[1][1][1][2011-01-01 18:30:25]
+[1][2][1][NULL]
+[2][0][2][0000-00-00 00:00:00]
+[2][1][2][2011-01-01 18:30:25]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 = 0
+code=0 rows=3
+[0][0][0][0000-00-00 00:00:00]
+[1][0][1][0000-00-00 00:00:00]
+[2][0][2][0000-00-00 00:00:00]
+
+FILTER(DATETIME) v2 != 0
+code=0 rows=6
+[0][1][0][2011-01-01 18:30:25]
+[0][2][0][NULL]
+[1][1][1][2011-01-01 18:30:25]
+[1][2][1][NULL]
+[2][1][2][2011-01-01 18:30:25]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 >= 0
+code=0 rows=6
+[0][0][0][0000-00-00 00:00:00]
+[0][1][0][2011-01-01 18:30:25]
+[1][0][1][0000-00-00 00:00:00]
+[1][1][1][2011-01-01 18:30:25]
+[2][0][2][0000-00-00 00:00:00]
+[2][1][2][2011-01-01 18:30:25]
+
+FILTER(DATETIME) v2 < 0
+code=0 rows=3
+[0][2][0][NULL]
+[1][2][1][NULL]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 > 0
+code=0 rows=3
+[0][1][0][2011-01-01 18:30:25]
+[1][1][1][2011-01-01 18:30:25]
+[2][1][2][2011-01-01 18:30:25]
+
+FILTER(DATETIME) v2 <= 0
+code=0 rows=6
+[0][0][0][0000-00-00 00:00:00]
+[0][2][0][NULL]
+[1][0][1][0000-00-00 00:00:00]
+[1][2][1][NULL]
+[2][0][2][0000-00-00 00:00:00]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 = 2011-01-01 18:30:25
+code=0 rows=3
+[0][1][0][2011-01-01 18:30:25]
+[1][1][1][2011-01-01 18:30:25]
+[2][1][2][2011-01-01 18:30:25]
+
+FILTER(DATETIME) v2 != 2011-01-01 18:30:25
+code=0 rows=6
+[0][0][0][0000-00-00 00:00:00]
+[0][2][0][NULL]
+[1][0][1][0000-00-00 00:00:00]
+[1][2][1][NULL]
+[2][0][2][0000-00-00 00:00:00]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 >= 2011-01-01 18:30:25
+code=0 rows=3
+[0][1][0][2011-01-01 18:30:25]
+[1][1][1][2011-01-01 18:30:25]
+[2][1][2][2011-01-01 18:30:25]
+
+FILTER(DATETIME) v2 < 2011-01-01 18:30:25
+code=0 rows=6
+[0][0][0][0000-00-00 00:00:00]
+[0][2][0][NULL]
+[1][0][1][0000-00-00 00:00:00]
+[1][2][1][NULL]
+[2][0][2][0000-00-00 00:00:00]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 > 2011-01-01 18:30:25
+code=0 rows=0
+
+FILTER(DATETIME) v2 <= 2011-01-01 18:30:25
+code=0 rows=9
+[0][0][0][0000-00-00 00:00:00]
+[0][1][0][2011-01-01 18:30:25]
+[0][2][0][NULL]
+[1][0][1][0000-00-00 00:00:00]
+[1][1][1][2011-01-01 18:30:25]
+[1][2][1][NULL]
+[2][0][2][0000-00-00 00:00:00]
+[2][1][2][2011-01-01 18:30:25]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 = NULL
+code=0 rows=3
+[0][2][0][NULL]
+[1][2][1][NULL]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 != NULL
+code=0 rows=6
+[0][0][0][0000-00-00 00:00:00]
+[0][1][0][2011-01-01 18:30:25]
+[1][0][1][0000-00-00 00:00:00]
+[1][1][1][2011-01-01 18:30:25]
+[2][0][2][0000-00-00 00:00:00]
+[2][1][2][2011-01-01 18:30:25]
+
+FILTER(DATETIME) v2 >= NULL
+code=0 rows=9
+[0][0][0][0000-00-00 00:00:00]
+[0][1][0][2011-01-01 18:30:25]
+[0][2][0][NULL]
+[1][0][1][0000-00-00 00:00:00]
+[1][1][1][2011-01-01 18:30:25]
+[1][2][1][NULL]
+[2][0][2][0000-00-00 00:00:00]
+[2][1][2][2011-01-01 18:30:25]
+[2][2][2][NULL]
+
+FILTER(DATETIME) v2 < NULL
+code=0 rows=0
+
+FILTER(DATETIME) v2 > NULL
+code=0 rows=6
+[0][0][0][0000-00-00 00:00:00]
+[0][1][0][2011-01-01 18:30:25]
+[1][0][1][0000-00-00 00:00:00]
+[1][1][1][2011-01-01 18:30:25]
+[2][0][2][0000-00-00 00:00:00]
+[2][1][2][2011-01-01 18:30:25]
+
+FILTER(DATETIME) v2 <= NULL
+code=0 rows=3
+[0][2][0][NULL]
+[1][2][1][NULL]
+[2][2][2][NULL]
+
+
+TIME -------------------------------------------------
+
+FILTER(TIME) NO FILTER
+code=0 rows=9
+[0][0][0][00:00:00]
+[0][1][0][18:30:25]
+[0][2][0][NULL]
+[1][0][1][00:00:00]
+[1][1][1][18:30:25]
+[1][2][1][NULL]
+[2][0][2][00:00:00]
+[2][1][2][18:30:25]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 = 0
+code=0 rows=3
+[0][0][0][00:00:00]
+[1][0][1][00:00:00]
+[2][0][2][00:00:00]
+
+FILTER(TIME) v2 != 0
+code=0 rows=6
+[0][1][0][18:30:25]
+[0][2][0][NULL]
+[1][1][1][18:30:25]
+[1][2][1][NULL]
+[2][1][2][18:30:25]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 >= 0
+code=0 rows=6
+[0][0][0][00:00:00]
+[0][1][0][18:30:25]
+[1][0][1][00:00:00]
+[1][1][1][18:30:25]
+[2][0][2][00:00:00]
+[2][1][2][18:30:25]
+
+FILTER(TIME) v2 < 0
+code=0 rows=3
+[0][2][0][NULL]
+[1][2][1][NULL]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 > 0
+code=0 rows=3
+[0][1][0][18:30:25]
+[1][1][1][18:30:25]
+[2][1][2][18:30:25]
+
+FILTER(TIME) v2 <= 0
+code=0 rows=6
+[0][0][0][00:00:00]
+[0][2][0][NULL]
+[1][0][1][00:00:00]
+[1][2][1][NULL]
+[2][0][2][00:00:00]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 = 18:30:25
+code=0 rows=3
+[0][1][0][18:30:25]
+[1][1][1][18:30:25]
+[2][1][2][18:30:25]
+
+FILTER(TIME) v2 != 18:30:25
+code=0 rows=6
+[0][0][0][00:00:00]
+[0][2][0][NULL]
+[1][0][1][00:00:00]
+[1][2][1][NULL]
+[2][0][2][00:00:00]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 >= 18:30:25
+code=0 rows=3
+[0][1][0][18:30:25]
+[1][1][1][18:30:25]
+[2][1][2][18:30:25]
+
+FILTER(TIME) v2 < 18:30:25
+code=0 rows=6
+[0][0][0][00:00:00]
+[0][2][0][NULL]
+[1][0][1][00:00:00]
+[1][2][1][NULL]
+[2][0][2][00:00:00]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 > 18:30:25
+code=0 rows=0
+
+FILTER(TIME) v2 <= 18:30:25
+code=0 rows=9
+[0][0][0][00:00:00]
+[0][1][0][18:30:25]
+[0][2][0][NULL]
+[1][0][1][00:00:00]
+[1][1][1][18:30:25]
+[1][2][1][NULL]
+[2][0][2][00:00:00]
+[2][1][2][18:30:25]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 = NULL
+code=0 rows=3
+[0][2][0][NULL]
+[1][2][1][NULL]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 != NULL
+code=0 rows=6
+[0][0][0][00:00:00]
+[0][1][0][18:30:25]
+[1][0][1][00:00:00]
+[1][1][1][18:30:25]
+[2][0][2][00:00:00]
+[2][1][2][18:30:25]
+
+FILTER(TIME) v2 >= NULL
+code=0 rows=9
+[0][0][0][00:00:00]
+[0][1][0][18:30:25]
+[0][2][0][NULL]
+[1][0][1][00:00:00]
+[1][1][1][18:30:25]
+[1][2][1][NULL]
+[2][0][2][00:00:00]
+[2][1][2][18:30:25]
+[2][2][2][NULL]
+
+FILTER(TIME) v2 < NULL
+code=0 rows=0
+
+FILTER(TIME) v2 > NULL
+code=0 rows=6
+[0][0][0][00:00:00]
+[0][1][0][18:30:25]
+[1][0][1][00:00:00]
+[1][1][1][18:30:25]
+[2][0][2][00:00:00]
+[2][1][2][18:30:25]
+
+FILTER(TIME) v2 <= NULL
+code=0 rows=3
+[0][2][0][NULL]
+[1][2][1][NULL]
+[2][2][2][NULL]
+
+
+YEAR(4) -------------------------------------------------
+
+FILTER(YEAR(4)) NO FILTER
+code=0 rows=8
+[1][0][1][1901]
+[1][1][1][2011]
+[1][2][1][2155]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][2][2][2155]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 = 1901
+code=0 rows=2
+[1][0][1][1901]
+[2][0][2][1901]
+
+FILTER(YEAR(4)) v2 != 1901
+code=0 rows=6
+[1][1][1][2011]
+[1][2][1][2155]
+[1][3][1][NULL]
+[2][1][2][2011]
+[2][2][2][2155]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 >= 1901
+code=0 rows=6
+[1][0][1][1901]
+[1][1][1][2011]
+[1][2][1][2155]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 < 1901
+code=0 rows=2
+[1][3][1][NULL]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 > 1901
+code=0 rows=4
+[1][1][1][2011]
+[1][2][1][2155]
+[2][1][2][2011]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 <= 1901
+code=0 rows=4
+[1][0][1][1901]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 = 2011
+code=0 rows=2
+[1][1][1][2011]
+[2][1][2][2011]
+
+FILTER(YEAR(4)) v2 != 2011
+code=0 rows=6
+[1][0][1][1901]
+[1][2][1][2155]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][2][2][2155]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 >= 2011
+code=0 rows=4
+[1][1][1][2011]
+[1][2][1][2155]
+[2][1][2][2011]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 < 2011
+code=0 rows=4
+[1][0][1][1901]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 > 2011
+code=0 rows=2
+[1][2][1][2155]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 <= 2011
+code=0 rows=6
+[1][0][1][1901]
+[1][1][1][2011]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 = 2155
+code=0 rows=2
+[1][2][1][2155]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 != 2155
+code=0 rows=6
+[1][0][1][1901]
+[1][1][1][2011]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 >= 2155
+code=0 rows=2
+[1][2][1][2155]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 < 2155
+code=0 rows=6
+[1][0][1][1901]
+[1][1][1][2011]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 > 2155
+code=0 rows=0
+
+FILTER(YEAR(4)) v2 <= 2155
+code=0 rows=8
+[1][0][1][1901]
+[1][1][1][2011]
+[1][2][1][2155]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][2][2][2155]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 = NULL
+code=0 rows=2
+[1][3][1][NULL]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 != NULL
+code=0 rows=6
+[1][0][1][1901]
+[1][1][1][2011]
+[1][2][1][2155]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 >= NULL
+code=0 rows=8
+[1][0][1][1901]
+[1][1][1][2011]
+[1][2][1][2155]
+[1][3][1][NULL]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][2][2][2155]
+[2][3][2][NULL]
+
+FILTER(YEAR(4)) v2 < NULL
+code=0 rows=0
+
+FILTER(YEAR(4)) v2 > NULL
+code=0 rows=6
+[1][0][1][1901]
+[1][1][1][2011]
+[1][2][1][2155]
+[2][0][2][1901]
+[2][1][2][2011]
+[2][2][2][2155]
+
+FILTER(YEAR(4)) v2 <= NULL
+code=0 rows=2
+[1][3][1][NULL]
+[2][3][2][NULL]
+
+
+CHAR(10) -------------------------------------------------
+
+FILTER(CHAR(10)) NO FILTER
+code=0 rows=15
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 = B
+code=0 rows=3
+[0][0][0][B
+[1][0][1][B
+[2][0][2][B
+
+FILTER(CHAR(10)) v2 != B
+code=0 rows=12
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 >= B
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(CHAR(10)) v2 < B
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 > B
+code=0 rows=9
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(CHAR(10)) v2 <= B
+code=0 rows=6
+[0][0][0][B
+[0][4][0][NULL]
+[1][0][1][B
+[1][4][1][NULL]
+[2][0][2][B
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 = GI
+code=0 rows=3
+[0][1][0][GI
+[1][1][1][GI
+[2][1][2][GI
+
+FILTER(CHAR(10)) v2 != GI
+code=0 rows=12
+[0][0][0][B
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI
+[0][2][0][JHFFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[2][1][2][GI
+[2][2][2][JHFFE
+
+FILTER(CHAR(10)) v2 < GI
+code=0 rows=9
+[0][0][0][B
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(CHAR(10)) v2 <= GI
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(CHAR(10)) v2 != JHFFE
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(CHAR(10)) v2 < JHFFE
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(CHAR(10)) v2 <= JHFFE
+code=0 rows=15
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH]
+[1][3][1][FDHHDEDBHH]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(CHAR(10)) v2 != FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 >= FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(CHAR(10)) v2 < FDHHDEDBHH
+code=0 rows=6
+[0][0][0][B
+[0][4][0][NULL]
+[1][0][1][B
+[1][4][1][NULL]
+[2][0][2][B
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 > FDHHDEDBHH
+code=0 rows=6
+[0][1][0][GI
+[0][2][0][JHFFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[2][1][2][GI
+[2][2][2][JHFFE
+
+FILTER(CHAR(10)) v2 <= FDHHDEDBHH
+code=0 rows=9
+[0][0][0][B
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 = NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 != NULL
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(CHAR(10)) v2 >= NULL
+code=0 rows=15
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(CHAR(10)) v2 < NULL
+code=0 rows=0
+
+FILTER(CHAR(10)) v2 > NULL
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(CHAR(10)) v2 <= NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+
+VARCHAR(10) -------------------------------------------------
+
+FILTER(VARCHAR(10)) NO FILTER
+code=0 rows=15
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 = B
+code=0 rows=3
+[0][0][0][B]
+[1][0][1][B]
+[2][0][2][B]
+
+FILTER(VARCHAR(10)) v2 != B
+code=0 rows=12
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 >= B
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(10)) v2 < B
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 > B
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(10)) v2 <= B
+code=0 rows=6
+[0][0][0][B]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 = GI
+code=0 rows=3
+[0][1][0][GI]
+[1][1][1][GI]
+[2][1][2][GI]
+
+FILTER(VARCHAR(10)) v2 != GI
+code=0 rows=12
+[0][0][0][B]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(10)) v2 < GI
+code=0 rows=9
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(10)) v2 <= GI
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(10)) v2 != JHFFE
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(10)) v2 < JHFFE
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(VARCHAR(10)) v2 <= JHFFE
+code=0 rows=15
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH]
+[1][3][1][FDHHDEDBHH]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(10)) v2 != FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 >= FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(10)) v2 < FDHHDEDBHH
+code=0 rows=6
+[0][0][0][B]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 > FDHHDEDBHH
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(10)) v2 <= FDHHDEDBHH
+code=0 rows=9
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 = NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 != NULL
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(10)) v2 >= NULL
+code=0 rows=15
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARCHAR(10)) v2 < NULL
+code=0 rows=0
+
+FILTER(VARCHAR(10)) v2 > NULL
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(10)) v2 <= NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+
+BINARY(10) -------------------------------------------------
+
+FILTER(BINARY(10)) NO FILTER
+code=0 rows=15
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 = B
+code=0 rows=3
+[0][0][0][B
+[1][0][1][B
+[2][0][2][B
+
+FILTER(BINARY(10)) v2 != B
+code=0 rows=12
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 >= B
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(BINARY(10)) v2 < B
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 > B
+code=0 rows=9
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(BINARY(10)) v2 <= B
+code=0 rows=6
+[0][0][0][B
+[0][4][0][NULL]
+[1][0][1][B
+[1][4][1][NULL]
+[2][0][2][B
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 = GI
+code=0 rows=3
+[0][1][0][GI
+[1][1][1][GI
+[2][1][2][GI
+
+FILTER(BINARY(10)) v2 != GI
+code=0 rows=12
+[0][0][0][B
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI
+[0][2][0][JHFFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[2][1][2][GI
+[2][2][2][JHFFE
+
+FILTER(BINARY(10)) v2 < GI
+code=0 rows=9
+[0][0][0][B
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(BINARY(10)) v2 <= GI
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(BINARY(10)) v2 != JHFFE
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(BINARY(10)) v2 < JHFFE
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(BINARY(10)) v2 <= JHFFE
+code=0 rows=15
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH]
+[1][3][1][FDHHDEDBHH]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(BINARY(10)) v2 != FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 >= FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(BINARY(10)) v2 < FDHHDEDBHH
+code=0 rows=6
+[0][0][0][B
+[0][4][0][NULL]
+[1][0][1][B
+[1][4][1][NULL]
+[2][0][2][B
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 > FDHHDEDBHH
+code=0 rows=6
+[0][1][0][GI
+[0][2][0][JHFFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[2][1][2][GI
+[2][2][2][JHFFE
+
+FILTER(BINARY(10)) v2 <= FDHHDEDBHH
+code=0 rows=9
+[0][0][0][B
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 = NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 != NULL
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(BINARY(10)) v2 >= NULL
+code=0 rows=15
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(BINARY(10)) v2 < NULL
+code=0 rows=0
+
+FILTER(BINARY(10)) v2 > NULL
+code=0 rows=12
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH]
+
+FILTER(BINARY(10)) v2 <= NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+
+VARBINARY(10) -------------------------------------------------
+
+FILTER(VARBINARY(10)) NO FILTER
+code=0 rows=15
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 = B
+code=0 rows=3
+[0][0][0][B]
+[1][0][1][B]
+[2][0][2][B]
+
+FILTER(VARBINARY(10)) v2 != B
+code=0 rows=12
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 >= B
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARBINARY(10)) v2 < B
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 > B
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARBINARY(10)) v2 <= B
+code=0 rows=6
+[0][0][0][B]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 = GI
+code=0 rows=3
+[0][1][0][GI]
+[1][1][1][GI]
+[2][1][2][GI]
+
+FILTER(VARBINARY(10)) v2 != GI
+code=0 rows=12
+[0][0][0][B]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARBINARY(10)) v2 < GI
+code=0 rows=9
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARBINARY(10)) v2 <= GI
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARBINARY(10)) v2 != JHFFE
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARBINARY(10)) v2 < JHFFE
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(VARBINARY(10)) v2 <= JHFFE
+code=0 rows=15
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH]
+[1][3][1][FDHHDEDBHH]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARBINARY(10)) v2 != FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 >= FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARBINARY(10)) v2 < FDHHDEDBHH
+code=0 rows=6
+[0][0][0][B]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 > FDHHDEDBHH
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARBINARY(10)) v2 <= FDHHDEDBHH
+code=0 rows=9
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 = NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 != NULL
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARBINARY(10)) v2 >= NULL
+code=0 rows=15
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][NULL]
+
+FILTER(VARBINARY(10)) v2 < NULL
+code=0 rows=0
+
+FILTER(VARBINARY(10)) v2 > NULL
+code=0 rows=12
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARBINARY(10)) v2 <= NULL
+code=0 rows=3
+[0][4][0][NULL]
+[1][4][1][NULL]
+[2][4][2][NULL]
+
+
+CHAR(255) -------------------------------------------------
+
+FILTER(CHAR(255)) NO FILTER
+code=0 rows=24
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = B
+code=0 rows=3
+[0][0][0][B
+[1][0][1][B
+[2][0][2][B
+
+FILTER(CHAR(255)) v2 != B
+code=0 rows=21
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= B
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(CHAR(255)) v2 < B
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > B
+code=0 rows=18
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(CHAR(255)) v2 <= B
+code=0 rows=6
+[0][0][0][B
+[0][7][0][NULL]
+[1][0][1][B
+[1][7][1][NULL]
+[2][0][2][B
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = GI
+code=0 rows=3
+[0][1][0][GI
+[1][1][1][GI
+[2][1][2][GI
+
+FILTER(CHAR(255)) v2 != GI
+code=0 rows=21
+[0][0][0][B
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI
+[0][2][0][JHFFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[2][1][2][GI
+[2][2][2][JHFFE
+
+FILTER(CHAR(255)) v2 < GI
+code=0 rows=18
+[0][0][0][B
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(CHAR(255)) v2 <= GI
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(CHAR(255)) v2 != JHFFE
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE
+[1][2][1][JHFFE
+[2][2][2][JHFFE
+
+FILTER(CHAR(255)) v2 < JHFFE
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(CHAR(255)) v2 <= JHFFE
+code=0 rows=24
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH
+[1][3][1][FDHHDEDBHH
+[2][3][2][FDHHDEDBHH
+
+FILTER(CHAR(255)) v2 != FDHHDEDBHH
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= FDHHDEDBHH
+code=0 rows=12
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+
+FILTER(CHAR(255)) v2 < FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+
+FILTER(CHAR(255)) v2 <= FDHHDEDBHH
+code=0 rows=15
+[0][0][0][B
+[0][3][0][FDHHDEDBHH
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=3
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+
+FILTER(CHAR(255)) v2 != FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=9
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+
+FILTER(CHAR(255)) v2 < FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=15
+[0][0][0][B
+[0][3][0][FDHHDEDBHH
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=6
+[0][1][0][GI
+[0][2][0][JHFFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[2][1][2][GI
+[2][2][2][JHFFE
+
+FILTER(CHAR(255)) v2 <= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=18
+[0][0][0][B
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=3
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+
+FILTER(CHAR(255)) v2 != DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=15
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+
+FILTER(CHAR(255)) v2 < DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=9
+[0][0][0][B
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=12
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+
+FILTER(CHAR(255)) v2 <= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=12
+[0][0][0][B
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=3
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(CHAR(255)) v2 != DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 >= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=18
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(CHAR(255)) v2 < DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=6
+[0][0][0][B
+[0][7][0][NULL]
+[1][0][1][B
+[1][7][1][NULL]
+[2][0][2][B
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 > DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=15
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+
+FILTER(CHAR(255)) v2 <= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=9
+[0][0][0][B
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 = NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 != NULL
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(CHAR(255)) v2 >= NULL
+code=0 rows=24
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(CHAR(255)) v2 < NULL
+code=0 rows=0
+
+FILTER(CHAR(255)) v2 > NULL
+code=0 rows=21
+[0][0][0][B
+[0][1][0][GI
+[0][2][0][JHFFE
+[0][3][0][FDHHDEDBHH
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][0][1][B
+[1][1][1][GI
+[1][2][1][JHFFE
+[1][3][1][FDHHDEDBHH
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][0][2][B
+[2][1][2][GI
+[2][2][2][JHFFE
+[2][3][2][FDHHDEDBHH
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(CHAR(255)) v2 <= NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+
+VARCHAR(255) -------------------------------------------------
+
+FILTER(VARCHAR(255)) NO FILTER
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = B
+code=0 rows=3
+[0][0][0][B]
+[1][0][1][B]
+[2][0][2][B]
+
+FILTER(VARCHAR(255)) v2 != B
+code=0 rows=21
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= B
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(VARCHAR(255)) v2 < B
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > B
+code=0 rows=18
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(VARCHAR(255)) v2 <= B
+code=0 rows=6
+[0][0][0][B]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = GI
+code=0 rows=3
+[0][1][0][GI]
+[1][1][1][GI]
+[2][1][2][GI]
+
+FILTER(VARCHAR(255)) v2 != GI
+code=0 rows=21
+[0][0][0][B]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(255)) v2 < GI
+code=0 rows=18
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(255)) v2 <= GI
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(255)) v2 != JHFFE
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(255)) v2 < JHFFE
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(VARCHAR(255)) v2 <= JHFFE
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH]
+[1][3][1][FDHHDEDBHH]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(255)) v2 != FDHHDEDBHH
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= FDHHDEDBHH
+code=0 rows=12
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(255)) v2 < FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(255)) v2 <= FDHHDEDBHH
+code=0 rows=15
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=3
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(255)) v2 != FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(255)) v2 < FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=15
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(255)) v2 <= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=18
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=3
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+
+FILTER(VARCHAR(255)) v2 != DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=15
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+
+FILTER(VARCHAR(255)) v2 < DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=9
+[0][0][0][B]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=12
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(255)) v2 <= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=12
+[0][0][0][B]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=3
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(VARCHAR(255)) v2 != DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 >= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=18
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(VARCHAR(255)) v2 < DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=6
+[0][0][0][B]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 > DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=15
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+
+FILTER(VARCHAR(255)) v2 <= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI
+code=0 rows=9
+[0][0][0][B]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 = NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 != NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(VARCHAR(255)) v2 >= NULL
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(255)) v2 < NULL
+code=0 rows=0
+
+FILTER(VARCHAR(255)) v2 > NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGI]
+
+FILTER(VARCHAR(255)) v2 <= NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+
+VARCHAR(511) -------------------------------------------------
+
+FILTER(VARCHAR(511)) NO FILTER
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = B
+code=0 rows=3
+[0][0][0][B]
+[1][0][1][B]
+[2][0][2][B]
+
+FILTER(VARCHAR(511)) v2 != B
+code=0 rows=21
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= B
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(VARCHAR(511)) v2 < B
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > B
+code=0 rows=18
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(VARCHAR(511)) v2 <= B
+code=0 rows=6
+[0][0][0][B]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = GI
+code=0 rows=3
+[0][1][0][GI]
+[1][1][1][GI]
+[2][1][2][GI]
+
+FILTER(VARCHAR(511)) v2 != GI
+code=0 rows=21
+[0][0][0][B]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= GI
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(511)) v2 < GI
+code=0 rows=18
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > GI
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(511)) v2 <= GI
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(511)) v2 != JHFFE
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= JHFFE
+code=0 rows=3
+[0][2][0][JHFFE]
+[1][2][1][JHFFE]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(511)) v2 < JHFFE
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > JHFFE
+code=0 rows=0
+
+FILTER(VARCHAR(511)) v2 <= JHFFE
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = FDHHDEDBHH
+code=0 rows=3
+[0][3][0][FDHHDEDBHH]
+[1][3][1][FDHHDEDBHH]
+[2][3][2][FDHHDEDBHH]
+
+FILTER(VARCHAR(511)) v2 != FDHHDEDBHH
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= FDHHDEDBHH
+code=0 rows=12
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(511)) v2 < FDHHDEDBHH
+code=0 rows=12
+[0][0][0][B]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > FDHHDEDBHH
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(511)) v2 <= FDHHDEDBHH
+code=0 rows=15
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=3
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(511)) v2 != FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=9
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(511)) v2 < FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=15
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=6
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+
+FILTER(VARCHAR(511)) v2 <= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=0 rows=18
+[0][0][0][B]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=3
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+
+FILTER(VARCHAR(511)) v2 != DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=15
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+
+FILTER(VARCHAR(511)) v2 < DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=9
+[0][0][0][B]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=12
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+
+FILTER(VARCHAR(511)) v2 <= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=0 rows=12
+[0][0][0][B]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=0 rows=3
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(VARCHAR(511)) v2 != DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 >= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=0 rows=18
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(VARCHAR(511)) v2 < DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=0 rows=6
+[0][0][0][B]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 > DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=0 rows=15
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+
+FILTER(VARCHAR(511)) v2 <= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=0 rows=9
+[0][0][0][B]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 = NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 != NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(VARCHAR(511)) v2 >= NULL
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(VARCHAR(511)) v2 < NULL
+code=0 rows=0
+
+FILTER(VARCHAR(511)) v2 > NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(VARCHAR(511)) v2 <= NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+
+LONGTEXT -------------------------------------------------
+
+FILTER(LONGTEXT) NO FILTER
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(LONGTEXT) v2 = B
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != B
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= B
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < B
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > B
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= B
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 != DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 >= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 < DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 > DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 <= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGTEXT) v2 = NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(LONGTEXT) v2 != NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(LONGTEXT) v2 >= NULL
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(LONGTEXT) v2 < NULL
+code=0 rows=0
+
+FILTER(LONGTEXT) v2 > NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(LONGTEXT) v2 <= NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+
+LONGBLOB -------------------------------------------------
+
+FILTER(LONGBLOB) NO FILTER
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(LONGBLOB) v2 = B
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != B
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= B
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < B
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > B
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= B
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= GI
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= JHFFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= FDHHDEDBHH
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 != DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 >= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 < DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 > DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 <= DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA
+code=2 rows=0
+[filterblob]
+FILTER(LONGBLOB) v2 = NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
+FILTER(LONGBLOB) v2 != NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(LONGBLOB) v2 >= NULL
+code=0 rows=24
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[0][7][0][NULL]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][7][1][NULL]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][7][2][NULL]
+
+FILTER(LONGBLOB) v2 < NULL
+code=0 rows=0
+
+FILTER(LONGBLOB) v2 > NULL
+code=0 rows=21
+[0][0][0][B]
+[0][1][0][GI]
+[0][2][0][JHFFE]
+[0][3][0][FDHHDEDBHH]
+[0][4][0][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[0][5][0][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[0][6][0][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[1][0][1][B]
+[1][1][1][GI]
+[1][2][1][JHFFE]
+[1][3][1][FDHHDEDBHH]
+[1][4][1][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[1][5][1][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[1][6][1][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+[2][0][2][B]
+[2][1][2][GI]
+[2][2][2][JHFFE]
+[2][3][2][FDHHDEDBHH]
+[2][4][2][FEFJEICICEFFADGGIEBCCGIDFJECIJHBGJGJFCCBJEBBBCAGGCHFEAAIGDIGAAIBFIHHJBGEBGDADBIIHHIJEDDDIBHIFDFIFAIF]
+[2][5][2][DIEIIDGEIGAHICBIACDFGJAJBAAECEIGIDFFHFFFDDADDIHGECGEEADDAHBAHGAHGIIAFFIHAGBDAHDCAHJHFGDJIEEBJDGDEFBHDGJGHEJDHBJDIBDAGIIBGAAHCJGFBCFEDBGDIBGACBJFDFADJEDFACDCDJCIDECEHJFBGCCBJAECGEBCBFAGEICBHAHIGGDBGEFE]
+[2][6][2][DHDIHIGFJIFCHGDCFCDAJIDDAAJCEIGDAFCGCECIADFFHJBEIBBIFICGHIAFJCGJCHEBDIBFBAEDHFEDFJAGDGIBHFJIEFHGJHCEDAIBJDHIFDEDCFDIIFAEEGABDIBHCGCJDCHJJICEFIJHDBGCGJHAJBHFHIHCCHDJJBJFDHCIAFAJHBAECAIBHGHIFCDAGDBHGJDFIHGJIAFBIEFHCEFFCDEAGBBCAAHGCBCIAJCBDBCGGJHJEGBAGCFAFGIBHDGDHDCBCEHIJJAIDDCICCAAIGBFIFGBGIAAFEJFGFEEJFDDGJGGDECECJIBIIDDFEAIAEJGCJCBFDAGEAAEBGHFJAHFABGHHGDFBGJGEJFADJIGGGDCCBHABJHADDHGFIIDDEABFDBFEHJCECBCFAAJCBEIHAIJDCGDGCGDFFHCDEJCGCGGEIFBDHADJEAAGDBCAJGDCFABCJGGJCEGHAHFJEJCCAIHFCAEBCHHEHIHEGICGFCAHJAEFHAFIEA]
+
+FILTER(LONGBLOB) v2 <= NULL
+code=0 rows=3
+[0][7][0][NULL]
+[1][7][1][NULL]
+[2][7][2][NULL]
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test19.pl b/plugin/handler_socket/regtest/test_01_lib/test19.pl
new file mode 100644
index 00000000000..6c43267c927
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test19.pl
@@ -0,0 +1,190 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for filters
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use bigint;
+use hstest;
+
+my $numeric_types = [
+ [ 'TINYINT', -128, 127 ],
+ [ 'TINYINT UNSIGNED', 0, 255 ],
+ [ 'SMALLINT', -32768, 32768 ],
+ [ 'SMALLINT UNSIGNED', 0, 65535 ],
+ [ 'MEDIUMINT', -8388608, 8388607 ],
+ [ 'MEDIUMINT UNSIGNED', 0, 16777215 ],
+ [ 'INT', -2147483648, 2147483647 ],
+ [ 'INT UNSIGNED', 0, 4294967295 ],
+ [ 'BIGINT', -9223372036854775808, 9223372036854775807 ],
+ [ 'BIGINT UNSIGNED', 0, 18446744073709551615 ],
+ [ 'FLOAT', -32768, 32768 ],
+ [ 'DOUBLE', -2147483648, 2147483647 ],
+];
+my $datetime_types = [
+ [ 'DATE', '0000-00-00', '2011-01-01', '9999-12-31' ],
+ [ 'DATETIME', 0, '2011-01-01 18:30:25' ],
+ [ 'TIME', 0, '18:30:25' ],
+ [ 'YEAR(4)', 1901, 2011, 2155 ],
+ # [ 'TIMESTAMP', 0, 999999999 ], # DOES NOT WORK YET
+];
+my $string_types = [
+ [ 'CHAR(10)', undef, 1, 2, 5, 10 ],
+ [ 'VARCHAR(10)', undef, 1, 2, 5, 10 ],
+ [ 'BINARY(10)', undef, 1, 2, 5, 10 ],
+ [ 'VARBINARY(10)', undef, 1, 2, 5, 10 ],
+ [ 'CHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
+ [ 'VARCHAR(255)', undef, 1, 2, 5, 10, 100, 200, 255 ],
+ [ 'VARCHAR(511)', undef, 1, 2, 5, 10, 100, 200, 511 ],
+ [ 'LONGTEXT', 500, 1, 2, 5, 10, 100, 200, 511 ], # NOT SUPPORTED YET
+ [ 'LONGBLOB', 500, 1, 2, 5, 10, 100, 200, 511 ], # NOT SUPPORTED YET
+# [ 'VARCHAR(4096)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095 ],
+# [ 'VARCHAR(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
+# [ 'VARBINARY(16383)', 500, 1, 2, 5, 10, 100, 200, 255, 256, 4095, 4096, 16383 ],
+];
+
+for my $rec (@$numeric_types) {
+ my ($typ, $minval, $maxval) = @$rec;
+ my @vals = ();
+ push(@vals, 0);
+ push(@vals, $maxval);
+ if ($minval != 0) {
+ push(@vals, $minval);
+ }
+ my $v1 = $minval;
+ my $v2 = $maxval;
+ for (my $i = 0; $i < 3; ++$i) {
+ $v1 /= 3;
+ $v2 /= 3;
+ push(@vals, int($v1));
+ push(@vals, int($v2));
+ }
+ my %vm = map { $_ => 1 } @vals;
+ @vals = sort { $a <=> $b } keys %vm;
+ push(@vals, undef);
+ test_one($typ, undef, \@vals);
+}
+
+for my $rec (@$datetime_types) {
+ my ($typ, @vals) = @$rec;
+ push(@vals, undef);
+ test_one($typ, undef, \@vals);
+}
+
+for my $rec (@$string_types) {
+ my ($typ, $keylen, @vs) = @$rec;
+ my @vals = ();
+ srand(999);
+ for my $len (@vs) {
+ my $s = '';
+ my @arr = ();
+ # print "$len 1\n";
+ for (my $i = 0; $i < $len; ++$i) {
+ my $v = int(rand(10));
+ $arr[$i] = chr(65 + $v);
+ }
+ # print "2\n";
+ push(@vals, join('', @arr));
+ }
+ push(@vals, undef);
+ test_one($typ, $keylen, \@vals);
+}
+
+my $hs;
+
+sub test_one {
+ my ($typ, $keylen, $values) = @_;
+ print "\n$typ -------------------------------------------------\n\n";
+ my $keylen_str = '';
+ if (defined($keylen)) {
+ $keylen_str = "($keylen)";
+ }
+ my $dbh = hstest::init_testdb();
+ my $table = 'hstesttbl';
+ my $tablesize = 3;
+ $dbh->do(
+ "create table $table " .
+ "(k1 int not null, k2 int not null, " .
+ "v1 int not null, v2 $typ default null, " .
+ "primary key (k1, k2) ) engine = innodb");
+ my $sth = $dbh->prepare("insert into $table values (?,?,?,?)");
+ for (my $i = 0; $i < $tablesize; ++$i) {
+ my $j = 0;
+ for my $v (@$values) {
+ $sth->execute($i, $j, $i, $v);
+ ++$j;
+ }
+ }
+ $hs = hstest::get_hs_connection(undef, 9999);
+ my $dbname = $hstest::conf{dbname};
+ $hs->open_index(1, $dbname, $table, '', 'k1,k2,v1,v2', 'v2');
+ my $minval = $values->[0];
+ # select * ... where (k1, k2) >= ('', $minval)
+ exec_multi(
+ 4, "FILTER($typ) NO FILTER",
+ [ 1, '>=', [ '', $minval ], 1000, 0 ]
+ );
+ for my $v (@$values) {
+ my $vstr = defined($v) ? $v : 'NULL';
+ # select * ... where (k1, k2) >= ('', $minval) and v2 = $v
+ exec_multi(
+ 4, "FILTER($typ) v2 = $vstr",
+ [ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '=', 0, $v ] ] ]
+ );
+ # select * ... where (k1, k2) >= ('', $minval) and v2 != $v
+ exec_multi(
+ 4, "FILTER($typ) v2 != $vstr",
+ [ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '!=', 0, $v ] ] ]
+ );
+ # select * ... where (k1, k2) >= ('', $minval) and v2 >= $v
+ exec_multi(
+ 4, "FILTER($typ) v2 >= $vstr",
+ [ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '>=', 0, $v ] ] ]
+ );
+ # select * ... where (k1, k2) >= ('', $minval) and v2 < $v
+ exec_multi(
+ 4, "FILTER($typ) v2 < $vstr",
+ [ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '<', 0, $v ] ] ]
+ );
+ # select * ... where (k1, k2) >= ('', $minval) and v2 > $v
+ exec_multi(
+ 4, "FILTER($typ) v2 > $vstr",
+ [ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '>', 0, $v ] ] ]
+ );
+ # select * ... where (k1, k2) >= ('', $minval) and v2 <= $v
+ exec_multi(
+ 4, "FILTER($typ) v2 <= $vstr",
+ [ 1, '>=', [ '', $minval ], 1000, 0, undef, undef, [ [ 'F', '<=', 0, $v ] ] ]
+ );
+ }
+ undef $hs;
+}
+
+sub exec_multi {
+ my $width = shift(@_);
+ my $mess = shift(@_);
+ print "$mess\n";
+ my $mres = $hs->execute_multi(\@_);
+ for my $res (@$mres) {
+ my $code = shift(@$res);
+ my $nrows = $code == 0 ? scalar(@$res) / $width : 0;
+ print "code=$code rows=$nrows\n";
+ my $i = 0;
+ for my $fld (@$res) {
+ $fld = 'NULL' if !defined($fld);
+ print "[$fld]";
+ if (++$i >= $width) {
+ print "\n";
+ $i = 0;
+ }
+ }
+ print "\n";
+ }
+}
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test20.expected b/plugin/handler_socket/regtest/test_01_lib/test20.expected
new file mode 100644
index 00000000000..996f63870d2
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test20.expected
@@ -0,0 +1,2 @@
+open_index 1st r=1
+open_index 2nd r=0
diff --git a/plugin/handler_socket/regtest/test_01_lib/test20.pl b/plugin/handler_socket/regtest/test_01_lib/test20.pl
new file mode 100644
index 00000000000..139bbf9aba1
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test20.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for a bug that table mdl is not released when open_index is failed
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $dbname = $hstest::conf{dbname};
+my $table = 'hstesttbl';
+
+$dbh->do("drop table if exists $table");
+
+my $hs = hstest::get_hs_connection();
+my $r = $hs->open_index(1, $dbname, $table, '', 'k,v'); # fails
+print "open_index 1st r=$r\n";
+undef $hs;
+
+$dbh->do(
+ "create table $table (k varchar(30) primary key, v varchar(30) not null) " .
+ "engine = innodb");
+
+$hs = hstest::get_hs_connection();
+$r = $hs->open_index(1, $dbname, $table, '', 'k,v'); # success
+print "open_index 2nd r=$r\n";
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test21.expected b/plugin/handler_socket/regtest/test_01_lib/test21.expected
new file mode 100644
index 00000000000..1d78f805b6f
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test21.expected
@@ -0,0 +1,11 @@
+HS
+k10 v704-10
+k30 v52-30
+k40 v878-40
+k50 v682-50
+SQL
+k10 v704-10
+k30 v52-30
+k40 v878-40
+k50 v682-50
+END
diff --git a/plugin/handler_socket/regtest/test_01_lib/test21.pl b/plugin/handler_socket/regtest/test_01_lib/test21.pl
new file mode 100644
index 00000000000..413ea636400
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test21.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for 'IN'
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $table = 'hstesttbl';
+my $tablesize = 100;
+$dbh->do(
+ "create table $table (k varchar(30) primary key, v varchar(30) not null) " .
+ "engine = innodb");
+srand(999);
+
+my %valmap = ();
+
+my $sth = $dbh->prepare("insert into $table values (?,?)");
+for (my $i = 0; $i < $tablesize; ++$i) {
+ my $k = "k" . $i;
+ my $v = "v" . int(rand(1000)) . "-" . $i;
+ $sth->execute($k, $v);
+ $valmap{$k} = $v;
+}
+
+my $hs = hstest::get_hs_connection();
+my $dbname = $hstest::conf{dbname};
+$hs->open_index(1, $dbname, $table, '', 'k,v');
+my $vs = [ 'k10', 'k20x', 'k30', 'k40', 'k50' ];
+# select k,v from $table where k in $vs
+my $r = $hs->execute_single(1, '=', [ '' ], 10000, 0, undef, undef, undef,
+ 0, $vs);
+shift(@$r);
+print "HS\n";
+my $len = scalar(@$r) / 2;
+for (my $i = 0; $i < $len; ++$i) {
+ my $k = $r->[$i * 2];
+ my $v = $r->[$i * 2 + 1];
+ print "$k $v\n";
+}
+
+print "SQL\n";
+my $aref = $dbh->selectall_arrayref(
+ "select k,v from $table where k in ('k10', 'k20x', 'k30', 'k40', 'k50') "
+ . "order by k");
+for my $row (@$aref) {
+ my ($k, $v) = @$row;
+ print "$k $v\n";
+}
+print "END\n";
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test22.expected b/plugin/handler_socket/regtest/test_01_lib/test22.expected
new file mode 100644
index 00000000000..5ad2bfae1f8
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test22.expected
@@ -0,0 +1,9 @@
+HS
+k10 v704-10 1
+k30 v52-30 1
+k50 v682-50 1
+SQL
+k10 v704-10 1
+k30 v52-30 1
+k50 v682-50 1
+END
diff --git a/plugin/handler_socket/regtest/test_01_lib/test22.pl b/plugin/handler_socket/regtest/test_01_lib/test22.pl
new file mode 100644
index 00000000000..cf029944292
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test22.pl
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for 'IN' and filters
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $table = 'hstesttbl';
+my $tablesize = 100;
+$dbh->do(
+ "create table $table (k varchar(30) primary key, " .
+ "v varchar(30) not null, v2 int not null) " .
+ "engine = innodb");
+srand(999);
+
+my %valmap = ();
+
+my $sth = $dbh->prepare("insert into $table values (?,?,?)");
+for (my $i = 0; $i < $tablesize; ++$i) {
+ my $k = "k" . $i;
+ my $v = "v" . int(rand(1000)) . "-" . $i;
+ my $v2 = ($i / 10) % 2;
+ $sth->execute($k, $v, $v2);
+ $valmap{$k} = $v;
+}
+
+my $hs = hstest::get_hs_connection();
+my $dbname = $hstest::conf{dbname};
+$hs->open_index(1, $dbname, $table, '', 'k,v,v2', 'v2');
+my $vs = [ 'k10', 'k20x', 'k30', 'k40', 'k50' ];
+# select k,v,v2 from $table where k in $vs
+my $r = $hs->execute_single(1, '=', [ '' ], 10000, 0, undef, undef,
+ [['F', '=', 0, '1']], 0, $vs);
+shift(@$r);
+print "HS\n";
+my $len = scalar(@$r) / 3;
+for (my $i = 0; $i < $len; ++$i) {
+ my $k = $r->[$i * 3];
+ my $v = $r->[$i * 3 + 1];
+ my $v2 = $r->[$i * 3 + 2];
+ print "$k $v $v2\n";
+}
+
+print "SQL\n";
+my $aref = $dbh->selectall_arrayref(
+ "select k,v,v2 from $table where k in ('k10', 'k20x', 'k30', 'k40', 'k50') "
+ . "and v2 = '1' order by k");
+for my $row (@$aref) {
+ my ($k, $v, $v2) = @$row;
+ print "$k $v $v2\n";
+}
+print "END\n";
+
diff --git a/plugin/handler_socket/regtest/test_01_lib/test23.expected b/plugin/handler_socket/regtest/test_01_lib/test23.expected
new file mode 100644
index 00000000000..16ed1884c4b
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test23.expected
@@ -0,0 +1,101 @@
+HS
+k0 v102-0 0
+k1 v635-1 0
+k10 MOD 1
+k11 v751-11 1
+k12 v367-12 1
+k13 v400-13 1
+k14 v397-14 1
+k15 v170-15 1
+k16 v719-16 1
+k17 v734-17 1
+k18 v587-18 1
+k19 v494-19 1
+k2 v803-2 0
+k20 v523-20 0
+k21 v954-21 0
+k22 v433-22 0
+k23 v820-23 0
+k24 v283-24 0
+k25 v837-25 0
+k26 v205-26 0
+k27 v415-27 0
+k28 v545-28 0
+k29 v583-29 0
+k3 v925-3 0
+k30 MOD 1
+k31 v323-31 1
+k32 v614-32 1
+k33 v679-33 1
+k34 v805-34 1
+k35 v451-35 1
+k36 v115-36 1
+k37 v269-37 1
+k38 v218-38 1
+k39 v617-39 1
+k4 v775-4 0
+k40 v878-40 0
+k41 v345-41 0
+k42 v512-42 0
+k43 v969-43 0
+k44 v408-44 0
+k45 v291-45 0
+k46 v858-46 0
+k47 v953-47 0
+k48 v710-48 0
+k49 v142-49 0
+k5 v537-5 0
+k50 MOD 1
+k51 v934-51 1
+k52 v621-52 1
+k53 v965-53 1
+k54 v574-54 1
+k55 v204-55 1
+k56 v298-56 1
+k57 v134-57 1
+k58 v983-58 1
+k59 v444-59 1
+k6 v592-6 0
+k60 v144-60 0
+k61 v152-61 0
+k62 v187-62 0
+k63 v215-63 0
+k64 v8-64 0
+k65 v697-65 0
+k66 v651-66 0
+k67 v280-67 0
+k68 v701-68 0
+k69 v537-69 0
+k7 v414-7 0
+k70 v413-70 1
+k71 v69-71 1
+k72 v86-72 1
+k73 v822-73 1
+k74 v670-74 1
+k75 v370-75 1
+k76 v806-76 1
+k77 v688-77 1
+k78 v26-78 1
+k79 v66-79 1
+k8 v590-8 0
+k80 v802-80 0
+k81 v171-81 0
+k82 v557-82 0
+k83 v847-83 0
+k84 v777-84 0
+k85 v730-85 0
+k86 v987-86 0
+k87 v115-87 0
+k88 v646-88 0
+k89 v496-89 0
+k9 v302-9 0
+k90 v120-90 1
+k91 v684-91 1
+k92 v374-92 1
+k93 v65-93 1
+k94 v370-94 1
+k95 v174-95 1
+k96 v828-96 1
+k97 v867-97 1
+k98 v759-98 1
+k99 v703-99 1
diff --git a/plugin/handler_socket/regtest/test_01_lib/test23.pl b/plugin/handler_socket/regtest/test_01_lib/test23.pl
new file mode 100644
index 00000000000..83c2194bfa6
--- /dev/null
+++ b/plugin/handler_socket/regtest/test_01_lib/test23.pl
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+# vim:sw=2:ai
+
+# test for 'IN', filters, and modifications
+
+BEGIN {
+ push @INC, "../common/";
+};
+
+use strict;
+use warnings;
+use hstest;
+
+my $dbh = hstest::init_testdb();
+my $table = 'hstesttbl';
+my $tablesize = 100;
+$dbh->do(
+ "create table $table (k varchar(30) primary key, " .
+ "v varchar(30) not null, v2 int not null) " .
+ "engine = innodb");
+srand(999);
+
+my %valmap = ();
+
+my $sth = $dbh->prepare("insert into $table values (?,?,?)");
+for (my $i = 0; $i < $tablesize; ++$i) {
+ my $k = "k" . $i;
+ my $v = "v" . int(rand(1000)) . "-" . $i;
+ my $v2 = ($i / 10) % 2;
+ $sth->execute($k, $v, $v2);
+ $valmap{$k} = $v;
+}
+
+my $hs = hstest::get_hs_connection(undef, 9999);
+my $dbname = $hstest::conf{dbname};
+$hs->open_index(1, $dbname, $table, '', 'k,v,v2', 'v2');
+$hs->open_index(2, $dbname, $table, '', 'v', 'v2');
+my $vs = [ 'k10', 'k20x', 'k30', 'k40', 'k50' ];
+# update $table set v = 'MOD' where k in $vs and v2 = '1'
+my $r = $hs->execute_single(2, '=', [ '' ], 10000, 0, 'U', [ 'MOD' ],
+ [['F', '=', 0, '1']], 0, $vs);
+$r = $hs->execute_single(1, '>=', [ '' ], 10000, 0);
+shift(@$r);
+print "HS\n";
+my $len = scalar(@$r) / 3;
+for (my $i = 0; $i < $len; ++$i) {
+ my $k = $r->[$i * 3];
+ my $v = $r->[$i * 3 + 1];
+ my $v2 = $r->[$i * 3 + 2];
+ print "$k $v $v2\n";
+}
+
diff --git a/regex/my_regex.h b/regex/my_regex.h
index 0d1cedf5430..30896e29b91 100644
--- a/regex/my_regex.h
+++ b/regex/my_regex.h
@@ -28,6 +28,7 @@ typedef struct {
/* === regcomp.c === */
+typedef int (*my_regex_stack_check_t)();
extern int my_regcomp(my_regex_t *, const char *, int, CHARSET_INFO *charset);
#define REG_BASIC 0000
#define REG_EXTENDED 0001
@@ -76,7 +77,8 @@ extern void my_regfree(my_regex_t *);
/* === reginit.c === */
-extern void my_regex_init(CHARSET_INFO *cs); /* Should be called for multithread progs */
+/* Should be called for multithread progs */
+extern void my_regex_init(CHARSET_INFO *cs, my_regex_stack_check_t func);
extern void my_regex_end(void); /* If one wants a clean end */
#ifdef __cplusplus
diff --git a/regex/regcomp.c b/regex/regcomp.c
index 81c435ed552..e163a9ba7f4 100644
--- a/regex/regcomp.c
+++ b/regex/regcomp.c
@@ -31,6 +31,9 @@ struct parse {
CHARSET_INFO *charset; /* for ctype things */
};
+/* Check if there is enough stack space for recursion. */
+my_regex_stack_check_t my_regex_enough_mem_in_stack= NULL;
+
#include "regcomp.ih"
static char nuls[10]; /* place to point scanner in event of error */
@@ -117,7 +120,7 @@ CHARSET_INFO *charset;
# define GOODFLAGS(f) ((f)&~REG_DUMP)
#endif
- my_regex_init(charset); /* Init cclass if neaded */
+ my_regex_init(charset, NULL); /* Init cclass if neaded */
preg->charset=charset;
cflags = GOODFLAGS(cflags);
if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
@@ -222,7 +225,15 @@ int stop; /* character this ERE should end at */
/* do a bunch of concatenated expressions */
conc = HERE();
while (MORE() && (c = PEEK()) != '|' && c != stop)
- p_ere_exp(p);
+ {
+ if (my_regex_enough_mem_in_stack &&
+ my_regex_enough_mem_in_stack())
+ {
+ SETERROR(REG_ESPACE);
+ return;
+ }
+ p_ere_exp(p);
+ }
if(REQUIRE(HERE() != conc, REG_EMPTY)) {}/* require nonempty */
if (!EAT('|'))
diff --git a/regex/reginit.c b/regex/reginit.c
index 5980de24030..3d2cd64d1e7 100644
--- a/regex/reginit.c
+++ b/regex/reginit.c
@@ -4,10 +4,12 @@
#include <m_ctype.h>
#include <m_string.h>
#include "cclass.h"
+#include "my_regex.h"
static my_bool regex_inited=0;
+extern my_regex_stack_check_t my_regex_enough_mem_in_stack;
-void my_regex_init(CHARSET_INFO *cs)
+void my_regex_init(CHARSET_INFO *cs, my_regex_stack_check_t func)
{
char buff[CCLASS_LAST][256];
int count[CCLASS_LAST];
@@ -16,6 +18,7 @@ void my_regex_init(CHARSET_INFO *cs)
if (!regex_inited)
{
regex_inited=1;
+ my_regex_enough_mem_in_stack= func;
bzero((uchar*) &count,sizeof(count));
for (i=1 ; i<= 255; i++)
@@ -74,6 +77,7 @@ void my_regex_end()
int i;
for (i=0; i < CCLASS_LAST ; i++)
free((char*) cclasses[i].chars);
+ my_regex_enough_mem_in_stack= NULL;
regex_inited=0;
}
}
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index aabb1fdb4b7..468517d27cd 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -28,9 +28,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
-CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
@@ -62,11 +62,11 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'IGNORE_BAD_TABLE_OPTIONS', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
-- Create general_log if CSV is enabled.
-SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0');
+SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP(6) NOT NULL, user_host MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
@@ -74,7 +74,7 @@ DROP PREPARE stmt;
-- Create slow_log if CSV is enabled.
-SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
+SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP(6) NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME(6) NOT NULL, lock_time TIME(6) NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 44fadcc6e00..245bfe01c0a 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -222,7 +222,7 @@ ALTER TABLE func
SET @old_log_state = @@global.general_log;
SET GLOBAL general_log = 'OFF';
ALTER TABLE general_log
- MODIFY event_time TIMESTAMP NOT NULL,
+ MODIFY event_time TIMESTAMP(6) NOT NULL,
MODIFY user_host MEDIUMTEXT NOT NULL,
MODIFY thread_id INTEGER NOT NULL,
MODIFY server_id INTEGER UNSIGNED NOT NULL,
@@ -233,10 +233,10 @@ SET GLOBAL general_log = @old_log_state;
SET @old_log_state = @@global.slow_query_log;
SET GLOBAL slow_query_log = 'OFF';
ALTER TABLE slow_log
- MODIFY start_time TIMESTAMP NOT NULL,
+ MODIFY start_time TIMESTAMP(6) NOT NULL,
MODIFY user_host MEDIUMTEXT NOT NULL,
- MODIFY query_time TIME NOT NULL,
- MODIFY lock_time TIME NOT NULL,
+ MODIFY query_time TIME(6) NOT NULL,
+ MODIFY lock_time TIME(6) NOT NULL,
MODIFY rows_sent INTEGER NOT NULL,
MODIFY rows_examined INTEGER NOT NULL,
MODIFY db VARCHAR(512) NOT NULL,
@@ -363,7 +363,7 @@ ALTER TABLE procs_priv
COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
ALTER TABLE procs_priv
- MODIFY Timestamp timestamp(14) AFTER Proc_priv;
+ MODIFY Timestamp timestamp AFTER Proc_priv;
#
# proc
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index 398573875d9..ec4b418a4eb 100644
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -856,7 +856,7 @@ A sample log-pos table definition:
CREATE TABLE log_pos (
host varchar(60) NOT null,
- time_stamp timestamp(14) NOT NULL,
+ time_stamp timestamp NOT NULL,
log_file varchar(32) default NULL,
log_pos int(11) default NULL,
master_host varchar(60) NULL,
diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh
index 76334d76108..de92fd80a40 100644
--- a/sql-bench/server-cfg.sh
+++ b/sql-bench/server-cfg.sh
@@ -179,12 +179,23 @@ sub new
{
$limits{'working_blobs'} = 0; # HEAP tables can't handle BLOB's
}
+ # HEAP is deprecated in favor of MEMORY
+ if (defined($main::opt_create_options) &&
+ $main::opt_create_options =~ /engine=memory/i)
+ {
+ $limits{'working_blobs'} = 0; # MEMORY tables can't handle BLOB's
+ }
if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /engine=innodb/i)
{
$self->{'transactions'} = 1; # Transactions enabled
}
if (defined($main::opt_create_options) &&
+ $main::opt_create_options =~ /engine=pbxt/i)
+ {
+ $self->{'transactions'} = 1; # Transactions enabled
+ }
+ if (defined($main::opt_create_options) &&
$main::opt_create_options =~ /engine=ndb/i)
{
$self->{'transactions'} = 1; # Transactions enabled
diff --git a/sql-bench/test-table-elimination.sh b/sql-bench/test-table-elimination.sh
index 338a7ceb4b5..0dcfe975486 100755
--- a/sql-bench/test-table-elimination.sh
+++ b/sql-bench/test-table-elimination.sh
@@ -1,3 +1,4 @@
+
#!@PERL@
# Test of table elimination feature
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 30edf820cbd..1d7960101a7 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -18,6 +18,7 @@
#include <m_ctype.h>
/* Windows version of localtime_r() is declared in my_ptrhead.h */
#include <my_pthread.h>
+#include <mysqld_error.h>
ulonglong log_10_int[20]=
{
@@ -81,7 +82,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
if (not_zero_date)
{
if ((((flags & TIME_NO_ZERO_IN_DATE) || !(flags & TIME_FUZZY_DATE)) &&
- (ltime->month == 0 || ltime->day == 0)) ||
+ (ltime->month == 0 || ltime->day == 0)) || ltime->neg ||
(!(flags & TIME_INVALID_DATES) &&
ltime->month && ltime->day > days_in_month[ltime->month-1] &&
(ltime->month != 2 || calc_days_in_year(ltime->year) != 366 ||
@@ -158,7 +159,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
enum enum_mysql_timestamp_type
str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
- uint flags, int *was_cut)
+ ulong flags, int *was_cut)
{
uint field_length, UNINIT_VAR(year_length), digits, i, number_of_fields;
uint date[MAX_DATE_PARTS], date_len[MAX_DATE_PARTS];
@@ -171,10 +172,17 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
my_bool found_delimitier= 0, found_space= 0;
uint frac_pos, frac_len;
DBUG_ENTER("str_to_datetime");
- DBUG_PRINT("ENTER",("str: %.*s",length,str));
+ DBUG_PRINT("enter",("str: %.*s",length,str));
LINT_INIT(field_length);
+ if (flags & TIME_TIME_ONLY)
+ {
+ enum enum_mysql_timestamp_type ret;
+ ret= str_to_time(str, length, l_time, flags, was_cut);
+ DBUG_RETURN(ret);
+ }
+
*was_cut= 0;
/* Skip space at start */
@@ -477,12 +485,13 @@ err:
work with times where the time arguments are in the above order.
RETURN
- 0 ok
- 1 error
+ MYSQL_TIMESTAMP_TIME
+ MYSQL_TIMESTAMP_ERROR
*/
-my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
- int *warning)
+enum enum_mysql_timestamp_type
+str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
+ ulong fuzzydate, int *warning)
{
ulong date[5];
ulonglong value;
@@ -501,7 +510,7 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
length--;
}
if (str == end)
- return 1;
+ return MYSQL_TIMESTAMP_ERROR;
/* Check first if this is a full TIMESTAMP */
if (length >= 12)
@@ -509,12 +518,13 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time,
int was_cut;
enum enum_mysql_timestamp_type
res= str_to_datetime(str, length, l_time,
- (TIME_FUZZY_DATE | TIME_DATETIME_ONLY), &was_cut);
+ (fuzzydate & ~TIME_TIME_ONLY) | TIME_DATETIME_ONLY,
+ &was_cut);
if ((int) res >= (int) MYSQL_TIMESTAMP_ERROR)
{
if (was_cut)
*warning|= MYSQL_TIME_WARN_TRUNCATED;
- return res == MYSQL_TIMESTAMP_ERROR;
+ return res;
}
}
@@ -609,7 +619,7 @@ fractional:
((str[1] == '-' || str[1] == '+') &&
(end - str) > 2 &&
my_isdigit(&my_charset_latin1, str[2]))))
- return 1;
+ return MYSQL_TIMESTAMP_ERROR;
if (internal_format_positions[7] != 255)
{
@@ -632,7 +642,7 @@ fractional:
if (date[0] > UINT_MAX || date[1] > UINT_MAX ||
date[2] > UINT_MAX || date[3] > UINT_MAX ||
date[4] > UINT_MAX)
- return 1;
+ return MYSQL_TIMESTAMP_ERROR;
l_time->year= 0; /* For protocol::store_time */
l_time->month= 0;
@@ -644,8 +654,8 @@ fractional:
l_time->time_type= MYSQL_TIMESTAMP_TIME;
/* Check if the value is valid and fits into MYSQL_TIME range */
- if (check_time_range(l_time, warning))
- return 1;
+ if (check_time_range(l_time, 6, warning))
+ return MYSQL_TIMESTAMP_ERROR;
/* Check if there is garbage at end of the MYSQL_TIME specification */
if (str != end)
@@ -659,7 +669,7 @@ fractional:
}
} while (++str != end);
}
- return 0;
+ return MYSQL_TIMESTAMP_TIME;
}
@@ -669,6 +679,7 @@ fractional:
SYNOPSIS:
check_time_range()
time pointer to MYSQL_TIME value
+ uint dec
warning set MYSQL_TIME_WARN_OUT_OF_RANGE flag if the value is out of range
DESCRIPTION
@@ -681,24 +692,31 @@ fractional:
1 time value is invalid
*/
-int check_time_range(struct st_mysql_time *my_time, int *warning)
+int check_time_range(struct st_mysql_time *my_time, uint dec, int *warning)
{
longlong hour;
+ static ulong max_sec_part[TIME_SECOND_PART_DIGITS+1]= {000000, 900000, 990000,
+ 999000, 999900, 999990, 999999};
if (my_time->minute >= 60 || my_time->second >= 60)
return 1;
hour= my_time->hour + (24*my_time->day);
+
+ if (dec == AUTO_SEC_PART_DIGITS)
+ dec= TIME_SECOND_PART_DIGITS;
+
if (hour <= TIME_MAX_HOUR &&
(hour != TIME_MAX_HOUR || my_time->minute != TIME_MAX_MINUTE ||
- my_time->second != TIME_MAX_SECOND || !my_time->second_part))
+ my_time->second != TIME_MAX_SECOND ||
+ my_time->second_part <= max_sec_part[dec]))
return 0;
my_time->day= 0;
my_time->hour= TIME_MAX_HOUR;
my_time->minute= TIME_MAX_MINUTE;
my_time->second= TIME_MAX_SECOND;
- my_time->second_part= 0;
+ my_time->second_part= max_sec_part[dec];
*warning|= MYSQL_TIME_WARN_OUT_OF_RANGE;
return 0;
}
@@ -715,7 +733,7 @@ void my_init_time(void)
time_t seconds;
struct tm *l_time,tm_tmp;
MYSQL_TIME my_time;
- my_bool not_used;
+ uint not_used;
seconds= (time_t) time((time_t*) 0);
localtime_r(&seconds,&tm_tmp);
@@ -776,7 +794,7 @@ long calc_daynr(uint year,uint month,uint day)
int y= year; /* may be < 0 temporarily */
DBUG_ENTER("calc_daynr");
- if (y == 0 && month == 0 && day == 0)
+ if (y == 0 && month == 0)
DBUG_RETURN(0); /* Skip errors */
/* Cast to int to be able to handle month == 0 */
delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day);
@@ -787,6 +805,7 @@ long calc_daynr(uint year,uint month,uint day)
temp=(int) ((y/100+1)*3)/4;
DBUG_PRINT("exit",("year: %d month: %d day: %d -> daynr: %ld",
y+(month <= 2),month,day,delsum+y/4-temp));
+ DBUG_ASSERT(delsum+(int) y/4-temp > 0);
DBUG_RETURN(delsum+(int) y/4-temp);
} /* calc_daynr */
@@ -800,7 +819,11 @@ long calc_daynr(uint year,uint month,uint day)
t - time value to be converted
my_timezone - pointer to long where offset of system time zone
from UTC will be stored for caching
- in_dst_time_gap - set to true if time falls into spring time-gap
+ error_code - 0, if the conversion was successful;
+ ER_WARN_DATA_OUT_OF_RANGE, if t contains datetime value
+ which is out of TIMESTAMP range;
+ ER_WARN_INVALID_TIMESTAMP, if t represents value which
+ doesn't exists (falls into the spring time-gap).
NOTES
The idea is to cache the time zone offset from UTC (including daylight
@@ -814,8 +837,7 @@ long calc_daynr(uint year,uint month,uint day)
Time in UTC seconds since Unix Epoch representation.
*/
my_time_t
-my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
- my_bool *in_dst_time_gap)
+my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, uint *error_code)
{
uint loop;
time_t tmp= 0;
@@ -832,7 +854,11 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
memcpy(&tmp_time, t_src, sizeof(MYSQL_TIME));
if (!validate_timestamp_range(t))
+ {
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
return 0;
+ }
+ *error_code= 0;
/*
Calculate the gmt time based on current time and timezone
@@ -978,7 +1004,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
else if (diff == -3600)
tmp-=t->minute*60 + t->second; /* Move to previous hour */
- *in_dst_time_gap= 1;
+ *error_code= ER_WARN_INVALID_TIMESTAMP;
}
*my_timezone= current_timezone;
@@ -996,8 +1022,11 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
with unsigned time_t tmp+= shift*86400L might result in a number,
larger then TIMESTAMP_MAX_VALUE, so another check will work.
*/
- if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE))
+ if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tmp))
+ {
tmp= 0;
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
+ }
return (my_time_t) tmp;
} /* my_system_gmt_sec */
@@ -1017,22 +1046,27 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type)
using default format.
This functions don't check that given MYSQL_TIME structure members are
in valid range. If they are not, return value won't reflect any
- valid date either. Additionally, make_time doesn't take into
- account time->day member: it's assumed that days have been converted
- to hours already.
+ valid date either.
RETURN
number of characters written to 'to'
*/
-int my_time_to_str(const MYSQL_TIME *l_time, char *to)
+int my_time_to_str(const MYSQL_TIME *l_time, char *to, uint digits)
{
- uint extra_hours= 0;
- return my_sprintf(to, (to, "%s%02u:%02u:%02u",
- (l_time->neg ? "-" : ""),
- extra_hours+ l_time->hour,
- l_time->minute,
- l_time->second));
+ ulong day= (l_time->year || l_time->month) ? 0 : l_time->day;
+
+ if (digits == AUTO_SEC_PART_DIGITS)
+ digits= l_time->second_part ? TIME_SECOND_PART_DIGITS : 0;
+
+ DBUG_ASSERT(digits <= TIME_SECOND_PART_DIGITS);
+
+ return sprintf(to,
+ digits ? "%s%02lu:%02u:%02u.%0*lu"
+ : "%s%02lu:%02u:%02u",
+ (l_time->neg ? "-" : ""),
+ day * 24L + l_time->hour, l_time->minute, l_time->second,
+ digits, (ulong)sec_part_shift(l_time->second_part, digits));
}
int my_date_to_str(const MYSQL_TIME *l_time, char *to)
@@ -1043,15 +1077,19 @@ int my_date_to_str(const MYSQL_TIME *l_time, char *to)
l_time->day));
}
-int my_datetime_to_str(const MYSQL_TIME *l_time, char *to)
+int my_datetime_to_str(const MYSQL_TIME *l_time, char *to, uint digits)
{
- return my_sprintf(to, (to, "%04u-%02u-%02u %02u:%02u:%02u",
- l_time->year,
- l_time->month,
- l_time->day,
- l_time->hour,
- l_time->minute,
- l_time->second));
+ if (digits == AUTO_SEC_PART_DIGITS)
+ digits= l_time->second_part ? TIME_SECOND_PART_DIGITS : 0;
+
+ DBUG_ASSERT(digits <= TIME_SECOND_PART_DIGITS);
+
+ return sprintf(to,
+ digits ? "%04u-%02u-%02u %02u:%02u:%02u.%0*lu"
+ : "%04u-%02u-%02u %02u:%02u:%02u",
+ l_time->year, l_time->month, l_time->day,
+ l_time->hour, l_time->minute, l_time->second,
+ digits, (ulong)sec_part_shift(l_time->second_part, digits));
}
@@ -1062,19 +1100,22 @@ int my_datetime_to_str(const MYSQL_TIME *l_time, char *to)
SYNOPSIS
my_TIME_to_string()
+ RETURN
+ length of string
+
NOTE
The string must have at least MAX_DATE_STRING_REP_LENGTH bytes reserved.
*/
-int my_TIME_to_str(const MYSQL_TIME *l_time, char *to)
+int my_TIME_to_str(const MYSQL_TIME *l_time, char *to, uint digits)
{
switch (l_time->time_type) {
case MYSQL_TIMESTAMP_DATETIME:
- return my_datetime_to_str(l_time, to);
+ return my_datetime_to_str(l_time, to, digits);
case MYSQL_TIMESTAMP_DATE:
return my_date_to_str(l_time, to);
case MYSQL_TIMESTAMP_TIME:
- return my_time_to_str(l_time, to);
+ return my_time_to_str(l_time, to, digits);
case MYSQL_TIMESTAMP_NONE:
case MYSQL_TIMESTAMP_ERROR:
to[0]='\0';
@@ -1112,16 +1153,15 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to)
Datetime value in YYYYMMDDHHMMSS format.
*/
-longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
+longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res,
uint flags, int *was_cut)
{
long part1,part2;
*was_cut= 0;
- bzero((char*) time_res, sizeof(*time_res));
time_res->time_type=MYSQL_TIMESTAMP_DATE;
- if (nr == LL(0) || nr >= LL(10000101000000))
+ if (nr == 0 || nr >= 10000101000000LL || sec_part)
{
time_res->time_type=MYSQL_TIMESTAMP_DATETIME;
goto ok;
@@ -1171,22 +1211,87 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
time_res->hour= (int) (part2/10000L); part2%=10000L;
time_res->minute=(int) part2 / 100;
time_res->second=(int) part2 % 100;
+ time_res->second_part= sec_part;
+ time_res->neg= 0;
if (time_res->year <= 9999 && time_res->month <= 12 &&
time_res->day <= 31 && time_res->hour <= 23 &&
time_res->minute <= 59 && time_res->second <= 59 &&
- !check_date(time_res, (nr != 0), flags, was_cut))
+ sec_part <= TIME_MAX_SECOND_PART &&
+ !check_date(time_res, nr || sec_part, flags, was_cut))
return nr;
/* Don't want to have was_cut get set if NO_ZERO_DATE was violated. */
- if (!nr && (flags & TIME_NO_ZERO_DATE))
- return LL(-1);
+ if (nr || !(flags & TIME_NO_ZERO_DATE))
+ *was_cut= 1;
+ return LL(-1);
err:
- *was_cut= 1;
+ {
+ /* reset everything except time_type */
+ enum enum_mysql_timestamp_type save= time_res->time_type;
+ bzero((char*) time_res, sizeof(*time_res));
+ time_res->time_type= save; /* Restore range */
+ *was_cut= 1; /* Found invalid date */
+ }
return LL(-1);
}
+/*
+ Convert a pair of integers to a MYSQL_TIME struct.
+
+ @param[in] nr a number to convert
+ @param[out] ltime Date to check.
+ @param[out] was_cut MYSQL_TIME_WARN_OUT_OF_RANGE if the value was
+ modified to fit in the valid range. Otherwise 0.
+
+ @details
+ Takes a number in the [-]HHHMMSS.uuuuuu,
+ YYMMDDHHMMSS.uuuuuu, or in the YYYYMMDDHHMMSS.uuuuuu formats.
+
+ @return
+ 0 time value is valid, but was possibly truncated
+ -1 time value is invalid
+*/
+int number_to_time(my_bool neg, longlong nr, ulong sec_part,
+ MYSQL_TIME *ltime, int *was_cut)
+{
+ if (nr > 9999999 && neg == 0)
+ {
+ if (number_to_datetime(nr, sec_part, ltime,
+ TIME_FUZZY_DATE | TIME_INVALID_DATES, was_cut) < 0)
+ return -1;
+
+ ltime->year= ltime->month= ltime->day= 0;
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
+ *was_cut= MYSQL_TIME_WARN_TRUNCATED;
+ return 0;
+ }
+
+ *was_cut= 0;
+ ltime->year= ltime->month= ltime->day= 0;
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
+
+ ltime->neg= neg;
+
+ if (nr > TIME_MAX_VALUE)
+ {
+ nr= TIME_MAX_VALUE;
+ sec_part= TIME_MAX_SECOND_PART;
+ *was_cut= MYSQL_TIME_WARN_OUT_OF_RANGE;
+ }
+ ltime->hour = (uint)(nr/100/100);
+ ltime->minute= nr/100%100;
+ ltime->second= nr%100;
+ ltime->second_part= sec_part;
+
+ if (ltime->minute < 60 && ltime->second < 60 && sec_part <= TIME_MAX_SECOND_PART)
+ return 0;
+
+ *was_cut= MYSQL_TIME_WARN_TRUNCATED;
+ return -1;
+}
+
/* Convert time value to integer in YYYYMMDDHHMMSS format */
@@ -1235,7 +1340,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time)
DESCRIPTION
The function is used when we need to convert value of time item
to a number if it's used in numeric context, i. e.:
- SELECT NOW()+1, CURDATE()+0, CURTIMIE()+0;
+ SELECT NOW()+1, CURDATE()+0, CURTIME()+0;
SELECT ?+1;
NOTE
@@ -1262,3 +1367,41 @@ ulonglong TIME_to_ulonglong(const MYSQL_TIME *my_time)
return 0;
}
+double TIME_to_double(const MYSQL_TIME *my_time)
+{
+ double d= (double)TIME_to_ulonglong(my_time);
+
+ if (my_time->time_type == MYSQL_TIMESTAMP_DATE)
+ return d;
+
+ d+= my_time->second_part/(double)TIME_SECOND_PART_FACTOR;
+ return my_time->neg ? -d : d;
+}
+
+longlong pack_time(MYSQL_TIME *my_time)
+{
+ return ((((((my_time->year * 13ULL +
+ my_time->month) * 32ULL +
+ my_time->day) * 24ULL +
+ my_time->hour) * 60ULL +
+ my_time->minute) * 60ULL +
+ my_time->second) * 1000000ULL +
+ my_time->second_part) * (my_time->neg ? -1 : 1);
+}
+
+#define get_one(WHERE, FACTOR) WHERE= (ulong)(packed % FACTOR); packed/= FACTOR
+
+MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time)
+{
+ if ((my_time->neg= packed < 0))
+ packed= -packed;
+ get_one(my_time->second_part, 1000000ULL);
+ get_one(my_time->second, 60ULL);
+ get_one(my_time->minute, 60ULL);
+ get_one(my_time->hour, 24ULL);
+ get_one(my_time->day, 32ULL);
+ get_one(my_time->month, 13ULL);
+ my_time->year= (uint)packed;
+ my_time->time_type= MYSQL_TIMESTAMP_DATETIME;
+ return my_time;
+}
diff --git a/sql/create_options.cc b/sql/create_options.cc
index a7124310279..42c69436897 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -258,7 +258,7 @@ static const size_t ha_option_type_sizeof[]=
@retval FALSE OK
*/
-my_bool parse_option_list(THD* thd, void **option_struct,
+my_bool parse_option_list(THD* thd, void *option_struct_arg,
engine_option_value *option_list,
ha_create_table_option *rules,
my_bool suppress_warning,
@@ -267,6 +267,7 @@ my_bool parse_option_list(THD* thd, void **option_struct,
ha_create_table_option *opt;
size_t option_struct_size= 0;
engine_option_value *val= option_list;
+ void **option_struct= (void**)option_struct_arg;
DBUG_ENTER("parse_option_list");
DBUG_PRINT("enter",
("struct: 0x%lx list: 0x%lx rules: 0x%lx suppres %u root 0x%lx",
diff --git a/sql/create_options.h b/sql/create_options.h
index b66bbf43570..174abb1a59a 100644
--- a/sql/create_options.h
+++ b/sql/create_options.h
@@ -70,7 +70,7 @@ class Create_field;
my_bool parse_engine_table_options(THD *thd, handlerton *ht,
TABLE_SHARE *share);
-my_bool parse_option_list(THD* thd, void **option_struct,
+my_bool parse_option_list(THD* thd, void *option_struct,
engine_option_value *option_list,
ha_create_table_option *rules,
my_bool suppress_warning,
diff --git a/sql/derror.cc b/sql/derror.cc
index a8cfa00ad1d..ae47f550dc6 100644
--- a/sql/derror.cc
+++ b/sql/derror.cc
@@ -1,4 +1,5 @@
/* Copyright (C) 2000-2005 MySQL AB
+ Copyright (C) 2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,6 +25,7 @@
#include "mysql_priv.h"
#include "mysys_err.h"
+static bool check_error_mesg(const char *file_name, const char **errmsg);
static bool read_texts(const char *file_name,const char ***point,
uint error_messages);
static void init_myfunc_errs(void);
@@ -32,9 +34,12 @@ static void init_myfunc_errs(void);
Read messages from errorfile.
This function can be called multiple times to reload the messages.
- If it fails to load the messages, it will fail softly by initializing
- the errmesg pointer to an array of empty strings or by keeping the
- old array if it exists.
+
+ If it fails to load the messages:
+ - If we already have error messages loaded, keep the old ones and
+ return FALSE(ok)
+ - Initializing the errmesg pointer to an array of empty strings
+ and return TRUE (error)
@retval
FALSE OK
@@ -44,25 +49,44 @@ static void init_myfunc_errs(void);
bool init_errmessage(void)
{
- const char **errmsgs, **ptr;
+ const char **errmsgs, **ptr, **org_errmsgs;
+ bool error= FALSE;
DBUG_ENTER("init_errmessage");
/*
Get a pointer to the old error messages pointer array.
read_texts() tries to free it.
*/
- errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
+ org_errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
/* Read messages from file. */
- if (read_texts(ERRMSG_FILE, &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) &&
- !errmsgs)
+ if (read_texts(ERRMSG_FILE, &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) ||
+ check_error_mesg(ERRMSG_FILE, errmsgs))
{
- if (!(errmsgs= (const char**) my_malloc((ER_ERROR_LAST-ER_ERROR_FIRST+1)*
- sizeof(char*), MYF(0))))
- DBUG_RETURN(TRUE);
- for (ptr= errmsgs; ptr < errmsgs + ER_ERROR_LAST - ER_ERROR_FIRST; ptr++)
- *ptr= "";
+ x_free(errmsgs);
+
+ if (org_errmsgs)
+ {
+ /* Use old error messages */
+ errmsgs= org_errmsgs;
+ }
+ else
+ {
+ /*
+ No error messages. Create a temporary empty error message so
+ that we don't get a crash if some code wrongly tries to access
+ a non existing error message.
+ */
+ if (!(errmsgs= (const char**) my_malloc((ER_ERROR_LAST-ER_ERROR_FIRST+1)*
+ sizeof(char*), MYF(0))))
+ DBUG_RETURN(TRUE);
+ for (ptr= errmsgs; ptr < errmsgs + ER_ERROR_LAST - ER_ERROR_FIRST; ptr++)
+ *ptr= "";
+ error= TRUE;
+ }
}
+ else
+ x_free(org_errmsgs); // Free old language
/* Register messages for use with my_error(). */
if (my_error_register(errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST))
@@ -73,7 +97,29 @@ bool init_errmessage(void)
errmesg= errmsgs; /* Init global variabel */
init_myfunc_errs(); /* Init myfunc messages */
- DBUG_RETURN(FALSE);
+ DBUG_RETURN(error);
+}
+
+
+/**
+ Check the error messages array contains all relevant error messages
+*/
+
+static bool check_error_mesg(const char *file_name, const char **errmsg)
+{
+ /*
+ The last MySQL error message can't be an empty string; If it is,
+ it means that the error file doesn't contain all MySQL messages
+ and is probably from an older version of MySQL / MariaDB.
+ */
+ if (errmsg[ER_LAST_MYSQL_ERROR_MESSAGE -1 - ER_ERROR_FIRST][0] == 0)
+ {
+ sql_print_error("Error message file '%s' is probably from and older "
+ "version of MariaDB / MYSQL as it doesn't contain all "
+ "error messages", file_name);
+ return 1;
+ }
+ return 0;
}
@@ -99,6 +145,8 @@ static bool read_texts(const char *file_name,const char ***point,
const char *errmsg;
DBUG_ENTER("read_texts");
+ *point= 0;
+
LINT_INIT(buff);
funktpos=0;
if ((file=my_open(fn_format(name,file_name,language,"",4),
@@ -108,6 +156,7 @@ static bool read_texts(const char *file_name,const char ***point,
funktpos=1;
if (my_read(file,(uchar*) head,32,MYF(MY_NABP))) goto err;
+ funktpos=2;
if (head[0] != (uchar) 254 || head[1] != (uchar) 254 ||
head[2] != 2 || head[3] != 1)
goto err; /* purecov: inspected */
@@ -133,19 +182,16 @@ Please install the latest version of this file.",name);
if (count < error_messages)
{
sql_print_error("\
-Error message file '%s' had only %d error messages,\n\
-but it should contain at least %d error messages.\n\
-Check that the above file is the right version for this program!",
+Error message file '%s' had only %d error messages, but it should contain at least %d error messages.\nCheck that the above file is the right version for this program!",
name,count,error_messages);
VOID(my_close(file,MYF(MY_WME)));
DBUG_RETURN(1);
}
- x_free((uchar*) *point); /* Free old language */
if (!(*point= (const char**)
my_malloc((size_t) (length+count*sizeof(char*)),MYF(0))))
{
- funktpos=2; /* purecov: inspected */
+ funktpos=3; /* purecov: inspected */
goto err; /* purecov: inspected */
}
buff= (uchar*) (*point + count);
@@ -169,9 +215,11 @@ Check that the above file is the right version for this program!",
err:
switch (funktpos) {
- case 2:
+ case 3:
errmsg= "Not enough memory for messagefile '%s'";
break;
+ case 2:
+ errmsg= "Incompatible header in messagefile '%s'. Probably from another version of MariaDB";
case 1:
errmsg= "Can't read from messagefile '%s'";
break;
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 959f6ec06c0..98c75c479e6 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -464,7 +464,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
DBUG_RETURN(TRUE);
starts_null= table->field[ET_FIELD_STARTS]->is_null();
- my_bool not_used= FALSE;
+ uint not_used;
if (!starts_null)
{
table->field[ET_FIELD_STARTS]->get_date(&time, TIME_NO_ZERO_DATE);
@@ -646,7 +646,7 @@ add_interval(MYSQL_TIME *ltime, const Time_zone *time_zone,
if (date_add_interval(ltime, scale, interval))
return 0;
- my_bool not_used;
+ uint not_used;
return time_zone->TIME_to_gmt_sec(ltime, &not_used);
}
@@ -927,7 +927,7 @@ Event_queue_element::compute_next_execution_time()
goto ret;
}
- time_now= (my_time_t) current_thd->query_start();
+ time_now= current_thd->query_start();
DBUG_PRINT("info",("NOW: [%lu]", (ulong) time_now));
@@ -1130,7 +1130,7 @@ err:
void
Event_queue_element::mark_last_executed(THD *thd)
{
- last_executed= (my_time_t) thd->query_start();
+ last_executed= thd->query_start();
last_executed_changed= TRUE;
execution_count++;
@@ -1190,7 +1190,7 @@ append_datetime(String *buf, Time_zone *time_zone, my_time_t secs,
*/
MYSQL_TIME time;
time_zone->gmt_sec_to_TIME(&time, secs);
- buf->append(dtime_buff, my_datetime_to_str(&time, dtime_buff));
+ buf->append(dtime_buff, my_datetime_to_str(&time, dtime_buff, 0));
buf->append(STRING_WITH_LEN("'"));
}
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index 13a2f8cf7c2..2d8524e5d89 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -232,6 +232,9 @@ mysql_event_fill_row(THD *thd,
rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
rs|= fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE);
+ if (!is_update)
+ rs|= fields[ET_FIELD_CREATED]->set_time();
+
/*
Change the SQL_MODE only if body was present in an ALTER EVENT and of course
always during CREATE EVENT.
@@ -278,7 +281,7 @@ mysql_event_fill_row(THD *thd,
my_tz_OFFSET0->gmt_sec_to_TIME(&time, et->starts);
fields[ET_FIELD_STARTS]->set_notnull();
- fields[ET_FIELD_STARTS]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ fields[ET_FIELD_STARTS]->store_time(&time);
}
if (!et->ends_null)
@@ -287,7 +290,7 @@ mysql_event_fill_row(THD *thd,
my_tz_OFFSET0->gmt_sec_to_TIME(&time, et->ends);
fields[ET_FIELD_ENDS]->set_notnull();
- fields[ET_FIELD_ENDS]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ fields[ET_FIELD_ENDS]->store_time(&time);
}
}
else if (et->execute_at)
@@ -306,8 +309,7 @@ mysql_event_fill_row(THD *thd,
my_tz_OFFSET0->gmt_sec_to_TIME(&time, et->execute_at);
fields[ET_FIELD_EXECUTE_AT]->set_notnull();
- fields[ET_FIELD_EXECUTE_AT]->
- store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ fields[ET_FIELD_EXECUTE_AT]->store_time(&time);
}
else
{
@@ -318,7 +320,7 @@ mysql_event_fill_row(THD *thd,
*/
}
- ((Field_timestamp *)fields[ET_FIELD_MODIFIED])->set_time();
+ rs|= fields[ET_FIELD_MODIFIED]->set_time();
if (et->comment.str)
{
@@ -425,8 +427,8 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table,
key_copy(key_buf, event_table->record[0], key_info, key_len);
if (!(ret= event_table->file->ha_index_read_map(event_table->record[0],
key_buf,
- (key_part_map)1,
- HA_READ_PREFIX)))
+ (key_part_map) 1,
+ HA_READ_KEY_EXACT)))
{
DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret));
do
@@ -674,8 +676,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
goto end;
}
- ((Field_timestamp *)table->field[ET_FIELD_CREATED])->set_time();
-
/*
mysql_event_fill_row() calls my_error() in case of error so no need to
handle it here
@@ -1087,8 +1087,7 @@ update_timing_fields_for_event(THD *thd,
my_tz_OFFSET0->gmt_sec_to_TIME(&time, last_executed);
fields[ET_FIELD_LAST_EXECUTED]->set_notnull();
- fields[ET_FIELD_LAST_EXECUTED]->store_time(&time,
- MYSQL_TIMESTAMP_DATETIME);
+ fields[ET_FIELD_LAST_EXECUTED]->store_time(&time);
}
if (update_status)
{
diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc
index 86905b38627..4555da44f18 100644
--- a/sql/event_parse_data.cc
+++ b/sql/event_parse_data.cc
@@ -111,7 +111,7 @@ Event_parse_data::init_name(THD *thd, sp_name *spn)
void
Event_parse_data::check_if_in_the_past(THD *thd, my_time_t ltime_utc)
{
- if (ltime_utc >= (my_time_t) thd->query_start())
+ if (ltime_utc >= thd->query_start())
return;
/*
@@ -198,7 +198,7 @@ Event_parse_data::check_dates(THD *thd, int previous_on_completion)
int
Event_parse_data::init_execute_at(THD *thd)
{
- my_bool not_used;
+ uint not_used;
MYSQL_TIME ltime;
my_time_t ltime_utc;
@@ -215,7 +215,7 @@ Event_parse_data::init_execute_at(THD *thd)
(starts_null && ends_null)));
DBUG_ASSERT(starts_null && ends_null);
- if ((not_used= item_execute_at->get_date(&ltime, TIME_NO_ZERO_DATE)))
+ if (item_execute_at->get_date(&ltime, TIME_NO_ZERO_DATE))
goto wrong_value;
ltime_utc= TIME_to_timestamp(thd,&ltime,&not_used);
@@ -368,7 +368,7 @@ wrong_value:
int
Event_parse_data::init_starts(THD *thd)
{
- my_bool not_used;
+ uint not_used;
MYSQL_TIME ltime;
my_time_t ltime_utc;
@@ -379,7 +379,7 @@ Event_parse_data::init_starts(THD *thd)
if (item_starts->fix_fields(thd, &item_starts))
goto wrong_value;
- if ((not_used= item_starts->get_date(&ltime, TIME_NO_ZERO_DATE)))
+ if (item_starts->get_date(&ltime, TIME_NO_ZERO_DATE))
goto wrong_value;
ltime_utc= TIME_to_timestamp(thd, &ltime, &not_used);
@@ -422,7 +422,7 @@ wrong_value:
int
Event_parse_data::init_ends(THD *thd)
{
- my_bool not_used;
+ uint not_used;
MYSQL_TIME ltime;
my_time_t ltime_utc;
@@ -434,7 +434,7 @@ Event_parse_data::init_ends(THD *thd)
goto error_bad_params;
DBUG_PRINT("info", ("convert to TIME"));
- if ((not_used= item_ends->get_date(&ltime, TIME_NO_ZERO_DATE)))
+ if (item_ends->get_date(&ltime, TIME_NO_ZERO_DATE))
goto error_bad_params;
ltime_utc= TIME_to_timestamp(thd, &ltime, &not_used);
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index 2a354fe6cfd..6016048aa9c 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -530,9 +530,10 @@ Event_queue::empty_queue()
*/
void
-Event_queue::dbug_dump_queue(time_t now)
+Event_queue::dbug_dump_queue(my_time_t when)
{
#ifndef DBUG_OFF
+ my_time_t now= when;
Event_queue_element *et;
uint i;
DBUG_ENTER("Event_queue::dbug_dump_queue");
@@ -618,9 +619,9 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
time or until signaled. Release LOCK_queue while waiting.
*/
struct timespec top_time;
- set_timespec(top_time, next_activation_at - thd->query_start());
- cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__);
+ set_timespec_time_nsec(top_time, next_activation_at*1000000000ULL);
+ cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__);
continue;
}
@@ -748,12 +749,14 @@ Event_queue::cond_wait(THD *thd, struct timespec *abstime, const char* msg,
thd->enter_cond(&COND_queue_state, &LOCK_event_queue, msg);
- DBUG_PRINT("info", ("pthread_cond_%swait", abstime? "timed":""));
- if (!abstime)
- pthread_cond_wait(&COND_queue_state, &LOCK_event_queue);
- else
- pthread_cond_timedwait(&COND_queue_state, &LOCK_event_queue, abstime);
-
+ if (!thd->killed)
+ {
+ DBUG_PRINT("info", ("pthread_cond_%swait", abstime ? "timed" : ""));
+ if (!abstime)
+ pthread_cond_wait(&COND_queue_state, &LOCK_event_queue);
+ else
+ pthread_cond_timedwait(&COND_queue_state, &LOCK_event_queue, abstime);
+ }
mutex_last_locked_in_func= func;
mutex_last_locked_at_line= line;
mutex_queue_data_locked= TRUE;
diff --git a/sql/event_queue.h b/sql/event_queue.h
index 2870ecb4d0b..e1f814adf20 100644
--- a/sql/event_queue.h
+++ b/sql/event_queue.h
@@ -98,7 +98,7 @@ private:
void
- dbug_dump_queue(time_t now);
+ dbug_dump_queue(my_time_t now);
/* LOCK_event_queue is the mutex which protects the access to the queue. */
pthread_mutex_t LOCK_event_queue;
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 4d6636eedb2..ecddcb7ca46 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -648,7 +648,14 @@ Event_scheduler::stop()
/* thd could be 0x0, when shutting down */
sql_print_information("Event Scheduler: "
"Waiting for the scheduler thread to reply");
- COND_STATE_WAIT(thd, NULL, "Waiting scheduler to stop");
+
+ /*
+ Wait only 2 seconds, as there is a small chance the thread missed the
+ above awake() call and we may have to do it again
+ */
+ struct timespec top_time;
+ set_timespec(top_time, 2);
+ COND_STATE_WAIT(thd, &top_time, "Waiting scheduler to stop");
} while (state == STOPPING);
DBUG_PRINT("info", ("Scheduler thread has cleaned up. Set state to INIT"));
sql_print_information("Event Scheduler: Stopped");
diff --git a/sql/field.cc b/sql/field.cc
index 461d6c1eda2..50f66363c1f 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
-
+ Copyright (c) 2009-2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
@@ -47,6 +47,17 @@ template class List<Create_field>;
template class List_iterator<Create_field>;
#endif
+static const char *zero_timestamp="0000-00-00 00:00:00.000000";
+
+/* number of bytes to store second_part part of the TIMESTAMP(N) */
+static uint sec_part_bytes[MAX_DATETIME_PRECISION+1]= { 0, 1, 1, 2, 2, 3, 3 };
+
+/* number of bytes to store DATETIME(N) */
+static uint datetime_hires_bytes[MAX_DATETIME_PRECISION+1]= { 5, 6, 6, 7, 7, 7, 8 };
+
+/* number of bytes to store TIME(N) */
+static uint time_hires_bytes[MAX_DATETIME_PRECISION+1]= { 3, 4, 4, 5, 5, 5, 6 };
+
uchar Field_null::null[1]={1};
const char field_separator=',';
@@ -69,7 +80,7 @@ const char field_separator=',';
#define FIELDTYPE_TEAR_FROM (MYSQL_TYPE_BIT + 1)
#define FIELDTYPE_TEAR_TO (MYSQL_TYPE_NEWDECIMAL - 1)
#define FIELDTYPE_NUM (FIELDTYPE_TEAR_FROM + (255 - FIELDTYPE_TEAR_TO))
-inline int field_type2index (enum_field_types field_type)
+static inline int field_type2index (enum_field_types field_type)
{
return (field_type < FIELDTYPE_TEAR_FROM ?
field_type :
@@ -1408,13 +1419,6 @@ int Field::store(const char *to, uint length, CHARSET_INFO *cs,
should be overridden. The other functions are just convenience
functions and hence should not be overridden.
- The value of <code>low_byte_first</code> is dependent on how the
- packed data is going to be used: for local use, e.g., temporary
- store on disk or in memory, use the native format since that is
- faster. For data that is going to be transfered to other machines
- (e.g., when writing data to the binary log), data should always be
- stored in little-endian format.
-
@note The default method for packing fields just copy the raw bytes
of the record into the destination, but never more than
<code>max_length</code> characters.
@@ -1432,15 +1436,9 @@ int Field::store(const char *to, uint length, CHARSET_INFO *cs,
is 1000. This information is sometimes needed to decide how to pack
the data.
- @param low_byte_first
- @c TRUE if integers should be stored little-endian, @c FALSE if
- native format should be used. Note that for little-endian machines,
- the value of this flag is a moot point since the native format is
- little-endian.
*/
uchar *
-Field::pack(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
+Field::pack(uchar *to, const uchar *from, uint max_length)
{
uint32 length= pack_length();
set_if_smaller(length, max_length);
@@ -1471,16 +1469,10 @@ Field::pack(uchar *to, const uchar *from, uint max_length,
@param param_data Real type and original pack length of the field
data
- @param low_byte_first
- If this flag is @c true, all composite entities (e.g., lengths)
- should be unpacked in little-endian format; otherwise, the entities
- are unpacked in native order.
-
@return New pointer into memory based on from + length of the data
*/
const uchar *
-Field::unpack(uchar* to, const uchar *from, uint param_data,
- bool low_byte_first __attribute__((unused)))
+Field::unpack(uchar* to, const uchar *from, uint param_data)
{
uint length=pack_length();
int from_type= 0;
@@ -1578,17 +1570,19 @@ longlong Field::convert_decimal2longlong(const my_decimal *val,
i= 0;
*err= 1;
}
- else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR &
- ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
- val, TRUE, &i)))
+ else if (warn_if_overflow(my_decimal2int((E_DEC_ERROR &
+ ~E_DEC_OVERFLOW &
+ ~E_DEC_TRUNCATED),
+ val, TRUE, &i)))
{
i= ~(longlong) 0;
*err= 1;
}
}
- else if (warn_if_overflow(my_decimal2int(E_DEC_ERROR &
- ~E_DEC_OVERFLOW & ~E_DEC_TRUNCATED,
- val, FALSE, &i)))
+ else if (warn_if_overflow(my_decimal2int((E_DEC_ERROR &
+ ~E_DEC_OVERFLOW &
+ ~E_DEC_TRUNCATED),
+ val, FALSE, &i)))
{
i= (val->sign() ? LONGLONG_MIN : LONGLONG_MAX);
*err= 1;
@@ -1748,16 +1742,6 @@ bool Field::get_date(MYSQL_TIME *ltime,uint fuzzydate)
return 0;
}
-bool Field::get_time(MYSQL_TIME *ltime)
-{
- char buff[40];
- String tmp(buff,sizeof(buff),&my_charset_bin),*res;
- if (!(res=val_str(&tmp)) ||
- str_to_time_with_warn(res->ptr(), res->length(), ltime))
- return 1;
- return 0;
-}
-
/**
This is called when storing a date in a string.
@@ -1765,11 +1749,11 @@ bool Field::get_time(MYSQL_TIME *ltime)
Needs to be changed if/when we want to support different time formats.
*/
-int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg)
+int Field::store_time_dec(MYSQL_TIME *ltime, uint dec)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
char buff[MAX_DATE_STRING_REP_LENGTH];
- uint length= (uint) my_TIME_to_str(ltime, buff);
+ uint length= (uint) my_TIME_to_str(ltime, buff, dec);
return store(buff, length, &my_charset_bin);
}
@@ -2759,10 +2743,10 @@ int Field_new_decimal::store_decimal(const my_decimal *decimal_value)
}
-int Field_new_decimal::store_time(MYSQL_TIME *ltime, timestamp_type t_type)
+int Field_new_decimal::store_time_dec(MYSQL_TIME *ltime, uint dec)
{
- my_decimal decimal_value;
- return store_value(date2my_decimal(ltime, &decimal_value));
+ my_decimal decimal_value;
+ return store_value(date2my_decimal(ltime, &decimal_value));
}
@@ -2930,13 +2914,10 @@ uint Field_new_decimal::is_equal(Create_field *new_field)
@return New pointer into memory based on from + length of the data
*/
const uchar *
-Field_new_decimal::unpack(uchar* to,
- const uchar *from,
- uint param_data,
- bool low_byte_first)
+Field_new_decimal::unpack(uchar* to, const uchar *from, uint param_data)
{
if (param_data == 0)
- return Field::unpack(to, from, param_data, low_byte_first);
+ return Field::unpack(to, from, param_data);
uint from_precision= (param_data & 0xff00) >> 8U;
uint from_decimal= param_data & 0x00ff;
@@ -2970,6 +2951,15 @@ Field_new_decimal::unpack(uchar* to,
return from+len;
}
+int Field_num::store_time_dec(MYSQL_TIME *ltime, uint dec)
+{
+ longlong v= TIME_to_ulonglong(ltime);
+ if (ltime->neg == 0)
+ return store(v, true);
+ return store(-v, false);
+}
+
+
/****************************************************************************
** tiny int
****************************************************************************/
@@ -3158,14 +3148,7 @@ int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
error= get_int(cs, from, len, &rnd, UINT_MAX16, INT_MIN16, INT_MAX16);
store_tmp= unsigned_flag ? (int) (ulonglong) rnd : (int) rnd;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int2store(ptr, store_tmp);
- }
- else
-#endif
- shortstore(ptr, (short) store_tmp);
+ int2store(ptr, store_tmp);
return error;
}
@@ -3210,14 +3193,7 @@ int Field_short::store(double nr)
else
res=(int16) (int) nr;
}
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int2store(ptr,res);
- }
- else
-#endif
- shortstore(ptr,res);
+ int2store(ptr,res);
return error;
}
@@ -3265,14 +3241,7 @@ int Field_short::store(longlong nr, bool unsigned_val)
else
res=(int16) nr;
}
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int2store(ptr,res);
- }
- else
-#endif
- shortstore(ptr,res);
+ int2store(ptr,res);
return error;
}
@@ -3281,12 +3250,7 @@ double Field_short::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
short j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint2korr(ptr);
- else
-#endif
- shortget(j,ptr);
+ j=sint2korr(ptr);
return unsigned_flag ? (double) (unsigned short) j : (double) j;
}
@@ -3294,12 +3258,7 @@ longlong Field_short::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
short j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint2korr(ptr);
- else
-#endif
- shortget(j,ptr);
+ j=sint2korr(ptr);
return unsigned_flag ? (longlong) (unsigned short) j : (longlong) j;
}
@@ -3314,12 +3273,7 @@ String *Field_short::val_str(String *val_buffer,
val_buffer->alloc(mlength);
char *to=(char*) val_buffer->ptr();
short j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint2korr(ptr);
- else
-#endif
- shortget(j,ptr);
+ j=sint2korr(ptr);
if (unsigned_flag)
length=(uint) cs->cset->long10_to_str(cs, to, mlength, 10,
@@ -3342,18 +3296,8 @@ bool Field_short::send_binary(Protocol *protocol)
int Field_short::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
short a,b;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- a=sint2korr(a_ptr);
- b=sint2korr(b_ptr);
- }
- else
-#endif
- {
- shortget(a,a_ptr);
- shortget(b,b_ptr);
- }
+ a=sint2korr(a_ptr);
+ b=sint2korr(b_ptr);
if (unsigned_flag)
return ((unsigned short) a < (unsigned short) b) ? -1 :
@@ -3363,24 +3307,11 @@ int Field_short::cmp(const uchar *a_ptr, const uchar *b_ptr)
void Field_short::sort_string(uchar *to,uint length __attribute__((unused)))
{
-#ifdef WORDS_BIGENDIAN
- if (!table->s->db_low_byte_first)
- {
- if (unsigned_flag)
- to[0] = ptr[0];
- else
- to[0] = (char) (ptr[0] ^ 128); /* Revers signbit */
- to[1] = ptr[1];
- }
+ if (unsigned_flag)
+ to[0] = ptr[1];
else
-#endif
- {
- if (unsigned_flag)
- to[0] = ptr[1];
- else
- to[0] = (char) (ptr[1] ^ 128); /* Revers signbit */
- to[1] = ptr[0];
- }
+ to[0] = (char) (ptr[1] ^ 128); /* Revers signbit */
+ to[1] = ptr[0];
}
void Field_short::sql_type(String &res) const
@@ -3595,14 +3526,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
error= get_int(cs, from, len, &rnd, UINT_MAX32, INT_MIN32, INT_MAX32);
store_tmp= unsigned_flag ? (long) (ulonglong) rnd : (long) rnd;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int4store(ptr, store_tmp);
- }
- else
-#endif
- longstore(ptr, store_tmp);
+ int4store(ptr, store_tmp);
return error;
}
@@ -3647,14 +3571,7 @@ int Field_long::store(double nr)
if (error)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int4store(ptr,res);
- }
- else
-#endif
- longstore(ptr,res);
+ int4store(ptr,res);
return error;
}
@@ -3700,14 +3617,7 @@ int Field_long::store(longlong nr, bool unsigned_val)
if (error)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int4store(ptr,res);
- }
- else
-#endif
- longstore(ptr,res);
+ int4store(ptr,res);
return error;
}
@@ -3716,12 +3626,7 @@ double Field_long::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
int32 j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint4korr(ptr);
- else
-#endif
- longget(j,ptr);
+ j=sint4korr(ptr);
return unsigned_flag ? (double) (uint32) j : (double) j;
}
@@ -3731,12 +3636,7 @@ longlong Field_long::val_int(void)
int32 j;
/* See the comment in Field_long::store(long long) */
DBUG_ASSERT(table->in_use == current_thd);
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint4korr(ptr);
- else
-#endif
- longget(j,ptr);
+ j=sint4korr(ptr);
return unsigned_flag ? (longlong) (uint32) j : (longlong) j;
}
@@ -3750,12 +3650,7 @@ String *Field_long::val_str(String *val_buffer,
val_buffer->alloc(mlength);
char *to=(char*) val_buffer->ptr();
int32 j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint4korr(ptr);
- else
-#endif
- longget(j,ptr);
+ j=sint4korr(ptr);
if (unsigned_flag)
length=cs->cset->long10_to_str(cs,to,mlength, 10,(long) (uint32)j);
@@ -3777,18 +3672,8 @@ bool Field_long::send_binary(Protocol *protocol)
int Field_long::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
int32 a,b;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- a=sint4korr(a_ptr);
- b=sint4korr(b_ptr);
- }
- else
-#endif
- {
- longget(a,a_ptr);
- longget(b,b_ptr);
- }
+ a=sint4korr(a_ptr);
+ b=sint4korr(b_ptr);
if (unsigned_flag)
return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 : 0;
return (a < b) ? -1 : (a > b) ? 1 : 0;
@@ -3796,28 +3681,13 @@ int Field_long::cmp(const uchar *a_ptr, const uchar *b_ptr)
void Field_long::sort_string(uchar *to,uint length __attribute__((unused)))
{
-#ifdef WORDS_BIGENDIAN
- if (!table->s->db_low_byte_first)
- {
- if (unsigned_flag)
- to[0] = ptr[0];
- else
- to[0] = (char) (ptr[0] ^ 128); /* Revers signbit */
- to[1] = ptr[1];
- to[2] = ptr[2];
- to[3] = ptr[3];
- }
+ if (unsigned_flag)
+ to[0] = ptr[3];
else
-#endif
- {
- if (unsigned_flag)
- to[0] = ptr[3];
- else
- to[0] = (char) (ptr[3] ^ 128); /* Revers signbit */
- to[1] = ptr[2];
- to[2] = ptr[1];
- to[3] = ptr[0];
- }
+ to[0] = (char) (ptr[3] ^ 128); /* Revers signbit */
+ to[1] = ptr[2];
+ to[2] = ptr[1];
+ to[3] = ptr[0];
}
@@ -3851,14 +3721,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
error= 1;
else
error= 0;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int8store(ptr,tmp);
- }
- else
-#endif
- longlongstore(ptr,tmp);
+ int8store(ptr,tmp);
return error;
}
@@ -3866,51 +3729,15 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_longlong::store(double nr)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- int error= 0;
+ bool error;
longlong res;
- nr= rint(nr);
- if (unsigned_flag)
- {
- if (nr < 0)
- {
- res=0;
- error= 1;
- }
- else if (nr >= (double) ULONGLONG_MAX)
- {
- res= ~(longlong) 0;
- error= 1;
- }
- else
- res=(longlong) double2ulonglong(nr);
- }
- else
- {
- if (nr <= (double) LONGLONG_MIN)
- {
- res= LONGLONG_MIN;
- error= (nr < (double) LONGLONG_MIN);
- }
- else if (nr >= (double) (ulonglong) LONGLONG_MAX)
- {
- res= LONGLONG_MAX;
- error= (nr > (double) LONGLONG_MAX);
- }
- else
- res=(longlong) nr;
- }
+ res= double_to_longlong(nr, unsigned_flag, &error);
+
if (error)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int8store(ptr,res);
- }
- else
-#endif
- longlongstore(ptr,res);
+ int8store(ptr,res);
return error;
}
@@ -3934,14 +3761,7 @@ int Field_longlong::store(longlong nr, bool unsigned_val)
}
}
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int8store(ptr,nr);
- }
- else
-#endif
- longlongstore(ptr,nr);
+ int8store(ptr,nr);
return error;
}
@@ -3950,14 +3770,7 @@ double Field_longlong::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
longlong j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- j=sint8korr(ptr);
- }
- else
-#endif
- longlongget(j,ptr);
+ j=sint8korr(ptr);
/* The following is open coded to avoid a bug in gcc 3.3 */
if (unsigned_flag)
{
@@ -3972,12 +3785,7 @@ longlong Field_longlong::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
longlong j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint8korr(ptr);
- else
-#endif
- longlongget(j,ptr);
+ j=sint8korr(ptr);
return j;
}
@@ -3991,12 +3799,7 @@ String *Field_longlong::val_str(String *val_buffer,
val_buffer->alloc(mlength);
char *to=(char*) val_buffer->ptr();
longlong j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- j=sint8korr(ptr);
- else
-#endif
- longlongget(j,ptr);
+ j=sint8korr(ptr);
length=(uint) (cs->cset->longlong10_to_str)(cs,to,mlength,
unsigned_flag ? 10 : -10, j);
@@ -4017,18 +3820,8 @@ bool Field_longlong::send_binary(Protocol *protocol)
int Field_longlong::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
longlong a,b;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- a=sint8korr(a_ptr);
- b=sint8korr(b_ptr);
- }
- else
-#endif
- {
- longlongget(a,a_ptr);
- longlongget(b,b_ptr);
- }
+ a=sint8korr(a_ptr);
+ b=sint8korr(b_ptr);
if (unsigned_flag)
return ((ulonglong) a < (ulonglong) b) ? -1 :
((ulonglong) a > (ulonglong) b) ? 1 : 0;
@@ -4037,36 +3830,17 @@ int Field_longlong::cmp(const uchar *a_ptr, const uchar *b_ptr)
void Field_longlong::sort_string(uchar *to,uint length __attribute__((unused)))
{
-#ifdef WORDS_BIGENDIAN
- if (!table->s->db_low_byte_first)
- {
- if (unsigned_flag)
- to[0] = ptr[0];
- else
- to[0] = (char) (ptr[0] ^ 128); /* Revers signbit */
- to[1] = ptr[1];
- to[2] = ptr[2];
- to[3] = ptr[3];
- to[4] = ptr[4];
- to[5] = ptr[5];
- to[6] = ptr[6];
- to[7] = ptr[7];
- }
+ if (unsigned_flag)
+ to[0] = ptr[7];
else
-#endif
- {
- if (unsigned_flag)
- to[0] = ptr[7];
- else
- to[0] = (char) (ptr[7] ^ 128); /* Revers signbit */
- to[1] = ptr[6];
- to[2] = ptr[5];
- to[3] = ptr[4];
- to[4] = ptr[3];
- to[5] = ptr[2];
- to[6] = ptr[1];
- to[7] = ptr[0];
- }
+ to[0] = (char) (ptr[7] ^ 128); /* Revers signbit */
+ to[1] = ptr[6];
+ to[2] = ptr[5];
+ to[3] = ptr[4];
+ to[4] = ptr[3];
+ to[5] = ptr[2];
+ to[6] = ptr[1];
+ to[7] = ptr[0];
}
@@ -4083,43 +3857,6 @@ void Field_longlong::sql_type(String &res) const
Floating-point numbers
*/
-uchar *
-Field_real::pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first)
-{
- DBUG_ENTER("Field_real::pack");
- DBUG_ASSERT(max_length >= pack_length());
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first != table->s->db_low_byte_first)
- {
- const uchar *dptr= from + pack_length();
- while (dptr-- > from)
- *to++ = *dptr;
- DBUG_RETURN(to);
- }
- else
-#endif
- DBUG_RETURN(Field::pack(to, from, max_length, low_byte_first));
-}
-
-const uchar *
-Field_real::unpack(uchar *to, const uchar *from,
- uint param_data, bool low_byte_first)
-{
- DBUG_ENTER("Field_real::unpack");
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first != table->s->db_low_byte_first)
- {
- const uchar *dptr= from + pack_length();
- while (dptr-- > from)
- *to++ = *dptr;
- DBUG_RETURN(from + pack_length());
- }
- else
-#endif
- DBUG_RETURN(Field::unpack(to, from, param_data, low_byte_first));
-}
-
/****************************************************************************
single precision float
****************************************************************************/
@@ -4144,17 +3881,21 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_float::store(double nr)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- int error= truncate(&nr, FLT_MAX);
- float j= (float)nr;
-
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
+ int error= truncate_double(&nr, field_length,
+ not_fixed ? NOT_FIXED_DEC : dec,
+ unsigned_flag, FLT_MAX);
+ if (error)
{
- float4store(ptr,j);
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
+ if (error < 0) // Wrong double value
+ {
+ error= 1;
+ set_null();
+ }
}
- else
-#endif
- memcpy_fixed(ptr,(uchar*) &j,sizeof(j));
+ float j= (float)nr;
+
+ float4store(ptr,j);
return error;
}
@@ -4170,28 +3911,14 @@ double Field_float::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
float j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float4get(j,ptr);
- }
- else
-#endif
- memcpy_fixed((uchar*) &j,ptr,sizeof(j));
+ float4get(j,ptr);
return ((double) j);
}
longlong Field_float::val_int(void)
{
float j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float4get(j,ptr);
- }
- else
-#endif
- memcpy_fixed((uchar*) &j,ptr,sizeof(j));
+ float4get(j,ptr);
return (longlong) rint(j);
}
@@ -4201,14 +3928,7 @@ String *Field_float::val_str(String *val_buffer,
{
ASSERT_COLUMN_MARKED_FOR_READ;
float nr;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float4get(nr,ptr);
- }
- else
-#endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
+ float4get(nr,ptr);
uint to_length=max(field_length,70);
val_buffer->alloc(to_length);
@@ -4283,18 +4003,8 @@ String *Field_float::val_str(String *val_buffer,
int Field_float::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
float a,b;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float4get(a,a_ptr);
- float4get(b,b_ptr);
- }
- else
-#endif
- {
- memcpy_fixed(&a,a_ptr,sizeof(float));
- memcpy_fixed(&b,b_ptr,sizeof(float));
- }
+ float4get(a,a_ptr);
+ float4get(b,b_ptr);
return (a < b) ? -1 : (a > b) ? 1 : 0;
}
@@ -4303,14 +4013,7 @@ int Field_float::cmp(const uchar *a_ptr, const uchar *b_ptr)
void Field_float::sort_string(uchar *to,uint length __attribute__((unused)))
{
float nr;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float4get(nr,ptr);
- }
- else
-#endif
- memcpy_fixed(&nr,ptr,sizeof(float));
+ float4get(nr,ptr);
uchar *tmp= to;
if (nr == (float) 0.0)
@@ -4406,16 +4109,20 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_double::store(double nr)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- int error= truncate(&nr, DBL_MAX);
-
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
+ int error= truncate_double(&nr, field_length,
+ not_fixed ? NOT_FIXED_DEC : dec,
+ unsigned_flag, DBL_MAX);
+ if (error)
{
- float8store(ptr,nr);
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
+ if (error < 0) // Wrong double value
+ {
+ error= 1;
+ set_null();
+ }
}
- else
-#endif
- doublestore(ptr,nr);
+
+ float8store(ptr,nr);
return error;
}
@@ -4430,28 +4137,31 @@ int Field_double::store(longlong nr, bool unsigned_val)
If a field has fixed length, truncate the double argument pointed to by 'nr'
appropriately.
Also ensure that the argument is within [-max_value; max_value] range.
+
+ return
+ 0 ok
+ -1 Illegal double value
+ 1 Value was truncated
*/
-int Field_real::truncate(double *nr, double max_value)
+int truncate_double(double *nr, uint field_length, uint dec,
+ bool unsigned_flag, double max_value)
{
- int error= 1;
+ int error= 0;
double res= *nr;
if (isnan(res))
{
- res= 0;
- set_null();
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
- goto end;
+ *nr= 0;
+ return -1;
}
else if (unsigned_flag && res < 0)
{
- res= 0;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
- goto end;
+ *nr= 0;
+ return 1;
}
- if (!not_fixed)
+ if (dec < NOT_FIXED_DEC)
{
uint order= field_length - dec;
uint step= array_elements(log_10) - 1;
@@ -4467,22 +4177,70 @@ int Field_real::truncate(double *nr, double max_value)
if (res < -max_value)
{
- res= -max_value;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
+ res= -max_value;
+ error= 1;
}
else if (res > max_value)
{
res= max_value;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
+ error= 1;
}
- else
- error= 0;
-end:
*nr= res;
return error;
}
+/*
+ Convert double to longlong / ulonglong.
+ If double is outside of range, adjust return value and set error.
+
+ SYNOPSIS
+ double_to_longlong()
+ nr Number to convert
+ unsigned_flag 1 if result is unsigned
+ error Will be set to 1 in case of overflow.
+*/
+
+longlong double_to_longlong(double nr, bool unsigned_flag, bool *error)
+{
+ longlong res;
+
+ *error= 0;
+
+ nr= rint(nr);
+ if (unsigned_flag)
+ {
+ if (nr < 0)
+ {
+ res= 0;
+ *error= 1;
+ }
+ else if (nr >= (double) ULONGLONG_MAX)
+ {
+ res= ~(longlong) 0;
+ *error= 1;
+ }
+ else
+ res= (longlong) double2ulonglong(nr);
+ }
+ else
+ {
+ if (nr <= (double) LONGLONG_MIN)
+ {
+ res= LONGLONG_MIN;
+ *error= (nr < (double) LONGLONG_MIN);
+ }
+ else if (nr >= (double) (ulonglong) LONGLONG_MAX)
+ {
+ res= LONGLONG_MAX;
+ *error= (nr > (double) LONGLONG_MAX);
+ }
+ else
+ res= (longlong) nr;
+ }
+ return res;
+}
+
int Field_real::store_decimal(const my_decimal *dm)
{
@@ -4491,18 +4249,17 @@ int Field_real::store_decimal(const my_decimal *dm)
return store(dbl);
}
+int Field_real::store_time_dec(MYSQL_TIME *ltime, uint dec)
+{
+ return store(TIME_to_double(ltime));
+}
+
+
double Field_double::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
double j;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float8get(j,ptr);
- }
- else
-#endif
- doubleget(j,ptr);
+ float8get(j,ptr);
return j;
}
@@ -4511,28 +4268,11 @@ longlong Field_double::val_int(void)
ASSERT_COLUMN_MARKED_FOR_READ;
double j;
longlong res;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float8get(j,ptr);
- }
- else
-#endif
- doubleget(j,ptr);
- /* Check whether we fit into longlong range */
- if (j <= (double) LONGLONG_MIN)
- {
- res= (longlong) LONGLONG_MIN;
- goto warn;
- }
- if (j >= (double) (ulonglong) LONGLONG_MAX)
- {
- res= (longlong) LONGLONG_MAX;
- goto warn;
- }
- return (longlong) rint(j);
+ bool error;
+ float8get(j,ptr);
-warn:
+ res= double_to_longlong(j, 0, &error);
+ if (error)
{
char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
String tmp(buf, sizeof(buf), &my_charset_latin1), *str;
@@ -4554,19 +4294,20 @@ my_decimal *Field_real::val_decimal(my_decimal *decimal_value)
}
+bool Field_real::get_date(MYSQL_TIME *ltime,uint fuzzydate)
+{
+ ASSERT_COLUMN_MARKED_FOR_READ;
+ double nr= val_real();
+ return double_to_datetime_with_warn(nr, ltime, fuzzydate, field_name);
+}
+
+
String *Field_double::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
ASSERT_COLUMN_MARKED_FOR_READ;
double nr;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float8get(nr,ptr);
- }
- else
-#endif
- doubleget(nr,ptr);
+ float8get(nr,ptr);
uint to_length= DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE;
val_buffer->alloc(to_length);
@@ -4647,18 +4388,8 @@ bool Field_double::send_binary(Protocol *protocol)
int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
double a,b;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float8get(a,a_ptr);
- float8get(b,b_ptr);
- }
- else
-#endif
- {
- doubleget(a, a_ptr);
- doubleget(b, b_ptr);
- }
+ float8get(a,a_ptr);
+ float8get(b,b_ptr);
return (a < b) ? -1 : (a > b) ? 1 : 0;
}
@@ -4670,14 +4401,7 @@ int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr)
void Field_double::sort_string(uchar *to,uint length __attribute__((unused)))
{
double nr;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- float8get(nr,ptr);
- }
- else
-#endif
- doubleget(nr,ptr);
+ float8get(nr,ptr);
change_double_for_sort(nr, to);
}
@@ -4765,12 +4489,12 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
const char *field_name_arg,
TABLE_SHARE *share,
CHARSET_INFO *cs)
- :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
+ :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs)
{
/* For 4.0 MYD and 4.0 InnoDB compatibility */
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (!share->timestamp_field && unireg_check != NONE)
+ flags|= UNSIGNED_FLAG;
+ if (unireg_check != NONE && !share->timestamp_field)
{
/* This timestamp has auto-update */
share->timestamp_field= this;
@@ -4781,20 +4505,6 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
}
-Field_timestamp::Field_timestamp(bool maybe_null_arg,
- const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0, MAX_DATETIME_WIDTH,
- maybe_null_arg ? (uchar*) "": 0, 0,
- NONE, field_name_arg, cs)
-{
- /* For 4.0 MYD and 4.0 InnoDB compatibility */
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (unireg_check != TIMESTAMP_DN_FIELD)
- flags|= ON_UPDATE_NOW_FLAG;
-}
-
-
/**
Get auto-set type for TIMESTAMP field.
@@ -4829,136 +4539,135 @@ timestamp_auto_set_type Field_timestamp::get_auto_set_type() const
}
}
+my_time_t Field_timestamp::get_timestamp(ulong *sec_part) const
+{
+ ASSERT_COLUMN_MARKED_FOR_READ;
+ *sec_part= 0;
+ return sint4korr(ptr);
+}
-int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
+int Field_timestamp::store_TIME_with_warning(THD *thd, MYSQL_TIME *l_time,
+ const Lazy_string *str,
+ bool was_cut,
+ bool have_smth_to_conv)
{
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- MYSQL_TIME l_time;
- my_time_t tmp= 0;
- int error;
- bool have_smth_to_conv;
- my_bool in_dst_time_gap;
- THD *thd= table ? table->in_use : current_thd;
+ uint error = 0;
+ my_time_t timestamp;
- /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
- have_smth_to_conv= (str_to_datetime(from, len, &l_time,
- (thd->variables.sql_mode &
- MODE_NO_ZERO_DATE) |
- MODE_NO_ZERO_IN_DATE, &error) >
- MYSQL_TIMESTAMP_ERROR);
-
- if (error || !have_smth_to_conv)
+ if (was_cut || !have_smth_to_conv)
{
error= 1;
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
- from, len, MYSQL_TIMESTAMP_DATETIME, 1);
+ str, MYSQL_TIMESTAMP_DATETIME, 1);
}
-
/* Only convert a correct date (not a zero date) */
- if (have_smth_to_conv && l_time.month)
+ if (have_smth_to_conv && l_time->month)
{
- if (!(tmp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap)))
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- from, len, MYSQL_TIMESTAMP_DATETIME, !error);
- error= 1;
- }
- else if (in_dst_time_gap)
+ uint conversion_error;
+ timestamp= TIME_to_timestamp(thd, l_time, &conversion_error);
+ if (timestamp == 0 && l_time->second_part == 0)
+ conversion_error= ER_WARN_DATA_OUT_OF_RANGE;
+ if (conversion_error)
{
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_INVALID_TIMESTAMP,
- from, len, MYSQL_TIMESTAMP_DATETIME, !error);
+ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, conversion_error,
+ str, MYSQL_TIMESTAMP_DATETIME, !error);
error= 1;
}
}
- store_timestamp(tmp);
+ else
+ {
+ timestamp= 0;
+ l_time->second_part= 0;
+ }
+ store_TIME(timestamp, l_time->second_part);
return error;
}
-int Field_timestamp::store(double nr)
+int Field_timestamp::store_time_dec(MYSQL_TIME *ltime, uint dec)
{
- int error= 0;
- if (nr < 0 || nr > 99991231235959.0)
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- nr, MYSQL_TIMESTAMP_DATETIME);
- nr= 0; // Avoid overflow on buff
- error= 1;
- }
- error|= Field_timestamp::store((longlong) rint(nr), FALSE);
- return error;
+ THD *thd= table->in_use;
+ int unused;
+ MYSQL_TIME l_time= *ltime;
+ Lazy_string_time str(ltime);
+ bool valid= !check_date(&l_time, pack_time(&l_time) != 0,
+ (thd->variables.sql_mode & MODE_NO_ZERO_DATE) |
+ MODE_NO_ZERO_IN_DATE, &unused);
+
+ return store_TIME_with_warning(thd, &l_time, &str, false, valid);
}
-int Field_timestamp::store(longlong nr, bool unsigned_val)
+int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
MYSQL_TIME l_time;
- my_time_t timestamp= 0;
int error;
- my_bool in_dst_time_gap;
- THD *thd= table ? table->in_use : current_thd;
+ int have_smth_to_conv;
+ Lazy_string_str str(from, len);
+ THD *thd= table->in_use;
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
- longlong tmp= number_to_datetime(nr, &l_time, (thd->variables.sql_mode &
+ have_smth_to_conv= (str_to_datetime(from, len, &l_time,
+ (thd->variables.sql_mode &
+ MODE_NO_ZERO_DATE) |
+ MODE_NO_ZERO_IN_DATE, &error) >
+ MYSQL_TIMESTAMP_ERROR);
+ return store_TIME_with_warning(thd, &l_time, &str, error, have_smth_to_conv);
+}
+
+
+int Field_timestamp::store(double nr)
+{
+ MYSQL_TIME l_time;
+ int error;
+ Lazy_string_double str(nr);
+ THD *thd= table->in_use;
+
+ longlong tmp= double_to_datetime(nr, &l_time, (thd->variables.sql_mode &
MODE_NO_ZERO_DATE) |
MODE_NO_ZERO_IN_DATE, &error);
- if (tmp == LL(-1))
- {
- error= 2;
- }
+ return store_TIME_with_warning(thd, &l_time, &str, error, tmp != -1);
+}
- if (!error && tmp)
- {
- if (!(timestamp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap)))
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- nr, MYSQL_TIMESTAMP_DATETIME, 1);
- error= 1;
- }
- if (in_dst_time_gap)
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_INVALID_TIMESTAMP,
- nr, MYSQL_TIMESTAMP_DATETIME, 1);
- error= 1;
- }
- } else if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_DATA_TRUNCATED,
- nr, MYSQL_TIMESTAMP_DATETIME, 1);
- store_timestamp(timestamp);
- return error;
+int Field_timestamp::store(longlong nr, bool unsigned_val)
+{
+ MYSQL_TIME l_time;
+ int error;
+ Lazy_string_num str(nr);
+ THD *thd= table->in_use;
+
+ /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
+ longlong tmp= number_to_datetime(nr, 0, &l_time, (thd->variables.sql_mode &
+ MODE_NO_ZERO_DATE) |
+ MODE_NO_ZERO_IN_DATE, &error);
+ return store_TIME_with_warning(thd, &l_time, &str, error, tmp != LL(-1));
}
+
double Field_timestamp::val_real(void)
{
- ASSERT_COLUMN_MARKED_FOR_READ;
return (double) Field_timestamp::val_int();
}
+
longlong Field_timestamp::val_int(void)
{
- ASSERT_COLUMN_MARKED_FOR_READ;
- uint32 temp;
MYSQL_TIME time_tmp;
- THD *thd= table ? table->in_use : current_thd;
+ THD *thd= table->in_use;
thd->time_zone_used= 1;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- temp=uint4korr(ptr);
- else
-#endif
- longget(temp,ptr);
+ ulong sec_part;
+ my_time_t temp= get_timestamp(&sec_part);
- if (temp == 0L) // No time
- return(0); /* purecov: inspected */
+ /*
+ Field_timestamp() and Field_timestamp_hres() shares this code.
+ This is why are also testing sec_part below.
+ */
+
+ if (temp == 0 && sec_part == 0)
+ return(0);
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp);
@@ -4970,10 +4679,9 @@ longlong Field_timestamp::val_int(void)
String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
{
- ASSERT_COLUMN_MARKED_FOR_READ;
- uint32 temp, temp2;
+ uint32 temp2;
+ THD *thd= table->in_use;
MYSQL_TIME time_tmp;
- THD *thd= table ? table->in_use : current_thd;
char *to;
val_buffer->alloc(field_length+1);
@@ -4981,20 +4689,16 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
val_buffer->length(field_length);
thd->time_zone_used= 1;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- temp=uint4korr(ptr);
- else
-#endif
- longget(temp,ptr);
+ ulong sec_part;
+ my_time_t temp= get_timestamp(&sec_part);
- if (temp == 0L)
+ if (temp == 0 && sec_part == 0)
{ /* Zero time is "000000" */
- val_ptr->set(STRING_WITH_LEN("0000-00-00 00:00:00"), &my_charset_bin);
+ val_ptr->set(zero_timestamp, field_length, &my_charset_bin);
return val_ptr;
}
val_buffer->set_charset(&my_charset_bin); // Safety
-
+
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp);
temp= time_tmp.year % 100;
@@ -5043,16 +4747,11 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
- long temp;
- THD *thd= table ? table->in_use : current_thd;
+ THD *thd= table->in_use;
thd->time_zone_used= 1;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- temp=uint4korr(ptr);
- else
-#endif
- longget(temp,ptr);
- if (temp == 0L)
+ ulong sec_part;
+ my_time_t temp= get_timestamp(&sec_part);
+ if (temp == 0 && sec_part == 0)
{ /* Zero time is "000000" */
if (fuzzydate & TIME_NO_ZERO_DATE)
return 1;
@@ -5061,61 +4760,35 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate)
else
{
thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp);
+ ltime->second_part= sec_part;
}
return 0;
}
-bool Field_timestamp::get_time(MYSQL_TIME *ltime)
-{
- return Field_timestamp::get_date(ltime,0);
-}
-
bool Field_timestamp::send_binary(Protocol *protocol)
{
- MYSQL_TIME tm;
- Field_timestamp::get_date(&tm, 0);
- return protocol->store(&tm);
+ MYSQL_TIME ltime;
+ Field_timestamp::get_date(&ltime, 0);
+ return protocol->store(&ltime, 0);
}
int Field_timestamp::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
int32 a,b;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- a=sint4korr(a_ptr);
- b=sint4korr(b_ptr);
- }
- else
-#endif
- {
- longget(a,a_ptr);
- longget(b,b_ptr);
- }
+ a=sint4korr(a_ptr);
+ b=sint4korr(b_ptr);
return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 : 0;
}
void Field_timestamp::sort_string(uchar *to,uint length __attribute__((unused)))
{
-#ifdef WORDS_BIGENDIAN
- if (!table || !table->s->db_low_byte_first)
- {
- to[0] = ptr[0];
- to[1] = ptr[1];
- to[2] = ptr[2];
- to[3] = ptr[3];
- }
- else
-#endif
- {
- to[0] = ptr[3];
- to[1] = ptr[2];
- to[2] = ptr[1];
- to[3] = ptr[0];
- }
+ to[0] = ptr[3];
+ to[1] = ptr[2];
+ to[2] = ptr[1];
+ to[3] = ptr[0];
}
@@ -5125,149 +4798,450 @@ void Field_timestamp::sql_type(String &res) const
}
-void Field_timestamp::set_time()
+int Field_timestamp::set_time()
{
- THD *thd= table ? table->in_use : current_thd;
- long tmp= (long) thd->query_start();
+ THD *thd= table->in_use;
set_notnull();
- store_timestamp(tmp);
+ store_TIME(thd->query_start(), 0);
+ return 0;
}
-/****************************************************************************
-** time type
-** In string context: HH:MM:SS
-** In number context: HHMMSS
-** Stored as a 3 byte unsigned int
-****************************************************************************/
+void Field_timestamp_hires::sql_type(String &res) const
+{
+ CHARSET_INFO *cs=res.charset();
+ res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(),
+ "timestamp(%u)", dec));
+}
-int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
+#ifdef NOT_USED
+static void store_native(ulonglong num, uchar *to, uint bytes)
+{
+ switch(bytes) {
+ case 1: *to= (uchar)num; break;
+ case 2: shortstore(to, (ushort)num); break;
+ case 3: int3store(to, num); /* Sic!*/ break;
+ case 4: longstore(to, (ulong)num); break;
+ case 8: longlongstore(to, num); break;
+ default: DBUG_ASSERT(0);
+ }
+}
+
+static longlong read_native(const uchar *from, uint bytes)
+{
+ switch(bytes) {
+ case 1: return from[0];
+ case 2: { uint16 tmp; shortget(tmp, from); return tmp; }
+ case 3: return uint3korr(from);
+ case 4: { uint32 tmp; longget(tmp, from); return tmp; }
+ case 8: { longlong tmp; longlongget(tmp, from); return tmp; }
+ default: DBUG_ASSERT(0); return 0;
+ }
+}
+#endif
+
+static void store_lowendian(ulonglong num, uchar *to, uint bytes)
+{
+ switch(bytes) {
+ case 1: *to= (uchar)num; break;
+ case 2: int2store(to, num); break;
+ case 3: int3store(to, num); break;
+ case 4: int4store(to, num); break;
+ case 8: int8store(to, num); break;
+ default: DBUG_ASSERT(0);
+ }
+}
+
+static longlong read_lowendian(const uchar *from, uint bytes)
+{
+ switch(bytes) {
+ case 1: return from[0];
+ case 2: return uint2korr(from);
+ case 3: return uint3korr(from);
+ case 4: return uint4korr(from);
+ case 8: return sint8korr(from);
+ default: DBUG_ASSERT(0); return 0;
+ }
+}
+
+static void store_bigendian(ulonglong num, uchar *to, uint bytes)
+{
+ switch(bytes) {
+ case 1: mi_int1store(to, num); break;
+ case 2: mi_int2store(to, num); break;
+ case 3: mi_int3store(to, num); break;
+ case 4: mi_int4store(to, num); break;
+ case 5: mi_int5store(to, num); break;
+ case 6: mi_int6store(to, num); break;
+ case 7: mi_int7store(to, num); break;
+ case 8: mi_int8store(to, num); break;
+ default: DBUG_ASSERT(0);
+ }
+}
+
+static longlong read_bigendian(const uchar *from, uint bytes)
+{
+ switch(bytes) {
+ case 1: return mi_uint1korr(from);
+ case 2: return mi_uint2korr(from);
+ case 3: return mi_uint3korr(from);
+ case 4: return mi_uint4korr(from);
+ case 5: return mi_uint5korr(from);
+ case 6: return mi_uint6korr(from);
+ case 7: return mi_uint7korr(from);
+ case 8: return mi_sint8korr(from);
+ default: DBUG_ASSERT(0); return 0;
+ }
+}
+
+void Field_timestamp_hires::store_TIME(my_time_t timestamp, ulong sec_part)
+{
+ mi_int4store(ptr, timestamp);
+ store_bigendian(sec_part_shift(sec_part, dec), ptr+4, sec_part_bytes[dec]);
+}
+
+my_time_t Field_timestamp_hires::get_timestamp(ulong *sec_part) const
+{
+ ASSERT_COLUMN_MARKED_FOR_READ;
+ *sec_part= (long)sec_part_unshift(read_bigendian(ptr+4, sec_part_bytes[dec]), dec);
+ return mi_uint4korr(ptr);
+}
+
+double Field_timestamp_hires::val_real(void)
+{
+ MYSQL_TIME time_tmp;
+ THD *thd= table->in_use;
+
+ thd->time_zone_used= 1;
+ ulong sec_part;
+ my_time_t temp= get_timestamp(&sec_part);
+
+ if (temp == 0 && sec_part == 0)
+ return(0);
+
+ thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp);
+
+ return time_tmp.year * 1e10 + time_tmp.month * 1e8 +
+ time_tmp.day * 1e6 + time_tmp.hour * 1e4 +
+ time_tmp.minute * 1e2 + time_tmp.second + sec_part*1e-6;
+}
+
+String *Field_timestamp_hires::val_str(String *val_buffer, String *val_ptr)
+{
+ String *tmp= Field_timestamp::val_str(val_buffer, val_ptr);
+ ulong sec_part= (ulong)read_bigendian(ptr+4, sec_part_bytes[dec]);
+
+ if (tmp->ptr() == zero_timestamp)
+ return tmp;
+
+ char *buf= const_cast<char*>(tmp->ptr() + MAX_DATETIME_WIDTH);
+ for (int i=dec; i>0; i--, sec_part/=10)
+ buf[i]= (char)(sec_part % 10) + '0';
+ buf[0]= '.';
+ buf[dec+1]= 0;
+ return tmp;
+}
+
+
+my_decimal *Field_timestamp_hires::val_decimal(my_decimal *d)
{
MYSQL_TIME ltime;
- long tmp;
- int error= 0;
- int warning;
+ get_date(&ltime, 0);
+ longlong intg= TIME_to_ulonglong(&ltime);
+ return seconds2my_decimal(ltime.neg, intg, ltime.second_part, d);
+}
+
+int Field_timestamp_hires::store_decimal(const my_decimal *d)
+{
+ ulonglong nr;
+ ulong sec_part;
+ int error;
+ MYSQL_TIME ltime;
+ longlong tmp;
+ THD *thd= table->in_use;
+ Lazy_string_decimal str(d);
- if (str_to_time(from, len, &ltime, &warning))
+ if (my_decimal2seconds(d, &nr, &sec_part))
{
- tmp=0L;
+ tmp= -1;
error= 2;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
- from, len, MYSQL_TIMESTAMP_TIME, 1);
}
else
- {
- if (warning & MYSQL_TIME_WARN_TRUNCATED)
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_DATA_TRUNCATED,
- from, len, MYSQL_TIMESTAMP_TIME, 1);
- error= 1;
- }
- if (warning & MYSQL_TIME_WARN_OUT_OF_RANGE)
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- from, len, MYSQL_TIMESTAMP_TIME, !error);
- error= 1;
- }
- if (ltime.month)
- ltime.day=0;
- tmp=(ltime.day*24L+ltime.hour)*10000L+(ltime.minute*100+ltime.second);
- }
-
- if (ltime.neg)
- tmp= -tmp;
- int3store(ptr,tmp);
- return error;
+ tmp= number_to_datetime(nr, sec_part, &ltime, TIME_NO_ZERO_IN_DATE |
+ (thd->variables.sql_mode &
+ MODE_NO_ZERO_DATE), &error);
+
+ return store_TIME_with_warning(thd, &ltime, &str, error, tmp != -1);
}
+int Field_timestamp_hires::set_time()
+{
+ THD *thd= table->in_use;
+ set_notnull();
+ store_TIME(thd->query_start(), thd->query_start_sec_part());
+ return 0;
+}
-int Field_time::store_time(MYSQL_TIME *ltime, timestamp_type time_type)
+bool Field_timestamp_hires::send_binary(Protocol *protocol)
{
- long tmp= ((ltime->month ? 0 : ltime->day * 24L) + ltime->hour) * 10000L +
- (ltime->minute * 100 + ltime->second);
- if (ltime->neg)
- tmp= -tmp;
- return Field_time::store((longlong) tmp, FALSE);
+ MYSQL_TIME ltime;
+ Field_timestamp::get_date(&ltime, 0);
+ return protocol->store(&ltime, dec);
}
-int Field_time::store(double nr)
+int Field_timestamp_hires::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
+ int32 a,b;
+ ulong a_sec_part, b_sec_part;
+ a= mi_uint4korr(a_ptr);
+ a_sec_part= (ulong)read_bigendian(a_ptr+4, sec_part_bytes[dec]);
+ b= mi_uint4korr(b_ptr);
+ b_sec_part= (ulong)read_bigendian(b_ptr+4, sec_part_bytes[dec]);
+ return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 :
+ a_sec_part < b_sec_part ? -1 : a_sec_part > b_sec_part ? 1 : 0;
+}
+
+
+void Field_timestamp_hires::sort_string(uchar *to,uint length)
+{
+ DBUG_ASSERT(length == Field_timestamp_hires::pack_length());
+ memcpy(to, ptr, length);
+}
+
+uint32 Field_timestamp_hires::pack_length() const
+{
+ return 4 + sec_part_bytes[dec];
+}
+
+void Field_timestamp_hires::make_field(Send_field *field)
+{
+ Field::make_field(field);
+ field->decimals= dec;
+}
+
+/*
+ Store string into a date/time field
+
+ RETURN
+ 0 ok
+ 1 Value was cut during conversion
+ 2 value was out of range
+ 3 Datetime value that was cut (warning level NOTE)
+ This is used by opt_range.cc:get_mm_leaf().
+*/
+int Field_temporal::store_TIME_with_warning(MYSQL_TIME *ltime,
+ const Lazy_string *str,
+ int was_cut, int have_smth_to_conv)
+{
+ MYSQL_ERROR::enum_warning_level trunc_level= MYSQL_ERROR::WARN_LEVEL_WARN;
+ int ret= 2;
+
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- long tmp;
- int error= 0;
- if (nr > (double)TIME_MAX_VALUE)
+
+ if (was_cut == 0 &&
+ have_smth_to_conv == 0 &&
+ temporal_type() != MYSQL_TIMESTAMP_TIME) // special case: zero date
+ was_cut= MYSQL_TIME_WARN_OUT_OF_RANGE;
+ else
+ if (!have_smth_to_conv)
{
- tmp= TIME_MAX_VALUE;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_TIME);
- error= 1;
+ bzero(ltime, sizeof(*ltime));
+ was_cut= MYSQL_TIME_WARN_TRUNCATED;
+ ret= 1;
}
- else if (nr < (double)-TIME_MAX_VALUE)
+ else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) &&
+ temporal_type() == MYSQL_TIMESTAMP_DATE &&
+ (ltime->hour || ltime->minute || ltime->second || ltime->second_part))
{
- tmp= -TIME_MAX_VALUE;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_TIME);
- error= 1;
+ trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE;
+ was_cut|= MYSQL_TIME_WARN_TRUNCATED;
+ ret= 3;
}
- else
+ else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) &&
+ temporal_type() == MYSQL_TIMESTAMP_TIME &&
+ (ltime->year || ltime->month))
{
- tmp=(long) floor(fabs(nr)); // Remove fractions
- if (nr < 0)
- tmp= -tmp;
- if (tmp % 100 > 59 || tmp/100 % 100 > 59)
- {
- tmp=0;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE, nr,
- MYSQL_TIMESTAMP_TIME);
- error= 1;
- }
+ ltime->year= ltime->month= ltime->day= 0;
+ trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE;
+ was_cut|= MYSQL_TIME_WARN_TRUNCATED;
+ ret= 3;
}
- int3store(ptr,tmp);
- return error;
+
+ /*
+ error code logic:
+ MYSQL_TIME_WARN_TRUNCATED means that the value was not a date/time at all.
+ it will be stored as zero date/time.
+ MYSQL_TIME_WARN_OUT_OF_RANGE means that the value was a date/time,
+ that is, it was parsed as such, but the value was invalid.
+
+ Also, MYSQL_TIME_WARN_TRUNCATED is used when storing a DATETIME in
+ a DATE field and non-zero time part is thrown away.
+ */
+ if (was_cut & MYSQL_TIME_WARN_TRUNCATED)
+ set_datetime_warning(trunc_level, WARN_DATA_TRUNCATED,
+ str, temporal_type(), 1);
+ if (was_cut & MYSQL_TIME_WARN_OUT_OF_RANGE)
+ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
+ str, temporal_type(), 1);
+
+ store_TIME(ltime);
+ return was_cut ? ret : 0;
}
-int Field_time::store(longlong nr, bool unsigned_val)
+int Field_temporal::store(const char *from,uint len,CHARSET_INFO *cs)
+{
+ MYSQL_TIME ltime;
+ int error;
+ enum enum_mysql_timestamp_type func_res;
+ THD *thd= table->in_use;
+ Lazy_string_str str(from, len);
+
+ func_res= str_to_datetime(from, len, &ltime,
+ (TIME_FUZZY_DATE |
+ (thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))),
+ &error);
+ return store_TIME_with_warning(&ltime, &str, error, func_res > MYSQL_TIMESTAMP_ERROR);
+}
+
+
+int Field_temporal::store(double nr)
{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- long tmp;
int error= 0;
- if (nr < (longlong) -TIME_MAX_VALUE && !unsigned_val)
- {
- tmp= -TIME_MAX_VALUE;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE, nr,
- MYSQL_TIMESTAMP_TIME, 1);
- error= 1;
- }
- else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val))
- {
- tmp= TIME_MAX_VALUE;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE, nr,
- MYSQL_TIMESTAMP_TIME, 1);
- error= 1;
- }
- else
+ MYSQL_TIME ltime;
+ THD *thd= table->in_use;
+ Lazy_string_double str(nr);
+
+ longlong tmp= double_to_datetime(nr, &ltime,
+ (TIME_FUZZY_DATE |
+ (thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE |
+ MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))), &error);
+ return store_TIME_with_warning(&ltime, &str, error, tmp != -1);
+}
+
+
+int Field_temporal::store(longlong nr, bool unsigned_val)
+{
+ int error;
+ MYSQL_TIME ltime;
+ longlong tmp;
+ THD *thd= table->in_use;
+ Lazy_string_num str(nr);
+
+ tmp= number_to_datetime(nr, 0, &ltime, (TIME_FUZZY_DATE |
+ (thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE |
+ MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))), &error);
+
+ return store_TIME_with_warning(&ltime, &str, error, tmp != -1);
+}
+
+
+int Field_temporal::store_time_dec(MYSQL_TIME *ltime, uint dec)
+{
+ int error = 0, have_smth_to_conv= 1;
+ MYSQL_TIME l_time= *ltime;
+ Lazy_string_time str(ltime);
+ /*
+ We don't perform range checking here since values stored in TIME
+ structure always fit into DATETIME range.
+ */
+ have_smth_to_conv= !check_date(&l_time, pack_time(&l_time) != 0,
+ (TIME_FUZZY_DATE |
+ (current_thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))), &error);
+ return store_TIME_with_warning(&l_time, &str, error, have_smth_to_conv);
+}
+
+my_decimal *Field_temporal::val_decimal(my_decimal *d)
+{
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, TIME_FUZZY_DATE))
{
- tmp=(long) nr;
- if (tmp % 100 > 59 || tmp/100 % 100 > 59)
- {
- tmp=0;
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE, nr,
- MYSQL_TIMESTAMP_TIME, 1);
- error= 1;
- }
+ bzero(&ltime, sizeof(ltime));
+ ltime.time_type= mysql_type_to_time_type(type());
}
+ longlong intg= TIME_to_ulonglong(&ltime);
+ return seconds2my_decimal(ltime.neg, intg, ltime.second_part, d);
+}
+
+/****************************************************************************
+** time type
+** In string context: HH:MM:SS
+** In number context: HHMMSS
+** Stored as a 3 byte unsigned int
+****************************************************************************/
+
+void Field_time::store_TIME(MYSQL_TIME *ltime)
+{
+ long tmp= (ltime->day*24L+ltime->hour)*10000L +
+ (ltime->minute*100+ltime->second);
+ if (ltime->neg)
+ tmp= -tmp;
int3store(ptr,tmp);
- return error;
+}
+
+int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
+{
+ MYSQL_TIME ltime;
+ Lazy_string_str str(from, len);
+ int was_cut;
+ int have_smth_to_conv=
+ str_to_time(from, len, &ltime,
+ table->in_use->variables.sql_mode &
+ (MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
+ MODE_INVALID_DATES),
+ &was_cut) > MYSQL_TIMESTAMP_ERROR;
+
+ return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
+}
+
+
+int Field_time::store_time_dec(MYSQL_TIME *ltime, uint dec)
+{
+ MYSQL_TIME l_time= *ltime;
+ Lazy_string_time str(ltime);
+ int was_cut= 0;
+
+ int have_smth_to_conv= !check_time_range(&l_time, decimals(), &was_cut);
+ return store_TIME_with_warning(&l_time, &str, was_cut, have_smth_to_conv);
}
+int Field_time::store(double nr)
+{
+ MYSQL_TIME ltime;
+ Lazy_string_double str(nr);
+ int was_cut;
+ bool neg= nr < 0;
+ if (neg)
+ nr= -nr;
+ int have_smth_to_conv= !number_to_time(neg, (longlong)nr,
+ (ulong)((nr - floor(nr)) * TIME_SECOND_PART_FACTOR),
+ &ltime, &was_cut);
+
+ return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
+}
+
+
+int Field_time::store(longlong nr, bool unsigned_val)
+{
+ MYSQL_TIME ltime;
+ Lazy_string_num str(nr);
+ int was_cut;
+ int have_smth_to_conv= !number_to_time(nr < 0, nr < 0 ? -nr : nr,
+ 0, &ltime, &was_cut);
+
+ return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
+}
+
+
double Field_time::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
@@ -5293,7 +5267,6 @@ String *Field_time::val_str(String *val_buffer,
{
ASSERT_COLUMN_MARKED_FOR_READ;
MYSQL_TIME ltime;
- val_buffer->alloc(MAX_DATE_STRING_REP_LENGTH);
long tmp=(long) sint3korr(ptr);
ltime.neg= 0;
if (tmp < 0)
@@ -5301,11 +5274,19 @@ String *Field_time::val_str(String *val_buffer,
tmp= -tmp;
ltime.neg= 1;
}
+ ltime.year= ltime.month= 0;
ltime.day= (uint) 0;
ltime.hour= (uint) (tmp/10000);
ltime.minute= (uint) (tmp/100 % 100);
ltime.second= (uint) (tmp % 100);
- make_time((DATE_TIME_FORMAT*) 0, &ltime, val_buffer);
+ ltime.second_part= 0;
+
+ val_buffer->alloc(MAX_DATE_STRING_REP_LENGTH);
+ uint length= (uint) my_time_to_str(&ltime,
+ const_cast<char*>(val_buffer->ptr()), 0);
+ val_buffer->length(length);
+ val_buffer->set_charset(&my_charset_bin);
+
return val_buffer;
}
@@ -5319,8 +5300,8 @@ String *Field_time::val_str(String *val_buffer,
bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
- THD *thd= table ? table->in_use : current_thd;
- if (!(fuzzydate & TIME_FUZZY_DATE))
+ THD *thd= table->in_use;
+ if (!(fuzzydate & (TIME_FUZZY_DATE|TIME_TIME_ONLY)))
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
@@ -5328,12 +5309,6 @@ bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
thd->row_count);
return 1;
}
- return Field_time::get_time(ltime);
-}
-
-
-bool Field_time::get_time(MYSQL_TIME *ltime)
-{
long tmp=(long) sint3korr(ptr);
ltime->neg=0;
if (tmp < 0)
@@ -5354,11 +5329,9 @@ bool Field_time::get_time(MYSQL_TIME *ltime)
bool Field_time::send_binary(Protocol *protocol)
{
- MYSQL_TIME tm;
- Field_time::get_time(&tm);
- tm.day= tm.hour/24; // Move hours to days
- tm.hour-= tm.day*24;
- return protocol->store_time(&tm);
+ MYSQL_TIME ltime;
+ Field_time::get_date(&ltime, TIME_TIME_ONLY);
+ return protocol->store_time(&ltime, 0);
}
@@ -5382,6 +5355,120 @@ void Field_time::sql_type(String &res) const
res.set_ascii(STRING_WITH_LEN("time"));
}
+int Field_time_hires::reset()
+{
+ store_bigendian(zero_point, ptr, Field_time_hires::pack_length());
+ return 0;
+}
+
+void Field_time_hires::store_TIME(MYSQL_TIME *ltime)
+{
+ ulonglong packed= sec_part_shift(pack_time(ltime), dec) + zero_point;
+ store_bigendian(packed, ptr, Field_time_hires::pack_length());
+}
+
+int Field_time_hires::store_decimal(const my_decimal *d)
+{
+ ulonglong nr;
+ ulong sec_part;
+ Lazy_string_decimal str(d);
+ MYSQL_TIME ltime;
+ int was_cut;
+ bool neg= my_decimal2seconds(d, &nr, &sec_part);
+
+ int have_smth_to_conv= !number_to_time(neg, nr, sec_part, &ltime, &was_cut);
+
+ return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
+}
+
+uint32 Field_time_hires::pack_length() const
+{
+ return time_hires_bytes[dec];
+}
+
+longlong Field_time_hires::val_int(void)
+{
+ ASSERT_COLUMN_MARKED_FOR_READ;
+ MYSQL_TIME ltime;
+ Field_time_hires::get_date(&ltime, TIME_TIME_ONLY);
+ longlong val= TIME_to_ulonglong_time(&ltime);
+ return ltime.neg ? -val : val;
+}
+
+double Field_time_hires::val_real(void)
+{
+ ASSERT_COLUMN_MARKED_FOR_READ;
+ MYSQL_TIME ltime;
+ Field_time_hires::get_date(&ltime, TIME_TIME_ONLY);
+ return TIME_to_double(&ltime);
+}
+
+String *Field_time_hires::val_str(String *str,
+ String *unused __attribute__((unused)))
+{
+ ASSERT_COLUMN_MARKED_FOR_READ;
+ MYSQL_TIME ltime;
+ Field_time_hires::get_date(&ltime, TIME_TIME_ONLY);
+ str->alloc(field_length+1);
+ str->length(my_time_to_str(&ltime, (char*) str->ptr(), dec));
+ str->set_charset(&my_charset_bin);
+ return str;
+}
+
+bool Field_time_hires::get_date(MYSQL_TIME *ltime, uint fuzzydate)
+{
+ uint32 len= pack_length();
+ longlong packed= read_bigendian(ptr, len);
+
+ packed= sec_part_unshift(packed - zero_point, dec);
+
+ unpack_time(packed, ltime);
+ /*
+ unpack_time() returns MYSQL_TIMESTAMP_DATETIME.
+ To get MYSQL_TIMESTAMP_TIME we few adjustments
+ */
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
+ ltime->hour+= (ltime->month*32+ltime->day)*24;
+ ltime->month= ltime->day= 0;
+ return fuzzydate & (TIME_FUZZY_DATE | TIME_TIME_ONLY) ? 0 : 1;
+}
+
+
+bool Field_time_hires::send_binary(Protocol *protocol)
+{
+ MYSQL_TIME ltime;
+ Field_time_hires::get_date(&ltime, TIME_TIME_ONLY);
+ return protocol->store_time(&ltime, dec);
+}
+
+
+int Field_time_hires::cmp(const uchar *a_ptr, const uchar *b_ptr)
+{
+ ulonglong a=read_bigendian(a_ptr, Field_time_hires::pack_length());
+ ulonglong b=read_bigendian(b_ptr, Field_time_hires::pack_length());
+ return (a < b) ? -1 : (a > b) ? 1 : 0;
+}
+
+void Field_time_hires::sort_string(uchar *to,uint length __attribute__((unused)))
+{
+ DBUG_ASSERT(length == Field_time_hires::pack_length());
+ memcpy(to, ptr, length);
+ to[0]^= 128;
+}
+
+void Field_time_hires::sql_type(String &res) const
+{
+ CHARSET_INFO *cs=res.charset();
+ res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(),
+ "time(%u)", dec));
+}
+
+void Field_time_hires::make_field(Send_field *field)
+{
+ Field::make_field(field);
+ field->decimals= dec;
+}
+
/****************************************************************************
** year type
** Save in a byte the year 0, 1901->2155
@@ -5457,6 +5544,17 @@ int Field_year::store(longlong nr, bool unsigned_val)
}
+int Field_year::store_time_dec(MYSQL_TIME *ltime, uint dec)
+{
+ Lazy_string_time str(ltime);
+ if (Field_year::store(ltime->year, 0))
+ return 1;
+
+ set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
+ &str, ltime->time_type, 1);
+ return 0;
+}
+
bool Field_year::send_binary(Protocol *protocol)
{
ASSERT_COLUMN_MARKED_FOR_READ;
@@ -5474,6 +5572,7 @@ double Field_year::val_real(void)
longlong Field_year::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
+ DBUG_ASSERT(field_length == 2 || field_length == 4);
int tmp= (int) ptr[0];
if (field_length != 4)
tmp%=100; // Return last 2 char
@@ -5486,6 +5585,7 @@ longlong Field_year::val_int(void)
String *Field_year::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
+ DBUG_ASSERT(field_length < 5);
val_buffer->alloc(5);
val_buffer->length(field_length);
char *to=(char*) val_buffer->ptr();
@@ -5494,6 +5594,15 @@ String *Field_year::val_str(String *val_buffer,
}
+bool Field_year::get_date(MYSQL_TIME *ltime,uint fuzzydate)
+{
+ int tmp= (int) ptr[0];
+ if (tmp || field_length != 4)
+ tmp+= 1900;
+ return int_to_datetime_with_warn(tmp * 10000, ltime, fuzzydate, field_name);
+}
+
+
void Field_year::sql_type(String &res) const
{
CHARSET_INFO *cs=res.charset();
@@ -5509,102 +5618,12 @@ void Field_year::sql_type(String &res) const
** Stored as a 4 byte unsigned int
****************************************************************************/
-int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
-{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- MYSQL_TIME l_time;
- uint32 tmp;
- int error;
- THD *thd= table ? table->in_use : current_thd;
-
- if (str_to_datetime(from, len, &l_time, TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES)),
- &error) <= MYSQL_TIMESTAMP_ERROR)
- {
- tmp= 0;
- error= 2;
- }
- else
- tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
-
- if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
- from, len, MYSQL_TIMESTAMP_DATE, 1);
-
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- int4store(ptr,tmp);
- }
- else
-#endif
- longstore(ptr,tmp);
- return error;
-}
-
-
-int Field_date::store(double nr)
-{
- longlong tmp;
- if (nr >= 19000000000000.0 && nr <= 99991231235959.0)
- nr=floor(nr/1000000.0); // Timestamp to date
- if (nr < 0.0 || nr > 99991231.0)
- {
- tmp= LL(0);
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- nr, MYSQL_TIMESTAMP_DATE);
- }
- else
- tmp= (longlong) rint(nr);
-
- return Field_date::store(tmp, TRUE);
-}
-
-
-int Field_date::store(longlong nr, bool unsigned_val)
+void Field_date::store_TIME(MYSQL_TIME *ltime)
{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- MYSQL_TIME not_used;
- int error;
- longlong initial_nr= nr;
- THD *thd= table ? table->in_use : current_thd;
-
- nr= number_to_datetime(nr, &not_used, (TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE |
- MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))), &error);
-
- if (nr == LL(-1))
- {
- nr= 0;
- error= 2;
- }
-
- if (nr >= 19000000000000.0 && nr <= 99991231235959.0)
- nr= (longlong) floor(nr/1000000.0); // Timestamp to date
-
- if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- error == 2 ? ER_WARN_DATA_OUT_OF_RANGE :
- WARN_DATA_TRUNCATED, initial_nr,
- MYSQL_TIMESTAMP_DATETIME, 1);
-
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- int4store(ptr, nr);
- }
- else
-#endif
- longstore(ptr, nr);
- return error;
+ uint tmp= ltime->year*10000L + ltime->month*100+ltime->day;
+ int4store(ptr,tmp);
}
-
bool Field_date::send_binary(Protocol *protocol)
{
longlong tmp= Field_date::val_int();
@@ -5620,12 +5639,7 @@ double Field_date::val_real(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
int32 j;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- j=sint4korr(ptr);
- else
-#endif
- longget(j,ptr);
+ j=sint4korr(ptr);
return (double) (uint32) j;
}
@@ -5634,12 +5648,7 @@ longlong Field_date::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
int32 j;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- j=sint4korr(ptr);
- else
-#endif
- longget(j,ptr);
+ j=sint4korr(ptr);
return (longlong) (uint32) j;
}
@@ -5649,67 +5658,38 @@ String *Field_date::val_str(String *val_buffer,
{
ASSERT_COLUMN_MARKED_FOR_READ;
MYSQL_TIME ltime;
- val_buffer->alloc(field_length);
int32 tmp;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- tmp=sint4korr(ptr);
- else
-#endif
- longget(tmp,ptr);
+ tmp=sint4korr(ptr);
ltime.neg= 0;
ltime.year= (int) ((uint32) tmp/10000L % 10000);
ltime.month= (int) ((uint32) tmp/100 % 100);
ltime.day= (int) ((uint32) tmp % 100);
- make_date((DATE_TIME_FORMAT *) 0, &ltime, val_buffer);
- return val_buffer;
-}
+ val_buffer->alloc(MAX_DATE_STRING_REP_LENGTH);
+ uint length= (uint) my_date_to_str(&ltime,
+ const_cast<char*>(val_buffer->ptr()));
+ val_buffer->length(length);
+ val_buffer->set_charset(&my_charset_bin);
-bool Field_date::get_time(MYSQL_TIME *ltime)
-{
- bzero((char *)ltime, sizeof(MYSQL_TIME));
- return 0;
+ return val_buffer;
}
int Field_date::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
int32 a,b;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- a=sint4korr(a_ptr);
- b=sint4korr(b_ptr);
- }
- else
-#endif
- {
- longget(a,a_ptr);
- longget(b,b_ptr);
- }
+ a=sint4korr(a_ptr);
+ b=sint4korr(b_ptr);
return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 : 0;
}
void Field_date::sort_string(uchar *to,uint length __attribute__((unused)))
{
-#ifdef WORDS_BIGENDIAN
- if (!table || !table->s->db_low_byte_first)
- {
- to[0] = ptr[0];
- to[1] = ptr[1];
- to[2] = ptr[2];
- to[3] = ptr[3];
- }
- else
-#endif
- {
- to[0] = ptr[3];
- to[1] = ptr[2];
- to[2] = ptr[1];
- to[3] = ptr[0];
- }
+ to[0] = ptr[3];
+ to[1] = ptr[2];
+ to[2] = ptr[1];
+ to[3] = ptr[0];
}
void Field_date::sql_type(String &res) const
@@ -5724,153 +5704,10 @@ void Field_date::sql_type(String &res) const
** In number context: YYYYMMDD
****************************************************************************/
-/*
- Store string into a date field
-
- SYNOPSIS
- Field_newdate::store()
- from Date string
- len Length of date field
- cs Character set (not used)
-
- RETURN
- 0 ok
- 1 Value was cut during conversion
- 2 Wrong date string
- 3 Datetime value that was cut (warning level NOTE)
- This is used by opt_range.cc:get_mm_leaf(). Note that there is a
- nearly-identical class Field_date doesn't ever return 3 from its
- store function.
-*/
-
-int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
+void Field_newdate::store_TIME(MYSQL_TIME *ltime)
{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- long tmp;
- MYSQL_TIME l_time;
- int error;
- THD *thd= table ? table->in_use : current_thd;
- enum enum_mysql_timestamp_type ret;
- if ((ret= str_to_datetime(from, len, &l_time,
- (TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))),
- &error)) <= MYSQL_TIMESTAMP_ERROR)
- {
- tmp= 0;
- error= 2;
- }
- else
- {
- tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
- if (!error && (ret != MYSQL_TIMESTAMP_DATE) &&
- (l_time.hour || l_time.minute || l_time.second || l_time.second_part))
- error= 3; // Datetime was cut (note)
- }
-
- if (error)
- set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE :
- MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_DATA_TRUNCATED,
- from, len, MYSQL_TIMESTAMP_DATE, 1);
-
- int3store(ptr, tmp);
- return error;
-}
-
-
-int Field_newdate::store(double nr)
-{
- if (nr < 0.0 || nr > 99991231235959.0)
- {
- int3store(ptr,(int32) 0);
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE);
- return 1;
- }
- return Field_newdate::store((longlong) rint(nr), FALSE);
-}
-
-
-int Field_newdate::store(longlong nr, bool unsigned_val)
-{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- MYSQL_TIME l_time;
- longlong tmp;
- int error;
- THD *thd= table ? table->in_use : current_thd;
- if (number_to_datetime(nr, &l_time,
- (TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))),
- &error) == LL(-1))
- {
- tmp= 0L;
- error= 2;
- }
- else
- tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
-
- if (!error && l_time.time_type != MYSQL_TIMESTAMP_DATE &&
- (l_time.hour || l_time.minute || l_time.second || l_time.second_part))
- error= 3;
-
- if (error)
- set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE :
- MYSQL_ERROR::WARN_LEVEL_WARN,
- error == 2 ?
- ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED,
- nr,MYSQL_TIMESTAMP_DATE, 1);
-
- int3store(ptr,tmp);
- return error;
-}
-
-
-int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
-{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- long tmp;
- int error= 0;
- if (time_type == MYSQL_TIMESTAMP_DATE ||
- time_type == MYSQL_TIMESTAMP_DATETIME)
- {
- tmp=ltime->year*16*32+ltime->month*32+ltime->day;
- if (check_date(ltime, tmp != 0,
- (TIME_FUZZY_DATE |
- (current_thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))), &error))
- {
- char buff[MAX_DATE_STRING_REP_LENGTH];
- String str(buff, sizeof(buff), &my_charset_latin1);
- tmp= 0;
- make_date((DATE_TIME_FORMAT *) 0, ltime, &str);
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
- str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
- }
- if (!error && ltime->time_type != MYSQL_TIMESTAMP_DATE &&
- (ltime->hour || ltime->minute || ltime->second || ltime->second_part))
- {
- char buff[MAX_DATE_STRING_REP_LENGTH];
- String str(buff, sizeof(buff), &my_charset_latin1);
- make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_NOTE,
- WARN_DATA_TRUNCATED,
- str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1);
- error= 3;
- }
- }
- else
- {
- tmp=0;
- error= 1;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
- }
+ uint tmp= ltime->year*16*32 + ltime->month*32+ltime->day;
int3store(ptr,tmp);
- return error;
}
@@ -5935,14 +5772,11 @@ bool Field_newdate::get_date(MYSQL_TIME *ltime,uint fuzzydate)
ltime->year= (tmp >> 9);
ltime->time_type= MYSQL_TIMESTAMP_DATE;
ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0;
- return ((!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ?
- 1 : 0);
-}
-
-
-bool Field_newdate::get_time(MYSQL_TIME *ltime)
-{
- return Field_newdate::get_date(ltime,0);
+ if (!tmp)
+ return fuzzydate & TIME_NO_ZERO_DATE;
+ if (!ltime->month || !ltime->day)
+ return !(fuzzydate & TIME_FUZZY_DATE);
+ return 0;
}
@@ -5976,150 +5810,20 @@ void Field_newdate::sql_type(String &res) const
** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.
****************************************************************************/
-int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
-{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- MYSQL_TIME time_tmp;
- int error;
- ulonglong tmp= 0;
- enum enum_mysql_timestamp_type func_res;
- THD *thd= table ? table->in_use : current_thd;
-
- func_res= str_to_datetime(from, len, &time_tmp,
- (TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))),
- &error);
- if ((int) func_res > (int) MYSQL_TIMESTAMP_ERROR)
- tmp= TIME_to_ulonglong_datetime(&time_tmp);
- else
- error= 1; // Fix if invalid zero date
-
- if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- from, len, MYSQL_TIMESTAMP_DATETIME, 1);
-
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- int8store(ptr,tmp);
- }
- else
-#endif
- longlongstore(ptr,tmp);
- return error;
-}
-
-
-int Field_datetime::store(double nr)
-{
- int error= 0;
- if (nr < 0.0 || nr > 99991231235959.0)
- {
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_OUT_OF_RANGE,
- nr, MYSQL_TIMESTAMP_DATETIME);
- nr= 0.0;
- error= 1;
- }
- error|= Field_datetime::store((longlong) rint(nr), FALSE);
- return error;
-}
-
-
-int Field_datetime::store(longlong nr, bool unsigned_val)
+void Field_datetime::store_TIME(MYSQL_TIME *ltime)
{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- MYSQL_TIME not_used;
- int error;
- longlong initial_nr= nr;
- THD *thd= table ? table->in_use : current_thd;
-
- nr= number_to_datetime(nr, &not_used, (TIME_FUZZY_DATE |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE |
- MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))), &error);
-
- if (nr == LL(-1))
- {
- nr= 0;
- error= 2;
- }
-
- if (error)
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- error == 2 ? ER_WARN_DATA_OUT_OF_RANGE :
- WARN_DATA_TRUNCATED, initial_nr,
- MYSQL_TIMESTAMP_DATETIME, 1);
-
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- int8store(ptr,nr);
- }
- else
-#endif
- longlongstore(ptr,nr);
- return error;
-}
-
-
-int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
-{
- ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
- longlong tmp;
- int error= 0;
- /*
- We don't perform range checking here since values stored in TIME
- structure always fit into DATETIME range.
- */
- if (time_type == MYSQL_TIMESTAMP_DATE ||
- time_type == MYSQL_TIMESTAMP_DATETIME)
- {
- tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+
- (ltime->hour*10000L+ltime->minute*100+ltime->second));
- if (check_date(ltime, tmp != 0,
- (TIME_FUZZY_DATE |
- (current_thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
- MODE_INVALID_DATES))), &error))
- {
- char buff[MAX_DATE_STRING_REP_LENGTH];
- String str(buff, sizeof(buff), &my_charset_latin1);
- tmp= 0;
- make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
- set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
- str.ptr(), str.length(), MYSQL_TIMESTAMP_DATETIME,1);
- }
- }
- else
- {
- tmp=0;
- error= 1;
- set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
- }
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- int8store(ptr,tmp);
- }
- else
-#endif
- longlongstore(ptr,tmp);
- return error;
+ ulonglong tmp= TIME_to_ulonglong_datetime(ltime);
+ int8store(ptr,tmp);
}
bool Field_datetime::send_binary(Protocol *protocol)
{
MYSQL_TIME tm;
Field_datetime::get_date(&tm, TIME_FUZZY_DATE);
- return protocol->store(&tm);
+ return protocol->store(&tm, 0);
}
-
-
+
+
double Field_datetime::val_real(void)
{
return (double) Field_datetime::val_int();
@@ -6129,12 +5833,7 @@ longlong Field_datetime::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
longlong j;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- j=sint8korr(ptr);
- else
-#endif
- longlongget(j,ptr);
+ j=sint8korr(ptr);
return j;
}
@@ -6142,20 +5841,16 @@ longlong Field_datetime::val_int(void)
String *Field_datetime::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
{
- ASSERT_COLUMN_MARKED_FOR_READ;
val_buffer->alloc(field_length);
val_buffer->length(field_length);
+
+ ASSERT_COLUMN_MARKED_FOR_READ;
ulonglong tmp;
long part1,part2;
char *pos;
int part3;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- tmp=sint8korr(ptr);
- else
-#endif
- longlongget(tmp,ptr);
+ tmp= Field_datetime::val_int();
/*
Avoid problem with slow longlong arithmetic and sprintf
@@ -6204,65 +5899,148 @@ bool Field_datetime::get_date(MYSQL_TIME *ltime, uint fuzzydate)
ltime->day= (int) (part1%100);
ltime->month= (int) (part1/100%100);
ltime->year= (int) (part1/10000);
- return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0;
-}
-
-bool Field_datetime::get_time(MYSQL_TIME *ltime)
-{
- return Field_datetime::get_date(ltime,0);
+ if (!tmp)
+ return (fuzzydate & TIME_NO_ZERO_DATE) != 0;
+ if (!ltime->month || !ltime->day)
+ return !(fuzzydate & TIME_FUZZY_DATE);
+ return 0;
}
int Field_datetime::cmp(const uchar *a_ptr, const uchar *b_ptr)
{
longlong a,b;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- a=sint8korr(a_ptr);
- b=sint8korr(b_ptr);
- }
- else
-#endif
- {
- longlongget(a,a_ptr);
- longlongget(b,b_ptr);
- }
+ a=sint8korr(a_ptr);
+ b=sint8korr(b_ptr);
return ((ulonglong) a < (ulonglong) b) ? -1 :
((ulonglong) a > (ulonglong) b) ? 1 : 0;
}
void Field_datetime::sort_string(uchar *to,uint length __attribute__((unused)))
{
-#ifdef WORDS_BIGENDIAN
- if (!table || !table->s->db_low_byte_first)
+ to[0] = ptr[7];
+ to[1] = ptr[6];
+ to[2] = ptr[5];
+ to[3] = ptr[4];
+ to[4] = ptr[3];
+ to[5] = ptr[2];
+ to[6] = ptr[1];
+ to[7] = ptr[0];
+}
+
+
+void Field_datetime::sql_type(String &res) const
+{
+ res.set_ascii(STRING_WITH_LEN("datetime"));
+}
+
+void Field_datetime_hires::store_TIME(MYSQL_TIME *ltime)
+{
+ ulonglong packed= sec_part_shift(pack_time(ltime), dec);
+ store_bigendian(packed, ptr, pack_length());
+}
+
+int Field_datetime_hires::store_decimal(const my_decimal *d)
+{
+ ulonglong nr;
+ ulong sec_part;
+ int error;
+ MYSQL_TIME ltime;
+ longlong tmp;
+ THD *thd= table->in_use;
+ Lazy_string_decimal str(d);
+
+ if (my_decimal2seconds(d, &nr, &sec_part))
{
- to[0] = ptr[0];
- to[1] = ptr[1];
- to[2] = ptr[2];
- to[3] = ptr[3];
- to[4] = ptr[4];
- to[5] = ptr[5];
- to[6] = ptr[6];
- to[7] = ptr[7];
+ tmp= -1;
+ error= 2;
}
else
-#endif
- {
- to[0] = ptr[7];
- to[1] = ptr[6];
- to[2] = ptr[5];
- to[3] = ptr[4];
- to[4] = ptr[3];
- to[5] = ptr[2];
- to[6] = ptr[1];
- to[7] = ptr[0];
- }
+ tmp= number_to_datetime(nr, sec_part, &ltime, (TIME_FUZZY_DATE |
+ (thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE |
+ MODE_NO_ZERO_DATE |
+ MODE_INVALID_DATES))), &error);
+
+ return store_TIME_with_warning(&ltime, &str, error, tmp != -1);
}
+bool Field_datetime_hires::send_binary(Protocol *protocol)
+{
+ MYSQL_TIME ltime;
+ Field_datetime_hires::get_date(&ltime, TIME_FUZZY_DATE);
+ return protocol->store(&ltime, dec);
+}
-void Field_datetime::sql_type(String &res) const
+
+double Field_datetime_hires::val_real(void)
{
- res.set_ascii(STRING_WITH_LEN("datetime"));
+ MYSQL_TIME ltime;
+ Field_datetime_hires::get_date(&ltime, TIME_FUZZY_DATE);
+ return TIME_to_double(&ltime);
+}
+
+longlong Field_datetime_hires::val_int(void)
+{
+ MYSQL_TIME ltime;
+ Field_datetime_hires::get_date(&ltime, TIME_FUZZY_DATE);
+ return TIME_to_ulonglong_datetime(&ltime);
+}
+
+
+String *Field_datetime_hires::val_str(String *str,
+ String *unused __attribute__((unused)))
+{
+ MYSQL_TIME ltime;
+ Field_datetime_hires::get_date(&ltime, TIME_FUZZY_DATE);
+ str->alloc(field_length+1);
+ str->length(field_length);
+ my_datetime_to_str(&ltime, (char*) str->ptr(), dec);
+ str->set_charset(&my_charset_bin);
+ return str;
+}
+
+bool Field_datetime_hires::get_date(MYSQL_TIME *ltime, uint fuzzydate)
+{
+ ulonglong packed= read_bigendian(ptr, pack_length());
+ unpack_time(sec_part_unshift(packed, dec), ltime);
+ if (!packed)
+ return fuzzydate & TIME_NO_ZERO_DATE;
+ if (!ltime->month || !ltime->day)
+ return !(fuzzydate & TIME_FUZZY_DATE);
+ return 0;
+}
+
+uint32 Field_datetime_hires::pack_length() const
+{
+ return datetime_hires_bytes[dec];
+}
+
+int Field_datetime_hires::cmp(const uchar *a_ptr, const uchar *b_ptr)
+{
+ ulonglong a=read_bigendian(a_ptr, pack_length());
+ ulonglong b=read_bigendian(b_ptr, pack_length());
+ return a < b ? -1 : a > b ? 1 : 0;
+}
+
+void Field_datetime_hires::sort_string(uchar *to,
+ uint length __attribute__((unused)))
+{
+ DBUG_ASSERT(length == pack_length());
+ memcpy(to, ptr, length);
+}
+
+
+void Field_datetime_hires::sql_type(String &res) const
+{
+ CHARSET_INFO *cs=res.charset();
+ res.length(cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(),
+ "datetime(%u)", dec));
+}
+
+void Field_datetime_hires::make_field(Send_field *field)
+{
+ Field::make_field(field);
+ field->decimals= dec;
}
/****************************************************************************
@@ -6720,9 +6498,7 @@ void Field_string::sql_type(String &res) const
}
-uchar *Field_string::pack(uchar *to, const uchar *from,
- uint max_length,
- bool low_byte_first __attribute__((unused)))
+uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length)
{
uint length= min(field_length,max_length);
uint local_char_length= max_length/field_charset->mbmaxlen;
@@ -6764,10 +6540,7 @@ uchar *Field_string::pack(uchar *to, const uchar *from,
@return New pointer into memory based on from + length of the data
*/
const uchar *
-Field_string::unpack(uchar *to,
- const uchar *from,
- uint param_data,
- bool low_byte_first __attribute__((unused)))
+Field_string::unpack(uchar *to, const uchar *from, uint param_data)
{
uint from_length, length;
@@ -7229,9 +7002,7 @@ uint32 Field_varstring::data_length()
Here the number of length bytes are depending on the given max_length
*/
-uchar *Field_varstring::pack(uchar *to, const uchar *from,
- uint max_length,
- bool low_byte_first __attribute__((unused)))
+uchar *Field_varstring::pack(uchar *to, const uchar *from, uint max_length)
{
uint length= length_bytes == 1 ? (uint) *from : uint2korr(from);
set_if_smaller(max_length, field_length);
@@ -7251,8 +7022,7 @@ uchar *Field_varstring::pack(uchar *to, const uchar *from,
uchar *
-Field_varstring::pack_key(uchar *to, const uchar *key, uint max_length,
- bool low_byte_first __attribute__((unused)))
+Field_varstring::pack_key(uchar *to, const uchar *key, uint max_length)
{
uint length= length_bytes == 1 ? (uint) *key : uint2korr(key);
uint local_char_length= ((field_charset->mbmaxlen > 1) ?
@@ -7289,8 +7059,7 @@ Field_varstring::pack_key(uchar *to, const uchar *key, uint max_length,
*/
const uchar *
-Field_varstring::unpack_key(uchar *to, const uchar *key, uint max_length,
- bool low_byte_first __attribute__((unused)))
+Field_varstring::unpack_key(uchar *to, const uchar *key, uint max_length)
{
/* get length of the blob key */
uint32 length= *key++;
@@ -7317,9 +7086,8 @@ Field_varstring::unpack_key(uchar *to, const uchar *key, uint max_length,
end of key storage
*/
-uchar *
-Field_varstring::pack_key_from_key_image(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
+uchar * Field_varstring::pack_key_from_key_image(uchar *to, const uchar *from,
+ uint max_length)
{
/* Key length is always stored as 2 bytes */
uint length= uint2korr(from);
@@ -7350,9 +7118,7 @@ Field_varstring::pack_key_from_key_image(uchar *to, const uchar *from, uint max_
@return New pointer into memory based on from + length of the data
*/
const uchar *
-Field_varstring::unpack(uchar *to, const uchar *from,
- uint param_data,
- bool low_byte_first __attribute__((unused)))
+Field_varstring::unpack(uchar *to, const uchar *from, uint param_data)
{
uint length;
uint l_bytes= (param_data && (param_data < field_length)) ?
@@ -7578,103 +7344,15 @@ Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
}
-void Field_blob::store_length(uchar *i_ptr,
- uint i_packlength,
- uint32 i_number,
- bool low_byte_first)
-{
- switch (i_packlength) {
- case 1:
- i_ptr[0]= (uchar) i_number;
- break;
- case 2:
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- {
- int2store(i_ptr,(unsigned short) i_number);
- }
- else
-#endif
- shortstore(i_ptr,(unsigned short) i_number);
- break;
- case 3:
- int3store(i_ptr,i_number);
- break;
- case 4:
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- {
- int4store(i_ptr,i_number);
- }
- else
-#endif
- longstore(i_ptr,i_number);
- }
-}
-
-
-uint32 Field_blob::get_length(const uchar *pos, uint packlength_arg, bool low_byte_first)
+void Field_blob::store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
{
- switch (packlength_arg) {
- case 1:
- return (uint32) pos[0];
- case 2:
- {
- uint16 tmp;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- tmp=sint2korr(pos);
- else
-#endif
- shortget(tmp,pos);
- return (uint32) tmp;
- }
- case 3:
- return (uint32) uint3korr(pos);
- case 4:
- {
- uint32 tmp;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- tmp=uint4korr(pos);
- else
-#endif
- longget(tmp,pos);
- return (uint32) tmp;
- }
- }
- /* When expanding this, see also MAX_FIELD_BLOBLENGTH. */
- return 0; // Impossible
+ store_lowendian(i_number, i_ptr, i_packlength);
}
-/**
- Put a blob length field into a record buffer.
-
- Depending on the maximum length of a blob, its length field is
- put into 1 to 4 bytes. This is a property of the blob object,
- described by 'packlength'.
-
- @param pos Pointer into the record buffer.
- @param length The length value to put.
-*/
-
-void Field_blob::put_length(uchar *pos, uint32 length)
+uint32 Field_blob::get_length(const uchar *pos, uint packlength_arg)
{
- switch (packlength) {
- case 1:
- *pos= (char) length;
- break;
- case 2:
- int2store(pos, length);
- break;
- case 3:
- int3store(pos, length);
- break;
- case 4:
- int4store(pos, length);
- break;
- }
+ return (uint32)read_lowendian(pos, packlength_arg);
}
@@ -8013,20 +7691,7 @@ void Field_blob::sort_string(uchar *to,uint length)
length-= packlength;
pos= to+length;
- switch (packlength) {
- case 1:
- *pos= (char) blob_length;
- break;
- case 2:
- mi_int2store(pos, blob_length);
- break;
- case 3:
- mi_int3store(pos, blob_length);
- break;
- case 4:
- mi_int4store(pos, blob_length);
- break;
- }
+ store_bigendian(blob_length, pos, packlength);
}
memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
@@ -8056,14 +7721,11 @@ void Field_blob::sql_type(String &res) const
}
}
-uchar *Field_blob::pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first)
+uchar *Field_blob::pack(uchar *to, const uchar *from, uint max_length)
{
DBUG_ENTER("Field_blob::pack");
- DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx;"
- " max_length: %u; low_byte_first: %d",
- (ulong) to, (ulong) from,
- max_length, low_byte_first));
+ DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx; max_length: %u",
+ (ulong) to, (ulong) from, max_length));
DBUG_DUMP("record", from, table->s->reclength);
uchar *save= ptr;
ptr= (uchar*) from;
@@ -8074,7 +7736,7 @@ uchar *Field_blob::pack(uchar *to, const uchar *from,
length given is smaller than the actual length of the blob, we
just store the initial bytes of the blob.
*/
- store_length(to, packlength, min(length, max_length), low_byte_first);
+ store_length(to, packlength, min(length, max_length));
/*
Store the actual blob data, which will occupy 'length' bytes.
@@ -8107,18 +7769,14 @@ uchar *Field_blob::pack(uchar *to, const uchar *from,
@return New pointer into memory based on from + length of the data
*/
-const uchar *Field_blob::unpack(uchar *to,
- const uchar *from,
- uint param_data,
- bool low_byte_first)
+const uchar *Field_blob::unpack(uchar *to, const uchar *from, uint param_data)
{
DBUG_ENTER("Field_blob::unpack");
- DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx;"
- " param_data: %u; low_byte_first: %d",
- (ulong) to, (ulong) from, param_data, low_byte_first));
+ DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx; param_data: %u",
+ (ulong) to, (ulong) from, param_data));
uint const master_packlength=
param_data > 0 ? param_data & 0xFF : packlength;
- uint32 const length= get_length(from, master_packlength, low_byte_first);
+ uint32 const length= get_length(from, master_packlength);
DBUG_DUMP("packed", from, length + master_packlength);
bitmap_set_bit(table->write_set, field_index);
store(reinterpret_cast<const char*>(from) + master_packlength,
@@ -8175,8 +7833,7 @@ int Field_blob::pack_cmp(const uchar *b, uint key_length_arg,
/** Create a packed key that will be used for storage from a MySQL row. */
uchar *
-Field_blob::pack_key(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
+Field_blob::pack_key(uchar *to, const uchar *from, uint max_length)
{
uchar *save= ptr;
ptr= (uchar*) from;
@@ -8220,8 +7877,7 @@ Field_blob::pack_key(uchar *to, const uchar *from, uint max_length,
*/
const uchar *
-Field_blob::unpack_key(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
+Field_blob::unpack_key(uchar *to, const uchar *from, uint max_length)
{
/* get length of the blob key */
uint32 length= *from++;
@@ -8229,7 +7885,7 @@ Field_blob::unpack_key(uchar *to, const uchar *from, uint max_length,
length+= *from++ << 8;
/* put the length into the record buffer */
- put_length(to, length);
+ store_length(to, packlength, length);
/* put the address of the blob buffer or NULL */
if (length)
@@ -8244,9 +7900,8 @@ Field_blob::unpack_key(uchar *to, const uchar *from, uint max_length,
/** Create a packed key that will be used for storage from a MySQL key. */
-uchar *
-Field_blob::pack_key_from_key_image(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
+uchar *Field_blob::pack_key_from_key_image(uchar *to, const uchar *from,
+ uint max_length)
{
uint length=uint2korr(from);
if (length > max_length)
@@ -8397,39 +8052,7 @@ enum ha_base_keytype Field_enum::key_type() const
void Field_enum::store_type(ulonglong value)
{
- switch (packlength) {
- case 1: ptr[0]= (uchar) value; break;
- case 2:
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int2store(ptr,(unsigned short) value);
- }
- else
-#endif
- shortstore(ptr,(unsigned short) value);
- break;
- case 3: int3store(ptr,(long) value); break;
- case 4:
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int4store(ptr,value);
- }
- else
-#endif
- longstore(ptr,(long) value);
- break;
- case 8:
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- {
- int8store(ptr,value);
- }
- else
-#endif
- longlongstore(ptr,value); break;
- }
+ store_lowendian(value, ptr, packlength);
}
@@ -8515,46 +8138,7 @@ double Field_enum::val_real(void)
longlong Field_enum::val_int(void)
{
ASSERT_COLUMN_MARKED_FOR_READ;
- switch (packlength) {
- case 1:
- return (longlong) ptr[0];
- case 2:
- {
- uint16 tmp;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- tmp=sint2korr(ptr);
- else
-#endif
- shortget(tmp,ptr);
- return (longlong) tmp;
- }
- case 3:
- return (longlong) uint3korr(ptr);
- case 4:
- {
- uint32 tmp;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- tmp=uint4korr(ptr);
- else
-#endif
- longget(tmp,ptr);
- return (longlong) tmp;
- }
- case 8:
- {
- longlong tmp;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- tmp=sint8korr(ptr);
- else
-#endif
- longlongget(tmp,ptr);
- return tmp;
- }
- }
- return 0; // impossible
+ return read_lowendian(ptr, packlength);
}
@@ -9307,8 +8891,7 @@ void Field_bit::sql_type(String &res) const
uchar *
-Field_bit::pack(uchar *to, const uchar *from, uint max_length,
- bool low_byte_first __attribute__((unused)))
+Field_bit::pack(uchar *to, const uchar *from, uint max_length)
{
DBUG_ASSERT(max_length > 0);
uint length;
@@ -9355,8 +8938,7 @@ Field_bit::pack(uchar *to, const uchar *from, uint max_length,
@return New pointer into memory based on from + length of the data
*/
const uchar *
-Field_bit::unpack(uchar *to, const uchar *from, uint param_data,
- bool low_byte_first __attribute__((unused)))
+Field_bit::unpack(uchar *to, const uchar *from, uint param_data)
{
uint const from_len= (param_data >> 8U) & 0x00ff;
uint const from_bit_len= param_data & 0x00ff;
@@ -9490,6 +9072,7 @@ void Create_field::create_length_to_internal_length(void)
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
+ case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VARCHAR:
@@ -9812,28 +9395,14 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
}
break;
case MYSQL_TYPE_TIMESTAMP:
- if (fld_length == NULL)
+ if (length > MAX_DATETIME_PRECISION)
{
- length= MAX_DATETIME_WIDTH;
- }
- else if (length != MAX_DATETIME_WIDTH)
- {
- /*
- We support only even TIMESTAMP lengths less or equal than 14
- and 19 as length of 4.1 compatible representation. Silently
- shrink it to MAX_DATETIME_COMPRESSED_WIDTH.
- */
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
+ MAX_DATETIME_PRECISION);
+ DBUG_RETURN(TRUE);
}
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
- Since we silently rewrite down to MAX_DATETIME_COMPRESSED_WIDTH bytes,
- the parser should not raise errors unless bizzarely large.
- */
- max_field_charlength= UINT_MAX;
+ length+= MAX_DATETIME_WIDTH + (length ? 1 : 0);
+ flags|= UNSIGNED_FLAG;
if (fld_default_value)
{
@@ -9881,10 +9450,22 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
length= MAX_DATE_WIDTH;
break;
case MYSQL_TYPE_TIME:
- length= 10;
+ if (length > MAX_DATETIME_PRECISION)
+ {
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
+ MAX_DATETIME_PRECISION);
+ DBUG_RETURN(TRUE);
+ }
+ length+= MIN_TIME_WIDTH + (length ? 1 : 0);
break;
case MYSQL_TYPE_DATETIME:
- length= MAX_DATETIME_WIDTH;
+ if (length > MAX_DATETIME_PRECISION)
+ {
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
+ MAX_DATETIME_PRECISION);
+ DBUG_RETURN(TRUE);
+ }
+ length+= MAX_DATETIME_WIDTH + (length ? 1 : 0);
break;
case MYSQL_TYPE_SET:
{
@@ -10004,14 +9585,22 @@ uint32 calc_pack_length(enum_field_types type,uint32 length)
case MYSQL_TYPE_TINY : return 1;
case MYSQL_TYPE_SHORT : return 2;
case MYSQL_TYPE_INT24:
- case MYSQL_TYPE_NEWDATE:
- case MYSQL_TYPE_TIME: return 3;
+ case MYSQL_TYPE_NEWDATE: return 3;
+ case MYSQL_TYPE_TIME: return length > MIN_TIME_WIDTH
+ ? time_hires_bytes[length - 1 - MIN_TIME_WIDTH]
+ : 3;
case MYSQL_TYPE_TIMESTAMP:
+ return length > MAX_DATETIME_WIDTH
+ ? 4 + sec_part_bytes[length - 1 - MAX_DATETIME_WIDTH]
+ : 4;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_LONG : return 4;
case MYSQL_TYPE_FLOAT : return sizeof(float);
case MYSQL_TYPE_DOUBLE: return sizeof(double);
case MYSQL_TYPE_DATETIME:
+ return length > MAX_DATETIME_WIDTH
+ ? datetime_hires_bytes[length - 1 - MAX_DATETIME_WIDTH]
+ : 8;
case MYSQL_TYPE_LONGLONG: return 8; /* Don't crash if no longlong */
case MYSQL_TYPE_NULL : return 0;
case MYSQL_TYPE_TINY_BLOB: return 1+portable_sizeof_char_ptr;
@@ -10183,9 +9772,12 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
f_is_zerofill(pack_flag) != 0,
f_is_dec(pack_flag) == 0);
case MYSQL_TYPE_TIMESTAMP:
- return new Field_timestamp(ptr,field_length, null_pos, null_bit,
- unireg_check, field_name, share,
- field_charset);
+ {
+ uint dec= field_length > MAX_DATETIME_WIDTH ?
+ field_length - MAX_DATETIME_WIDTH - 1: 0;
+ return new_Field_timestamp(ptr, null_pos, null_bit, unireg_check,
+ field_name, share, dec, field_charset);
+ }
case MYSQL_TYPE_YEAR:
return new Field_year(ptr,field_length,null_pos,null_bit,
unireg_check, field_name);
@@ -10196,11 +9788,19 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
return new Field_newdate(ptr,null_pos,null_bit,
unireg_check, field_name, field_charset);
case MYSQL_TYPE_TIME:
- return new Field_time(ptr,null_pos,null_bit,
- unireg_check, field_name, field_charset);
+ {
+ uint dec= field_length > MIN_TIME_WIDTH ?
+ field_length - MIN_TIME_WIDTH - 1: 0;
+ return new_Field_time(ptr, null_pos, null_bit, unireg_check,
+ field_name, dec, field_charset);
+ }
case MYSQL_TYPE_DATETIME:
- return new Field_datetime(ptr,null_pos,null_bit,
- unireg_check, field_name, field_charset);
+ {
+ uint dec= field_length > MAX_DATETIME_WIDTH ?
+ field_length - MAX_DATETIME_WIDTH - 1: 0;
+ return new_Field_datetime(ptr, null_pos, null_bit, unireg_check,
+ field_name, dec, field_charset);
+ }
case MYSQL_TYPE_NULL:
return new Field_null(ptr, field_length, unireg_check, field_name,
field_charset);
@@ -10373,7 +9973,7 @@ uint32 Field_blob::max_display_length()
0 otherwise
*/
-bool
+void
Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
int cuted_increment)
{
@@ -10387,9 +9987,7 @@ Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
thd->cuted_fields+= cuted_increment;
push_warning_printf(thd, level, code, ER(code), field_name,
thd->row_count);
- return 0;
}
- return level >= MYSQL_ERROR::WARN_LEVEL_WARN;
}
@@ -10399,7 +9997,6 @@ Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
@param level level of message (Note/Warning/Error)
@param code error code of message to be produced
@param str string value which we tried to save
- @param str_length length of string which we tried to save
@param ts_type type of datetime value (datetime/date/time)
@param cuted_increment whenever we should increase cut fields count or not
@@ -10407,80 +10004,42 @@ Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code,
This function will always produce some warning but won't increase cut
fields counter if count_cuted_fields ==FIELD_CHECK_IGNORE for current
thread.
-*/
-
-void
-Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
- const char *str, uint str_length,
- timestamp_type ts_type, int cuted_increment)
-{
- THD *thd= table ? table->in_use : current_thd;
- if ((thd->really_abort_on_warning() &&
- level >= MYSQL_ERROR::WARN_LEVEL_WARN) ||
- set_warning(level, code, cuted_increment))
- make_truncated_value_warning(thd, level, str, str_length, ts_type,
- field_name);
-}
-
-
-/**
- Produce warning or note about integer datetime value saved into field.
-
- @param level level of message (Note/Warning/Error)
- @param code error code of message to be produced
- @param nr numeric value which we tried to save
- @param ts_type type of datetime value (datetime/date/time)
- @param cuted_increment whenever we should increase cut fields count or not
- @note
- This function will always produce some warning but won't increase cut
- fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
- thread.
+ See also bug#2336
*/
-void
-Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
- longlong nr, timestamp_type ts_type,
- int cuted_increment)
+
+void Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level,
+ uint code, const Lazy_string *str,
+ timestamp_type ts_type, int cuted_increment)
{
- THD *thd= table ? table->in_use : current_thd;
- if (thd->really_abort_on_warning() ||
- set_warning(level, code, cuted_increment))
- {
- char str_nr[22];
- char *str_end= longlong10_to_str(nr, str_nr, -10);
- make_truncated_value_warning(thd, level, str_nr, (uint) (str_end - str_nr),
- ts_type, field_name);
- }
+ THD *thd= table->in_use;
+ if (thd->really_abort_on_warning() && level >= MYSQL_ERROR::WARN_LEVEL_WARN)
+ make_truncated_value_warning(thd, level, str, ts_type, field_name);
+ else
+ set_warning(level, code, cuted_increment);
}
-/**
- Produce warning or note about double datetime data saved into field.
-
- @param level level of message (Note/Warning/Error)
- @param code error code of message to be produced
- @param nr double value which we tried to save
- @param ts_type type of datetime value (datetime/date/time)
-
- @note
- This function will always produce some warning but won't increase cut
- fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
- thread.
+/*
+ @brief
+ Return possible keys for a field
+
+ @details
+ Return bit map of keys over this field which can be used by the range
+ optimizer. For a field of a generic table such keys are all keys that starts
+ from this field. For a field of a materialized derived table/view such keys
+ are all keys in which this field takes a part. This is less restrictive as
+ keys for a materialized derived table/view are generated on the fly from
+ present fields, thus the case when a field for the beginning of a key is
+ absent is impossible.
+
+ @return map of possible keys
*/
-void
-Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
- double nr, timestamp_type ts_type)
+key_map Field::get_possible_keys()
{
- THD *thd= table ? table->in_use : current_thd;
- if (thd->really_abort_on_warning() ||
- set_warning(level, code, 1))
- {
- /* DBL_DIG is enough to print '-[digits].E+###' */
- char str_nr[DBL_DIG + 8];
- uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr));
- make_truncated_value_warning(thd, level, str_nr, str_len, ts_type,
- field_name);
- }
+ DBUG_ASSERT(table->pos_in_table_list);
+ return (table->pos_in_table_list->is_materialized_derived() ?
+ part_of_key : key_start);
}
diff --git a/sql/field.h b/sql/field.h
index d695479f197..f3f0ff193c7 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2010 Oracle and/or its affiliates.
+ Copyright (c) 2009-2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,6 +14,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+#include "my_compare.h" /* for clr_rec_bits */
+
/*
Because of the function new_field() all field classes that have static
variables must declare the size_of() member function.
@@ -23,16 +26,19 @@
#endif
#define NOT_FIXED_DEC 31
-#define DATETIME_DEC 6
const uint32 max_field_size= (uint32) 4294967295U;
class Send_field;
class Protocol;
class Create_field;
class Relay_log_info;
+struct ha_field_option_struct;
struct st_cache_field;
int field_conv(Field *to,Field *from);
+int truncate_double(double *nr, uint field_length, uint dec,
+ bool unsigned_flag, double max_value);
+longlong double_to_longlong(double nr, bool unsigned_flag, bool *error);
inline uint get_enum_pack_length(int elements)
{
@@ -135,7 +141,7 @@ public:
const char *field_name;
/** reference to the list of options or NULL */
engine_option_value *option_list;
- void *option_struct; /* structure with parsed options */
+ ha_field_option_struct *option_struct; /* structure with parsed options */
LEX_STRING comment;
/* Field is part of the following keys */
key_map key_start, part_of_key, part_of_key_not_clustered;
@@ -198,7 +204,9 @@ public:
virtual int store(double nr)=0;
virtual int store(longlong nr, bool unsigned_val)=0;
virtual int store_decimal(const my_decimal *d)=0;
- virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
+ virtual int store_time_dec(MYSQL_TIME *ltime, uint dec);
+ int store_time(MYSQL_TIME *ltime)
+ { return store_time_dec(ltime, TIME_SECOND_PART_DIGITS); }
int store(const char *to, uint length, CHARSET_INFO *cs,
enum_check_fields check_level);
virtual double val_real(void)=0;
@@ -226,7 +234,6 @@ public:
virtual bool str_needs_quotes() { return FALSE; }
virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); }
- virtual Item_result cast_to_int_type () const { return result_type(); }
static bool type_can_have_key_part(enum_field_types);
static enum_field_types field_type_merge(enum_field_types, enum_field_types);
static Item_result result_merge_type(enum_field_types);
@@ -381,14 +388,6 @@ public:
virtual void make_field(Send_field *);
virtual void sort_string(uchar *buff,uint length)=0;
virtual bool optimize_range(uint idx, uint part);
- /*
- This should be true for fields which, when compared with constant
- items, can be casted to longlong. In this case we will at 'fix_fields'
- stage cast the constant items to longlongs and at the execution stage
- use field->val_int() for comparison. Used to optimize clauses like
- 'a_column BETWEEN date_const, date_const'.
- */
- virtual bool can_be_compared_as_longlong() const { return FALSE; }
virtual void free() {}
virtual Field *new_field(MEM_ROOT *root, struct st_table *new_table,
bool keep_type);
@@ -472,44 +471,39 @@ public:
}
virtual bool send_binary(Protocol *protocol);
- virtual uchar *pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
+ virtual uchar *pack(uchar *to, const uchar *from, uint max_length);
/**
@overload Field::pack(uchar*, const uchar*, uint, bool)
*/
uchar *pack(uchar *to, const uchar *from)
{
DBUG_ENTER("Field::pack");
- uchar *result= this->pack(to, from, UINT_MAX, table->s->db_low_byte_first);
+ uchar *result= this->pack(to, from, UINT_MAX);
DBUG_RETURN(result);
}
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first);
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data);
/**
@overload Field::unpack(uchar*, const uchar*, uint, bool)
*/
const uchar *unpack(uchar* to, const uchar *from)
{
DBUG_ENTER("Field::unpack");
- const uchar *result= unpack(to, from, 0U, table->s->db_low_byte_first);
+ const uchar *result= unpack(to, from, 0);
DBUG_RETURN(result);
}
- virtual uchar *pack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual uchar *pack_key(uchar* to, const uchar *from, uint max_length)
{
- return pack(to, from, max_length, low_byte_first);
+ return pack(to, from, max_length);
}
- virtual uchar *pack_key_from_key_image(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual uchar *pack_key_from_key_image(uchar* to, const uchar *from, uint max_length)
{
- return pack(to, from, max_length, low_byte_first);
+ return pack(to, from, max_length);
}
- virtual const uchar *unpack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual const uchar *unpack_key(uchar* to, const uchar *from, uint max_length)
{
- return unpack(to, from, max_length, low_byte_first);
+ return unpack(to, from, max_length);
}
virtual uint packed_col_length(const uchar *to, uint length)
{ return length;}
@@ -529,7 +523,7 @@ public:
void copy_from_tmp(int offset);
uint fill_cache_field(struct st_cache_field *copy);
virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- virtual bool get_time(MYSQL_TIME *ltime);
+ bool get_time(MYSQL_TIME *ltime) { return get_date(ltime, TIME_TIME_ONLY); }
virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; }
virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
virtual bool has_charset(void) const { return FALSE; }
@@ -537,16 +531,12 @@ public:
virtual enum Derivation derivation(void) const
{ return DERIVATION_IMPLICIT; }
virtual void set_derivation(enum Derivation derivation_arg) { }
- bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
+ virtual int set_time() { return 1; }
+ void set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
int cuted_increment);
void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
- const char *str, uint str_len,
- timestamp_type ts_type, int cuted_increment);
- void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
- longlong nr, timestamp_type ts_type,
+ const Lazy_string *str, timestamp_type ts_type,
int cuted_increment);
- void set_datetime_warning(MYSQL_ERROR::enum_warning_level, const uint code,
- double nr, timestamp_type ts_type);
inline bool check_overflow(int op_result)
{
return (op_result == E_DEC_OVERFLOW);
@@ -588,6 +578,9 @@ public:
DBUG_ASSERT(0);
return GEOM_GEOMETRY;
}
+
+ key_map get_possible_keys();
+
/* Hash value */
virtual void hash(ulong *nr, ulong *nr2);
@@ -639,75 +632,26 @@ private:
{ return 0; }
protected:
- /*
- Helper function to pack()/unpack() int32 values
- */
- static void handle_int32(uchar *to, const uchar *from,
- bool low_byte_first_from, bool low_byte_first_to)
+ uchar *pack_int(uchar *to, const uchar *from, size_t size)
{
- int32 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_from)
- val = sint4korr(from);
- else
-#endif
- longget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_to)
- int4store(to, val);
- else
-#endif
- longstore(to, val);
+ memcpy(to, from, size);
+ return to + size;
}
- /*
- Helper function to pack()/unpack() int64 values
- */
- static void handle_int64(uchar* to, const uchar *from,
- bool low_byte_first_from, bool low_byte_first_to)
+ const uchar *unpack_int(uchar* to, const uchar *from, size_t size)
{
- int64 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_from)
- val = sint8korr(from);
- else
-#endif
- longlongget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_to)
- int8store(to, val);
- else
-#endif
- longlongstore(to, val);
+ memcpy(to, from, size);
+ return from + size;
}
- uchar *pack_int32(uchar *to, const uchar *from, bool low_byte_first_to)
- {
- handle_int32(to, from, table->s->db_low_byte_first, low_byte_first_to);
- return to + sizeof(int32);
- }
-
- const uchar *unpack_int32(uchar* to, const uchar *from,
- bool low_byte_first_from)
- {
- handle_int32(to, from, low_byte_first_from, table->s->db_low_byte_first);
- return from + sizeof(int32);
- }
-
- uchar *pack_int64(uchar* to, const uchar *from, bool low_byte_first_to)
- {
- handle_int64(to, from, table->s->db_low_byte_first, low_byte_first_to);
- return to + sizeof(int64);
- }
-
- const uchar *unpack_int64(uchar* to, const uchar *from,
- bool low_byte_first_from)
- {
- handle_int64(to, from, low_byte_first_from, table->s->db_low_byte_first);
- return from + sizeof(int64);
- }
+ uchar *pack_int32(uchar *to, const uchar *from)
+ { return pack_int(to, from, 4); }
+ const uchar *unpack_int32(uchar* to, const uchar *from)
+ { return unpack_int(to, from, 4); }
+ uchar *pack_int64(uchar* to, const uchar *from)
+ { return pack_int(to, from, 8); }
+ const uchar *unpack_int64(uchar* to, const uchar *from)
+ { return unpack_int(to, from, 8); }
bool field_flags_are_binary()
{
@@ -725,7 +669,7 @@ public:
uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg);
- Item_result result_type () const { return REAL_RESULT; }
+ enum Item_result result_type () const { return INT_RESULT; }
void prepend_zeros(String *value);
void add_zerofill_and_unsigned(String &res) const;
friend class Create_field;
@@ -736,6 +680,7 @@ public:
int store_decimal(const my_decimal *);
my_decimal *val_decimal(my_decimal *);
uint is_equal(Create_field *new_field);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
int check_int(CHARSET_INFO *cs, const char *str, int length,
const char *int_end, int error);
bool get_int(CHARSET_INFO *cs, const char *from, uint len,
@@ -773,7 +718,6 @@ public:
bool eq_cmp_as_binary() { return test(flags & BINARY_FLAG); }
};
-
/* base class for Field_string, Field_varstring and Field_blob */
class Field_longstr :public Field_str
@@ -806,15 +750,13 @@ public:
field_name_arg, dec_arg, zero_arg, unsigned_arg),
not_fixed(dec_arg >= NOT_FIXED_DEC)
{}
+ Item_result result_type () const { return REAL_RESULT; }
int store_decimal(const my_decimal *);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
my_decimal *val_decimal(my_decimal *);
- int truncate(double *nr, double max_length);
uint32 max_display_length() { return field_length; }
uint size_of() const { return sizeof(*this); }
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first);
- virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
};
@@ -843,15 +785,13 @@ public:
void overflow(bool negative);
bool zero_pack() const { return 0; }
void sql_type(String &str) const;
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first)
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data)
{
- return Field::unpack(to, from, param_data, low_byte_first);
+ return Field::unpack(to, from, param_data);
}
- virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual uchar *pack(uchar* to, const uchar *from, uint max_length)
{
- return Field::pack(to, from, max_length, low_byte_first);
+ return Field::pack(to, from, max_length);
}
};
@@ -886,7 +826,7 @@ public:
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
int store_decimal(const my_decimal *);
double val_real(void);
longlong val_int(void);
@@ -904,8 +844,7 @@ public:
int compatible_field_size(uint field_metadata,
const Relay_log_info *rli, uint16 mflags);
uint is_equal(Create_field *new_field);
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first);
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data);
static Field *create_from_item (Item *);
};
@@ -920,7 +859,6 @@ public:
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_TINY;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
@@ -938,15 +876,13 @@ public:
void sql_type(String &str) const;
uint32 max_display_length() { return 4; }
- virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual uchar *pack(uchar* to, const uchar *from, uint max_length)
{
*to= *from;
return to + 1;
}
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first)
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data)
{
*to= *from;
return from + 1;
@@ -969,7 +905,6 @@ public:
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, 0, 0, unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_SHORT;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
@@ -987,43 +922,19 @@ public:
void sql_type(String &str) const;
uint32 max_display_length() { return 6; }
- virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual uchar *pack(uchar* to, const uchar *from, uint max_length)
{
int16 val;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- val = sint2korr(from);
- else
-#endif
- shortget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- int2store(to, val);
- else
-#endif
- shortstore(to, val);
+ val = sint2korr(from);
+ int2store(to, val);
return to + sizeof(val);
}
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first)
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data)
{
int16 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- val = sint2korr(from);
- else
-#endif
- shortget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- int2store(to, val);
- else
-#endif
- shortstore(to, val);
+ val = sint2korr(from);
+ int2store(to, val);
return from + sizeof(val);
}
};
@@ -1038,7 +949,6 @@ public:
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_INT24;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
@@ -1056,16 +966,14 @@ public:
void sql_type(String &str) const;
uint32 max_display_length() { return 8; }
- virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first)
+ virtual uchar *pack(uchar* to, const uchar *from, uint max_length)
{
- return Field::pack(to, from, max_length, low_byte_first);
+ return Field::pack(to, from, max_length);
}
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first)
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data)
{
- return Field::unpack(to, from, param_data, low_byte_first);
+ return Field::unpack(to, from, param_data);
}
};
@@ -1085,7 +993,6 @@ public:
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_LONG;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
@@ -1103,21 +1010,18 @@ public:
void sql_type(String &str) const;
uint32 max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length __attribute__((unused)),
- bool low_byte_first)
+ uint max_length __attribute__((unused)))
{
- return pack_int32(to, from, low_byte_first);
+ return pack_int32(to, from);
}
virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data __attribute__((unused)),
- bool low_byte_first)
+ uint param_data __attribute__((unused)))
{
- return unpack_int32(to, from, low_byte_first);
+ return unpack_int32(to, from);
}
};
-#ifdef HAVE_LONG_LONG
class Field_longlong :public Field_num {
public:
Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
@@ -1134,7 +1038,6 @@ public:
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_LONGLONG;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
@@ -1154,22 +1057,18 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
uint32 max_display_length() { return 20; }
virtual uchar *pack(uchar* to, const uchar *from,
- uint max_length __attribute__((unused)),
- bool low_byte_first)
+ uint max_length __attribute__((unused)))
{
- return pack_int64(to, from, low_byte_first);
+ return pack_int64(to, from);
}
virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data __attribute__((unused)),
- bool low_byte_first)
+ uint param_data __attribute__((unused)))
{
- return unpack_int64(to, from, low_byte_first);
+ return unpack_int64(to, from);
}
};
-#endif
class Field_float :public Field_real {
@@ -1276,10 +1175,14 @@ public:
void sql_type(String &str) const;
uint size_of() const { return sizeof(*this); }
uint32 max_display_length() { return 4; }
+ void move_field_offset(my_ptrdiff_t ptr_diff) {}
};
class Field_timestamp :public Field_str {
+protected:
+ int store_TIME_with_warning(THD *, MYSQL_TIME *, const Lazy_string *,
+ bool, bool);
public:
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
@@ -1289,11 +1192,11 @@ public:
CHARSET_INFO *cs);
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
- enum Item_result cmp_type () const { return INT_RESULT; }
+ enum Item_result cmp_type () const { return TIME_RESULT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1302,9 +1205,9 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 0; }
- void set_time();
+ uint decimals() const { return 0; }
+ virtual int set_time();
virtual void set_default()
{
if (table->timestamp_field == this &&
@@ -1314,43 +1217,62 @@ public:
Field::set_default();
}
/* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
- inline long get_timestamp(bool *null_value)
- {
- if ((*null_value= is_null()))
- return 0;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- return sint4korr(ptr);
-#endif
- long tmp;
- longget(tmp,ptr);
- return tmp;
- }
- inline void store_timestamp(my_time_t timestamp)
+ virtual my_time_t get_timestamp(ulong *sec_part) const;
+ virtual void store_TIME(my_time_t timestamp, ulong sec_part)
{
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
- int4store(ptr,timestamp);
- }
- else
-#endif
- longstore(ptr,(uint32) timestamp);
+ int4store(ptr,timestamp);
}
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
timestamp_auto_set_type get_auto_set_type() const;
uchar *pack(uchar *to, const uchar *from,
- uint max_length __attribute__((unused)), bool low_byte_first)
+ uint max_length __attribute__((unused)))
{
- return pack_int32(to, from, low_byte_first);
+ return pack_int32(to, from);
}
const uchar *unpack(uchar* to, const uchar *from,
- uint param_data __attribute__((unused)),
- bool low_byte_first)
+ uint param_data __attribute__((unused)))
+ {
+ return unpack_int32(to, from);
+ }
+};
+
+
+class Field_timestamp_hires :public Field_timestamp {
+ uint dec;
+public:
+ Field_timestamp_hires(uchar *ptr_arg,
+ uchar *null_ptr_arg, uchar null_bit_arg,
+ enum utype unireg_check_arg, const char *field_name_arg,
+ TABLE_SHARE *share, uint dec_arg, CHARSET_INFO *cs) :
+ Field_timestamp(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1, null_ptr_arg,
+ null_bit_arg, unireg_check_arg, field_name_arg, share, cs),
+ dec(dec_arg)
{
- return unpack_int32(to, from, low_byte_first);
+ DBUG_ASSERT(dec);
+ DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
}
+ void sql_type(String &str) const;
+ my_time_t get_timestamp(ulong *sec_part) const;
+ void store_TIME(my_time_t timestamp, ulong sec_part);
+ int store_decimal(const my_decimal *d);
+ my_decimal* val_decimal(my_decimal*);
+ double val_real(void);
+ String *val_str(String*,String *);
+ bool send_binary(Protocol *protocol);
+ int cmp(const uchar *,const uchar *);
+ void sort_string(uchar *buff,uint length);
+ uint decimals() const { return dec; }
+ int set_time();
+ enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
+ void make_field(Send_field *field);
+ uint32 pack_length() const;
+ uchar *pack(uchar *to, const uchar *from, uint max_length)
+ { return Field::pack(to, from, max_length); }
+ const uchar *unpack(uchar* to, const uchar *from, uint param_data)
+ { return Field::unpack(to, from, param_data); }
+ uint size_of() const { return sizeof(*this); }
+ bool eq_def(Field *field)
+ { return Field_str::eq_def(field) && dec == field->decimals(); }
};
@@ -1366,80 +1288,93 @@ public:
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool send_binary(Protocol *protocol);
+ uint32 max_display_length() { return field_length; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
};
-class Field_date :public Field_str {
+class Field_temporal: public Field_str {
+protected:
+ int store_TIME_with_warning(MYSQL_TIME *ltime, const Lazy_string *str,
+ int was_cut, int have_smth_to_conv);
+ virtual void store_TIME(MYSQL_TIME *ltime) = 0;
+ virtual timestamp_type temporal_type() = 0;
+public:
+ Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, utype unireg_check_arg,
+ const char *field_name_arg, CHARSET_INFO *charset_arg)
+ :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
+ field_name_arg, charset_arg) { }
+ enum Item_result cmp_type () const { return TIME_RESULT; }
+ int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(double nr);
+ int store(longlong nr, bool unsigned_val);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
+ my_decimal *val_decimal(my_decimal*);
+ bool eq_def(Field *field)
+ {
+ return (Field_str::eq_def(field) && decimals() == field->decimals());
+ }
+};
+
+class Field_date :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type()
+ { return MYSQL_TIMESTAMP_DATE; }
public:
Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
CHARSET_INFO *cs)
- :Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ :Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_date(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0, MAX_DATE_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
- enum Item_result cmp_type () const { return INT_RESULT; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(double nr);
- int store(longlong nr, bool unsigned_val);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
- bool get_time(MYSQL_TIME *ltime);
+ uint decimals() const { return 0; }
bool send_binary(Protocol *protocol);
int cmp(const uchar *,const uchar *);
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
uchar *pack(uchar* to, const uchar *from,
- uint max_length __attribute__((unused)), bool low_byte_first)
+ uint max_length __attribute__((unused)))
{
- return pack_int32(to, from, low_byte_first);
+ return pack_int32(to, from);
}
const uchar *unpack(uchar* to, const uchar *from,
- uint param_data __attribute__((unused)),
- bool low_byte_first)
+ uint param_data __attribute__((unused)))
{
- return unpack_int32(to, from, low_byte_first);
+ return unpack_int32(to, from);
}
};
-class Field_newdate :public Field_str {
+class Field_newdate :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type() { return MYSQL_TIMESTAMP_DATE; }
public:
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
CHARSET_INFO *cs)
- :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ :Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_newdate(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;}
enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
- enum Item_result cmp_type () const { return INT_RESULT; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(double nr);
- int store(longlong nr, bool unsigned_val);
- int store_time(MYSQL_TIME *ltime, timestamp_type type);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
+ uint decimals() const { return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1448,75 +1383,89 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
};
-class Field_time :public Field_str {
+class Field_time :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type()
+ { return MYSQL_TIMESTAMP_TIME; }
public:
- Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const char *field_name_arg, CHARSET_INFO *cs)
+ :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_time(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
- enum Item_result cmp_type () const { return INT_RESULT; }
- int store_time(MYSQL_TIME *ltime, timestamp_type type);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
+ uint decimals() const { return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
bool send_binary(Protocol *protocol);
- bool get_time(MYSQL_TIME *ltime);
int cmp(const uchar *,const uchar *);
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
};
+class Field_time_hires :public Field_time {
+ uint dec;
+ longlong zero_point;
+ void store_TIME(MYSQL_TIME *ltime);
+public:
+ Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
+ enum utype unireg_check_arg, const char *field_name_arg,
+ uint dec_arg, CHARSET_INFO *cs)
+ :Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + 1, null_ptr_arg,
+ null_bit_arg, unireg_check_arg, field_name_arg, cs),
+ dec(dec_arg)
+ {
+ DBUG_ASSERT(dec);
+ DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
+ zero_point= sec_part_shift(
+ ((TIME_MAX_VALUE_SECONDS+1LL)*TIME_SECOND_PART_FACTOR), dec);
+ }
+ enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
+ uint decimals() const { return dec; }
+ int store_decimal(const my_decimal *d);
+ longlong val_int(void);
+ double val_real(void);
+ String *val_str(String*,String *);
+ int reset(void);
+ bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
+ bool send_binary(Protocol *protocol);
+ int cmp(const uchar *,const uchar *);
+ void sort_string(uchar *buff,uint length);
+ uint32 pack_length() const;
+ void sql_type(String &str) const;
+ void make_field(Send_field *);
+ uint size_of() const { return sizeof(*this); }
+};
-class Field_datetime :public Field_str {
+class Field_datetime :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type()
+ { return MYSQL_TIMESTAMP_DATETIME; }
public:
- Field_datetime(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const char *field_name_arg, CHARSET_INFO *cs)
+ :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_datetime(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0, MAX_DATETIME_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
-#ifdef HAVE_LONG_LONG
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
-#endif
- enum Item_result cmp_type () const { return INT_RESULT; }
- uint decimals() const { return DATETIME_DEC; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(double nr);
- int store(longlong nr, bool unsigned_val);
- int store_time(MYSQL_TIME *ltime, timestamp_type type);
- int reset(void)
- {
- ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
- return 0;
- }
+ uint decimals() const { return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1525,24 +1474,98 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
uchar *pack(uchar* to, const uchar *from,
- uint max_length __attribute__((unused)), bool low_byte_first)
+ uint max_length __attribute__((unused)))
{
- return pack_int64(to, from, low_byte_first);
+ return pack_int64(to, from);
}
const uchar *unpack(uchar* to, const uchar *from,
- uint param_data __attribute__((unused)),
- bool low_byte_first)
+ uint param_data __attribute__((unused)))
{
- return unpack_int64(to, from, low_byte_first);
+ return unpack_int64(to, from);
}
};
+class Field_datetime_hires :public Field_datetime {
+ void store_TIME(MYSQL_TIME *ltime);
+ uint dec;
+public:
+ Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const char *field_name_arg, uint dec_arg,
+ CHARSET_INFO *cs)
+ :Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1,
+ null_ptr_arg, null_bit_arg, unireg_check_arg,
+ field_name_arg, cs), dec(dec_arg)
+ {
+ DBUG_ASSERT(dec);
+ DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
+ }
+ enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
+ uint decimals() const { return dec; }
+ void make_field(Send_field *field);
+ int store_decimal(const my_decimal *d);
+ double val_real(void);
+ longlong val_int(void);
+ String *val_str(String*,String *);
+ bool send_binary(Protocol *protocol);
+ int cmp(const uchar *,const uchar *);
+ void sort_string(uchar *buff,uint length);
+ uint32 pack_length() const;
+ void sql_type(String &str) const;
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ uchar *pack(uchar *to, const uchar *from, uint max_length)
+ { return Field::pack(to, from, max_length); }
+ const uchar *unpack(uchar* to, const uchar *from, uint param_data)
+ { return Field::unpack(to, from, param_data); }
+ uint size_of() const { return sizeof(*this); }
+};
+
+static inline Field_timestamp *
+new_Field_timestamp(uchar *ptr, uchar *null_ptr, uchar null_bit,
+ enum Field::utype unireg_check, const char *field_name,
+ TABLE_SHARE *share, uint dec, CHARSET_INFO *cs)
+{
+ if (dec==0)
+ return new Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
+ unireg_check, field_name, share, cs);
+ if (dec == NOT_FIXED_DEC)
+ dec= MAX_DATETIME_PRECISION;
+ return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check,
+ field_name, share, dec, cs);
+}
+
+static inline Field_time *
+new_Field_time(uchar *ptr, uchar *null_ptr, uchar null_bit,
+ enum Field::utype unireg_check, const char *field_name,
+ uint dec, CHARSET_INFO *cs)
+{
+ if (dec == 0)
+ return new Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit,
+ unireg_check, field_name, cs);
+ if (dec == NOT_FIXED_DEC)
+ dec= MAX_DATETIME_PRECISION;
+ return new Field_time_hires(ptr, null_ptr, null_bit,
+ unireg_check, field_name, dec, cs);
+}
+
+static inline Field_datetime *
+new_Field_datetime(uchar *ptr, uchar *null_ptr, uchar null_bit,
+ enum Field::utype unireg_check,
+ const char *field_name, uint dec, CHARSET_INFO *cs)
+{
+ if (dec == 0)
+ return new Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
+ unireg_check, field_name, cs);
+ if (dec == NOT_FIXED_DEC)
+ dec= MAX_DATETIME_PRECISION;
+ return new Field_datetime_hires(ptr, null_ptr, null_bit,
+ unireg_check, field_name, dec, cs);
+}
+
class Field_string :public Field_longstr {
public:
bool can_alter_field_type;
@@ -1587,9 +1610,8 @@ public:
void sort_string(uchar *buff,uint length);
void sql_type(String &str) const;
virtual uchar *pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first);
+ uint max_length);
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data);
uint pack_length_from_metadata(uint field_metadata)
{
DBUG_PRINT("debug", ("field_metadata: 0x%04x", field_metadata));
@@ -1674,15 +1696,11 @@ public:
uint get_key_image(uchar *buff,uint length, imagetype type);
void set_key_image(const uchar *buff,uint length);
void sql_type(String &str) const;
- virtual uchar *pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- uchar *pack_key(uchar *to, const uchar *from, uint max_length, bool low_byte_first);
- uchar *pack_key_from_key_image(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
- virtual const uchar *unpack(uchar* to, const uchar *from,
- uint param_data, bool low_byte_first);
- const uchar *unpack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
+ virtual uchar *pack(uchar *to, const uchar *from, uint max_length);
+ uchar *pack_key(uchar *to, const uchar *from, uint max_length);
+ uchar *pack_key_from_key_image(uchar* to, const uchar *from, uint max_length);
+ virtual const uchar *unpack(uchar* to, const uchar *from, uint param_data);
+ const uchar *unpack_key(uchar* to, const uchar *from, uint max_length);
int pack_cmp(const uchar *a, const uchar *b, uint key_length,
bool insert_or_update);
int pack_cmp(const uchar *b, uint key_length,bool insert_or_update);
@@ -1790,14 +1808,7 @@ public:
int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; }
void reset_fields() { bzero((uchar*) &value,sizeof(value)); }
uint32 get_field_buffer_size(void) { return value.alloced_length(); }
-#ifndef WORDS_BIGENDIAN
- static
-#endif
- void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number, bool low_byte_first);
- void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
- {
- store_length(i_ptr, i_packlength, i_number, table->s->db_low_byte_first);
- }
+ void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number);
inline void store_length(uint32 number)
{
store_length(ptr, packlength, number);
@@ -1811,38 +1822,37 @@ public:
@returns The length in the row plus the size of the data.
*/
- uint32 get_packed_size(const uchar *ptr_arg, bool low_byte_first)
- {return packlength + get_length(ptr_arg, packlength, low_byte_first);}
+ uint32 get_packed_size(const uchar *ptr_arg)
+ {return packlength + get_length(ptr_arg, packlength);}
inline uint32 get_length(uint row_offset= 0)
- { return get_length(ptr+row_offset, this->packlength, table->s->db_low_byte_first); }
- uint32 get_length(const uchar *ptr, uint packlength, bool low_byte_first);
+ { return get_length(ptr+row_offset, this->packlength); }
+ uint32 get_length(const uchar *ptr, uint packlength);
uint32 get_length(const uchar *ptr_arg)
- { return get_length(ptr_arg, this->packlength, table->s->db_low_byte_first); }
- void put_length(uchar *pos, uint32 length);
+ { return get_length(ptr_arg, this->packlength); }
inline void get_ptr(uchar **str)
- {
- memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));
- }
+ {
+ memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));
+ }
inline void get_ptr(uchar **str, uint row_offset)
- {
- memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*));
- }
+ {
+ memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*));
+ }
inline void set_ptr(uchar *length, uchar *data)
- {
- memcpy(ptr,length,packlength);
- memcpy_fixed(ptr+packlength,&data,sizeof(char*));
- }
+ {
+ memcpy(ptr,length,packlength);
+ memcpy_fixed(ptr+packlength,&data,sizeof(char*));
+ }
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
- {
- uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
- store_length(ptr_ofs, packlength, length);
- memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*));
- }
+ {
+ uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
+ store_length(ptr_ofs, packlength, length);
+ memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*));
+ }
inline void set_ptr(uint32 length, uchar *data)
- {
- set_ptr_offset(0, length, data);
- }
+ {
+ set_ptr_offset(0, length, data);
+ }
uint get_key_image(uchar *buff,uint length, imagetype type);
void set_key_image(const uchar *buff,uint length);
void sql_type(String &str) const;
@@ -1859,21 +1869,17 @@ public:
memcpy_fixed(ptr+packlength,&tmp,sizeof(char*));
return 0;
}
- virtual uchar *pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- uchar *pack_key(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- uchar *pack_key_from_key_image(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
- virtual const uchar *unpack(uchar *to, const uchar *from,
- uint param_data, bool low_byte_first);
- const uchar *unpack_key(uchar* to, const uchar *from,
- uint max_length, bool low_byte_first);
+ virtual uchar *pack(uchar *to, const uchar *from, uint max_length);
+ uchar *pack_key(uchar *to, const uchar *from, uint max_length);
+ uchar *pack_key_from_key_image(uchar* to, const uchar *from, uint max_length);
+ virtual const uchar *unpack(uchar *to, const uchar *from, uint param_data);
+ const uchar *unpack_key(uchar* to, const uchar *from, uint max_length);
int pack_cmp(const uchar *a, const uchar *b, uint key_length,
bool insert_or_update);
int pack_cmp(const uchar *b, uint key_length,bool insert_or_update);
uint packed_col_length(const uchar *col_ptr, uint length);
uint max_packed_col_length(uint max_length);
+ /* Set if we should convert constant item's with convert_const_item */
void free() { value.free(); }
inline void clear_temporary() { bzero((uchar*) &value,sizeof(value)); }
friend int field_conv(Field *to,Field *from);
@@ -1940,7 +1946,6 @@ public:
Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
enum_field_types type() const { return MYSQL_TYPE_STRING; }
enum Item_result cmp_type () const { return INT_RESULT; }
- enum Item_result cast_to_int_type () const { return INT_RESULT; }
enum ha_base_keytype key_type() const;
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
@@ -2070,10 +2075,8 @@ public:
int compatible_field_size(uint field_metadata,
const Relay_log_info *rli, uint16 mflags);
void sql_type(String &str) const;
- virtual uchar *pack(uchar *to, const uchar *from,
- uint max_length, bool low_byte_first);
- virtual const uchar *unpack(uchar *to, const uchar *from,
- uint param_data, bool low_byte_first);
+ virtual uchar *pack(uchar *to, const uchar *from, uint max_length);
+ virtual const uchar *unpack(uchar *to, const uchar *from, uint param_data);
virtual void set_default();
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
@@ -2160,7 +2163,7 @@ public:
Field *field; // For alter table
engine_option_value *option_list;
/** structure with parsed options (for comparing fields in ALTER TABLE) */
- void *option_struct;
+ ha_field_option_struct *option_struct;
uint8 row,col,sc_length,interval_id; // For rea_create_table
uint offset,pack_flag;
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 3e52e67f2d9..afc4d8252ff 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -365,6 +365,14 @@ static void do_field_decimal(Copy_field *copy)
}
+static void do_field_temporal(Copy_field *copy)
+{
+ MYSQL_TIME ltime;
+ copy->from_field->get_date(&ltime, TIME_FUZZY_DATE);
+ copy->to_field->store_time_dec(&ltime, copy->from_field->decimals());
+}
+
+
/**
string copy for single byte characters set when to string is shorter than
from string.
@@ -561,7 +569,7 @@ void Copy_field::set(uchar *to,Field *from)
/*
To do:
- If 'save\ is set to true and the 'from' is a blob field, do_copy is set to
+ If 'save' is set to true and the 'from' is a blob field, do_copy is set to
do_save_blob rather than do_conv_blob. The only differences between them
appears to be:
@@ -638,13 +646,11 @@ void Copy_field::set(Field *to,Field *from,bool save)
Copy_field::Copy_func *
Copy_field::get_copy_func(Field *to,Field *from)
{
- bool compatible_db_low_byte_first= (to->table->s->db_low_byte_first ==
- from->table->s->db_low_byte_first);
if (to->flags & BLOB_FLAG)
{
if (!(from->flags & BLOB_FLAG) || from->charset() != to->charset())
return do_conv_blob;
- if (from_length != to_length || !compatible_db_low_byte_first)
+ if (from_length != to_length)
{
// Correct pointer to point at char pointer
to_ptr+= to_length - to->table->s->blob_ptr_size;
@@ -659,6 +665,16 @@ Copy_field::get_copy_func(Field *to,Field *from)
return do_field_int;
if (to->result_type() == DECIMAL_RESULT)
return do_field_decimal;
+ if (from->cmp_type() == TIME_RESULT)
+ {
+ /* If types are not 100 % identical then convert trough get_date() */
+ if (!to->eq_def(from) ||
+ ((to->table->in_use->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE)) &&
+ mysql_type_to_time_type(to->type()) != MYSQL_TIMESTAMP_TIME))
+ return do_field_temporal;
+ /* Do binary copy */
+ }
// Check if identical fields
if (from->result_type() == STRING_RESULT)
{
@@ -671,16 +687,7 @@ Copy_field::get_copy_func(Field *to,Field *from)
to->type() == MYSQL_TYPE_VARCHAR && !to->has_charset())
return do_field_varbinary_pre50;
- /*
- If we are copying date or datetime's we have to check the dates
- if we don't allow 'all' dates.
- */
- if (to->real_type() != from->real_type() ||
- !compatible_db_low_byte_first ||
- ((to->table->in_use->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) &&
- (to->type() == MYSQL_TYPE_DATE ||
- to->type() == MYSQL_TYPE_DATETIME)))
+ if (to->real_type() != from->real_type())
{
if (from->real_type() == MYSQL_TYPE_ENUM ||
from->real_type() == MYSQL_TYPE_SET)
@@ -727,8 +734,7 @@ Copy_field::get_copy_func(Field *to,Field *from)
}
}
else if (to->real_type() != from->real_type() ||
- to_length != from_length ||
- !compatible_db_low_byte_first)
+ to_length != from_length)
{
if (to->real_type() == MYSQL_TYPE_DECIMAL ||
to->result_type() == STRING_RESULT)
@@ -739,7 +745,7 @@ Copy_field::get_copy_func(Field *to,Field *from)
}
else
{
- if (!to->eq_def(from) || !compatible_db_low_byte_first)
+ if (!to->eq_def(from))
{
if (to->real_type() == MYSQL_TYPE_DECIMAL)
return do_field_string;
@@ -772,14 +778,13 @@ int field_conv(Field *to,Field *from)
{
if (to->pack_length() == from->pack_length() &&
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
+ to->decimals() == from->decimals() &&
to->real_type() != MYSQL_TYPE_ENUM &&
to->real_type() != MYSQL_TYPE_SET &&
to->real_type() != MYSQL_TYPE_BIT &&
(to->real_type() != MYSQL_TYPE_NEWDECIMAL ||
- ((to->field_length == from->field_length &&
- (((Field_num*)to)->dec == ((Field_num*)from)->dec)))) &&
+ to->field_length == from->field_length) &&
from->charset() == to->charset() &&
- to->table->s->db_low_byte_first == from->table->s->db_low_byte_first &&
(!(to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) ||
(to->type() != MYSQL_TYPE_DATE &&
@@ -820,7 +825,22 @@ int field_conv(Field *to,Field *from)
((Field_enum *)(to))->store_type(0);
return 0;
}
- else if ((from->result_type() == STRING_RESULT &&
+ if (from->result_type() == REAL_RESULT)
+ return to->store(from->val_real());
+ if (from->result_type() == DECIMAL_RESULT)
+ {
+ my_decimal buff;
+ return to->store_decimal(from->val_decimal(&buff));
+ }
+ if (from->cmp_type() == TIME_RESULT)
+ {
+ MYSQL_TIME ltime;
+ if (from->get_date(&ltime, TIME_FUZZY_DATE))
+ return to->reset();
+ else
+ return to->store_time_dec(&ltime, from->decimals());
+ }
+ if ((from->result_type() == STRING_RESULT &&
(to->result_type() == STRING_RESULT ||
(from->real_type() != MYSQL_TYPE_ENUM &&
from->real_type() != MYSQL_TYPE_SET))) ||
@@ -837,13 +857,5 @@ int field_conv(Field *to,Field *from)
*/
return to->store(result.c_ptr_quick(),result.length(),from->charset());
}
- else if (from->result_type() == REAL_RESULT)
- return to->store(from->val_real());
- else if (from->result_type() == DECIMAL_RESULT)
- {
- my_decimal buff;
- return to->store_decimal(from->val_decimal(&buff));
- }
- else
- return to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
+ return to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
}
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 6e3bf27afcc..559f4f1dcf6 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -231,7 +231,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
goto err;
}
if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX,
- DISK_BUFFER_SIZE, MYF(MY_WME)))
+ DISK_BUFFER_SIZE, MYF(ME_ERROR | MY_WME)))
goto err;
param.keys--; /* TODO: check why we do this */
@@ -266,7 +266,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
/* Open cached file if it isn't open */
if (! my_b_inited(outfile) &&
open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER,
- MYF(MY_WME)))
+ MYF(ME_ERROR | MY_WME)))
goto err;
if (reinit_io_cache(outfile,WRITE_CACHE,0L,0,0))
goto err;
@@ -318,8 +318,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
}
}
if (error)
- my_message(ER_FILSORT_ABORT, ER(ER_FILSORT_ABORT),
- MYF(ME_ERROR+ME_WAITTANG));
+ my_message(ER_FILSORT_ABORT, ER(ER_FILSORT_ABORT), MYF(0));
else
statistic_add(thd->status_var.filesort_rows,
(ulong) records, &LOCK_status);
@@ -612,10 +611,34 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
}
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
}
+
+ bool write_record= false;
if (error == 0)
+ {
param->examined_rows++;
-
- if (error == 0 && (!select || select->skip_record(thd) > 0))
+ if (select && select->cond)
+ {
+ /*
+ If the condition 'select->cond' contains a subquery, restore the
+ original read/write sets of the table 'sort_form' because when
+ SQL_SELECT::skip_record evaluates this condition. it may include a
+ correlated subquery predicate, such that some field in the subquery
+ refers to 'sort_form'.
+ */
+ if (select->cond->with_subselect)
+ sort_form->column_bitmaps_set(save_read_set, save_write_set,
+ save_vcol_set);
+ write_record= (select->skip_record(thd) > 0);
+ if (select->cond->with_subselect)
+ sort_form->column_bitmaps_set(&sort_form->tmp_set,
+ &sort_form->tmp_set,
+ &sort_form->tmp_set);
+ }
+ else
+ write_record= true;
+ }
+
+ if (write_record)
{
if (idx == param->keys)
{
@@ -628,7 +651,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
}
else
file->unlock_row();
-
+
/* It does not make sense to read more keys in case of a fatal error */
if (thd->is_error())
break;
@@ -850,25 +873,28 @@ static void make_sortkey(register SORTPARAM *param,
break;
}
case INT_RESULT:
+ case TIME_RESULT:
{
- longlong value= item->val_int_result();
+ longlong UNINIT_VAR(value);
+ if (sort_field->result_type == INT_RESULT)
+ value= item->val_int_result();
+ else
+ {
+ MYSQL_TIME buf;
+ if (item->get_date_result(&buf, TIME_FUZZY_DATE | TIME_INVALID_DATES))
+ DBUG_ASSERT(maybe_null && item->null_value);
+ else
+ value= pack_time(&buf);
+ }
if (maybe_null)
{
- *to++=1; /* purecov: inspected */
if (item->null_value)
{
- if (maybe_null)
- bzero((char*) to-1,sort_field->length+1);
- else
- {
- DBUG_PRINT("warning",
- ("Got null on something that shouldn't be null"));
- bzero((char*) to,sort_field->length);
- }
+ bzero((char*) to++, sort_field->length+1);
break;
}
+ *to++=1; /* purecov: inspected */
}
-#if SIZEOF_LONG_LONG > 4
to[7]= (uchar) value;
to[6]= (uchar) (value >> 8);
to[5]= (uchar) (value >> 16);
@@ -880,15 +906,6 @@ static void make_sortkey(register SORTPARAM *param,
to[0]= (uchar) (value >> 56);
else
to[0]= (uchar) (value >> 56) ^ 128; /* Reverse signbit */
-#else
- to[3]= (uchar) value;
- to[2]= (uchar) (value >> 8);
- to[1]= (uchar) (value >> 16);
- if (item->unsigned_flag) /* Fix sign */
- to[0]= (uchar) (value >> 24);
- else
- to[0]= (uchar) (value >> 24) ^ 128; /* Reverse signbit */
-#endif
break;
}
case DECIMAL_RESULT:
@@ -898,8 +915,7 @@ static void make_sortkey(register SORTPARAM *param,
{
if (item->null_value)
{
- bzero((char*)to, sort_field->length+1);
- to++;
+ bzero((char*) to++, sort_field->length+1);
break;
}
*to++=1;
@@ -1543,9 +1559,7 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
}
else
{
- sortorder->result_type= sortorder->item->result_type();
- if (sortorder->item->result_as_longlong())
- sortorder->result_type= INT_RESULT;
+ sortorder->result_type= sortorder->item->cmp_type();
switch (sortorder->result_type) {
case STRING_RESULT:
sortorder->length=sortorder->item->max_length;
@@ -1563,12 +1577,9 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
sortorder->length+= sortorder->suffix_length;
}
break;
+ case TIME_RESULT:
case INT_RESULT:
-#if SIZEOF_LONG_LONG > 4
sortorder->length=8; // Size of intern longlong
-#else
- sortorder->length=4;
-#endif
break;
case DECIMAL_RESULT:
sortorder->length=
@@ -1643,6 +1654,7 @@ get_addon_fields(THD *thd, Field **ptabfield, uint sortlength, uint *plength)
Actually we need only the fields referred in the
result set. And for some of them it makes sense to use
the values directly from sorted fields.
+ But beware the case when item->cmp_type() != item->result_type()
*/
*plength= 0;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 74ea36b5bd9..6a72623ce5d 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -164,8 +164,7 @@ const uint ha_partition::NO_CURRENT_PART_ID= 0xFFFFFFFF;
*/
ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share)
- :handler(hton, share), m_part_info(NULL), m_create_handler(FALSE),
- m_is_sub_partitioned(0)
+ :handler(hton, share)
{
DBUG_ENTER("ha_partition::ha_partition(table)");
init_alloc_root(&m_mem_root, 512, 512);
@@ -186,16 +185,46 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share)
*/
ha_partition::ha_partition(handlerton *hton, partition_info *part_info)
- :handler(hton, NULL), m_part_info(part_info), m_create_handler(TRUE),
- m_is_sub_partitioned(m_part_info->is_sub_partitioned())
+ :handler(hton, NULL)
{
DBUG_ENTER("ha_partition::ha_partition(part_info)");
+ DBUG_ASSERT(part_info);
init_alloc_root(&m_mem_root, 512, 512);
init_handler_variables();
- DBUG_ASSERT(m_part_info);
+ m_part_info= part_info;
+ m_create_handler= TRUE;
+ m_is_sub_partitioned= m_part_info->is_sub_partitioned();
DBUG_VOID_RETURN;
}
+/**
+ ha_partition constructor method used by ha_partition::clone()
+
+ @param hton Handlerton (partition_hton)
+ @param share Table share object
+ @param part_info_arg partition_info to use
+ @param clone_arg ha_partition to clone
+ @param clme_mem_root_arg MEM_ROOT to use
+
+ @return New partition handler
+*/
+
+ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share,
+ partition_info *part_info_arg,
+ ha_partition *clone_arg,
+ MEM_ROOT *clone_mem_root_arg)
+ :handler(hton, share)
+{
+ DBUG_ENTER("ha_partition::ha_partition(clone)");
+ init_alloc_root(&m_mem_root, 512, 512);
+ init_handler_variables();
+ m_part_info= part_info_arg;
+ m_create_handler= TRUE;
+ m_is_sub_partitioned= m_part_info->is_sub_partitioned();
+ m_is_clone_of= clone_arg;
+ m_clone_mem_root= clone_mem_root_arg;
+ DBUG_VOID_RETURN;
+}
/*
Initialize handler object
@@ -239,7 +268,6 @@ void ha_partition::init_handler_variables()
m_extra_prepare_for_update= FALSE;
m_extra_cache_part_id= NO_CURRENT_PART_ID;
m_handler_status= handler_not_initialized;
- m_low_byte_first= 1;
m_part_field_array= NULL;
m_ordered_rec_buffer= NULL;
m_top_entry= NO_CURRENT_PART_ID;
@@ -248,7 +276,6 @@ void ha_partition::init_handler_variables()
m_rec0= 0;
m_curr_key_info[0]= NULL;
m_curr_key_info[1]= NULL;
- is_clone= FALSE,
m_part_func_monotonicity_info= NON_MONOTONIC;
auto_increment_lock= FALSE;
auto_increment_safe_stmt_log_lock= FALSE;
@@ -256,6 +283,11 @@ void ha_partition::init_handler_variables()
this allows blackhole to work properly
*/
m_no_locks= 0;
+ m_part_info= NULL;
+ m_create_handler= FALSE;
+ m_is_sub_partitioned= 0;
+ m_is_clone_of= NULL;
+ m_clone_mem_root= NULL;
#ifdef DONT_HAVE_TO_BE_INITALIZED
m_start_key.flag= 0;
@@ -368,7 +400,8 @@ bool ha_partition::initialize_partition(MEM_ROOT *mem_root)
*/
DBUG_RETURN(0);
}
- else if (get_from_handler_file(table_share->normalized_path.str, mem_root))
+ else if (get_from_handler_file(table_share->normalized_path.str,
+ mem_root, false))
{
my_message(ER_UNKNOWN_ERROR, "Failed to read from the .par file", MYF(0));
DBUG_RETURN(1);
@@ -383,18 +416,11 @@ bool ha_partition::initialize_partition(MEM_ROOT *mem_root)
Verify that all partitions have the same table_flags.
*/
check_table_flags= m_file[0]->ha_table_flags();
- m_low_byte_first= m_file[0]->low_byte_first();
m_pkey_is_clustered= TRUE;
file_array= m_file;
do
{
file= *file_array;
- if (m_low_byte_first != file->low_byte_first())
- {
- // Cannot have handlers with different endian
- my_error(ER_MIX_HANDLER_ERROR, MYF(0));
- DBUG_RETURN(1);
- }
if (!file->primary_key_is_clustered())
m_pkey_is_clustered= FALSE;
if (check_table_flags != file->ha_table_flags())
@@ -1869,7 +1895,7 @@ uint ha_partition::del_ren_cre_table(const char *from,
DBUG_RETURN(TRUE);
}
- if (get_from_handler_file(from, ha_thd()->mem_root))
+ if (get_from_handler_file(from, ha_thd()->mem_root, false))
DBUG_RETURN(TRUE);
DBUG_ASSERT(m_file_buffer);
DBUG_PRINT("enter", ("from: (%s) to: (%s)", from, to));
@@ -2091,18 +2117,16 @@ static uint name_add(char *dest, const char *first_name, const char *sec_name)
}
-/*
+/**
Create the special .par file
- SYNOPSIS
- create_handler_file()
- name Full path of table name
+ @param name Full path of table name
- RETURN VALUE
- >0 Error code
- 0 Success
+ @return Operation status
+ @retval FALSE Error code
+ @retval TRUE Success
- DESCRIPTION
+ @note
Method used to create handler file with names of partitions, their
engine types and the number of partitions.
*/
@@ -2166,21 +2190,24 @@ bool ha_partition::create_handler_file(const char *name)
Array of engine types n * 4 bytes where
n = (m_tot_parts + 3)/4
Length of name part in bytes 4 bytes
+ (Names in filename format)
Name part m * 4 bytes where
m = ((length_name_part + 3)/4)*4
All padding bytes are zeroed
*/
- tot_partition_words= (tot_parts + 3) / 4;
- tot_name_words= (tot_name_len + 3) / 4;
+ tot_partition_words= (tot_parts + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
+ tot_name_words= (tot_name_len + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
+ /* 4 static words (tot words, checksum, tot partitions, name length) */
tot_len_words= 4 + tot_partition_words + tot_name_words;
- tot_len_byte= 4 * tot_len_words;
+ tot_len_byte= PAR_WORD_SIZE * tot_len_words;
file_buffer= (uchar *) my_alloca(tot_len_byte);
if (!file_buffer)
DBUG_RETURN(TRUE);
bzero(file_buffer, tot_len_byte);
- engine_array= (file_buffer + 12);
- name_buffer_ptr= (char*) (file_buffer + ((4 + tot_partition_words) * 4));
+ engine_array= (file_buffer + PAR_ENGINES_OFFSET);
+ name_buffer_ptr= (char*) (engine_array + tot_partition_words * PAR_WORD_SIZE
+ + PAR_WORD_SIZE);
part_it.rewind();
for (i= 0; i < no_parts; i++)
{
@@ -2218,13 +2245,15 @@ bool ha_partition::create_handler_file(const char *name)
}
chksum= 0;
int4store(file_buffer, tot_len_words);
- int4store(file_buffer + 8, tot_parts);
- int4store(file_buffer + 12 + (tot_partition_words * 4), tot_name_len);
+ int4store(file_buffer + PAR_NUM_PARTS_OFFSET, tot_parts);
+ int4store(file_buffer + PAR_ENGINES_OFFSET +
+ (tot_partition_words * PAR_WORD_SIZE),
+ tot_name_len);
for (i= 0; i < tot_len_words; i++)
- chksum^= uint4korr(file_buffer + 4 * i);
- int4store(file_buffer + 4, chksum);
+ chksum^= uint4korr(file_buffer + PAR_WORD_SIZE * i);
+ int4store(file_buffer + PAR_CHECKSUM_OFFSET, chksum);
/*
- Remove .frm extension and replace with .par
+ Add .par extension to the file name.
Create and write and close file
to be used at open, delete_table and rename_table
*/
@@ -2235,6 +2264,7 @@ bool ha_partition::create_handler_file(const char *name)
result= my_write(file, (uchar *) file_buffer, tot_len_byte,
MYF(MY_WME | MY_NABP)) != 0;
+ /* Write connection information (for federatedx engine) */
part_it.rewind();
for (i= 0; i < no_parts && !result; i++)
{
@@ -2245,7 +2275,10 @@ bool ha_partition::create_handler_file(const char *name)
if (my_write(file, buffer, 4, MYF(MY_WME | MY_NABP)) ||
my_write(file, (uchar *) part_elem->connect_string.str, length,
MYF(MY_WME | MY_NABP)))
+ {
result= TRUE;
+ break;
+ }
}
VOID(my_close(file, MYF(0)));
}
@@ -2255,14 +2288,9 @@ bool ha_partition::create_handler_file(const char *name)
DBUG_RETURN(result);
}
-/*
- Clear handler variables and free some memory
-
- SYNOPSIS
- clear_handler_file()
- RETURN VALUE
- NONE
+/**
+ Clear handler variables and free some memory
*/
void ha_partition::clear_handler_file()
@@ -2275,16 +2303,15 @@ void ha_partition::clear_handler_file()
m_connect_string= NULL;
}
-/*
+
+/**
Create underlying handler objects
- SYNOPSIS
- create_handlers()
- mem_root Allocate memory through this
+ @param mem_root Allocate memory through this
- RETURN VALUE
- TRUE Error
- FALSE Success
+ @return Operation status
+ @retval TRUE Error
+ @retval FALSE Success
*/
bool ha_partition::create_handlers(MEM_ROOT *mem_root)
@@ -2322,6 +2349,7 @@ bool ha_partition::create_handlers(MEM_ROOT *mem_root)
DBUG_RETURN(FALSE);
}
+
/*
Create underlying handler objects from partition info
@@ -2393,85 +2421,83 @@ error_end:
}
-/*
- Get info about partition engines and their names from the .par file
+/**
+ Read the .par file to get the partitions engines and names
- SYNOPSIS
- get_from_handler_file()
- name Full path of table name
- mem_root Allocate memory through this
+ @param name Name of table file (without extention)
- RETURN VALUE
- TRUE Error
- FALSE Success
+ @return Operation status
+ @retval true Failure
+ @retval false Success
- DESCRIPTION
- Open handler file to get partition names, engine types and number of
- partitions.
+ @note On success, m_file_buffer is allocated and must be
+ freed by the caller. m_name_buffer_ptr and m_tot_parts is also set.
*/
-bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
+bool ha_partition::read_par_file(const char *name)
{
- char buff[FN_REFLEN], *address_tot_name_len;
+ char buff[FN_REFLEN], *tot_name_len_offset;
File file;
- char *file_buffer, *name_buffer_ptr;
- handlerton **engine_array;
+ char *file_buffer;
uint i, len_bytes, len_words, tot_partition_words, tot_name_words, chksum;
- DBUG_ENTER("ha_partition::get_from_handler_file");
+ DBUG_ENTER("ha_partition::read_par_file");
DBUG_PRINT("enter", ("table name: '%s'", name));
if (m_file_buffer)
- DBUG_RETURN(FALSE);
+ DBUG_RETURN(false);
fn_format(buff, name, "", ha_par_ext, MY_APPEND_EXT);
/* Following could be done with my_stat to read in whole file */
if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0)
- DBUG_RETURN(TRUE);
- if (my_read(file, (uchar *) & buff[0], 8, MYF(MY_NABP)))
+ DBUG_RETURN(true);
+ if (my_read(file, (uchar *) & buff[0], PAR_WORD_SIZE, MYF(MY_NABP)))
goto err1;
len_words= uint4korr(buff);
- len_bytes= 4 * len_words;
+ len_bytes= PAR_WORD_SIZE * len_words;
+ if (my_seek(file, 0, MY_SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)
+ goto err1;
if (!(file_buffer= (char*) alloc_root(&m_mem_root, len_bytes)))
goto err1;
- VOID(my_seek(file, 0, MY_SEEK_SET, MYF(0)));
if (my_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP)))
goto err2;
chksum= 0;
for (i= 0; i < len_words; i++)
- chksum ^= uint4korr((file_buffer) + 4 * i);
+ chksum ^= uint4korr((file_buffer) + PAR_WORD_SIZE * i);
if (chksum)
goto err2;
- m_tot_parts= uint4korr((file_buffer) + 8);
+ m_tot_parts= uint4korr((file_buffer) + PAR_NUM_PARTS_OFFSET);
DBUG_PRINT("info", ("No of parts = %u", m_tot_parts));
- tot_partition_words= (m_tot_parts + 3) / 4;
- engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*));
- for (i= 0; i < m_tot_parts; i++)
- {
- engine_array[i]= ha_resolve_by_legacy_type(ha_thd(),
- (enum legacy_db_type)
- *(uchar *) ((file_buffer) +
- 12 + i));
- if (!engine_array[i])
- goto err3;
- }
- address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words;
- tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
+ tot_partition_words= (m_tot_parts + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
+
+ tot_name_len_offset= file_buffer + PAR_ENGINES_OFFSET +
+ PAR_WORD_SIZE * tot_partition_words;
+ tot_name_words= (uint4korr(tot_name_len_offset) + PAR_WORD_SIZE - 1) /
+ PAR_WORD_SIZE;
+ /*
+ Verify the total length = tot size word, checksum word, num parts word +
+ engines array + name length word + name array.
+ */
if (len_words != (tot_partition_words + tot_name_words + 4))
- goto err3;
- name_buffer_ptr= file_buffer + 16 + 4 * tot_partition_words;
+ goto err2;
+ m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
+ m_name_buffer_ptr= tot_name_len_offset + PAR_WORD_SIZE;
if (!(m_connect_string= (LEX_STRING*)
alloc_root(&m_mem_root, m_tot_parts * sizeof(LEX_STRING))))
- goto err3;
+ goto err2;
bzero(m_connect_string, m_tot_parts * sizeof(LEX_STRING));
+ /* Read connection arguments (for federated X engine) */
for (i= 0; i < m_tot_parts; i++)
{
LEX_STRING connect_string;
uchar buffer[4];
if (my_read(file, buffer, 4, MYF(MY_NABP)))
+ {
+ /* No extra options; Probably not a federatedx engine */
break;
+ }
connect_string.length= uint4korr(buffer);
connect_string.str= (char*) alloc_root(&m_mem_root, connect_string.length+1);
if (my_read(file, (uchar*) connect_string.str, connect_string.length,
@@ -2482,31 +2508,100 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
}
VOID(my_close(file, MYF(0)));
- m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
- m_name_buffer_ptr= name_buffer_ptr;
-
+ DBUG_RETURN(false);
+
+err2:
+err1:
+ VOID(my_close(file, MYF(0)));
+ DBUG_RETURN(true);
+}
+
+
+/**
+ Setup m_engine_array
+
+ @param mem_root MEM_ROOT to use for allocating new handlers
+
+ @return Operation status
+ @retval false Success
+ @retval true Failure
+*/
+
+bool ha_partition::setup_engine_array(MEM_ROOT *mem_root)
+{
+ uint i;
+ uchar *buff;
+ handlerton **engine_array;
+
+ DBUG_ASSERT(!m_file);
+ DBUG_ENTER("ha_partition::setup_engine_array");
+ engine_array= (handlerton **) my_alloca(m_tot_parts * sizeof(handlerton*));
+ if (!engine_array)
+ DBUG_RETURN(true);
+
+ buff= (uchar *) (m_file_buffer + PAR_ENGINES_OFFSET);
+ for (i= 0; i < m_tot_parts; i++)
+ {
+ engine_array[i]= ha_resolve_by_legacy_type(ha_thd(),
+ (enum legacy_db_type)
+ *(buff + i));
+ if (!engine_array[i])
+ goto err;
+ }
if (!(m_engine_array= (plugin_ref*)
alloc_root(&m_mem_root, m_tot_parts * sizeof(plugin_ref))))
- goto err3;
+ goto err;
for (i= 0; i < m_tot_parts; i++)
m_engine_array[i]= ha_lock_engine(NULL, engine_array[i]);
my_afree(engine_array);
- if (!m_file && create_handlers(mem_root))
+ if (create_handlers(mem_root))
{
clear_handler_file();
- DBUG_RETURN(TRUE);
+ DBUG_RETURN(true);
}
- DBUG_RETURN(FALSE);
-err3:
+ DBUG_RETURN(false);
+
+err:
my_afree(engine_array);
-err2:
-err1:
- VOID(my_close(file, MYF(0)));
- DBUG_RETURN(TRUE);
+ DBUG_RETURN(true);
+}
+
+
+/**
+ Get info about partition engines and their names from the .par file
+
+ @param name Full path of table name
+ @param mem_root Allocate memory through this
+ @param is_clone If it is a clone, don't create new handlers
+
+ @return Operation status
+ @retval true Error
+ @retval false Success
+
+ @note Open handler file to get partition names, engine types and number of
+ partitions.
+*/
+
+bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root,
+ bool is_clone)
+{
+ DBUG_ENTER("ha_partition::get_from_handler_file");
+ DBUG_PRINT("enter", ("table name: '%s'", name));
+
+ if (m_file_buffer)
+ DBUG_RETURN(false);
+
+ if (read_par_file(name))
+ DBUG_RETURN(true);
+
+ if (!is_clone && setup_engine_array(mem_root))
+ DBUG_RETURN(true);
+
+ DBUG_RETURN(false);
}
@@ -2553,13 +2648,13 @@ void ha_data_partition_destroy(void *ha_data)
int ha_partition::open(const char *name, int mode, uint test_if_locked)
{
- char *name_buffer_ptr= m_name_buffer_ptr;
- int error;
+ char *name_buffer_ptr;
+ int error= HA_ERR_INITIALIZATION;
uint alloc_len;
handler **file;
char name_buff[FN_REFLEN];
bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE);
- ulonglong check_table_flags= 0;
+ ulonglong check_table_flags;
DBUG_ENTER("ha_partition::open");
DBUG_ASSERT(table->s == table_share);
@@ -2567,8 +2662,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
m_mode= mode;
m_open_test_lock= test_if_locked;
m_part_field_array= m_part_info->full_part_field_array;
- if (get_from_handler_file(name, &table->mem_root))
- DBUG_RETURN(1);
+ if (get_from_handler_file(name, &table->mem_root, test(m_is_clone_of)))
+ DBUG_RETURN(error);
+ name_buffer_ptr= m_name_buffer_ptr;
m_start_key.length= 0;
m_rec0= table->record[0];
m_rec_length= table_share->stored_rec_length;
@@ -2578,7 +2674,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
{
if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME))))
{
- DBUG_RETURN(1);
+ DBUG_RETURN(error);
}
{
/*
@@ -2601,50 +2697,86 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
/* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */
if (bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1, FALSE))
- DBUG_RETURN(1);
+ DBUG_RETURN(error);
bitmap_clear_all(&m_bulk_insert_started);
/* Initialize the bitmap we use to determine what partitions are used */
- if (!is_clone)
+ if (!m_is_clone_of)
{
+ DBUG_ASSERT(!m_clone_mem_root);
if (bitmap_init(&(m_part_info->used_partitions), NULL, m_tot_parts, TRUE))
{
bitmap_free(&m_bulk_insert_started);
- DBUG_RETURN(1);
+ DBUG_RETURN(error);
}
bitmap_set_all(&(m_part_info->used_partitions));
}
+ if (m_is_clone_of)
+ {
+ uint i;
+ DBUG_ASSERT(m_clone_mem_root);
+ /* Allocate an array of handler pointers for the partitions handlers. */
+ alloc_len= (m_tot_parts + 1) * sizeof(handler*);
+ if (!(m_file= (handler **) alloc_root(m_clone_mem_root, alloc_len)))
+ goto err_alloc;
+ memset(m_file, 0, alloc_len);
+ /*
+ Populate them by cloning the original partitions. This also opens them.
+ Note that file->ref is allocated too.
+ */
+ file= m_is_clone_of->m_file;
+ for (i= 0; i < m_tot_parts; i++)
+ {
+ create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
+ FALSE);
+ if (!(m_file[i]= file[i]->clone(name_buff, m_clone_mem_root)))
+ {
+ error= HA_ERR_INITIALIZATION;
+ file= &m_file[i];
+ goto err_handler;
+ }
+ name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
+ }
+ }
+ else
+ {
+ file= m_file;
+ do
+ {
+ create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
+ FALSE);
+ table->s->connect_string = m_connect_string[(uint)(file-m_file)];
+ if ((error= (*file)->ha_open(table, name_buff, mode, test_if_locked)))
+ goto err_handler;
+ bzero(&table->s->connect_string, sizeof(LEX_STRING));
+ m_no_locks+= (*file)->lock_count();
+ name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
+ } while (*(++file));
+ }
+
file= m_file;
- do
+ ref_length= (*file)->ref_length;
+ check_table_flags= (((*file)->ha_table_flags() &
+ ~(PARTITION_DISABLED_TABLE_FLAGS)) |
+ (PARTITION_ENABLED_TABLE_FLAGS));
+ while (*(++file))
{
- create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
- FALSE);
- table->s->connect_string = m_connect_string[(uint)(file-m_file)];
- if ((error= (*file)->ha_open(table, (const char*) name_buff, mode,
- test_if_locked)))
- goto err_handler;
- bzero(&table->s->connect_string, sizeof(LEX_STRING));
- m_no_locks+= (*file)->lock_count();
- name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
+ DBUG_ASSERT(ref_length >= (*file)->ref_length);
set_if_bigger(ref_length, ((*file)->ref_length));
/*
Verify that all partitions have the same set of table flags.
Mask all flags that partitioning enables/disables.
*/
- if (!check_table_flags)
- {
- check_table_flags= (((*file)->ha_table_flags() &
- ~(PARTITION_DISABLED_TABLE_FLAGS)) |
- (PARTITION_ENABLED_TABLE_FLAGS));
- }
- else if (check_table_flags != (((*file)->ha_table_flags() &
- ~(PARTITION_DISABLED_TABLE_FLAGS)) |
- (PARTITION_ENABLED_TABLE_FLAGS)))
+ if (check_table_flags != (((*file)->ha_table_flags() &
+ ~(PARTITION_DISABLED_TABLE_FLAGS)) |
+ (PARTITION_ENABLED_TABLE_FLAGS)))
{
error= HA_ERR_INITIALIZATION;
+ /* set file to last handler, so all of them is closed */
+ file = &m_file[m_tot_parts - 1];
goto err_handler;
}
- } while (*(++file));
+ }
key_used_on_scan= m_file[0]->key_used_on_scan;
implicit_emptied= m_file[0]->implicit_emptied;
/*
@@ -2653,6 +2785,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
*/
ref_length+= PARTITION_BYTES_IN_POS;
m_ref_length= ref_length;
+
/*
Release buffer read from .par file. It will not be reused again after
being opened once.
@@ -2710,25 +2843,54 @@ err_handler:
DEBUG_SYNC(ha_thd(), "partition_open_error");
while (file-- != m_file)
(*file)->close();
+err_alloc:
bitmap_free(&m_bulk_insert_started);
- if (!is_clone)
+ if (!m_is_clone_of)
bitmap_free(&(m_part_info->used_partitions));
DBUG_RETURN(error);
}
-handler *ha_partition::clone(MEM_ROOT *mem_root)
+
+/**
+ Clone the open and locked partitioning handler.
+
+ @param mem_root MEM_ROOT to use.
+
+ @return Pointer to the successfully created clone or NULL
+
+ @details
+ This function creates a new ha_partition handler as a clone/copy. The
+ original (this) must already be opened and locked. The clone will use
+ the originals m_part_info.
+ It also allocates memory for ref + ref_dup.
+ In ha_partition::open() it will clone its original handlers partitions
+ which will allocate then on the correct MEM_ROOT and also open them.
+*/
+
+handler *ha_partition::clone(const char *name, MEM_ROOT *mem_root)
{
- handler *new_handler= get_new_handler(table->s, mem_root,
- table->s->db_type());
- ((ha_partition*)new_handler)->m_part_info= m_part_info;
- ((ha_partition*)new_handler)->is_clone= TRUE;
- if (new_handler && !new_handler->ha_open(table,
- table->s->normalized_path.str,
- table->db_stat,
- HA_OPEN_IGNORE_IF_LOCKED))
- return new_handler;
- return NULL;
+ ha_partition *new_handler;
+
+ DBUG_ENTER("ha_partition::clone");
+ new_handler= new (mem_root) ha_partition(ht, table_share, m_part_info,
+ this, mem_root);
+ /*
+ Allocate new_handler->ref here because otherwise ha_open will allocate it
+ on this->table->mem_root and we will not be able to reclaim that memory
+ when the clone handler object is destroyed.
+ */
+ if (new_handler &&
+ !(new_handler->ref= (uchar*) alloc_root(mem_root,
+ ALIGN_SIZE(m_ref_length)*2)))
+ new_handler= NULL;
+
+ if (new_handler &&
+ new_handler->ha_open(table, name,
+ table->db_stat, HA_OPEN_IGNORE_IF_LOCKED))
+ new_handler= NULL;
+
+ DBUG_RETURN((handler*) new_handler);
}
@@ -2759,7 +2921,7 @@ int ha_partition::close(void)
DBUG_ASSERT(table->s == table_share);
delete_queue(&m_queue);
bitmap_free(&m_bulk_insert_started);
- if (!is_clone)
+ if (!m_is_clone_of)
bitmap_free(&(m_part_info->used_partitions));
file= m_file;
@@ -4354,6 +4516,7 @@ int ha_partition::index_read_idx_map(uchar *buf, uint index,
break;
}
}
+ m_last_part= part;
}
else
{
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index f5e66c5913e..2d82ec721b5 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -55,6 +55,16 @@ typedef struct st_ha_data_partition
HA_DUPLICATE_POS | \
HA_CAN_SQL_HANDLER | \
HA_CAN_INSERT_DELAYED)
+
+/* First 4 bytes in the .par file is the number of 32-bit words in the file */
+#define PAR_WORD_SIZE 4
+/* offset to the .par file checksum */
+#define PAR_CHECKSUM_OFFSET 4
+/* offset to the total number of partitions */
+#define PAR_NUM_PARTS_OFFSET 8
+/* offset to the engines array */
+#define PAR_ENGINES_OFFSET 12
+
class ha_partition :public handler
{
private:
@@ -70,7 +80,7 @@ private:
/* Data for the partition handler */
int m_mode; // Open mode
uint m_open_test_lock; // Open test_if_locked
- char *m_file_buffer; // Buffer with names
+ char *m_file_buffer; // Content of the .par file
char *m_name_buffer_ptr; // Pointer to first partition name
MEM_ROOT m_mem_root;
plugin_ref *m_engine_array; // Array of types of the handlers
@@ -100,7 +110,6 @@ private:
for this since the MySQL Server sometimes allocating the handler object
without freeing them.
*/
- ulong m_low_byte_first;
enum enum_handler_status
{
handler_not_initialized= 0,
@@ -134,6 +143,13 @@ private:
bool m_is_sub_partitioned; // Is subpartitioned
bool m_ordered_scan_ongoing;
+ /*
+ If set, this object was created with ha_partition::clone and doesn't
+ "own" the m_part_info structure.
+ */
+ ha_partition *m_is_clone_of;
+ MEM_ROOT *m_clone_mem_root;
+
/*
We keep track if all underlying handlers are MyISAM since MyISAM has a
great number of extra flags not needed by other handlers.
@@ -170,11 +186,6 @@ private:
PARTITION_SHARE *share; /* Shared lock info */
#endif
- /*
- TRUE <=> this object was created with ha_partition::clone and doesn't
- "own" the m_part_info structure.
- */
- bool is_clone;
bool auto_increment_lock; /**< lock reading/updating auto_inc */
/**
Flag to keep the auto_increment lock through out the statement.
@@ -187,7 +198,7 @@ private:
/** used for prediction of start_bulk_insert rows */
enum_monotonicity_info m_part_func_monotonicity_info;
public:
- handler *clone(MEM_ROOT *mem_root);
+ handler *clone(const char *name, MEM_ROOT *mem_root);
virtual void set_part_info(partition_info *part_info)
{
m_part_info= part_info;
@@ -206,6 +217,10 @@ public:
*/
ha_partition(handlerton *hton, TABLE_SHARE * table);
ha_partition(handlerton *hton, partition_info * part_info);
+ ha_partition(handlerton *hton, TABLE_SHARE *share,
+ partition_info *part_info_arg,
+ ha_partition *clone_arg,
+ MEM_ROOT *clone_mem_root_arg);
~ha_partition();
/*
A partition handler has no characteristics in itself. It only inherits
@@ -276,7 +291,10 @@ private:
And one method to read it in.
*/
bool create_handler_file(const char *name);
- bool get_from_handler_file(const char *name, MEM_ROOT *mem_root);
+ bool setup_engine_array(MEM_ROOT *mem_root);
+ bool read_par_file(const char *name);
+ bool get_from_handler_file(const char *name, MEM_ROOT *mem_root,
+ bool is_clone);
bool new_handlers_from_part_info(MEM_ROOT *mem_root);
bool create_handlers(MEM_ROOT *mem_root);
void clear_handler_file();
@@ -858,6 +876,10 @@ public:
*/
virtual ulong index_flags(uint inx, uint part, bool all_parts) const
{
+ /*
+ The following code is not safe if you are using different
+ storage engines or different index types per partition.
+ */
return m_file[0]->index_flags(inx, part, all_parts);
}
@@ -884,12 +906,6 @@ public:
virtual uint max_supported_key_part_length() const;
/*
- All handlers in a partitioned table must have the same low_byte_first
- */
- virtual bool low_byte_first() const
- { return m_low_byte_first; }
-
- /*
The extra record buffer length is the maximum needed by all handlers.
The minimum record length is the maximum of all involved handlers.
*/
diff --git a/sql/handler.cc b/sql/handler.cc
index 520402c8e38..318e2e116e2 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -345,6 +345,7 @@ int ha_init_errors(void)
SETMSG(HA_ERR_AUTOINC_READ_FAILED, ER(ER_AUTOINC_READ_FAILED));
SETMSG(HA_ERR_AUTOINC_ERANGE, ER(ER_WARN_DATA_OUT_OF_RANGE));
SETMSG(HA_ERR_TOO_MANY_CONCURRENT_TRXS, ER(ER_TOO_MANY_CONCURRENT_TRXS));
+ SETMSG(HA_ERR_DISK_FULL, ER(ER_DISK_FULL));
/* Register the error messages for use with my_error(). */
return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST);
@@ -1311,7 +1312,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans)
{
#ifdef HAVE_QUERY_CACHE
if (thd->transaction.changed_tables)
- query_cache.invalidate(thd->transaction.changed_tables);
+ query_cache.invalidate(thd, thd->transaction.changed_tables);
#endif
thd->variables.tx_isolation=thd->session_tx_isolation;
}
@@ -2099,11 +2100,10 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
/****************************************************************************
** General handler functions
****************************************************************************/
-handler *handler::clone(MEM_ROOT *mem_root)
+handler *handler::clone(const char *name, MEM_ROOT *mem_root)
{
- handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
-
- if (!new_handler)
+ handler *new_handler= get_new_handler(table->s, mem_root, ht);
+ if (! new_handler)
return NULL;
/*
@@ -2111,17 +2111,27 @@ handler *handler::clone(MEM_ROOT *mem_root)
on this->table->mem_root and we will not be able to reclaim that memory
when the clone handler object is destroyed.
*/
- if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
+
+ if (!(new_handler->ref= (uchar*) alloc_root(mem_root,
+ ALIGN_SIZE(ref_length)*2)))
return NULL;
- if (new_handler->ha_open(table,
- table->s->normalized_path.str,
- table->db_stat,
+
+ /*
+ TODO: Implement a more efficient way to have more than one index open for
+ the same table instance. The ha_open call is not cachable for clone.
+
+ This is not critical as the engines already have the table open
+ and should be able to use the original instance of the table.
+ */
+ if (new_handler->ha_open(table, name, table->db_stat,
HA_OPEN_IGNORE_IF_LOCKED))
return NULL;
+
new_handler->cloned= 1; // Marker for debugging
return new_handler;
}
+
double handler::keyread_time(uint index, uint ranges, ha_rows rows)
{
/*
@@ -2599,8 +2609,9 @@ int handler::update_auto_increment()
void handler::column_bitmaps_signal()
{
DBUG_ENTER("column_bitmaps_signal");
- DBUG_PRINT("info", ("read_set: 0x%lx write_set: 0x%lx", (long) table->read_set,
- (long) table->write_set));
+ if (table)
+ DBUG_PRINT("info", ("read_set: 0x%lx write_set: 0x%lx",
+ (long) table->read_set, (long) table->write_set));
DBUG_VOID_RETURN;
}
@@ -2677,6 +2688,7 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
void handler::ha_release_auto_increment()
{
+ DBUG_ENTER("ha_release_auto_increment");
release_auto_increment();
insert_id_for_cur_row= 0;
auto_inc_interval_for_cur_row.replace(0, 0, 0);
@@ -2690,6 +2702,7 @@ void handler::ha_release_auto_increment()
*/
table->in_use->auto_inc_intervals_forced.empty();
}
+ DBUG_VOID_RETURN;
}
@@ -2750,6 +2763,11 @@ void handler::print_error(int error, myf errflag)
case ENOENT:
textno=ER_FILE_NOT_FOUND;
break;
+ case ENOSPC:
+ case HA_ERR_DISK_FULL:
+ textno= ER_DISK_FULL;
+ SET_FATAL_ERROR; // Ensure error is logged
+ break;
case HA_ERR_KEY_NOT_FOUND:
case HA_ERR_NO_ACTIVE_RECORD:
case HA_ERR_END_OF_FILE:
diff --git a/sql/handler.h b/sql/handler.h
index f674a8a56bb..4707aabbd52 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -23,7 +23,6 @@
#pragma interface /* gcc class implementation */
#endif
-#include <my_handler.h>
#include <ft_global.h>
#include <keycache.h>
@@ -162,8 +161,11 @@
*/
#define HA_KEY_SCAN_NOT_ROR 128
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
-
-
+/*
+ Data is clustered on this key. This means that when you read the key
+ you also get the row data without any additional disk reads.
+*/
+#define HA_CLUSTERED_INDEX 512
/*
bits in alter_table_flags:
@@ -600,6 +602,11 @@ struct handler_log_file_data {
See ha_example.cc for an example.
*/
+
+struct ha_table_option_struct;
+struct ha_field_option_struct;
+struct ha_index_option_struct;
+
enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */
HA_OPTION_TYPE_STRING, /* char * */
HA_OPTION_TYPE_ENUM, /* uint */
@@ -1168,9 +1175,9 @@ typedef struct st_ha_create_information
enum ha_choice page_checksum; ///< If we have page_checksums
engine_option_value *option_list; ///< list of table create options
/* the following three are only for ALTER TABLE, check_if_incompatible_data() */
- void *option_struct; ///< structure with parsed table options
- void **fileds_option_struct; ///< array of field option structures
- void **indexes_option_struct; ///< array of index option structures
+ ha_table_option_struct *option_struct; ///< structure with parsed table options
+ ha_field_option_struct **fields_option_struct; ///< array of field option structures
+ ha_index_option_struct **indexes_option_struct; ///< array of index option structures
} HA_CREATE_INFO;
@@ -1670,7 +1677,7 @@ public:
DBUG_ASSERT(locked == FALSE);
/* TODO: DBUG_ASSERT(inited == NONE); */
}
- virtual handler *clone(MEM_ROOT *mem_root);
+ virtual handler *clone(const char *name, MEM_ROOT *mem_root);
/** This is called after create to allow us to set up cached variables */
void init()
{
@@ -2227,7 +2234,6 @@ public:
virtual uint max_supported_key_part_length() const { return 255; }
virtual uint min_record_length(uint options) const { return 1; }
- virtual bool low_byte_first() const { return 1; }
virtual uint checksum() const { return 0; }
virtual bool is_crashed() const { return 0; }
virtual bool auto_repair() const { return 0; }
@@ -2307,9 +2313,28 @@ public:
/*
- @retval TRUE Primary key (if there is one) is clustered
- key covering all fields
- @retval FALSE otherwise
+ Check if the primary key (if there is one) is a clustered and a
+ reference key. This means:
+
+ - Data is stored together with the primary key (no secondary lookup
+ needed to find the row data). The optimizer uses this to find out
+ the cost of fetching data.
+ - The primary key is part of each secondary key and is used
+ to find the row data in the primary index when reading trough
+ secondary indexes.
+ - When doing a HA_KEYREAD_ONLY we get also all the primary key parts
+ into the row. This is critical property used by index_merge.
+
+ All the above is usually true for engines that store the row
+ data in the primary key index (e.g. in a b-tree), and use the primary
+ key value as a position(). InnoDB is an example of such an engine.
+
+ For such a clustered primary key, the following should also hold:
+ index_flags() should contain HA_CLUSTERED_INDEX
+ table_flags() should contain HA_TABLE_SCAN_ON_INDEX
+
+ @retval TRUE yes
+ @retval FALSE No.
*/
virtual bool primary_key_is_clustered() { return FALSE; }
virtual int cmp_ref(const uchar *ref1, const uchar *ref2)
diff --git a/sql/hostname.cc b/sql/hostname.cc
index ec090cbe02f..dfcdd3edd90 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -183,7 +184,7 @@ char * ip_to_hostname(struct in_addr *in, uint *errors)
&tmp_hostent,buff,sizeof(buff),&tmp_errno)))
{
DBUG_PRINT("error",("gethostbyaddr_r returned %d",tmp_errno));
- return 0;
+ DBUG_RETURN(0);
}
if (!(check=my_gethostbyname_r(hp->h_name,&tmp_hostent2,buff2,sizeof(buff2),
&tmp_errno)))
diff --git a/sql/item.cc b/sql/item.cc
index b0530f0e17e..cad3e60e5fc 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -197,10 +197,12 @@ bool Item::val_bool()
case STRING_RESULT:
return val_real() != 0.0;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
return 0; // Wrong (but safe)
}
+ return 0; // Wrong (but safe)
}
@@ -235,6 +237,21 @@ String *Item::val_string_from_decimal(String *str)
}
+String *Item::val_string_from_date(String *str)
+{
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, TIME_FUZZY_DATE) ||
+ str->alloc(MAX_DATE_STRING_REP_LENGTH))
+ {
+ null_value= 1;
+ return (String *) 0;
+ }
+ str->length(my_TIME_to_str(&ltime, const_cast<char*>(str->ptr()), decimals));
+ str->set_charset(&my_charset_bin);
+ return str;
+}
+
+
my_decimal *Item::val_decimal_from_real(my_decimal *decimal_value)
{
double nr= val_real();
@@ -331,7 +348,7 @@ int Item::save_time_in_field(Field *field)
if (get_time(&ltime))
return set_field_to_null_with_conversions(field, 0);
field->set_notnull();
- return field->store_time(&ltime, MYSQL_TIMESTAMP_TIME);
+ return field->store_time_dec(&ltime, decimals);
}
@@ -341,7 +358,7 @@ int Item::save_date_in_field(Field *field)
if (get_date(&ltime, TIME_FUZZY_DATE))
return set_field_to_null_with_conversions(field, 0);
field->set_notnull();
- return field->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
+ return field->store_time_dec(&ltime, decimals);
}
@@ -387,6 +404,8 @@ Item::Item():
decimals= 0; max_length= 0;
with_subselect= 0;
cmp_context= IMPOSSIBLE_RESULT;
+ /* Initially this item is not attached to any JOIN_TAB. */
+ join_tab_idx= MAX_TABLES;
/* Put item in free list so that we can free all items at end */
THD *thd= current_thd;
@@ -415,6 +434,7 @@ Item::Item():
tables.
*/
Item::Item(THD *thd, Item *item):
+ join_tab_idx(item->join_tab_idx),
is_expensive_cache(-1),
rsize(0),
str_value(item->str_value),
@@ -468,12 +488,40 @@ void Item::print_item_w_name(String *str, enum_query_type query_type)
}
+void Item::print_value(String *str)
+{
+ char buff[MAX_FIELD_WIDTH];
+ String *ptr, tmp(buff,sizeof(buff),str->charset());
+ ptr= val_str(&tmp);
+ if (!ptr)
+ str->append("NULL");
+ else
+ {
+ switch (result_type()) {
+ case STRING_RESULT:
+ append_unescaped(str, ptr->ptr(), ptr->length());
+ break;
+ case DECIMAL_RESULT:
+ case REAL_RESULT:
+ case INT_RESULT:
+ str->append(*ptr);
+ break;
+ case ROW_RESULT:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0);
+ }
+ }
+}
+
+
void Item::cleanup()
{
DBUG_ENTER("Item::cleanup");
DBUG_PRINT("enter", ("this: %p", this));
fixed=0;
marker= 0;
+ join_tab_idx= MAX_TABLES;
if (orig_name)
name= orig_name;
DBUG_VOID_RETURN;
@@ -511,6 +559,45 @@ void Item::rename(char *new_name)
name= new_name;
}
+Item_result Item::cmp_type() const
+{
+ switch (field_type()) {
+ case MYSQL_TYPE_DECIMAL:
+ case MYSQL_TYPE_NEWDECIMAL:
+ return DECIMAL_RESULT;
+ case MYSQL_TYPE_TINY:
+ case MYSQL_TYPE_SHORT:
+ case MYSQL_TYPE_LONG:
+ case MYSQL_TYPE_LONGLONG:
+ case MYSQL_TYPE_INT24:
+ case MYSQL_TYPE_YEAR:
+ case MYSQL_TYPE_BIT:
+ return INT_RESULT;
+ case MYSQL_TYPE_FLOAT:
+ case MYSQL_TYPE_DOUBLE:
+ return REAL_RESULT;
+ case MYSQL_TYPE_NULL:
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_TINY_BLOB:
+ case MYSQL_TYPE_MEDIUM_BLOB:
+ case MYSQL_TYPE_LONG_BLOB:
+ case MYSQL_TYPE_BLOB:
+ case MYSQL_TYPE_VAR_STRING:
+ case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_ENUM:
+ case MYSQL_TYPE_SET:
+ case MYSQL_TYPE_GEOMETRY:
+ return STRING_RESULT;
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_TIME:
+ case MYSQL_TYPE_DATETIME:
+ case MYSQL_TYPE_NEWDATE:
+ return TIME_RESULT;
+ };
+ DBUG_ASSERT(0);
+ return (Item_result)-1;
+}
/**
Traverse item tree possibly transforming it (replacing items).
@@ -648,7 +735,7 @@ void Item_ident::cleanup()
bool Item_ident::remove_dependence_processor(uchar * arg)
{
DBUG_ENTER("Item_ident::remove_dependence_processor");
- if (depended_from == (st_select_lex *) arg)
+ if (get_depended_from() == (st_select_lex *) arg)
depended_from= 0;
context= &((st_select_lex *) arg)->context;
DBUG_RETURN(0);
@@ -763,6 +850,23 @@ bool Item_field::register_field_in_bitmap(uchar *arg)
return 0;
}
+
+/*
+ Mark field in write_map
+
+ NOTES
+ This is used by UPDATE to register underlying fields of used view fields.
+*/
+
+bool Item_field::register_field_in_write_map(uchar *arg)
+{
+ TABLE *table= (TABLE *) arg;
+ if (field->table == table || !table)
+ bitmap_set_bit(field->table->write_set, field->field_index);
+ return 0;
+}
+
+
bool Item::check_cols(uint c)
{
if (c != 1)
@@ -980,12 +1084,52 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const
/**
Get the value of the function as a MYSQL_TIME structure.
- As a extra convenience the time structure is reset on error!
+ As a extra convenience the time structure is reset on error or NULL values!
*/
bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
{
- if (result_type() == STRING_RESULT)
+ if (field_type() == MYSQL_TYPE_TIME)
+ fuzzydate|= TIME_TIME_ONLY;
+
+ switch (result_type()) {
+ case INT_RESULT:
+ {
+ longlong value= val_int();
+ if (field_type() == MYSQL_TYPE_YEAR)
+ {
+ if (max_length == 2)
+ {
+ if (value < 70)
+ value+= 2000;
+ else if (value <= 1900)
+ value+= 1900;
+ }
+ value*= 10000; /* make it YYYYMMHH */
+ }
+ if (null_value || int_to_datetime_with_warn(value, ltime, fuzzydate,
+ field_name_or_null()))
+ goto err;
+ break;
+ }
+ case REAL_RESULT:
+ {
+ double value= val_real();
+ if (null_value || double_to_datetime_with_warn(value, ltime, fuzzydate,
+ field_name_or_null()))
+ goto err;
+ break;
+ }
+ case DECIMAL_RESULT:
+ {
+ my_decimal value, *res;
+ if (!(res= val_decimal(&value)) ||
+ decimal_to_datetime_with_warn(res, ltime, fuzzydate,
+ field_name_or_null()))
+ goto err;
+ break;
+ }
+ case STRING_RESULT:
{
char buff[40];
String tmp(buff,sizeof(buff), &my_charset_bin),*res;
@@ -993,21 +1137,12 @@ bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate)
str_to_datetime_with_warn(res->ptr(), res->length(),
ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
goto err;
+ break;
}
- else
- {
- longlong value= val_int();
- int was_cut;
- if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1))
- {
- char buff[22], *end;
- end= longlong10_to_str(value, buff, -10);
- make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE,
- NullS);
- goto err;
- }
+ default:
+ DBUG_ASSERT(0);
}
+
return 0;
err:
@@ -1015,23 +1150,20 @@ err:
return 1;
}
-/**
- Get time of first argument.\
-
- As a extra convenience the time structure is reset on error!
-*/
-
-bool Item::get_time(MYSQL_TIME *ltime)
+bool Item::get_seconds(ulonglong *sec, ulong *sec_part)
{
- char buff[40];
- String tmp(buff,sizeof(buff),&my_charset_bin),*res;
- if (!(res=val_str(&tmp)) ||
- str_to_time_with_warn(res->ptr(), res->length(), ltime))
- {
- bzero((char*) ltime,sizeof(*ltime));
- return 1;
+ if (result_type() == INT_RESULT)
+ { // optimize for an important special case
+ longlong val= val_int();
+ bool neg= val < 0 && !unsigned_flag;
+ *sec= neg ? -val : val;
+ *sec_part= 0;
+ return neg;
}
- return 0;
+ my_decimal tmp, *dec= val_decimal(&tmp);
+ if (!dec)
+ return 0;
+ return my_decimal2seconds(dec, sec, sec_part);
}
CHARSET_INFO *Item::default_charset()
@@ -1057,6 +1189,7 @@ int Item::save_in_field_no_warnings(Field *field, bool no_conversions)
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
ulong sql_mode= thd->variables.sql_mode;
thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
+ thd->variables.sql_mode|= MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
res= save_in_field(field, no_conversions);
thd->count_cuted_fields= tmp;
@@ -2166,16 +2299,6 @@ bool Item_field::get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
return 0;
}
-bool Item_field::get_time(MYSQL_TIME *ltime)
-{
- if ((null_value=field->is_null()) || field->get_time(ltime))
- {
- bzero((char*) ltime,sizeof(*ltime));
- return 1;
- }
- return 0;
-}
-
void Item_field::save_result(Field *to)
{
save_field_in_field(result_field, &null_value, to, TRUE);
@@ -2224,10 +2347,12 @@ bool Item_field::val_bool_result()
case STRING_RESULT:
return result_field->val_real() != 0.0;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
return 0; // Shut up compiler
}
+ return 0;
}
@@ -2271,13 +2396,17 @@ table_map Item_field::used_tables() const
{
if (field->table->const_table)
return 0; // const item
- return (depended_from ? OUTER_REF_TABLE_BIT : field->table->map);
+ return (get_depended_from() ? OUTER_REF_TABLE_BIT : field->table->map);
}
+table_map Item_field::all_used_tables() const
+{
+ return (get_depended_from() ? OUTER_REF_TABLE_BIT : field->table->map);
+}
void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
- if (new_parent == depended_from)
+ if (new_parent == get_depended_from())
depended_from= NULL;
Name_resolution_context *ctx= new Name_resolution_context();
ctx->outer_context= NULL; // We don't build a complete name resolver
@@ -2526,7 +2655,7 @@ my_decimal *Item_float::val_decimal(my_decimal *decimal_value)
void Item_string::print(String *str, enum_query_type query_type)
{
- if (query_type == QT_ORDINARY && is_cs_specified())
+ if (query_type != QT_IS && is_cs_specified())
{
str->append('_');
str->append(collation.collation->csname);
@@ -2534,7 +2663,7 @@ void Item_string::print(String *str, enum_query_type query_type)
str->append('\'');
- if (query_type == QT_ORDINARY ||
+ if (query_type != QT_IS ||
my_charset_same(str_value.charset(), system_charset_info))
{
str_value.print(str);
@@ -2562,18 +2691,19 @@ void Item_string::print(String *str, enum_query_type query_type)
double
-double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end)
+double_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
+ const char *end)
{
int error;
- char *org_end;
+ char *end_of_num= (char*) end;
double tmp;
- org_end= end;
- tmp= my_strntod(cs, (char*) cptr, end - cptr, &end, &error);
- if (error || (end != org_end && !check_if_only_end_space(cs, end, org_end)))
+ tmp= my_strntod(cs, (char*) cptr, end - cptr, &end_of_num, &error);
+ if (error || (end != end_of_num &&
+ !check_if_only_end_space(cs, end_of_num, end)))
{
char buff[80];
- strmake(buff, cptr, min(sizeof(buff)-1, (size_t) (org_end-cptr)));
+ strmake(buff, cptr, min(sizeof(buff)-1, (size_t) (end-cptr)));
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
@@ -2588,26 +2718,27 @@ double Item_string::val_real()
DBUG_ASSERT(fixed == 1);
return double_from_string_with_check(str_value.charset(),
str_value.ptr(),
- (char *) str_value.ptr() +
+ str_value.ptr() +
str_value.length());
}
longlong
-longlong_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end)
+longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
+ const char *end)
{
int err;
longlong tmp;
- char *org_end= end;
+ char *end_of_num= (char*) end;
- tmp= (*(cs->cset->strtoll10))(cs, cptr, &end, &err);
+ tmp= (*(cs->cset->strtoll10))(cs, cptr, &end_of_num, &err);
/*
TODO: Give error if we wanted a signed integer and we got an unsigned
one
*/
if (!current_thd->no_errors &&
(err > 0 ||
- (end != org_end && !check_if_only_end_space(cs, end, org_end))))
+ (end != end_of_num && !check_if_only_end_space(cs, end_of_num, end))))
{
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
@@ -2626,7 +2757,7 @@ longlong Item_string::val_int()
{
DBUG_ASSERT(fixed == 1);
return longlong_from_string_with_check(str_value.charset(), str_value.ptr(),
- (char *) str_value.ptr()+ str_value.length());
+ str_value.ptr()+ str_value.length());
}
@@ -2806,19 +2937,19 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
if (value.time.year > 9999 || value.time.month > 12 ||
value.time.day > 31 ||
(time_type != MYSQL_TIMESTAMP_TIME && value.time.hour > 23) ||
- value.time.minute > 59 || value.time.second > 59)
+ value.time.minute > 59 || value.time.second > 59 ||
+ value.time.second_part > TIME_MAX_SECOND_PART)
{
- char buff[MAX_DATE_STRING_REP_LENGTH];
- uint length= my_TIME_to_str(&value.time, buff);
+ Lazy_string_time str(&value.time);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- buff, length, time_type, 0);
+ &str, time_type, 0);
set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR);
}
state= TIME_VALUE;
maybe_null= 0;
max_length= max_length_arg;
- decimals= 0;
+ decimals= tm->second_part > 0 ? TIME_SECOND_PART_DIGITS : 0;
DBUG_VOID_RETURN;
}
@@ -2856,6 +2987,16 @@ bool Item_param::set_longdata(const char *str, ulong length)
(here), and first have to concatenate all pieces together,
write query to the binary log and only then perform conversion.
*/
+ if (str_value.length() + length > max_long_data_size)
+ {
+ my_message(ER_UNKNOWN_ERROR,
+ "Parameter of prepared statement which is set through "
+ "mysql_send_long_data() is longer than "
+ "'max_long_data_size' bytes",
+ MYF(0));
+ DBUG_RETURN(true);
+ }
+
if (str_value.append(str, length, &my_charset_bin))
DBUG_RETURN(TRUE);
state= LONG_DATA_VALUE;
@@ -2895,10 +3036,12 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
case REAL_RESULT:
set_double(*(double*)entry->value);
item_type= Item::REAL_ITEM;
+ param_type= MYSQL_TYPE_DOUBLE;
break;
case INT_RESULT:
set_int(*(longlong*)entry->value, MY_INT64_NUM_DECIMAL_DIGITS);
item_type= Item::INT_ITEM;
+ param_type= MYSQL_TYPE_LONGLONG;
break;
case STRING_RESULT:
{
@@ -2921,6 +3064,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
charset of connection, so we have to set it later.
*/
item_type= Item::STRING_ITEM;
+ param_type= MYSQL_TYPE_VARCHAR;
if (set_str((const char *)entry->value, entry->length))
DBUG_RETURN(1);
@@ -2936,9 +3080,12 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
my_decimal_precision_to_length_no_truncation(ent_value->precision(),
decimals, unsigned_flag);
item_type= Item::DECIMAL_ITEM;
+ param_type= MYSQL_TYPE_NEWDECIMAL;
break;
}
- default:
+ case ROW_RESULT:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
set_null();
}
@@ -3000,7 +3147,7 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
case DECIMAL_VALUE:
return field->store_decimal(&decimal_value);
case TIME_VALUE:
- field->store_time(&value.time, value.time.time_type);
+ field->store_time_dec(&value.time, decimals);
return 0;
case STRING_VALUE:
case LONG_DATA_VALUE:
@@ -3016,21 +3163,6 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
}
-bool Item_param::get_time(MYSQL_TIME *res)
-{
- if (state == TIME_VALUE)
- {
- *res= value.time;
- return 0;
- }
- /*
- If parameter value isn't supplied assertion will fire in val_str()
- which is called from Item::get_time().
- */
- return Item::get_time(res);
-}
-
-
bool Item_param::get_date(MYSQL_TIME *res, uint fuzzydate)
{
if (state == TIME_VALUE)
@@ -3160,7 +3292,8 @@ String *Item_param::val_str(String* str)
{
if (str->reserve(MAX_DATE_STRING_REP_LENGTH))
break;
- str->length((uint) my_TIME_to_str(&value.time, (char*) str->ptr()));
+ str->length((uint) my_TIME_to_str(&value.time, (char*) str->ptr(),
+ decimals));
str->set_charset(&my_charset_bin);
return str;
}
@@ -3212,7 +3345,7 @@ const String *Item_param::query_val_str(String* str) const
buf= str->c_ptr_quick();
ptr= buf;
*ptr++= '\'';
- ptr+= (uint) my_TIME_to_str(&value.time, ptr);
+ ptr+= (uint) my_TIME_to_str(&value.time, ptr, decimals);
*ptr++= '\'';
str->length((uint32) (ptr - buf));
break;
@@ -3406,6 +3539,7 @@ Item_param::set_param_type_and_swap_value(Item_param *src)
/****************************************************************************
Item_copy
****************************************************************************/
+
Item_copy *Item_copy::create (Item *item)
{
switch (item->result_type())
@@ -3419,7 +3553,9 @@ Item_copy *Item_copy::create (Item *item)
new Item_copy_uint (item) : new Item_copy_int (item);
case DECIMAL_RESULT:
return new Item_copy_decimal (item);
- default:
+ case TIME_RESULT:
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT (0);
}
/* should not happen */
@@ -3492,8 +3628,7 @@ void Item_copy_int::copy()
null_value=item->null_value;
}
-static int save_int_value_in_field (Field *field, longlong nr,
- bool null_value, bool unsigned_flag);
+static int save_int_value_in_field (Field *, longlong, bool, bool);
int Item_copy_int::save_in_field(Field *field, bool no_conversions)
{
@@ -4026,6 +4161,34 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
}
+/*
+ @brief
+ Whether a table belongs to an outer select.
+
+ @param table table to check
+ @param select current select
+
+ @details
+ Try to find select the table belongs to by ascending the derived tables chain.
+*/
+
+static
+bool is_outer_table(TABLE_LIST *table, SELECT_LEX *select)
+{
+ DBUG_ASSERT(table->select_lex != select);
+ TABLE_LIST *tl;
+
+ for (tl= select->master_unit()->derived;
+ tl && tl->is_merged_derived();
+ select= tl->select_lex, tl= select->master_unit()->derived)
+ {
+ if (tl->select_lex == table->select_lex)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
/**
Resolve the name of an outer select column reference.
@@ -4474,7 +4637,8 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
if (!outer_fixed && cached_table && cached_table->select_lex &&
context->select_lex &&
- cached_table->select_lex != context->select_lex)
+ cached_table->select_lex != context->select_lex &&
+ is_outer_table(cached_table, context->select_lex))
{
int ret;
if ((ret= fix_outer_field(thd, &from_field, reference)) < 0)
@@ -4675,7 +4839,7 @@ Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal)
The function checks whether a substitution of a field item for
an equal item is valid.
- @param arg *arg != NULL && **arg <-> the field is in the context
+ @param arg *arg != NULL <-> the field is in the context
where substitution for an equal item is valid
@note
@@ -4701,8 +4865,10 @@ Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal)
bool Item_field::subst_argument_checker(uchar **arg)
{
- return (!(*arg) && (result_type() != STRING_RESULT)) ||
- ((*arg) && (**arg));
+ return *arg &&
+ (*arg == (uchar *) Item::ANY_SUBST ||
+ result_type() != STRING_RESULT ||
+ (field->flags & BINARY_FLAG));
}
@@ -4784,12 +4950,8 @@ Item *Item_field::equal_fields_propagator(uchar *arg)
item= this;
else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()))
{
- /*
- We don't need to zero-fill timestamp columns here because they will be
- first converted to a string (in date/time format) and compared as such if
- compared with another string.
- */
- if (item && field->type() != FIELD_TYPE_TIMESTAMP && cmp_context != INT_RESULT)
+ if (item && field->type() != FIELD_TYPE_TIMESTAMP &&
+ cmp_context != INT_RESULT)
convert_zerofill_number_to_string(&item, (Field_num *)field);
else
item= this;
@@ -4912,25 +5074,12 @@ enum_field_types Item::field_type() const
case DECIMAL_RESULT: return MYSQL_TYPE_NEWDECIMAL;
case REAL_RESULT: return MYSQL_TYPE_DOUBLE;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
return MYSQL_TYPE_VARCHAR;
}
-}
-
-
-bool Item::is_datetime()
-{
- switch (field_type())
- {
- case MYSQL_TYPE_DATE:
- case MYSQL_TYPE_DATETIME:
- case MYSQL_TYPE_TIMESTAMP:
- return TRUE;
- default:
- break;
- }
- return FALSE;
+ return MYSQL_TYPE_VARCHAR;
}
@@ -5110,16 +5259,19 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
break;
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_DATE:
- field= new Field_newdate(maybe_null, name, &my_charset_bin);
+ field= new Field_newdate(0, null_ptr, 0, Field::NONE, name, &my_charset_bin);
break;
case MYSQL_TYPE_TIME:
- field= new Field_time(maybe_null, name, &my_charset_bin);
+ field= new_Field_time(0, null_ptr, 0, Field::NONE, name,
+ decimals, &my_charset_bin);
break;
case MYSQL_TYPE_TIMESTAMP:
- field= new Field_timestamp(maybe_null, name, &my_charset_bin);
+ field= new_Field_timestamp(0, null_ptr, 0,
+ Field::NONE, name, 0, decimals, &my_charset_bin);
break;
case MYSQL_TYPE_DATETIME:
- field= new Field_datetime(maybe_null, name, &my_charset_bin);
+ field= new_Field_datetime(0, null_ptr, 0, Field::NONE, name,
+ decimals, &my_charset_bin);
break;
case MYSQL_TYPE_YEAR:
field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
@@ -5356,12 +5508,6 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
}
-int Item_uint::save_in_field(Field *field, bool no_conversions)
-{
- /* Item_int::save_in_field handles both signed and unsigned. */
- return Item_int::save_in_field(field, no_conversions);
-}
-
static int save_int_value_in_field (Field *field, longlong nr,
bool null_value, bool unsigned_flag)
{
@@ -5378,6 +5524,22 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
}
+void Item_datetime::set(longlong packed)
+{
+ unpack_time(packed, &ltime);
+}
+
+int Item_datetime::save_in_field(Field *field, bool no_conversions)
+{
+ field->set_notnull();
+ return field->store_time_dec(&ltime, decimals);
+}
+
+longlong Item_datetime::val_int()
+{
+ return TIME_to_ulonglong(&ltime);
+}
+
int Item_decimal::save_in_field(Field *field, bool no_conversions)
{
field->set_notnull();
@@ -5395,7 +5557,9 @@ bool Item_int::eq(const Item *arg, bool binary_cmp) const
a basic constant.
*/
Item *item= (Item*) arg;
- return item->val_int() == value && item->unsigned_flag == unsigned_flag;
+ return (item->val_int() == value &&
+ ((longlong) value >= 0 ||
+ (item->unsigned_flag == unsigned_flag)));
}
return FALSE;
}
@@ -5739,7 +5903,10 @@ bool Item::send(Protocol *protocol, String *buffer)
{
String *res;
if ((res=val_str(buffer)))
+ {
+ DBUG_ASSERT(!null_value);
result= protocol->store(res->ptr(),res->length(),res->charset());
+ }
else
{
DBUG_ASSERT(null_value);
@@ -5806,7 +5973,7 @@ bool Item::send(Protocol *protocol, String *buffer)
if (f_type == MYSQL_TYPE_DATE)
return protocol->store_date(&tm);
else
- result= protocol->store(&tm);
+ result= protocol->store(&tm, decimals);
}
break;
}
@@ -5815,7 +5982,7 @@ bool Item::send(Protocol *protocol, String *buffer)
MYSQL_TIME tm;
get_time(&tm);
if (!null_value)
- result= protocol->store_time(&tm);
+ result= protocol->store_time(&tm, decimals);
break;
}
}
@@ -5896,17 +6063,7 @@ void Item_field::print(String *str, enum_query_type query_type)
{
if (field && field->table->const_table)
{
- char buff[MAX_FIELD_WIDTH];
- String tmp(buff,sizeof(buff),str->charset());
- field->val_str(&tmp);
- if (field->is_null())
- str->append("NULL");
- else
- {
- str->append('\'');
- str->append(tmp);
- str->append('\'');
- }
+ print_value(str);
return;
}
Item_ident::print(str, query_type);
@@ -5944,8 +6101,9 @@ public:
st_select_lex *sel;
for (sel= current_select; sel; sel= sel->outer_select())
{
+ List_iterator<TABLE_LIST> li(sel->leaf_tables);
TABLE_LIST *tbl;
- for (tbl= sel->leaf_tables; tbl; tbl= tbl->next_leaf)
+ while ((tbl= li++))
{
if (tbl->table == item->field->table)
{
@@ -6240,12 +6398,13 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
last_checked_context->select_lex->nest_level);
}
}
- else
+ else if (ref_type() != VIEW_REF)
{
if (depended_from && reference)
{
- DBUG_ASSERT(context->select_lex != depended_from);
- context->select_lex->register_dependency_item(depended_from, reference);
+ DBUG_ASSERT(context->select_lex != get_depended_from());
+ context->select_lex->register_dependency_item(get_depended_from(),
+ reference);
}
/*
It could be that we're referring to something that's in ancestor selects.
@@ -6376,9 +6535,11 @@ Item* Item_ref::transform(Item_transformer transformer, uchar *arg)
First the function applies the analyzer to the Item_ref object. Then
if the analizer succeeeds we first applies the compile method to the
- object the Item_ref object is referencing. If this returns a new
+ object the Item_ref object is referencing. If this returns a new
item the old item is substituted for a new one. After this the
transformer is applied to the Item_ref object itself.
+ The compile function is not called if the analyzer returns NULL
+ in the parameter arg_p.
@param analyzer the analyzer callback function to be applied to the
nodes of the tree of the object
@@ -6399,10 +6560,13 @@ Item* Item_ref::compile(Item_analyzer analyzer, uchar **arg_p,
/* Compile the Item we are referencing. */
DBUG_ASSERT((*ref) != NULL);
- uchar *arg_v= *arg_p;
- Item *new_item= (*ref)->compile(analyzer, &arg_v, transformer, arg_t);
- if (new_item && *ref != new_item)
- current_thd->change_item_tree(ref, new_item);
+ if (*arg_p)
+ {
+ uchar *arg_v= *arg_p;
+ Item *new_item= (*ref)->compile(analyzer, &arg_v, transformer, arg_t);
+ if (new_item && *ref != new_item)
+ current_thd->change_item_tree(ref, new_item);
+ }
/* Transform this Item object. */
return (this->*transformer)(arg_t);
@@ -6418,7 +6582,7 @@ void Item_ref::print(String *str, enum_query_type query_type)
{
THD *thd= current_thd;
append_identifier(thd, str, (*ref)->real_item()->name,
- (*ref)->real_item()->name_length);
+ strlen((*ref)->real_item()->name));
}
else
(*ref)->print(str, query_type);
@@ -6515,7 +6679,8 @@ bool Item_ref::val_bool_result()
case STRING_RESULT:
return result_field->val_real() != 0.0;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
}
@@ -6718,6 +6883,40 @@ bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
}
+Item* Item_direct_ref_to_ident::transform(Item_transformer transformer,
+ uchar *argument)
+{
+ DBUG_ASSERT(!current_thd->is_stmt_prepare());
+
+ Item *new_item= ident->transform(transformer, argument);
+ if (!new_item)
+ return 0;
+ DBUG_ASSERT(new_item->type() == FIELD_ITEM || new_item->type() == REF_ITEM);
+
+ if (ident != new_item)
+ current_thd->change_item_tree((Item**)&ident, new_item);
+ return (this->*transformer)(argument);
+}
+
+
+Item* Item_direct_ref_to_ident::compile(Item_analyzer analyzer, uchar **arg_p,
+ Item_transformer transformer,
+ uchar *arg_t)
+{
+ if (!(this->*analyzer)(arg_p))
+ return 0;
+
+ uchar *arg_v= *arg_p;
+ Item *new_item= ident->compile(analyzer, &arg_v, transformer, arg_t);
+ if (new_item && ident != new_item)
+ {
+ DBUG_ASSERT(new_item->type() == FIELD_ITEM || new_item->type() == REF_ITEM);
+ current_thd->change_item_tree((Item**)&ident, new_item);
+ }
+ return (this->*transformer)(arg_t);
+}
+
+
Item_cache_wrapper::~Item_cache_wrapper()
{
DBUG_ASSERT(expr_cache == 0);
@@ -7064,25 +7263,6 @@ bool Item_cache_wrapper::get_date(MYSQL_TIME *ltime, uint fuzzydate)
}
-/**
- Get the time value of the possibly cached item
-*/
-
-bool Item_cache_wrapper::get_time(MYSQL_TIME *ltime)
-{
- Item *cached_value;
- DBUG_ENTER("Item_cache_wrapper::get_time");
- if (!expr_cache)
- DBUG_RETURN((null_value= orig_item->get_time(ltime)));
-
- if ((cached_value= check_cache()))
- DBUG_RETURN((null_value= cached_value->get_time(ltime)));
-
- cache();
- DBUG_RETURN((null_value= expr_value->get_time(ltime)));
-}
-
-
int Item_cache_wrapper::save_in_field(Field *to, bool no_conversions)
{
int res;
@@ -7171,7 +7351,7 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference)
void Item_outer_ref::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
- if (depended_from == new_parent)
+ if (get_depended_from() == new_parent)
{
*ref= outer_ref;
(*ref)->fix_after_pullout(new_parent, ref);
@@ -7181,7 +7361,7 @@ void Item_outer_ref::fix_after_pullout(st_select_lex *new_parent, Item **ref)
void Item_ref::fix_after_pullout(st_select_lex *new_parent, Item **refptr)
{
(*ref)->fix_after_pullout(new_parent, ref);
- if (depended_from == new_parent)
+ if (get_depended_from() == new_parent)
depended_from= NULL;
}
@@ -7270,7 +7450,7 @@ Item_equal *Item_direct_view_ref::find_item_equal(COND_EQUAL *cond_equal)
The function checks whether a substitution of a reference to field item for
an equal item is valid.
- @param arg *arg != NULL && **arg <-> the reference is in the context
+ @param arg *arg != NULL <-> the reference is in the context
where substitution for an equal item is valid
@note
@@ -7283,11 +7463,19 @@ Item_equal *Item_direct_view_ref::find_item_equal(COND_EQUAL *cond_equal)
*/
bool Item_direct_view_ref::subst_argument_checker(uchar **arg)
{
- bool res= (!(*arg) && (result_type() != STRING_RESULT)) ||
- ((*arg) && (**arg));
+ bool res= FALSE;
+ if (*arg)
+ {
+ Item *item= real_item();
+ if (item->type() == FIELD_ITEM &&
+ (*arg == (uchar *) Item::ANY_SUBST ||
+ result_type() != STRING_RESULT ||
+ (((Item_field *) item)->field->flags & BINARY_FLAG)))
+ res= TRUE;
+ }
/* Block any substitution into the wrapped object */
if (*arg)
- **arg= (uchar) 0;
+ *arg= NULL;
return res;
}
@@ -7731,6 +7919,8 @@ Item_result item_cmp_type(Item_result a,Item_result b)
return INT_RESULT;
else if (a == ROW_RESULT || b == ROW_RESULT)
return ROW_RESULT;
+ else if (a == TIME_RESULT || b == TIME_RESULT)
+ return TIME_RESULT;
if ((a == INT_RESULT || a == DECIMAL_RESULT) &&
(b == INT_RESULT || b == DECIMAL_RESULT))
return DECIMAL_RESULT;
@@ -7744,11 +7934,20 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
Item *new_item= NULL;
if (item->basic_const_item())
return; // Can't be better
- Item_result res_type=item_cmp_type(comp_item->result_type(),
- item->result_type());
+ Item_result res_type=item_cmp_type(comp_item->cmp_type(), item->cmp_type());
char *name=item->name; // Alloced by sql_alloc
switch (res_type) {
+ case TIME_RESULT:
+ {
+ bool is_null;
+ Item **ref_copy= ref;
+ /* the following call creates a constant and puts it in new_item */
+ get_datetime_value(thd, &ref_copy, &new_item, comp_item, &is_null);
+ if (is_null)
+ new_item= new Item_null(name);
+ break;
+ }
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];
@@ -7823,8 +8022,9 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
(Item*) new Item_decimal(name, result, length, decimals));
break;
}
- default:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
+ break;
}
if (new_item)
thd->change_item_tree(ref, new_item);
@@ -7844,6 +8044,9 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
@note We only use this on the range optimizer/partition pruning,
because in some cases we can't store the value in the field
without some precision/character loss.
+
+ @todo rewrite it to use Arg_comparator (currently it's a simplified and
+ incomplete version of it)
*/
int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
@@ -7899,6 +8102,25 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
field_val= field->val_decimal(&field_buf);
return my_decimal_cmp(item_val, field_val);
}
+ /*
+ We have to check field->cmp_type() instead of res_type,
+ as result_type() - and thus res_type - can never be TIME_RESULT (yet).
+ */
+ if (field->cmp_type() == TIME_RESULT)
+ {
+ MYSQL_TIME field_time, item_time;
+ if (field->type() == MYSQL_TYPE_TIME)
+ {
+ field->get_time(&field_time);
+ item->get_time(&item_time);
+ }
+ else
+ {
+ field->get_date(&field_time, TIME_FUZZY_DATE | TIME_INVALID_DATES);
+ item->get_date(&item_time, TIME_FUZZY_DATE | TIME_INVALID_DATES);
+ }
+ return my_time_compare(&field_time, &item_time);
+ }
double result= item->val_real();
if (item->null_value)
return 0;
@@ -7938,11 +8160,13 @@ Item_cache* Item_cache::get_cache(const Item *item, const Item_result type)
return new Item_cache_str(item);
case ROW_RESULT:
return new Item_cache_row();
- default:
- // should never be in real life
+ case TIME_RESULT:
+ return new Item_cache_temporal(item->field_type());
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
- return 0;
+ break;
}
+ return 0; // Impossible
}
void Item_cache::store(Item *item)
@@ -7955,6 +8179,11 @@ void Item_cache::store(Item *item)
void Item_cache::print(String *str, enum_query_type query_type)
{
+ if (value_cached)
+ {
+ print_value(str);
+ return;
+ }
str->append(STRING_WITH_LEN("<cache>("));
if (example)
example->print(str, query_type);
@@ -7975,16 +8204,6 @@ bool Item_cache_int::cache_value()
}
-void Item_cache_int::store_longlong(Item *item, longlong val_arg)
-{
- /* An explicit values is given, save it. */
- value_cached= TRUE;
- value= val_arg;
- null_value= item->null_value;
- unsigned_flag= item->unsigned_flag;
-}
-
-
String *Item_cache_int::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -7993,7 +8212,7 @@ String *Item_cache_int::val_str(String *str)
null_value= TRUE;
return NULL;
}
- str->set(value, default_charset());
+ str->set_int(value, unsigned_flag, default_charset());
return str;
}
@@ -8032,6 +8251,97 @@ longlong Item_cache_int::val_int()
return value;
}
+
+int Item_cache_int::save_in_field(Field *field, bool no_conversions)
+{
+ int error;
+ if ((!value_cached && !cache_value()) || null_value)
+ return set_field_to_null_with_conversions(field, no_conversions);
+
+ field->set_notnull();
+ error= field->store(value, unsigned_flag);
+
+ return error ? error : field->table->in_use->is_error() ? 1 : 0;
+}
+
+
+String *Item_cache_temporal::val_str(String *str)
+{
+ DBUG_ASSERT(fixed == 1);
+ if ((!value_cached && !cache_value()) || null_value)
+ {
+ null_value= true;
+ return NULL;
+ }
+ return val_string_from_date(str);
+}
+
+
+bool Item_cache_temporal::cache_value()
+{
+ if (!example)
+ return false;
+ value_cached= true;
+
+ MYSQL_TIME ltime;
+ if (example->get_date(&ltime, TIME_FUZZY_DATE))
+ value=0;
+ else
+ value= pack_time(&ltime);
+ null_value= example->null_value;
+ return true;
+}
+
+
+bool Item_cache_temporal::get_date(MYSQL_TIME *ltime, uint fuzzydate)
+{
+ Lazy_string_num str(value);
+
+ if (!value_cached && !cache_value())
+ {
+ bzero((char*) ltime,sizeof(*ltime));
+ return 1;
+ }
+
+ unpack_time(value, ltime);
+ ltime->time_type= mysql_type_to_time_type(field_type());
+ if (ltime->time_type == MYSQL_TIMESTAMP_TIME)
+ {
+ ltime->hour+= (ltime->month*32+ltime->day)*24;
+ ltime->month= ltime->day= 0;
+ }
+ return 0;
+
+}
+
+
+int Item_cache_temporal::save_in_field(Field *field, bool no_conversions)
+{
+ int error;
+ if ((!value_cached && !cache_value()) || null_value)
+ return set_field_to_null_with_conversions(field, no_conversions);
+
+ field->set_notnull();
+
+ MYSQL_TIME ltime;
+ unpack_time(value, &ltime);
+ ltime.time_type= mysql_type_to_time_type(field_type());
+ error= field->store_time_dec(&ltime, decimals);
+
+
+ return error ? error : field->table->in_use->is_error() ? 1 : 0;
+}
+
+
+void Item_cache_temporal::store_packed(longlong val_arg)
+{
+ /* An explicit values is given, save it. */
+ value_cached= true;
+ value= val_arg;
+ null_value= false;
+}
+
+
bool Item_cache_real::cache_value()
{
if (!example)
@@ -8237,11 +8547,8 @@ my_decimal *Item_cache_str::val_decimal(my_decimal *decimal_val)
int Item_cache_str::save_in_field(Field *field, bool no_conversions)
{
if ((!value_cached && !cache_value()) || null_value)
- {
- field->set_notnull();
- null_value= TRUE;
- return 0;
- }
+ return set_field_to_null_with_conversions(field, no_conversions);
+
int res= Item_cache::save_in_field(field, no_conversions);
return (is_varbinary && field->type() == MYSQL_TYPE_STRING &&
value->length() < field->field_length) ? 1 : res;
@@ -8395,12 +8702,14 @@ Item_result Item_type_holder::result_type() const
enum_field_types Item_type_holder::get_real_type(Item *item)
{
+ if (item->type() == REF_ITEM)
+ item= item->real_item();
switch(item->type())
{
case FIELD_ITEM:
{
/*
- Item_fields::field_type ask Field_type() but sometimes field return
+ Item_field::field_type ask Field_type() but sometimes field return
a different type, like for enum/set, so we need to ask real type.
*/
Field *field= ((Item_field *) item)->field;
@@ -8442,7 +8751,8 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
case DECIMAL_RESULT:
return MYSQL_TYPE_NEWDECIMAL;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
return MYSQL_TYPE_VAR_STRING;
}
@@ -8769,6 +9079,49 @@ void view_error_processor(THD *thd, void *data)
((TABLE_LIST *)data)->hide_view_error(thd);
}
+
+st_select_lex *Item_ident::get_depended_from() const
+{
+ st_select_lex *dep;
+ if ((dep= depended_from))
+ for ( ; dep->merged_into; dep= dep->merged_into) ;
+ return dep;
+}
+
+
+table_map Item_ref::used_tables() const
+{
+ return get_depended_from() ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
+}
+
+
+void Item_ref::update_used_tables()
+{
+ if (!get_depended_from())
+ (*ref)->update_used_tables();
+}
+
+
+table_map Item_direct_view_ref::used_tables() const
+{
+ return get_depended_from() ?
+ OUTER_REF_TABLE_BIT :
+ (view->merged ? (*ref)->used_tables() : view->table->map);
+}
+
+
+/*
+ we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
+*/
+table_map Item_ref_null_helper::used_tables() const
+{
+ return (get_depended_from() ?
+ OUTER_REF_TABLE_BIT :
+ (*ref)->used_tables() | RAND_TABLE_BIT);
+}
+
+
+
/*****************************************************************************
** Instantiate templates
*****************************************************************************/
diff --git a/sql/item.h b/sql/item.h
index 120ff358098..1829f45d00b 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
-
+ Copyright (c) 2009-2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
@@ -18,6 +18,10 @@
#pragma interface /* gcc class implementation */
#endif
+C_MODE_START
+#include <ma_dyncol.h>
+C_MODE_END
+
inline
bool trace_unsupported_func(const char *where, const char *processor_name)
{
@@ -471,6 +475,17 @@ public:
};
+struct st_dyncall_create_def
+{
+ Item *num, *value;
+ CHARSET_INFO *cs;
+ uint len, frac;
+ DYNAMIC_COLUMN_TYPE type;
+};
+
+typedef struct st_dyncall_create_def DYNCALL_CREATE_DEF;
+
+
typedef bool (Item::*Item_processor) (uchar *arg);
/*
Analyzer function
@@ -494,6 +509,17 @@ class COND_EQUAL;
class Item {
Item(const Item &); /* Prevent use of these */
void operator=(Item &);
+ /**
+ The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached
+ to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the
+ make_cond_for_table procedure. During query execution, this item is
+ evaluated when the join loop reaches the corresponding JOIN_TAB.
+
+ If the value of join_tab_idx >= MAX_TABLES, this means that there is no
+ corresponding JOIN_TAB.
+ */
+ uint join_tab_idx;
+
public:
static void *operator new(size_t size) throw ()
{ return sql_alloc(size); }
@@ -539,6 +565,11 @@ public:
*/
Item *next;
uint32 max_length;
+ /*
+ TODO: convert name and name_length fields into LEX_STRING to keep them in
+ sync (see bug #11829681/60295 etc). Then also remove some strlen(name)
+ calls.
+ */
uint name_length; /* Length of name */
int8 marker;
uint8 decimals;
@@ -611,8 +642,11 @@ public:
{ return save_in_field(field, 1); }
virtual bool send(Protocol *protocol, String *str);
virtual bool eq(const Item *, bool binary_cmp) const;
+ /* result_type() of an item specifies how the value should be returned */
virtual Item_result result_type() const { return REAL_RESULT; }
- virtual Item_result cast_to_int_type() const { return result_type(); }
+ /* ... while cmp_type() specifies how it should be compared */
+ virtual Item_result cmp_type() const;
+ virtual Item_result cast_to_int_type() const { return cmp_type(); }
virtual enum_field_types string_field_type() const;
virtual enum_field_types field_type() const;
virtual enum Type type() const =0;
@@ -774,6 +808,7 @@ public:
String *val_string_from_real(String *str);
String *val_string_from_int(String *str);
String *val_string_from_decimal(String *str);
+ String *val_string_from_date(String *str);
my_decimal *val_decimal_from_real(my_decimal *decimal_value);
my_decimal *val_decimal_from_int(my_decimal *decimal_value);
my_decimal *val_decimal_from_string(my_decimal *decimal_value);
@@ -790,6 +825,8 @@ public:
/* This is also used to create fields in CREATE ... SELECT: */
virtual Field *tmp_table_field(TABLE *t_arg) { return 0; }
virtual const char *full_name() const { return name ? name : "???"; }
+ const char *field_name_or_null()
+ { return real_item()->type() == Item::FIELD_ITEM ? name : NULL; }
/*
*result* family of methods is analog of *val* family (see above) but
@@ -804,13 +841,18 @@ public:
{ return val_decimal(val); }
virtual bool val_bool_result() { return val_bool(); }
virtual bool is_null_result() { return is_null(); }
-
+ /*
+ Returns 1 if result type and collation for val_str() can change between
+ calls
+ */
+ virtual bool dynamic_result() { return 0; }
/*
Bitmap of tables used by item
(note: if you need to check dependencies on individual columns, check out
class Field_enumerator)
*/
virtual table_map used_tables() const { return (table_map) 0L; }
+ virtual table_map all_used_tables() const { return used_tables(); }
/*
Return table map of tables that can't be NULL tables (tables that are
used in a context where if they would contain a NULL row generated
@@ -865,6 +907,7 @@ public:
}
void print_item_w_name(String *, enum_query_type query_type);
+ void print_value(String *);
virtual void update_used_tables() {}
virtual void split_sum_func(THD *thd, Item **ref_pointer_array,
List<Item> &fields) {}
@@ -872,7 +915,9 @@ public:
void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
Item **ref, bool skip_registered);
virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- virtual bool get_time(MYSQL_TIME *ltime);
+ bool get_time(MYSQL_TIME *ltime)
+ { return get_date(ltime, TIME_TIME_ONLY | TIME_FUZZY_DATE); }
+ bool get_seconds(ulonglong *sec, ulong *sec_part);
virtual bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
{ return get_date(ltime,fuzzydate); }
/*
@@ -968,8 +1013,13 @@ public:
virtual bool reset_query_id_processor(uchar *query_id_arg) { return 0; }
virtual bool is_expensive_processor(uchar *arg) { return 0; }
virtual bool register_field_in_read_map(uchar *arg) { return 0; }
+ virtual bool register_field_in_write_map(uchar *arg) { return 0; }
virtual bool enumerate_field_refs_processor(uchar *arg) { return 0; }
virtual bool mark_as_eliminated_processor(uchar *arg) { return 0; }
+ virtual bool eliminate_subselect_processor(uchar *arg) { return 0; }
+ virtual bool set_fake_select_as_master_processor(uchar *arg) { return 0; }
+ virtual bool view_used_tables_processor(uchar *arg) { return 0; }
+ virtual bool eval_not_null_tables(uchar *opt_arg) { return 0; }
/* To call bool function for all arguments */
struct bool_func_call_args
@@ -985,6 +1035,7 @@ public:
(this->*(info->bool_function))();
return FALSE;
}
+
/*
The next function differs from the previous one that a bitmap to be updated
is passed as uchar *arg.
@@ -1057,12 +1108,23 @@ public:
return FALSE;
}
+ /*
+ The enumeration Subst_constraint is currently used only in implementations
+ of the virtual function subst_argument_checker.
+ */
+ enum Subst_constraint
+ {
+ NO_SUBST= 0, /* No substitution for a field is allowed */
+ ANY_SUBST, /* Any substitution for a field is allowed */
+ IDENTITY_SUBST /* Substitution for a field is allowed if any two
+ different values of the field type are not equal */
+ };
+
virtual bool subst_argument_checker(uchar **arg)
- {
- if (*arg)
- *arg= NULL;
- return TRUE;
+ {
+ return (*arg != NULL);
}
+
/*
@brief
Processor used to check acceptability of an item in the defining
@@ -1160,15 +1222,6 @@ public:
{
return 0;
}
- /*
- result_as_longlong() must return TRUE for Items representing DATE/TIME
- functions and DATE/TIME table fields.
- Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
- their values should be compared as integers (because the integer
- representation is more precise than the string one).
- */
- virtual bool result_as_longlong() { return FALSE; }
- bool is_datetime();
/*
Test whether an expression is expensive to compute. Used during
@@ -1196,12 +1249,30 @@ public:
{ return Field::GEOM_GEOMETRY; };
String *check_well_formed_result(String *str, bool send_error= 0);
bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
-
Item* set_expr_cache(THD *thd, List<Item*> &depends_on);
+ virtual Item *get_cached_item() { return NULL; }
virtual Item_equal *get_item_equal() { return NULL; }
virtual void set_item_equal(Item_equal *item_eq) {};
virtual Item_equal *find_item_equal(COND_EQUAL *cond_equal) { return NULL; }
+ /**
+ Set the join tab index to the minimal (left-most) JOIN_TAB to which this
+ Item is attached. The number is an index is depth_first_tab() traversal
+ order.
+ */
+ virtual void set_join_tab_idx(uint join_tab_idx_arg)
+ {
+ if (join_tab_idx_arg < join_tab_idx)
+ join_tab_idx= join_tab_idx_arg;
+ }
+ virtual uint get_join_tab_idx() { return join_tab_idx; }
+
+ table_map view_used_tables(TABLE_LIST *view)
+ {
+ view->view_used_tables= 0;
+ walk(&Item::view_used_tables_processor, 0, (uchar *) view);
+ return view->view_used_tables;
+ }
};
@@ -1601,6 +1672,7 @@ public:
Item_ident(TABLE_LIST *view_arg, const char *field_name_arg);
const char *full_name() const;
void cleanup();
+ st_select_lex *get_depended_from() const;
bool remove_dependence_processor(uchar * arg);
virtual void print(String *str, enum_query_type query_type);
virtual bool change_context_processor(uchar *cntx)
@@ -1688,13 +1760,14 @@ public:
int save_in_field(Field *field,bool no_conversions);
void save_org_in_field(Field *field);
table_map used_tables() const;
+ table_map all_used_tables() const;
enum Item_result result_type () const
{
return field->result_type();
}
Item_result cast_to_int_type() const
{
- return field->cast_to_int_type();
+ return field->cmp_type();
}
enum_field_types field_type() const
{
@@ -1709,7 +1782,6 @@ public:
Field *tmp_table_field(TABLE *t_arg) { return result_field; }
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
bool is_null() { return field->is_null(); }
void update_null_value();
Item *get_tmp_table_item(THD *thd);
@@ -1717,16 +1789,13 @@ public:
bool add_field_to_set_processor(uchar * arg);
bool find_item_in_field_list_processor(uchar *arg);
bool register_field_in_read_map(uchar *arg);
+ bool register_field_in_write_map(uchar *arg);
bool register_field_in_bitmap(uchar *arg);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool vcol_in_partition_func_processor(uchar *bool_arg);
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
bool enumerate_field_refs_processor(uchar *arg);
void cleanup();
- bool result_as_longlong()
- {
- return field->can_be_compared_as_longlong();
- }
Item_equal *get_item_equal() { return item_equal; }
void set_item_equal(Item_equal *item_eq) { item_equal= item_eq; }
Item_equal *find_item_equal(COND_EQUAL *cond_equal);
@@ -1878,6 +1947,7 @@ public:
Item_param(uint pos_in_query_arg);
enum Item_result result_type () const { return item_result_type; }
+ enum Item_result cast_to_int_type() const { return item_result_type; }
enum Type type() const { return item_type; }
enum_field_types field_type() const { return param_type; }
@@ -1885,7 +1955,6 @@ public:
longlong val_int();
my_decimal *val_decimal(my_decimal*);
String *val_str(String*);
- bool get_time(MYSQL_TIME *tm);
bool get_date(MYSQL_TIME *tm, uint fuzzydate);
int save_in_field(Field *field, bool no_conversions);
@@ -1986,19 +2055,31 @@ class Item_uint :public Item_int
{
public:
Item_uint(const char *str_arg, uint length);
- Item_uint(ulonglong i) :Item_int((ulonglong) i, 10) {}
+ Item_uint(ulonglong i) :Item_int(i, 10) {}
Item_uint(const char *str_arg, longlong i, uint length);
double val_real()
{ DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); }
String *val_str(String*);
Item *clone_item() { return new Item_uint(name, value, max_length); }
- int save_in_field(Field *field, bool no_conversions);
virtual void print(String *str, enum_query_type query_type);
Item_num *neg ();
uint decimal_precision() const { return max_length; }
};
+class Item_datetime :public Item_int
+{
+protected:
+ MYSQL_TIME ltime;
+public:
+ Item_datetime() :Item_int(0) { unsigned_flag=0; }
+ int save_in_field(Field *field, bool no_conversions);
+ longlong val_int();
+ double val_real() { return (double)val_int(); }
+ void set(longlong packed);
+};
+
+
/* decimal (fixed point) constant */
class Item_decimal :public Item_num
{
@@ -2242,9 +2323,11 @@ private:
longlong
-longlong_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end);
+longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
+ const char *end);
double
-double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end);
+double_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
+ const char *end);
class Item_static_string_func :public Item_string
{
@@ -2289,10 +2372,11 @@ class Item_return_date_time :public Item_partition_func_safe_string
{
enum_field_types date_time_field_type;
public:
- Item_return_date_time(const char *name_arg, enum_field_types field_type_arg)
- :Item_partition_func_safe_string(name_arg, 0, &my_charset_bin),
+ Item_return_date_time(const char *name_arg, uint length_arg,
+ enum_field_types field_type_arg)
+ :Item_partition_func_safe_string(name_arg, length_arg, &my_charset_bin),
date_time_field_type(field_type_arg)
- { }
+ { decimals= 0; }
enum_field_types field_type() const { return date_time_field_type; }
};
@@ -2486,15 +2570,8 @@ public:
Field *get_tmp_table_field()
{ return result_field ? result_field : (*ref)->get_tmp_table_field(); }
Item *get_tmp_table_item(THD *thd);
- table_map used_tables() const
- {
- return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
- }
- void update_used_tables()
- {
- if (!depended_from)
- (*ref)->update_used_tables();
- }
+ inline table_map used_tables() const;
+ inline void update_used_tables();
bool const_item() const
{
return (*ref)->const_item();
@@ -2532,10 +2609,6 @@ public:
(*ref)->restore_to_before_no_rows_in_result();
}
virtual void print(String *str, enum_query_type query_type);
- bool result_as_longlong()
- {
- return (*ref)->result_as_longlong();
- }
void cleanup();
Item_field *filed_for_view_update()
{ return (*ref)->filed_for_view_update(); }
@@ -2572,11 +2645,6 @@ public:
{
return trace_unsupported_by_check_vcol_func_processor("ref");
}
- bool get_time(MYSQL_TIME *ltime)
- {
- DBUG_ASSERT(fixed);
- return (*ref)->get_time(ltime);
- }
};
@@ -2614,6 +2682,43 @@ public:
virtual Ref_Type ref_type() { return DIRECT_REF; }
};
+
+/**
+ This class is the same as Item_direct_ref but created to wrap Item_ident
+ before fix_fields() call
+*/
+
+class Item_direct_ref_to_ident :public Item_direct_ref
+{
+ Item_ident *ident;
+public:
+ Item_direct_ref_to_ident(Item_ident *item)
+ :Item_direct_ref(item->context, (Item**)&item, item->table_name, item->field_name,
+ FALSE)
+ {
+ ident= item;
+ ref= (Item**)&ident;
+ }
+
+ bool fix_fields(THD *thd, Item **it)
+ {
+ DBUG_ASSERT(ident->type() == FIELD_ITEM || ident->type() == REF_ITEM);
+ if ((!ident->fixed && ident->fix_fields(thd, ref)) ||
+ ident->check_cols(1))
+ return TRUE;
+ set_properties();
+ return FALSE;
+ }
+
+ virtual void print(String *str, enum_query_type query_type)
+ { ident->print(str, query_type); }
+
+ virtual Item* transform(Item_transformer transformer, uchar *arg);
+ virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
+ Item_transformer transformer, uchar *arg_t);
+};
+
+
class Expression_cache;
class Item_cache;
@@ -2663,7 +2768,6 @@ public:
bool val_bool();
bool is_null();
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
bool send(Protocol *protocol, String *buffer)
{
if (result_field)
@@ -2708,7 +2812,6 @@ public:
}
bool enumerate_field_refs_processor(uchar *arg)
{ return orig_item->enumerate_field_refs_processor(arg); }
- bool result_as_longlong() { return orig_item->result_as_longlong(); }
Item_field *filed_for_view_update()
{ return orig_item->filed_for_view_update(); }
@@ -2746,12 +2849,14 @@ public:
class Item_direct_view_ref :public Item_direct_ref
{
Item_equal *item_equal;
+ TABLE_LIST *view;
public:
Item_direct_view_ref(Name_resolution_context *context_arg, Item **item,
- const char *table_name_arg,
- const char *field_name_arg)
+ const char *table_name_arg,
+ const char *field_name_arg,
+ TABLE_LIST *view_arg)
:Item_direct_ref(context_arg, item, table_name_arg, field_name_arg),
- item_equal(0) {}
+ item_equal(0), view(view_arg) {}
/* Constructor need to process subselect with temporary tables (see Item) */
Item_direct_view_ref(THD *thd, Item_direct_ref *item)
:Item_direct_ref(thd, item), item_equal(0) {}
@@ -2775,6 +2880,19 @@ public:
bool subst_argument_checker(uchar **arg);
Item *equal_fields_propagator(uchar *arg);
Item *replace_equal_field(uchar *arg);
+ table_map used_tables() const;
+ bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
+ {
+ return (*ref)->walk(processor, walk_subquery, arg) ||
+ (this->*processor)(arg);
+ }
+ bool view_used_tables_processor(uchar *arg)
+ {
+ TABLE_LIST *view_arg= (TABLE_LIST *) arg;
+ if (view_arg == view)
+ view_arg->view_used_tables|= (*ref)->used_tables();
+ return 0;
+ }
};
@@ -2865,15 +2983,7 @@ public:
bool val_bool();
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
virtual void print(String *str, enum_query_type query_type);
- /*
- we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
- */
- table_map used_tables() const
- {
- return (depended_from ?
- OUTER_REF_TABLE_BIT :
- (*ref)->used_tables() | RAND_TABLE_BIT);
- }
+ table_map used_tables() const;
};
/*
@@ -3131,6 +3241,17 @@ public:
value.
*/
+/*
+ Cached_item_XXX objects are not exactly caches. They do the following:
+
+ Each Cached_item_XXX object has
+ - its source item
+ - saved value of the source item
+ - cmp() method that compares the saved value with the current value of the
+ source item, and if they were not equal saves item's value into the saved
+ value.
+*/
+
class Cached_item :public Sql_alloc
{
public:
@@ -3465,28 +3586,54 @@ class Item_cache_int: public Item_cache
protected:
longlong value;
public:
- Item_cache_int(): Item_cache(),
+ Item_cache_int(): Item_cache(MYSQL_TYPE_LONGLONG),
value(0) {}
Item_cache_int(enum_field_types field_type_arg):
Item_cache(field_type_arg), value(0) {}
- virtual void store(Item *item){ Item_cache::store(item); }
- void store_longlong(Item *item, longlong val_arg);
double val_real();
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return INT_RESULT; }
- bool result_as_longlong() { return TRUE; }
bool cache_value();
+ int save_in_field(Field *field, bool no_conversions);
};
+class Item_cache_temporal: public Item_cache_int
+{
+public:
+ Item_cache_temporal(enum_field_types field_type_arg):
+ Item_cache_int(field_type_arg)
+ {
+ if (mysql_type_to_time_type(cached_field_type) == MYSQL_TIMESTAMP_ERROR)
+ cached_field_type= MYSQL_TYPE_DATETIME;
+ }
+
+ String* val_str(String *str);
+ bool cache_value();
+ bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
+ int save_in_field(Field *field, bool no_conversions);
+ void store_packed(longlong val_arg);
+ /*
+ Having a clone_item method tells optimizer that this object
+ is a constant and need not be optimized further.
+ Important when storing packed datetime values.
+ */
+ Item *clone_item()
+ {
+ Item_cache_temporal *item= new Item_cache_temporal(cached_field_type);
+ item->store_packed(value);
+ return item;
+ }
+};
+
class Item_cache_real: public Item_cache
{
double value;
public:
- Item_cache_real(): Item_cache(),
+ Item_cache_real(): Item_cache(MYSQL_TYPE_DOUBLE),
value(0) {}
double val_real();
@@ -3503,7 +3650,7 @@ class Item_cache_decimal: public Item_cache
protected:
my_decimal decimal_value;
public:
- Item_cache_decimal(): Item_cache() {}
+ Item_cache_decimal(): Item_cache(MYSQL_TYPE_NEWDECIMAL) {}
double val_real();
longlong val_int();
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 73191982b64..dc25cf5942c 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -29,10 +29,7 @@
#include <m_ctype.h>
#include "sql_select.h"
-static bool convert_constant_item(THD *, Item_field *, Item **);
-static longlong
-get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null);
+static bool convert_const_to_int(THD *, Item_field *, Item **);
static Item_result item_store_type(Item_result a, Item *item,
my_bool unsigned_flag)
@@ -76,6 +73,30 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
}
+/**
+ find an temporal type (item) that others will be converted to
+ for the purpose of comparison.
+
+ this is the type that will be used in warnings like
+ "Incorrect <<TYPE>> value".
+*/
+Item *find_date_time_item(Item **args, uint nargs, uint col)
+{
+ Item *date_arg= 0, **arg, **arg_end;
+ for (arg= args, arg_end= args + nargs; arg != arg_end ; arg++)
+ {
+ Item *item= arg[0]->element_index(col);
+ if (item->cmp_type() != TIME_RESULT)
+ continue;
+ if (item->field_type() == MYSQL_TYPE_DATETIME)
+ return item;
+ if (!date_arg)
+ date_arg= item;
+ }
+ return date_arg;
+}
+
+
/*
Compare row signature of two expressions
@@ -138,10 +159,10 @@ static int cmp_row_type(Item* item1, Item* item2)
static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
{
uint i;
- type[0]= items[0]->result_type();
+ type[0]= items[0]->cmp_type();
for (i= 1 ; i < nitems ; i++)
{
- type[0]= item_cmp_type(type[0], items[i]->result_type());
+ type[0]= item_cmp_type(type[0], items[i]->cmp_type());
/*
When aggregating types of two row expressions we have to check
that they have the same cardinality and that each component
@@ -207,7 +228,7 @@ static uint collect_cmp_types(Item **items, uint nitems, bool skip_nulls= FALSE)
{
uint i;
uint found_types;
- Item_result left_result= items[0]->result_type();
+ Item_result left_result= items[0]->cmp_type();
DBUG_ASSERT(nitems > 1);
found_types= 0;
for (i= 1; i < nitems ; i++)
@@ -215,11 +236,11 @@ static uint collect_cmp_types(Item **items, uint nitems, bool skip_nulls= FALSE)
if (skip_nulls && items[i]->type() == Item::NULL_ITEM)
continue; // Skip NULL constant items
if ((left_result == ROW_RESULT ||
- items[i]->result_type() == ROW_RESULT) &&
+ items[i]->cmp_type() == ROW_RESULT) &&
cmp_row_type(items[0], items[i]))
return 0;
found_types|= 1<< (uint)item_cmp_type(left_result,
- items[i]->result_type());
+ items[i]->cmp_type());
}
/*
Even if all right-hand items are NULLs and we are skipping them all, we need
@@ -395,12 +416,24 @@ longlong Item_func_nop_all::val_int()
1 Item was replaced with an integer version of the item
*/
-static bool convert_constant_item(THD *thd, Item_field *field_item,
+static bool convert_const_to_int(THD *thd, Item_field *field_item,
Item **item)
{
Field *field= field_item->field;
int result= 0;
+ /*
+ We don't need to convert an integer to an integer,
+ pretend it's already converted.
+
+ But we still convert it if it is compared with a Field_year,
+ as YEAR(2) may change the value of an integer when converting it
+ to an integer (say, 0 to 70).
+ */
+ if ((*item)->cmp_type() == INT_RESULT &&
+ field_item->field_type() != MYSQL_TYPE_YEAR)
+ return 1;
+
if ((*item)->const_item())
{
TABLE *table= field->table;
@@ -412,7 +445,8 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
LINT_INIT(old_maps[0]);
LINT_INIT(old_maps[1]);
- if (table)
+ /* table->read_set may not be set if we come here from a CREATE TABLE */
+ if (table && table->read_set)
dbug_tmp_use_all_columns(table, old_maps,
table->read_set, table->write_set);
/* For comparison purposes allow invalid dates like 2000-01-32 */
@@ -421,14 +455,12 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
/*
- Store the value of the field/constant if it references an outer field
- because the call to save_in_field below overrides that value.
- Don't save field value if no data has been read yet.
- Outer constant values are always saved.
+ Store the value of the field/constant because the call to save_in_field
+ below overrides that value. Don't save field value if no data has been
+ read yet.
*/
- bool save_field_value= (field_item->depended_from &&
- (field_item->const_item() ||
- !(field->table->status & STATUS_NO_RECORD)));
+ bool save_field_value= (field_item->const_item() ||
+ !(field->table->status & STATUS_NO_RECORD));
if (save_field_value)
orig_field_val= field->val_int();
if (!(*item)->is_null() && !(*item)->save_in_field(field, 1))
@@ -448,7 +480,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
}
thd->variables.sql_mode= orig_sql_mode;
thd->count_cuted_fields= orig_count_cuted_fields;
- if (table)
+ if (table && table->read_set)
dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_maps);
}
return result;
@@ -479,7 +511,6 @@ void Item_bool_func2::fix_length_and_dec()
to the collation of A.
*/
-
DTCollation coll;
if (args[0]->result_type() == STRING_RESULT &&
args[1]->result_type() == STRING_RESULT &&
@@ -488,48 +519,27 @@ void Item_bool_func2::fix_length_and_dec()
args[0]->cmp_context= args[1]->cmp_context=
item_cmp_type(args[0]->result_type(), args[1]->result_type());
- // Make a special case of compare with fields to get nicer DATE comparisons
- if (functype() == LIKE_FUNC) // Disable conversion in case of LIKE function.
- {
- set_cmp_func();
- return;
- }
+ /*
+ Make a special case of compare with fields to get nicer comparisons
+ of numbers with constant string.
+ This directly contradicts the manual (number and a string should
+ be compared as doubles), but seems to provide more
+ "intuitive" behavior in some cases (but less intuitive in others).
+ But disable conversion in case of LIKE function.
+ */
thd= current_thd;
- if (!thd->lex->is_ps_or_view_context_analysis())
+ if (functype() != LIKE_FUNC && !thd->lex->is_ps_or_view_context_analysis())
{
- if (args[0]->real_item()->type() == FIELD_ITEM)
+ int field;
+ if (args[field= 0]->real_item()->type() == FIELD_ITEM ||
+ args[field= 1]->real_item()->type() == FIELD_ITEM)
{
- Item_field *field_item= (Item_field*) (args[0]->real_item());
- if (field_item->field->can_be_compared_as_longlong() &&
- !(field_item->is_datetime() &&
- args[1]->result_type() == STRING_RESULT))
- {
- if (convert_constant_item(thd, field_item, &args[1]))
- {
- cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
- INT_RESULT); // Works for all types.
- args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
- return;
- }
- }
- }
- if (args[1]->real_item()->type() == FIELD_ITEM)
- {
- Item_field *field_item= (Item_field*) (args[1]->real_item());
- if (field_item->field->can_be_compared_as_longlong() &&
- !(field_item->is_datetime() &&
- args[0]->result_type() == STRING_RESULT))
- {
- if (convert_constant_item(thd, field_item, &args[0]))
- {
- cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
- INT_RESULT); // Works for all types.
- args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
- return;
- }
- }
+ Item_field *field_item= (Item_field*) (args[field]->real_item());
+ if (field_item->cmp_type() == INT_RESULT &&
+ convert_const_to_int(thd, field_item, &args[!field]))
+ args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
}
}
set_cmp_func();
@@ -543,6 +553,8 @@ int Arg_comparator::set_compare_func(Item_result_field *item, Item_result type)
[is_owner_equal_func()];
switch (type) {
+ case TIME_RESULT:
+ break;
case ROW_RESULT:
{
uint n= (*a)->cols();
@@ -636,8 +648,9 @@ int Arg_comparator::set_compare_func(Item_result_field *item, Item_result type)
}
break;
}
- default:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
+ break;
}
return 0;
}
@@ -651,12 +664,14 @@ int Arg_comparator::set_compare_func(Item_result_field *item, Item_result type)
@param[in] warn_name Field name for issuing the warning
@param[out] l_time The MYSQL_TIME objects is initialized.
- Parses a date provided in the string str into a MYSQL_TIME object. If the
- string contains an incorrect date or doesn't correspond to a date at all
- then a warning is issued. The warn_type and the warn_name arguments are used
- as the name and the type of the field when issuing the warning. If any input
- was discarded (trailing or non-timestamp-y characters), return value will be
- TRUE.
+ Parses a date provided in the string str into a MYSQL_TIME object.
+ The date is used for comparison, that is fuzzy dates are allowed
+ independently of sql_mode.
+ If the string contains an incorrect date or doesn't correspond to a date at
+ all then a warning is issued. The warn_type and the warn_name arguments are
+ used as the name and the type of the field when issuing the warning. If any
+ input was discarded (trailing or non-timestamp-y characters), return value
+ will be TRUE.
@return Status flag
@retval FALSE Success.
@@ -669,16 +684,15 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
bool value;
int error;
enum_mysql_timestamp_type timestamp_type;
+ int flags= TIME_FUZZY_DATE | MODE_INVALID_DATES;
+
+ if (warn_type == MYSQL_TIMESTAMP_TIME)
+ flags|= TIME_TIME_ONLY;
timestamp_type=
- str_to_datetime(str->ptr(), str->length(), l_time,
- (TIME_FUZZY_DATE | MODE_INVALID_DATES |
- (thd->variables.sql_mode &
- (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE))),
- &error);
-
- if (timestamp_type == MYSQL_TIMESTAMP_DATETIME ||
- timestamp_type == MYSQL_TIMESTAMP_DATE)
+ str_to_datetime(str->ptr(), str->length(), l_time, flags, &error);
+
+ if (timestamp_type > MYSQL_TIMESTAMP_ERROR)
/*
Do not return yet, we may still want to throw a "trailing garbage"
warning.
@@ -700,264 +714,31 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
/**
- @brief Convert date provided in a string to the int representation.
-
- @param[in] thd thread handle
- @param[in] str a string to convert
- @param[in] warn_type type of the timestamp for issuing the warning
- @param[in] warn_name field name for issuing the warning
- @param[out] error_arg could not extract a DATE or DATETIME
-
- @details Convert date provided in the string str to the int
- representation. If the string contains wrong date or doesn't
- contain it at all then a warning is issued. The warn_type and
- the warn_name arguments are used as the name and the type of the
- field when issuing the warning.
-
- @return
- converted value. 0 on error and on zero-dates -- check 'failure'
-*/
-static ulonglong get_date_from_str(THD *thd, String *str,
- timestamp_type warn_type,
- const char *warn_name, bool *error_arg)
-{
- MYSQL_TIME l_time;
- *error_arg= get_mysql_time_from_str(thd, str, warn_type, warn_name, &l_time);
-
- if (*error_arg)
- return 0;
- return TIME_to_ulonglong_datetime(&l_time);
-}
-
-
-/*
- Check whether compare_datetime() can be used to compare items.
+ Prepare the comparator (set the comparison function) for comparing
+ items *a1 and *a2 in the context of 'type'.
- SYNOPSIS
- Arg_comparator::can_compare_as_dates()
- a, b [in] items to be compared
- const_value [out] converted value of the string constant, if any
-
- DESCRIPTION
- Check several cases when the DATE/DATETIME comparator should be used.
- The following cases are checked:
- 1. Both a and b is a DATE/DATETIME field/function returning string or
- int result.
- 2. Only a or b is a DATE/DATETIME field/function returning string or
- int result and the other item (b or a) is an item with string result.
- If the second item is a constant one then it's checked to be
- convertible to the DATE/DATETIME type. If the constant can't be
- converted to a DATE/DATETIME then the compare_datetime() comparator
- isn't used and the warning about wrong DATE/DATETIME value is issued.
- In all other cases (date-[int|real|decimal]/[int|real|decimal]-date)
- the comparison is handled by other comparators.
- If the datetime comparator can be used and one the operands of the
- comparison is a string constant that was successfully converted to a
- DATE/DATETIME type then the result of the conversion is returned in the
- const_value if it is provided. If there is no constant or
- compare_datetime() isn't applicable then the *const_value remains
- unchanged.
+ @param[in] owner_arg Item, peforming the comparison (e.g. Item_func_eq)
+ @param[in,out] a1 first argument to compare
+ @param[in,out] a2 second argument to compare
+ @param[in] type type context to compare in
- RETURN
- the found type of date comparison
+ Both *a1 and *a2 can be replaced by this method - typically by constant
+ items, holding the cached converted value of the original (constant) item.
*/
-enum Arg_comparator::enum_date_cmp_type
-Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
-{
- enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
- Item *str_arg= 0, *date_arg= 0;
-
- if (a->type() == Item::ROW_ITEM || b->type() == Item::ROW_ITEM)
- return CMP_DATE_DFLT;
-
- if (a->is_datetime())
- {
- if (b->is_datetime())
- cmp_type= CMP_DATE_WITH_DATE;
- else if (b->result_type() == STRING_RESULT)
- {
- cmp_type= CMP_DATE_WITH_STR;
- date_arg= a;
- str_arg= b;
- }
- }
- else if (b->is_datetime() && a->result_type() == STRING_RESULT)
- {
- cmp_type= CMP_STR_WITH_DATE;
- date_arg= b;
- str_arg= a;
- }
-
- if (cmp_type != CMP_DATE_DFLT)
- {
- THD *thd= current_thd;
- /*
- Do not cache GET_USER_VAR() function as its const_item() may return TRUE
- for the current thread but it still may change during the execution.
- Don't use cache while in the context analysis mode only (i.e. for
- EXPLAIN/CREATE VIEW and similar queries). Cache is useless in such
- cases and can cause problems. For example evaluating subqueries can
- confuse storage engines since in context analysis mode tables
- aren't locked.
- */
- if (!thd->lex->is_ps_or_view_context_analysis() &&
- cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() &&
- (str_arg->type() != Item::FUNC_ITEM ||
- ((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
- {
- ulonglong value;
- bool error;
- String tmp, *str_val= 0;
- timestamp_type t_type= (date_arg->field_type() == MYSQL_TYPE_DATE ?
- MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME);
-
- str_val= str_arg->val_str(&tmp);
- if (str_arg->null_value)
- return CMP_DATE_DFLT;
- value= get_date_from_str(thd, str_val, t_type, date_arg->name, &error);
- if (error)
- return CMP_DATE_DFLT;
- if (const_value)
- *const_value= value;
- }
- }
- return cmp_type;
-}
-
-/*
- Retrieves correct TIME value from the given item.
-
- SYNOPSIS
- get_time_value()
- thd thread handle
- item_arg [in/out] item to retrieve TIME value from
- cache_arg [in/out] pointer to place to store the cache item to
- warn_item [in] unused
- is_null [out] TRUE <=> the item_arg is null
-
- DESCRIPTION
- Retrieves the correct TIME value from given item for comparison by the
- compare_datetime() function.
- If item's result can be compared as longlong then its int value is used
- and a value returned by get_time function is used otherwise.
- If an item is a constant one then its value is cached and it isn't
- get parsed again. An Item_cache_int object is used for for cached values.
- It seamlessly substitutes the original item. The cache item is marked as
- non-constant to prevent re-caching it again.
-
- RETURN
- obtained value
-*/
-
-longlong
-get_time_value(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null)
-{
- longlong value;
- Item *item= **item_arg;
- MYSQL_TIME ltime;
-
- if (item->result_as_longlong())
- {
- value= item->val_int();
- *is_null= item->null_value;
- }
- else
- {
- *is_null= item->get_time(&ltime);
- value= !*is_null ? (longlong) TIME_to_ulonglong_datetime(&ltime) : 0;
- }
- /*
- Do not cache GET_USER_VAR() function as its const_item() may return TRUE
- for the current thread but it still may change during the execution.
- */
- if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
- ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
- {
- Query_arena backup;
- Query_arena *save_arena= thd->switch_to_arena_for_cached_items(&backup);
- Item_cache_int *cache= new Item_cache_int();
- if (save_arena)
- thd->set_query_arena(save_arena);
-
- /* Mark the cache as non-const to prevent re-caching. */
- cache->set_used_tables(1);
- cache->store_longlong(item, value);
- *cache_arg= cache;
- *item_arg= cache_arg;
- }
- return value;
-}
-
-
int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
Item **a1, Item **a2,
Item_result type)
{
- ulonglong const_value= (ulonglong)-1;
thd= current_thd;
owner= owner_arg;
set_null= set_null && owner_arg;
a= a1;
b= a2;
- thd= current_thd;
- if (can_compare_as_dates(*a, *b, &const_value))
- {
- a_type= (*a)->field_type();
- b_type= (*b)->field_type();
- a_cache= 0;
- b_cache= 0;
-
- if (const_value != (ulonglong)-1)
- {
- /*
- cache_converted_constant can't be used here because it can't
- correctly convert a DATETIME value from string to int representation.
- */
- Query_arena backup;
- Query_arena *save_arena= thd->switch_to_arena_for_cached_items(&backup);
- Item_cache_int *cache= new Item_cache_int();
- if (save_arena)
- thd->set_query_arena(save_arena);
-
- /* Mark the cache as non-const to prevent re-caching. */
- cache->set_used_tables(1);
- if (!(*a)->is_datetime())
- {
- cache->store_longlong((*a), const_value);
- a_cache= cache;
- a= (Item **)&a_cache;
- }
- else
- {
- cache->store_longlong((*b), const_value);
- b_cache= cache;
- b= (Item **)&b_cache;
- }
- }
- is_nulls_eq= is_owner_equal_func();
- func= &Arg_comparator::compare_datetime;
- get_value_a_func= &get_datetime_value;
- get_value_b_func= &get_datetime_value;
- return 0;
- }
- else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME &&
- (*b)->field_type() == MYSQL_TYPE_TIME)
- {
- /* Compare TIME values as integers. */
- a_cache= 0;
- b_cache= 0;
- is_nulls_eq= is_owner_equal_func();
- func= &Arg_comparator::compare_datetime;
- get_value_a_func= &get_time_value;
- get_value_b_func= &get_time_value;
- return 0;
- }
- else if (type == STRING_RESULT &&
- (*a)->result_type() == STRING_RESULT &&
- (*b)->result_type() == STRING_RESULT)
+ if (type == STRING_RESULT &&
+ (*a)->result_type() == STRING_RESULT &&
+ (*b)->result_type() == STRING_RESULT)
{
DTCollation coll;
coll.set((*a)->collation.collation);
@@ -965,8 +746,10 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
b, 1, MY_COLL_CMP_CONV, 1))
return 1;
}
- else if (try_year_cmp_func(type))
- return 0;
+ if (type == INT_RESULT &&
+ (*a)->field_type() == MYSQL_TYPE_YEAR &&
+ (*b)->field_type() == MYSQL_TYPE_YEAR)
+ type= TIME_RESULT;
a= cache_converted_constant(thd, a, &a_cache, type);
b= cache_converted_constant(thd, b, &b_cache, type);
@@ -974,45 +757,6 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg,
}
-/*
- Helper function to call from Arg_comparator::set_cmp_func()
-*/
-
-bool Arg_comparator::try_year_cmp_func(Item_result type)
-{
- if (type == ROW_RESULT)
- return FALSE;
-
- bool a_is_year= (*a)->field_type() == MYSQL_TYPE_YEAR;
- bool b_is_year= (*b)->field_type() == MYSQL_TYPE_YEAR;
-
- if (!a_is_year && !b_is_year)
- return FALSE;
-
- if (a_is_year && b_is_year)
- {
- get_value_a_func= &get_year_value;
- get_value_b_func= &get_year_value;
- }
- else if (a_is_year && (*b)->is_datetime())
- {
- get_value_a_func= &get_year_value;
- get_value_b_func= &get_datetime_value;
- }
- else if (b_is_year && (*a)->is_datetime())
- {
- get_value_b_func= &get_year_value;
- get_value_a_func= &get_datetime_value;
- }
- else
- return FALSE;
-
- is_nulls_eq= is_owner_equal_func();
- func= &Arg_comparator::compare_datetime;
-
- return TRUE;
-}
-
/**
Convert and cache a constant.
@@ -1034,9 +778,14 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
Item **cache_item,
Item_result type)
{
- /* Don't need cache if doing context analysis only. */
+ /*
+ Don't need cache if doing context analysis only.
+ Also, get_datetime_value creates Item_cache internally.
+ Unless fixed, we should not do it here.
+ */
if (!thd->lex->is_ps_or_view_context_analysis() &&
- (*value)->const_item() && type != (*value)->result_type())
+ (*value)->const_item() && type != (*value)->result_type() &&
+ type != TIME_RESULT)
{
Item_cache *cache= Item_cache::get_cache(*value, type);
cache->setup(*value);
@@ -1054,112 +803,88 @@ void Arg_comparator::set_datetime_cmp_func(Item_result_field *owner_arg,
owner= owner_arg;
a= a1;
b= b1;
- a_type= (*a)->field_type();
- b_type= (*b)->field_type();
a_cache= 0;
b_cache= 0;
- is_nulls_eq= FALSE;
- func= &Arg_comparator::compare_datetime;
- get_value_a_func= &get_datetime_value;
- get_value_b_func= &get_datetime_value;
+ func= comparator_matrix[TIME_RESULT][is_owner_equal_func()];
}
-
-/*
+/**
Retrieves correct DATETIME value from given item.
- SYNOPSIS
- get_datetime_value()
- thd thread handle
- item_arg [in/out] item to retrieve DATETIME value from
- cache_arg [in/out] pointer to place to store the caching item to
- warn_item [in] item for issuing the conversion warning
- is_null [out] TRUE <=> the item_arg is null
+ @param[in] thd thread handle
+ @param[in,out] item_arg item to retrieve DATETIME value from
+ @param[in,out] cache_arg pointer to place to store the caching item to
+ @param[in] warn_item item for issuing the conversion warning
+ @param[out] is_null TRUE <=> the item_arg is null
- DESCRIPTION
+ @details
Retrieves the correct DATETIME value from given item for comparison by the
compare_datetime() function.
- If item's result can be compared as longlong then its int value is used
- and its string value is used otherwise. Strings are always parsed and
- converted to int values by the get_date_from_str() function.
- This allows us to compare correctly string dates with missed insignificant
- zeros. If an item is a constant one then its value is cached and it isn't
- get parsed again. An Item_cache_int object is used for caching values. It
- seamlessly substitutes the original item. The cache item is marked as
- non-constant to prevent re-caching it again. In order to compare
- correctly DATE and DATETIME items the result of the former are treated as
- a DATETIME with zero time (00:00:00).
- RETURN
- obtained value
+ If the value should be compared as time (TIME_RESULT), it's retrieved as
+ MYSQL_TIME. Otherwise it's read as a number/string and converted to time.
+ Constant items are cached, so the convertion is only done once for them.
+
+ Note the f_type behavior: if the item can be compared as time, then
+ f_type is this item's field_type(). Otherwise it's field_type() of
+ warn_item (which is the other operand of the comparison operator).
+ This logic provides correct string/number to date/time conversion
+ depending on the other operand (when comparing a string with a date, it's
+ parsed as a date, when comparing a string with a time it's parsed as a time)
+
+ If the item is a constant it is replaced by the Item_cache_int, that
+ holds the packed datetime value.
+
+ @return
+ MYSQL_TIME value, packed in a longlong, suitable for comparison.
*/
longlong
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null)
{
- longlong value= 0;
- String buf, *str= 0;
+ longlong UNINIT_VAR(value);
Item *item= **item_arg;
+ enum_field_types f_type= item->cmp_type() == TIME_RESULT ?
+ item->field_type() : warn_item->field_type();
- if (item->result_as_longlong())
+ if (item->result_type() == INT_RESULT && item->cmp_type() == TIME_RESULT)
{
+ /* it's our Item_cache_int, as created below */
value= item->val_int();
- *is_null= item->null_value;
- enum_field_types f_type= item->field_type();
- /*
- Item_date_add_interval may return MYSQL_TYPE_STRING as the result
- field type. To detect that the DATE value has been returned we
- compare it with 100000000L - any DATE value should be less than it.
- Don't shift cached DATETIME values up for the second time.
- */
- if (f_type == MYSQL_TYPE_DATE ||
- (f_type != MYSQL_TYPE_DATETIME && value < 100000000L))
- value*= 1000000L;
}
else
{
- str= item->val_str(&buf);
- *is_null= item->null_value;
+ MYSQL_TIME ltime;
+ uint fuzzydate= TIME_FUZZY_DATE | TIME_INVALID_DATES;
+ if (f_type == MYSQL_TYPE_TIME)
+ fuzzydate|= TIME_TIME_ONLY;
+ if (item->get_date(&ltime, fuzzydate))
+ value= 0; /* invalid date */
+ else
+ value= pack_time(&ltime);
}
- if (*is_null)
+ if ((*is_null= item->null_value))
return ~(ulonglong) 0;
- /*
- Convert strings to the integer DATE/DATETIME representation.
- Even if both dates provided in strings we can't compare them directly as
- strings as there is no warranty that they are correct and do not miss
- some insignificant zeros.
- */
- if (str)
+ if (cache_arg && item->const_item() && item->type() != Item::CACHE_ITEM)
{
- bool error;
- enum_field_types f_type= warn_item->field_type();
- timestamp_type t_type= f_type ==
- MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
- value= (longlong) get_date_from_str(thd, str, t_type, warn_item->name, &error);
/*
- If str did not contain a valid date according to the current
- SQL_MODE, get_date_from_str() has already thrown a warning,
- and we don't want to throw NULL on invalid date (see 5.2.6
- "SQL modes" in the manual), so we're done here.
+ cache the packed datetime value in the Item_cache object.
+ Because the packed datetime value is longlong, we use Item_cache_int,
+ and it has result_type() == INT_RESULT.
+ But we create it to have field_type() == MYSQL_TYPE_TIME (or
+ MYSQL_TIMESTAMP_DATE or MYSQL_TYPE_DATETIME), and thus it will have
+ cmp_type() == TIME_RESULT.
+ As no other item can have this combination of cmp_type() and
+ result_type(), it allows us to identify our cache items.
*/
- }
- /*
- Do not cache GET_USER_VAR() function as its const_item() may return TRUE
- for the current thread but it still may change during the execution.
- */
- if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
- ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
- {
Query_arena backup;
Query_arena *save_arena= thd->switch_to_arena_for_cached_items(&backup);
- Item_cache_int *cache= new Item_cache_int(MYSQL_TYPE_DATETIME);
+ Item_cache_temporal *cache= new Item_cache_temporal(f_type);
if (save_arena)
thd->set_query_arena(save_arena);
-
- /* Mark the cache as non-const to prevent re-caching. */
- cache->set_used_tables(1);
- cache->store_longlong(item, value);
+
+ cache->store_packed(value);
*cache_arg= cache;
*item_arg= cache_arg;
}
@@ -1168,67 +893,6 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
/*
- Retrieves YEAR value of 19XX-00-00 00:00:00 form from given item.
-
- SYNOPSIS
- get_year_value()
- thd thread handle
- item_arg [in/out] item to retrieve YEAR value from
- cache_arg [in/out] pointer to place to store the caching item to
- warn_item [in] item for issuing the conversion warning
- is_null [out] TRUE <=> the item_arg is null
-
- DESCRIPTION
- Retrieves the YEAR value of 19XX form from given item for comparison by the
- compare_datetime() function.
- Converts year to DATETIME of form YYYY-00-00 00:00:00 for the compatibility
- with the get_datetime_value function result.
-
- RETURN
- obtained value
-*/
-
-static longlong
-get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null)
-{
- longlong value= 0;
- Item *item= **item_arg;
-
- value= item->val_int();
- *is_null= item->null_value;
- if (*is_null)
- return ~(ulonglong) 0;
-
- /*
- Coerce value to the 19XX form in order to correctly compare
- YEAR(2) & YEAR(4) types.
- Here we are converting all item values but YEAR(4) fields since
- 1) YEAR(4) already has a regular YYYY form and
- 2) we don't want to convert zero/bad YEAR(4) values to the
- value of 2000.
- */
- Item *real_item= item->real_item();
- Field *field= NULL;
- if (real_item->type() == Item::FIELD_ITEM)
- field= ((Item_field *)real_item)->field;
- else if (real_item->type() == Item::CACHE_ITEM)
- field= ((Item_cache *)real_item)->field();
- if (!(field && field->type() == MYSQL_TYPE_YEAR && field->field_length == 4))
- {
- if (value < 70)
- value+= 100;
- if (value <= 1900)
- value+= 1900;
- }
- /* Convert year to DATETIME of form YYYY-00-00 00:00:00 (YYYY0000000000). */
- value*= 10000000000LL;
-
- return value;
-}
-
-
-/*
Compare items values as dates.
SYNOPSIS
@@ -1240,18 +904,9 @@ get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
with help of the get_datetime_value() function.
RETURN
- If is_nulls_eq is TRUE:
- 1 if items are equal or both are null
- 0 otherwise
- If is_nulls_eq is FALSE:
-1 a < b or at least one item is null
0 a == b
1 a > b
- See the table:
- is_nulls_eq | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
- a_is_null | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
- b_is_null | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
- result | 1 | 0 | 0 |0/1|-1 |-1 |-1 |-1/0/1|
*/
int Arg_comparator::compare_datetime()
@@ -1259,34 +914,40 @@ int Arg_comparator::compare_datetime()
bool a_is_null, b_is_null;
longlong a_value, b_value;
+ if (set_null)
+ owner->null_value= 1;
+
/* Get DATE/DATETIME/TIME value of the 'a' item. */
- a_value= (*get_value_a_func)(thd, &a, &a_cache, *b, &a_is_null);
- if (!is_nulls_eq && a_is_null)
- {
- if (set_null)
- owner->null_value= 1;
+ a_value= get_datetime_value(thd, &a, &a_cache, *b, &a_is_null);
+ if (a_is_null)
return -1;
- }
/* Get DATE/DATETIME/TIME value of the 'b' item. */
- b_value= (*get_value_b_func)(thd, &b, &b_cache, *a, &b_is_null);
- if (a_is_null || b_is_null)
- {
- if (set_null)
- owner->null_value= is_nulls_eq ? 0 : 1;
- return is_nulls_eq ? (a_is_null == b_is_null) : -1;
- }
+ b_value= get_datetime_value(thd, &b, &b_cache, *a, &b_is_null);
+ if (b_is_null)
+ return -1;
/* Here we have two not-NULL values. */
if (set_null)
owner->null_value= 0;
/* Compare values. */
- if (is_nulls_eq)
- return (a_value == b_value);
- return a_value < b_value ? -1 : (a_value > b_value ? 1 : 0);
+ return a_value < b_value ? -1 : a_value > b_value ? 1 : 0;
}
+int Arg_comparator::compare_e_datetime()
+{
+ bool a_is_null, b_is_null;
+ longlong a_value, b_value;
+
+ /* Get DATE/DATETIME/TIME value of the 'a' item. */
+ a_value= get_datetime_value(thd, &a, &a_cache, *b, &a_is_null);
+
+ /* Get DATE/DATETIME/TIME value of the 'b' item. */
+ b_value= get_datetime_value(thd, &b, &b_cache, *a, &b_is_null);
+ return a_is_null || b_is_null ? a_is_null == b_is_null
+ : a_value == b_value;
+}
int Arg_comparator::compare_string()
{
@@ -1743,7 +1404,10 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
with_sum_func= args[0]->with_sum_func;
with_field= args[0]->with_field;
if ((const_item_cache= args[0]->const_item()))
+ {
cache->store(args[0]);
+ cache->cache_value();
+ }
return 0;
}
@@ -1798,6 +1462,8 @@ Item *Item_in_optimizer::expr_cache_insert_transformer(uchar *thd_arg)
{
THD *thd= (THD*) thd_arg;
DBUG_ENTER("Item_in_optimizer::expr_cache_insert_transformer");
+ if (args[1]->type() != Item::SUBSELECT_ITEM)
+ DBUG_RETURN(this); // MAX/MIN transformed => do nothing
List<Item*> &depends_on= ((Item_subselect *)args[1])->depends_on;
if (expr_cache)
@@ -1901,7 +1567,15 @@ longlong Item_in_optimizer::val_int()
DBUG_ASSERT(fixed == 1);
cache->store(args[0]);
cache->cache_value();
-
+
+ if (args[1]->type() != Item::SUBSELECT_ITEM)
+ {
+ /* MAX/MIN transformed => pass through */
+ longlong res= args[1]->val_int();
+ null_value= args[1]->null_value;
+ return (res);
+ }
+
if (cache->null_value)
{
/*
@@ -2050,28 +1724,52 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, uchar *argument
if ((*args) != new_item)
current_thd->change_item_tree(args, new_item);
- /*
- Transform the right IN operand which should be an Item_in_subselect or a
- subclass of it. The left operand of the IN must be the same as the left
- operand of this Item_in_optimizer, so in this case there is no further
- transformation, we only make both operands the same.
- TODO: is it the way it should be?
- */
- DBUG_ASSERT((args[1])->type() == Item::SUBSELECT_ITEM &&
- (((Item_subselect*)(args[1]))->substype() ==
- Item_subselect::IN_SUBS ||
- ((Item_subselect*)(args[1]))->substype() ==
- Item_subselect::ALL_SUBS ||
- ((Item_subselect*)(args[1]))->substype() ==
- Item_subselect::ANY_SUBS));
-
- Item_in_subselect *in_arg= (Item_in_subselect*)args[1];
- in_arg->left_expr= args[0];
+ if (args[1]->type() != Item::SUBSELECT_ITEM)
+ {
+ /* MAX/MIN transformed => pass through */
+ new_item= args[1]->transform(transformer, argument);
+ if (!new_item)
+ return 0;
+ if (args[1] != new_item)
+ current_thd->change_item_tree(args, new_item);
+ }
+ else
+ {
+ /*
+ Transform the right IN operand which should be an Item_in_subselect or a
+ subclass of it. The left operand of the IN must be the same as the left
+ operand of this Item_in_optimizer, so in this case there is no further
+ transformation, we only make both operands the same.
+ TODO: is it the way it should be?
+ */
+ DBUG_ASSERT((args[1])->type() == Item::SUBSELECT_ITEM &&
+ (((Item_subselect*)(args[1]))->substype() ==
+ Item_subselect::IN_SUBS ||
+ ((Item_subselect*)(args[1]))->substype() ==
+ Item_subselect::ALL_SUBS ||
+ ((Item_subselect*)(args[1]))->substype() ==
+ Item_subselect::ANY_SUBS));
+ Item_in_subselect *in_arg= (Item_in_subselect*)args[1];
+ in_arg->left_expr= args[0];
+ }
return (this->*transformer)(argument);
}
+bool Item_in_optimizer::is_expensive_processor(uchar *arg)
+{
+ return args[0]->is_expensive_processor(arg) ||
+ args[1]->is_expensive_processor(arg);
+}
+
+
+bool Item_in_optimizer::is_expensive()
+{
+ return args[0]->is_expensive() || args[1]->is_expensive();
+}
+
+
longlong Item_func_eq::val_int()
{
DBUG_ASSERT(fixed == 1);
@@ -2363,6 +2061,16 @@ bool Item_func_between::fix_fields(THD *thd, Item **ref)
thd->lex->current_select->between_count++;
+
+ return 0;
+}
+
+
+bool Item_func_between::eval_not_null_tables(uchar *opt_arg)
+{
+ if (Item_func_opt_neg::eval_not_null_tables(NULL))
+ return 1;
+
/* not_null_tables_cache == union(T1(e),T1(e1),T1(e2)) */
if (pred_level && !negated)
return 0;
@@ -2371,19 +2079,15 @@ bool Item_func_between::fix_fields(THD *thd, Item **ref)
not_null_tables_cache= (args[0]->not_null_tables() |
(args[1]->not_null_tables() &
args[2]->not_null_tables()));
-
return 0;
-}
+}
void Item_func_between::fix_length_and_dec()
{
- max_length= 1;
- int i;
- bool datetime_found= FALSE;
- int time_items_found= 0;
- compare_as_dates= TRUE;
THD *thd= current_thd;
+ max_length= 1;
+ compare_as_dates= 0;
/*
As some compare functions are generated after sql_yacc,
@@ -2398,81 +2102,79 @@ void Item_func_between::fix_length_and_dec()
return;
/*
- Detect the comparison of DATE/DATETIME items.
- At least one of items should be a DATE/DATETIME item and other items
- should return the STRING result.
+ When comparing as date/time, we need to convert non-temporal values
+ (e.g. strings) to MYSQL_TIME. get_datetime_value() does it
+ automatically when one of the operands is a date/time. But here we
+ may need to compare two strings as dates (str1 BETWEEN str2 AND date).
+ For this to work, we need to know what date/time type we compare
+ strings as.
*/
- if (cmp_type == STRING_RESULT)
- {
- for (i= 0; i < 3; i++)
- {
- if (args[i]->is_datetime())
- {
- datetime_found= TRUE;
- continue;
- }
- if (args[i]->field_type() == MYSQL_TYPE_TIME &&
- args[i]->result_as_longlong())
- time_items_found++;
- }
- }
- if (!datetime_found)
- compare_as_dates= FALSE;
+ if (cmp_type == TIME_RESULT)
+ compare_as_dates= find_date_time_item(args, 3, 0);
- if (compare_as_dates)
- {
- ge_cmp.set_datetime_cmp_func(this, args, args + 1);
- le_cmp.set_datetime_cmp_func(this, args, args + 2);
- }
- else if (time_items_found == 3)
- {
- /* Compare TIME items as integers. */
- cmp_type= INT_RESULT;
- }
- else if (args[0]->real_item()->type() == FIELD_ITEM &&
- thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
- thd->lex->sql_command != SQLCOM_SHOW_CREATE)
+ /* See the comment about the similar block in Item_bool_func2 */
+ if (args[0]->real_item()->type() == FIELD_ITEM &&
+ !thd->lex->is_ps_or_view_context_analysis())
{
Item_field *field_item= (Item_field*) (args[0]->real_item());
- if (field_item->field->can_be_compared_as_longlong())
+ if (field_item->cmp_type() == INT_RESULT)
{
/*
- The following can't be recoded with || as convert_constant_item
+ The following can't be recoded with || as convert_const_to_int
changes the argument
*/
- if (convert_constant_item(thd, field_item, &args[1]))
- cmp_type=INT_RESULT; // Works for all types.
- if (convert_constant_item(thd, field_item, &args[2]))
- cmp_type=INT_RESULT; // Works for all types.
+ if (convert_const_to_int(thd, field_item, &args[1]))
+ cmp_type=INT_RESULT;
+ if (convert_const_to_int(thd, field_item, &args[2]))
+ cmp_type=INT_RESULT;
}
}
}
longlong Item_func_between::val_int()
-{ // ANSI BETWEEN
+{
DBUG_ASSERT(fixed == 1);
- if (compare_as_dates)
+
+ switch (cmp_type) {
+ case TIME_RESULT:
{
- int ge_res, le_res;
+ THD *thd= current_thd;
+ longlong value, a, b;
+ Item *cache, **ptr;
+ bool value_is_null, a_is_null, b_is_null;
+
+ ptr= &args[0];
+ value= get_datetime_value(thd, &ptr, &cache, compare_as_dates,
+ &value_is_null);
+ if (ptr != &args[0])
+ thd->change_item_tree(&args[0], *ptr);
- ge_res= ge_cmp.compare();
- if ((null_value= args[0]->null_value))
+ if ((null_value= value_is_null))
return 0;
- le_res= le_cmp.compare();
- if (!args[1]->null_value && !args[2]->null_value)
- return (longlong) ((ge_res >= 0 && le_res <=0) != negated);
- else if (args[1]->null_value)
- {
- null_value= le_res > 0; // not null if false range.
- }
+ ptr= &args[1];
+ a= get_datetime_value(thd, &ptr, &cache, compare_as_dates, &a_is_null);
+ if (ptr != &args[1])
+ thd->change_item_tree(&args[1], *ptr);
+
+ ptr= &args[2];
+ b= get_datetime_value(thd, &ptr, &cache, compare_as_dates, &b_is_null);
+ if (ptr != &args[2])
+ thd->change_item_tree(&args[2], *ptr);
+
+ if (!a_is_null && !b_is_null)
+ return (longlong) ((value >= a && value <= b) != negated);
+ if (a_is_null && b_is_null)
+ null_value=1;
+ else if (a_is_null)
+ null_value= value <= b; // not null if false range.
else
- {
- null_value= ge_res < 0;
- }
+ null_value= value >= a;
+ break;
}
- else if (cmp_type == STRING_RESULT)
+
+ case STRING_RESULT:
{
String *value,*a,*b;
value=args[0]->val_str(&value0);
@@ -2496,8 +2198,9 @@ longlong Item_func_between::val_int()
// Set to not null if false range.
null_value= sortcmp(value,a,cmp_collation.collation) >= 0;
}
+ break;
}
- else if (cmp_type == INT_RESULT)
+ case INT_RESULT:
{
longlong value=args[0]->val_int(), a, b;
if ((null_value=args[0]->null_value))
@@ -2516,8 +2219,9 @@ longlong Item_func_between::val_int()
{
null_value= value >= a;
}
+ break;
}
- else if (cmp_type == DECIMAL_RESULT)
+ case DECIMAL_RESULT:
{
my_decimal dec_buf, *dec= args[0]->val_decimal(&dec_buf),
a_buf, *a_dec, b_buf, *b_dec;
@@ -2534,8 +2238,9 @@ longlong Item_func_between::val_int()
null_value= (my_decimal_cmp(dec, b_dec) <= 0);
else
null_value= (my_decimal_cmp(dec, a_dec) >= 0);
+ break;
}
- else
+ case REAL_RESULT:
{
double value= args[0]->val_real(),a,b;
if ((null_value=args[0]->null_value))
@@ -2554,6 +2259,13 @@ longlong Item_func_between::val_int()
{
null_value= value >= a;
}
+ break;
+ }
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0);
+ null_value= 1;
+ return 0;
}
return (longlong) (!null_value && negated);
}
@@ -2604,7 +2316,8 @@ Item_func_ifnull::fix_length_and_dec()
decimals= 0;
break;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
cached_field_type= agg_field_type(args, 2);
@@ -2734,13 +2447,22 @@ Item_func_if::fix_fields(THD *thd, Item **ref)
if (Item_func::fix_fields(thd, ref))
return 1;
+ return 0;
+}
+
+
+bool
+Item_func_if::eval_not_null_tables(uchar *opt_arg)
+{
+ if (Item_func::eval_not_null_tables(NULL))
+ return 1;
+
not_null_tables_cache= (args[1]->not_null_tables() &
args[2]->not_null_tables());
return 0;
}
-
void
Item_func_if::fix_length_and_dec()
{
@@ -3171,16 +2893,17 @@ void Item_func_case::fix_length_and_dec()
found_types |= (1 << item_cmp_type(left_result_type, STRING_RESULT));
}
- for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
+ for (i= 0; i <= (uint)TIME_RESULT; i++)
{
if (found_types & (1 << i) && !cmp_items[i])
{
DBUG_ASSERT((Item_result)i != ROW_RESULT);
+ DBUG_ASSERT((Item_result)i != TIME_RESULT);
if ((Item_result)i == STRING_RESULT &&
agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV, 1))
return;
if (!(cmp_items[i]=
- cmp_item::get_comparator((Item_result)i,
+ cmp_item::get_comparator((Item_result)i, 0,
cmp_collation.collation)))
return;
}
@@ -3260,7 +2983,7 @@ void Item_func_case::cleanup()
uint i;
DBUG_ENTER("Item_func_case::cleanup");
Item_func::cleanup();
- for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
+ for (i= 0; i <= (uint)TIME_RESULT; i++)
{
delete cmp_items[i];
cmp_items[i]= 0;
@@ -3316,6 +3039,21 @@ double Item_func_coalesce::real_op()
}
+bool Item_func_coalesce::get_date(MYSQL_TIME *ltime,uint fuzzydate)
+{
+ DBUG_ASSERT(fixed == 1);
+ null_value= 0;
+ for (uint i= 0; i < arg_count; i++)
+ {
+ bool res= args[i]->get_date(ltime, fuzzydate);
+ if (!args[i]->null_value)
+ return res;
+ }
+ null_value=1;
+ return 1;
+}
+
+
my_decimal *Item_func_coalesce::decimal_op(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed == 1);
@@ -3335,6 +3073,14 @@ void Item_func_coalesce::fix_length_and_dec()
{
cached_field_type= agg_field_type(args, arg_count);
agg_result_type(&hybrid_type, args, arg_count);
+ Item_result cmp_type;
+ agg_cmp_type(&cmp_type, args, arg_count);
+ ///< @todo let result_type() return TIME_RESULT and remove this special case
+ if (cmp_type == TIME_RESULT)
+ {
+ count_real_length();
+ return;
+ }
switch (hybrid_type) {
case STRING_RESULT:
count_only_length();
@@ -3352,7 +3098,8 @@ void Item_func_coalesce::fix_length_and_dec()
decimals= 0;
break;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
}
@@ -3667,7 +3414,7 @@ uchar *in_decimal::get_value(Item *item)
}
-cmp_item* cmp_item::get_comparator(Item_result type,
+cmp_item* cmp_item::get_comparator(Item_result type, Item *warn_item,
CHARSET_INFO *cs)
{
switch (type) {
@@ -3681,7 +3428,9 @@ cmp_item* cmp_item::get_comparator(Item_result type,
return new cmp_item_row;
case DECIMAL_RESULT:
return new cmp_item_decimal;
- default:
+ case TIME_RESULT:
+ return new cmp_item_datetime(warn_item);
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
break;
}
@@ -3746,7 +3495,7 @@ void cmp_item_row::store_value(Item *item)
{
if (!comparators[i])
if (!(comparators[i]=
- cmp_item::get_comparator(item->element_index(i)->result_type(),
+ cmp_item::get_comparator(item->element_index(i)->result_type(), 0,
item->element_index(i)->collation.collation)))
break; // new failed
comparators[i]->store_value(item->element_index(i));
@@ -3922,11 +3671,22 @@ bool Item_func_in::nulls_in_row()
bool
Item_func_in::fix_fields(THD *thd, Item **ref)
{
- Item **arg, **arg_end;
if (Item_func_opt_neg::fix_fields(thd, ref))
return 1;
+ return 0;
+}
+
+
+bool
+Item_func_in::eval_not_null_tables(uchar *opt_arg)
+{
+ Item **arg, **arg_end;
+
+ if (Item_func_opt_neg::eval_not_null_tables(NULL))
+ return 1;
+
/* not_null_tables_cache == union(T1(e),union(T1(ei))) */
if (pred_level && negated)
return 0;
@@ -3947,20 +3707,17 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y)
(uchar *) y->ptr(),y->length(), 0);
}
-
void Item_func_in::fix_length_and_dec()
{
Item **arg, **arg_end;
bool const_itm= 1;
THD *thd= current_thd;
- bool datetime_found= FALSE;
/* TRUE <=> arguments values will be compared as DATETIMEs. */
- bool compare_as_datetime= FALSE;
Item *date_arg= 0;
uint found_types= 0;
uint type_cnt= 0, i;
Item_result cmp_type= STRING_RESULT;
- left_result_type= args[0]->result_type();
+ left_result_type= args[0]->cmp_type();
if (!(found_types= collect_cmp_types(args, arg_count, true)))
return;
@@ -3972,7 +3729,7 @@ void Item_func_in::fix_length_and_dec()
break;
}
}
- for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
+ for (i= 0; i <= (uint)TIME_RESULT; i++)
{
if (found_types & 1 << i)
{
@@ -3987,16 +3744,12 @@ void Item_func_in::fix_length_and_dec()
agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV, 1))
return;
arg_types_compatible= TRUE;
- }
- if (type_cnt == 1)
- {
- /*
- When comparing rows create the row comparator object beforehand to ease
- the DATETIME comparison detection procedure.
- */
+
if (cmp_type == ROW_RESULT)
{
+ uint cols= args[0]->cols();
cmp_item_row *cmp= 0;
+
if (const_itm && !nulls_in_row())
{
array= new in_row(arg_count-1, 0);
@@ -4008,66 +3761,20 @@ void Item_func_in::fix_length_and_dec()
return;
cmp_items[ROW_RESULT]= cmp;
}
- cmp->n= args[0]->cols();
+ cmp->n= cols;
cmp->alloc_comparators();
- }
- /* All DATE/DATETIME fields/functions has the STRING result type. */
- if (cmp_type == STRING_RESULT || cmp_type == ROW_RESULT)
- {
- uint col, cols= args[0]->cols();
- for (col= 0; col < cols; col++)
+ for (uint col= 0; col < cols; col++)
{
- bool skip_column= FALSE;
- /*
- Check that all items to be compared has the STRING result type and at
- least one of them is a DATE/DATETIME item.
- */
- for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++)
- {
- Item *itm= ((cmp_type == STRING_RESULT) ? arg[0] :
- arg[0]->element_index(col));
- if (itm->result_type() != STRING_RESULT)
- {
- skip_column= TRUE;
- break;
- }
- else if (itm->is_datetime())
- {
- datetime_found= TRUE;
- /*
- Internally all DATE/DATETIME values are converted to the DATETIME
- type. So try to find a DATETIME item to issue correct warnings.
- */
- if (!date_arg)
- date_arg= itm;
- else if (itm->field_type() == MYSQL_TYPE_DATETIME)
- {
- date_arg= itm;
- /* All arguments are already checked to have the STRING result. */
- if (cmp_type == STRING_RESULT)
- break;
- }
- }
- }
- if (skip_column)
- continue;
- if (datetime_found)
+ date_arg= find_date_time_item(args, arg_count, col);
+ if (date_arg)
{
- if (cmp_type == ROW_RESULT)
- {
- cmp_item **cmp= 0;
- if (array)
- cmp= ((in_row*)array)->tmp.comparators + col;
- else
- cmp= ((cmp_item_row*)cmp_items[ROW_RESULT])->comparators + col;
- *cmp= new cmp_item_datetime(date_arg);
- /* Reset variables for the next column. */
- date_arg= 0;
- datetime_found= FALSE;
- }
+ cmp_item **cmp= 0;
+ if (array)
+ cmp= ((in_row*)array)->tmp.comparators + col;
else
- compare_as_datetime= TRUE;
+ cmp= ((cmp_item_row*)cmp_items[ROW_RESULT])->comparators + col;
+ *cmp= new cmp_item_datetime(date_arg);
}
}
}
@@ -4078,74 +3785,71 @@ void Item_func_in::fix_length_and_dec()
*/
if (type_cnt == 1 && const_itm && !nulls_in_row())
{
- if (compare_as_datetime)
- array= new in_datetime(date_arg, arg_count - 1);
- else
+ /*
+ IN must compare INT columns and constants as int values (the same
+ way as equality does).
+ So we must check here if the column on the left and all the constant
+ values on the right can be compared as integers and adjust the
+ comparison type accordingly.
+
+ See the comment about the similar block in Item_bool_func2
+ */
+ if (args[0]->real_item()->type() == FIELD_ITEM &&
+ !thd->lex->is_ps_or_view_context_analysis() && cmp_type != INT_RESULT)
{
- /*
- IN must compare INT columns and constants as int values (the same
- way as equality does).
- So we must check here if the column on the left and all the constant
- values on the right can be compared as integers and adjust the
- comparison type accordingly.
- */
- if (args[0]->real_item()->type() == FIELD_ITEM &&
- thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
- thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
- cmp_type != INT_RESULT)
+ Item_field *field_item= (Item_field*) (args[0]->real_item());
+ if (field_item->cmp_type() == INT_RESULT)
{
- Item_field *field_item= (Item_field*) (args[0]->real_item());
- if (field_item->field->can_be_compared_as_longlong())
+ bool all_converted= TRUE;
+ for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
{
- bool all_converted= TRUE;
- for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
- {
- if (!convert_constant_item (thd, field_item, &arg[0]))
- all_converted= FALSE;
- }
- if (all_converted)
- cmp_type= INT_RESULT;
+ if (!convert_const_to_int(thd, field_item, &arg[0]))
+ all_converted= FALSE;
}
+ if (all_converted)
+ cmp_type= INT_RESULT;
}
- switch (cmp_type) {
- case STRING_RESULT:
- array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
- cmp_collation.collation);
- break;
- case INT_RESULT:
- array= new in_longlong(arg_count-1);
- break;
- case REAL_RESULT:
- array= new in_double(arg_count-1);
- break;
- case ROW_RESULT:
- /*
- The row comparator was created at the beginning but only DATETIME
- items comparators were initialized. Call store_value() to setup
- others.
- */
- ((in_row*)array)->tmp.store_value(args[0]);
- break;
- case DECIMAL_RESULT:
- array= new in_decimal(arg_count - 1);
- break;
- default:
- DBUG_ASSERT(0);
- return;
- }
+ }
+ switch (cmp_type) {
+ case STRING_RESULT:
+ array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
+ cmp_collation.collation);
+ break;
+ case INT_RESULT:
+ array= new in_longlong(arg_count-1);
+ break;
+ case REAL_RESULT:
+ array= new in_double(arg_count-1);
+ break;
+ case ROW_RESULT:
+ /*
+ The row comparator was created at the beginning but only DATETIME
+ items comparators were initialized. Call store_value() to setup
+ others.
+ */
+ ((in_row*)array)->tmp.store_value(args[0]);
+ break;
+ case DECIMAL_RESULT:
+ array= new in_decimal(arg_count - 1);
+ break;
+ case TIME_RESULT:
+ date_arg= find_date_time_item(args, arg_count, 0);
+ array= new in_datetime(date_arg, arg_count - 1);
+ break;
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0);
+ break;
}
if (array && !(thd->is_fatal_error)) // If not EOM
{
uint j=0;
for (uint i=1 ; i < arg_count ; i++)
{
- if (!args[i]->null_value) // Skip NULL values
- {
- array->set(j,args[i]);
- j++;
- }
- else
- have_null= 1;
+ array->set(j,args[i]);
+ if (!args[i]->null_value) // Skip NULL values
+ j++;
+ else
+ have_null= 1;
}
if ((array->used_count= j))
array->sort();
@@ -4153,23 +3857,21 @@ void Item_func_in::fix_length_and_dec()
}
else
{
- if (compare_as_datetime)
- cmp_items[STRING_RESULT]= new cmp_item_datetime(date_arg);
- else
+ for (i= 0; i <= (uint) TIME_RESULT; i++)
{
- for (i= 0; i <= (uint) DECIMAL_RESULT; i++)
+ if (found_types & (1 << i) && !cmp_items[i])
{
- if (found_types & (1 << i) && !cmp_items[i])
- {
- if ((Item_result)i == STRING_RESULT &&
- agg_arg_charsets(cmp_collation, args, arg_count,
- MY_COLL_CMP_CONV, 1))
- return;
- if (!cmp_items[i] && !(cmp_items[i]=
- cmp_item::get_comparator((Item_result)i,
- cmp_collation.collation)))
- return;
- }
+ if ((Item_result)i == STRING_RESULT &&
+ agg_arg_charsets(cmp_collation, args, arg_count,
+ MY_COLL_CMP_CONV, 1))
+ return;
+ if ((Item_result)i == TIME_RESULT)
+ date_arg= find_date_time_item(args, arg_count, 0);
+
+ if (!cmp_items[i] && !(cmp_items[i]=
+ cmp_item::get_comparator((Item_result)i, date_arg,
+ cmp_collation.collation)))
+ return;
}
}
}
@@ -4237,7 +3939,7 @@ longlong Item_func_in::val_int()
have_null= TRUE;
continue;
}
- Item_result cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
+ Item_result cmp_type= item_cmp_type(left_result_type, args[i]->cmp_type());
in_item= cmp_items[(uint)cmp_type];
DBUG_ASSERT(in_item);
if (!(value_added_map & (1 << (uint)cmp_type)))
@@ -4355,7 +4057,6 @@ Item_cond::fix_fields(THD *thd, Item **ref)
*/
while ((item=li++))
{
- table_map tmp_table_map;
while (item->type() == Item::COND_ITEM &&
((Item_cond*) item)->functype() == functype() &&
!((Item_cond*) item)->list.is_empty())
@@ -4377,11 +4078,12 @@ Item_cond::fix_fields(THD *thd, Item **ref)
and_tables_cache= (table_map) 0;
else
{
- tmp_table_map= item->not_null_tables();
+ table_map tmp_table_map= item->not_null_tables();
not_null_tables_cache|= tmp_table_map;
and_tables_cache&= tmp_table_map;
const_item_cache= FALSE;
- }
+ }
+
with_sum_func= with_sum_func || item->with_sum_func;
with_field= with_field || item->with_field;
with_subselect|= item->with_subselect;
@@ -4396,6 +4098,28 @@ Item_cond::fix_fields(THD *thd, Item **ref)
}
+bool
+Item_cond::eval_not_null_tables(uchar *opt_arg)
+{
+ Item *item;
+ List_iterator<Item> li(list);
+ and_tables_cache= ~(table_map) 0;
+ while ((item=li++))
+ {
+ table_map tmp_table_map;
+ if (item->const_item())
+ and_tables_cache= (table_map) 0;
+ else
+ {
+ tmp_table_map= item->not_null_tables();
+ not_null_tables_cache|= tmp_table_map;
+ and_tables_cache&= tmp_table_map;
+ }
+ }
+ return 0;
+}
+
+
void Item_cond::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
List_iterator<Item> li(list);
@@ -4739,12 +4463,6 @@ Item *and_expressions(Item *a, Item *b, Item **org_item)
longlong Item_func_isnull::val_int()
{
DBUG_ASSERT(fixed == 1);
- /*
- Handle optimization if the argument can't be null
- This has to be here because of the test in update_used_tables().
- */
- if (!used_tables_cache && !with_subselect)
- return cached_value;
return args[0]->is_null() ? 1: 0;
}
@@ -4752,12 +4470,6 @@ longlong Item_is_not_null_test::val_int()
{
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_is_not_null_test::val_int");
- if (!used_tables_cache && !with_subselect)
- {
- owner->was_null|= (!cached_value);
- DBUG_PRINT("info", ("cached: %ld", (long) cached_value));
- DBUG_RETURN(cached_value);
- }
if (args[0]->is_null())
{
DBUG_PRINT("info", ("null"));
@@ -4774,19 +4486,9 @@ longlong Item_is_not_null_test::val_int()
void Item_is_not_null_test::update_used_tables()
{
if (!args[0]->maybe_null)
- {
used_tables_cache= 0; /* is always true */
- cached_value= (longlong) 1;
- }
else
- {
args[0]->update_used_tables();
- if (!(used_tables_cache=args[0]->used_tables()) && !with_subselect)
- {
- /* Remember if the value is always NULL or never NULL */
- cached_value= (longlong) !args[0]->is_null();
- }
- }
}
@@ -5464,7 +5166,7 @@ Item *Item_func_nop_all::neg_transformer(THD *thd)
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
Item_func_not_all *new_item= new Item_func_not_all(args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
- allany->func= allany->func_creator(FALSE);
+ allany->create_comp_func(FALSE);
allany->all= !allany->all;
allany->upper_item= new_item;
return new_item;
@@ -5476,7 +5178,7 @@ Item *Item_func_not_all::neg_transformer(THD *thd)
Item_func_nop_all *new_item= new Item_func_nop_all(args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
allany->all= !allany->all;
- allany->func= allany->func_creator(TRUE);
+ allany->create_comp_func(TRUE);
allany->upper_item= new_item;
return new_item;
}
@@ -5547,9 +5249,9 @@ Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item)
{
const_item_cache= 0;
with_const= with_const_item;
- compare_as_dates= with_const_item && f2->is_datetime();
equal_items.push_back(f1);
equal_items.push_back(f2);
+ compare_as_dates= with_const_item && f2->cmp_type() == TIME_RESULT;
}
@@ -5606,7 +5308,7 @@ void Item_equal::add_const(Item *c, Item *f)
{
with_const= TRUE;
if (f)
- compare_as_dates= f->is_datetime();
+ compare_as_dates= f->cmp_type() == TIME_RESULT;
equal_items.push_front(c);
return;
}
@@ -5627,7 +5329,6 @@ void Item_equal::add_const(Item *c, Item *f)
const_item_cache= 1;
}
-
/**
@brief
Check whether a field is referred to in the multiple equality
@@ -5743,7 +5444,7 @@ void Item_equal::update_const()
Item *item;
while ((item= it++))
{
- if (item->const_item())
+ if (item->const_item() && !item->is_expensive())
{
if (item == equal_items.head())
with_const= TRUE;
@@ -5878,7 +5579,7 @@ longlong Item_equal::val_int()
void Item_equal::fix_length_and_dec()
{
Item *item= get_first(NULL);
- eval_item= cmp_item::get_comparator(item->result_type(),
+ eval_item= cmp_item::get_comparator(item->result_type(), 0,
item->collation.collation);
}
@@ -5923,6 +5624,11 @@ Item *Item_equal::transform(Item_transformer transformer, uchar *arg)
void Item_equal::print(String *str, enum_query_type query_type)
{
+ if (cond_false)
+ {
+ str->append('0');
+ return;
+ }
str->append(func_name());
str->append('(');
List_iterator_fast<Item> it(equal_items);
@@ -6009,28 +5715,12 @@ Item* Item_equal::get_first(Item *field_item)
{
/*
It's a field from an materialized semi-join. We can substitute it only
- for a field from the same semi-join.
+ for a field from the same semi-join. Find the first of such items.
*/
- JOIN_TAB *first= field_tab;
- JOIN *join= field_tab->join;
- int tab_idx= field_tab - field_tab->join->join_tab;
-
- DBUG_ASSERT(join->join_tab[tab_idx].table->map &
- emb_nest->sj_inner_tables);
- /* Find the first table of this semi-join nest */
- for (int i= tab_idx-1; i >= (int)join->const_tables; i--)
- {
- if (join->join_tab[i].table->map & emb_nest->sj_inner_tables)
- first= join->join_tab + i;
- else
- // Found first tab that doesn't belong to current SJ.
- break;
- }
- /* Find an item to substitute for. */
while ((item= it++))
{
- if (it.get_curr_field()->table->reginfo.join_tab >= first)
+ if (it.get_curr_field()->table->pos_in_table_list->embedding == emb_nest)
{
/*
If we found given field then return NULL to avoid unnecessary
@@ -6042,36 +5732,62 @@ Item* Item_equal::get_first(Item *field_item)
}
else
{
-#if 0
/*
The field is not in SJ-Materialization nest. We must return the first
- field that's not embedded in a SJ-Materialization nest.
- Example: suppose we have a join order:
+ field in the join order. The field may be inside a semi-join nest, i.e
+ a join order may look like this:
SJ-Mat(it1 it2) ot1 ot2
- and equality ot2.col = ot1.col = it2.col
- If we're looking for best substitute for 'ot2.col', we should pick ot1.col
- and not it2.col, because when we run a join between ot1 and ot2
- execution of SJ-Mat(...) has already finished and we can't rely on the
- value of it*.*.
- psergey-fix-fix: ^^ THAT IS INCORRECT ^^. Pick the first, whatever that
- is.
+ where we're looking what to substitute ot2.col for. In this case we must
+ still return it1.col, here's a proof why:
+
+ First let's note that either it1.col or it2.col participates in
+ subquery's IN-equality. It can't be otherwise, because materialization is
+ only applicable to uncorrelated subqueries, so the only way we could
+ infer "it1.col=ot1.col" is from the IN-equality. Ok, so IN-eqality has
+ it1.col or it2.col on its inner side. it1.col is first such item in the
+ join order, so it's not possible for SJ-Mat to be
+ SJ-Materialization-lookup, it is SJ-Materialization-Scan. The scan part
+ of this strategy will unpack value of it1.col=it2.col into it1.col
+ (that's the first equal item inside the subquery), and we'll be able to
+ get it from there. qed.
*/
- while ((item= it++))
- {
- Item_field *fld_item= (Item_field *) (item->real_item());
- TABLE_LIST *emb_nest= fld_item->field->table->pos_in_table_list->embedding;
- if (!emb_nest || !emb_nest->sj_mat_info ||
- !emb_nest->sj_mat_info->is_used)
- {
- return item;
- }
- }
-#endif
+
return equal_items.head();
}
// Shouldn't get here.
DBUG_ASSERT(0);
return NULL;
}
+
+
+longlong Item_func_dyncol_exists::val_int()
+{
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String tmp(buff, sizeof(buff), &my_charset_bin);
+ DYNAMIC_COLUMN col;
+ String *str;
+ ulonglong num;
+ enum enum_dyncol_func_result rc;
+
+ num= args[1]->val_int();
+ str= args[0]->val_str(&tmp);
+ if (args[0]->null_value || args[1]->null_value || num > UINT_MAX16)
+ goto null;
+ col.length= str->length();
+ /* We do not change the string, so could do this trick */
+ col.str= (char *)str->ptr();
+ rc= dynamic_column_exists(&col, (uint) num);
+ if (rc < 0)
+ {
+ dynamic_column_error_message(rc);
+ goto null;
+ }
+ null_value= FALSE;
+ return rc == ER_DYNCOL_YES;
+
+null:
+ null_value= TRUE;
+ return 0;
+}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 9f4efbc08be..285367ba9d6 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,32 +34,22 @@ class Arg_comparator: public Sql_alloc
Item **a, **b;
arg_cmp_func func;
Item_result_field *owner;
+ bool set_null; // TRUE <=> set owner->null_value
Arg_comparator *comparators; // used only for compare_row()
double precision;
/* Fields used in DATE/DATETIME comparison. */
THD *thd;
- enum_field_types a_type, b_type; // Types of a and b items
Item *a_cache, *b_cache; // Cached values of a and b items
- bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
- bool set_null; // TRUE <=> set owner->null_value
// when one of arguments is NULL.
- enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
- CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
- longlong (*get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null);
- longlong (*get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg,
- Item *warn_item, bool *is_null);
- bool try_year_cmp_func(Item_result type);
public:
DTCollation cmp_collation;
/* Allow owner function to use string buffers. */
String value1, value2;
- Arg_comparator(): comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE),
- get_value_a_func(0), get_value_b_func(0) {};
- Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), comparators(0), thd(0),
- a_cache(0), b_cache(0), set_null(TRUE),
- get_value_a_func(0), get_value_b_func(0) {};
+ Arg_comparator(): set_null(TRUE), comparators(0), thd(0),
+ a_cache(0), b_cache(0) {};
+ Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), set_null(TRUE),
+ comparators(0), thd(0), a_cache(0), b_cache(0) {};
int set_compare_func(Item_result_field *owner, Item_result type);
inline int set_compare_func(Item_result_field *owner_arg)
@@ -75,8 +66,8 @@ public:
{
set_null= set_null_arg;
return set_cmp_func(owner_arg, a1, a2,
- item_cmp_type((*a1)->result_type(),
- (*a2)->result_type()));
+ item_cmp_type((*a1)->cmp_type(),
+ (*a2)->cmp_type()));
}
inline int compare() { return (this->*func)(); }
@@ -99,14 +90,12 @@ public:
int compare_real_fixed();
int compare_e_real_fixed();
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
-
- static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
- ulonglong *const_val_arg);
+ int compare_e_datetime();
Item** cache_converted_constant(THD *thd, Item **value, Item **cache,
Item_result type);
void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1, Item **b1);
- static arg_cmp_func comparator_matrix [5][2];
+ static arg_cmp_func comparator_matrix [6][2];
inline bool is_owner_equal_func()
{
return (owner->type() == Item::FUNC_ITEM &&
@@ -266,6 +255,10 @@ public:
void keep_top_level_cache();
Item *transform(Item_transformer transformer, uchar *arg);
virtual Item *expr_cache_insert_transformer(uchar *thd_arg);
+ bool is_expensive_processor(uchar *arg);
+ bool is_expensive();
+ void set_join_tab_idx(uint join_tab_idx_arg)
+ { args[1]->set_join_tab_idx(join_tab_idx_arg); }
};
class Comp_creator
@@ -392,7 +385,10 @@ public:
}
Item *neg_transformer(THD *thd);
virtual Item *negated_item();
- bool subst_argument_checker(uchar **arg) { return TRUE; }
+ bool subst_argument_checker(uchar **arg)
+ {
+ return (*arg != NULL);
+ }
};
class Item_func_not :public Item_bool_func
@@ -628,9 +624,7 @@ public:
Item_result cmp_type;
String value0,value1,value2;
/* TRUE <=> arguments will be compared as dates. */
- bool compare_as_dates;
- /* Comparators used for DATE/DATETIME comparison. */
- Arg_comparator ge_cmp, le_cmp;
+ Item *compare_as_dates;
Item_func_between(Item *a, Item *b, Item *c)
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {}
longlong val_int();
@@ -643,6 +637,7 @@ public:
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
uint decimal_precision() const { return 1; }
+ bool eval_not_null_tables(uchar *opt_arg);
};
@@ -703,6 +698,7 @@ public:
const char *func_name() const { return "coalesce"; }
table_map not_null_tables() const { return 0; }
enum_field_types field_type() const { return cached_field_type; }
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
};
@@ -742,6 +738,7 @@ public:
void fix_length_and_dec();
uint decimal_precision() const;
const char *func_name() const { return "if"; }
+ bool eval_not_null_tables(uchar *opt_arg);
};
@@ -908,6 +905,16 @@ public:
lval_cache(0) {};
void set(uint pos,Item *item);
uchar *get_value(Item *item);
+ Item* create_item()
+ {
+ return new Item_datetime();
+ }
+ void value_to_item(uint pos, Item *item)
+ {
+ packed_longlong *val= reinterpret_cast<packed_longlong*>(base)+pos;
+ Item_datetime *dt= reinterpret_cast<Item_datetime*>(item);
+ dt->set(val->val);
+ }
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
};
@@ -967,7 +974,8 @@ public:
virtual int cmp(Item *item)= 0;
// for optimized IN with row
virtual int compare(cmp_item *item)= 0;
- static cmp_item* get_comparator(Item_result type, CHARSET_INFO *cs);
+ static cmp_item* get_comparator(Item_result type, Item * warn_item,
+ CHARSET_INFO *cs);
virtual cmp_item *make_same()= 0;
virtual void store_value_by_template(cmp_item *tmpl, Item *item)
{
@@ -1163,7 +1171,7 @@ class Item_func_case :public Item_func
Item_result cmp_type;
DTCollation cmp_collation;
enum_field_types cached_field_type;
- cmp_item *cmp_items[5]; /* For all result types */
+ cmp_item *cmp_items[6]; /* For all result types */
cmp_item *case_item;
public:
Item_func_case(List<Item> &list, Item *first_expr_arg, Item *else_expr_arg)
@@ -1253,7 +1261,7 @@ public:
Item_int_func::cleanup();
delete array;
array= 0;
- for (i= 0; i <= (uint)DECIMAL_RESULT + 1; i++)
+ for (i= 0; i <= (uint)TIME_RESULT; i++)
{
delete cmp_items[i];
cmp_items[i]= 0;
@@ -1268,6 +1276,7 @@ public:
bool nulls_in_row();
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
+ bool eval_not_null_tables(uchar *opt_arg);
};
class cmp_item_row :public cmp_item
@@ -1303,8 +1312,6 @@ public:
class Item_func_isnull :public Item_bool_func
{
-protected:
- longlong cached_value;
public:
Item_func_isnull(Item *a) :Item_bool_func(a) {}
longlong val_int();
@@ -1322,18 +1329,9 @@ public:
{
used_tables_cache= 0; /* is always false */
const_item_cache= 1;
- cached_value= (longlong) 0;
}
else
- {
args[0]->update_used_tables();
- if ((const_item_cache= !(used_tables_cache= args[0]->used_tables()) &&
- !with_subselect))
- {
- /* Remember if the value is always NULL or never NULL */
- cached_value= (longlong) args[0]->is_null();
- }
- }
}
table_map not_null_tables() const { return 0; }
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
@@ -1534,6 +1532,7 @@ public:
bool subst_argument_checker(uchar **arg) { return TRUE; }
Item *compile(Item_analyzer analyzer, uchar **arg_p,
Item_transformer transformer, uchar *arg_t);
+ bool eval_not_null_tables(uchar *opt_arg);
};
@@ -1869,3 +1868,11 @@ Item *and_expressions(Item *a, Item *b, Item **org_item);
bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
const char *warn_name, MYSQL_TIME *l_time);
+
+class Item_func_dyncol_exists :public Item_bool_func
+{
+public:
+ Item_func_dyncol_exists(Item *str, Item *num) :Item_bool_func(str, num) {}
+ longlong val_int();
+ const char *func_name() const { return "column_exists"; }
+};
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 8ff38bc4bc0..2a8f7eec52a 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -27,6 +27,69 @@
/*
=============================================================================
+ HELPER FUNCTIONS
+=============================================================================
+*/
+
+static const char* item_name(Item *a, String *str)
+{
+ if (a->name)
+ return a->name;
+ str->length(0);
+ a->print(str, QT_ORDINARY);
+ return str->c_ptr_safe();
+}
+
+
+static void wrong_precision_error(uint errcode, Item *a,
+ ulonglong number, ulong maximum)
+{
+ char buff[1024];
+ String buf(buff, sizeof(buff), system_charset_info);
+
+ my_error(errcode, MYF(0), (uint) min(number, UINT_MAX32),
+ item_name(a, &buf), maximum);
+}
+
+
+/**
+ Get precision and scale for a declaration
+
+ return
+ 0 ok
+ 1 error
+*/
+
+bool get_length_and_scale(ulonglong length, ulonglong decimals,
+ ulong *out_length, uint *out_decimals,
+ uint max_precision, uint max_scale,
+ Item *a)
+{
+ if (length > (ulonglong) max_precision)
+ {
+ wrong_precision_error(ER_TOO_BIG_PRECISION, a, length, max_precision);
+ return 1;
+ }
+ if (decimals > (ulonglong) max_scale)
+ {
+ wrong_precision_error(ER_TOO_BIG_SCALE, a, decimals, max_scale);
+ return 1;
+ }
+
+ *out_length= (ulong) length;
+ *out_decimals= (uint) decimals;
+ my_decimal_trim(out_length, out_decimals);
+
+ if (*out_length < *out_decimals)
+ {
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
+ return 1;
+ }
+ return 0;
+}
+
+/*
+=============================================================================
LOCAL DECLARATIONS
=============================================================================
*/
@@ -5387,6 +5450,17 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
CHARSET_INFO *cs)
{
Item *UNINIT_VAR(res);
+ ulonglong length= 0, decimals= 0;
+ int error;
+
+ /*
+ We don't have to check for error here as sql_yacc.yy has guaranteed
+ that the values are in range of ulonglong
+ */
+ if (c_len)
+ length= (ulonglong) my_strtoll10(c_len, NULL, &error);
+ if (c_dec)
+ decimals= (ulonglong) my_strtoll10(c_dec, NULL, &error);
switch (cast_type) {
case ITEM_CAST_BINARY:
@@ -5402,62 +5476,50 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
res= new (thd->mem_root) Item_date_typecast(a);
break;
case ITEM_CAST_TIME:
- res= new (thd->mem_root) Item_time_typecast(a);
- break;
- case ITEM_CAST_DATETIME:
- res= new (thd->mem_root) Item_datetime_typecast(a);
- break;
- case ITEM_CAST_DECIMAL:
- {
- ulong len= 0;
- uint dec= 0;
-
- if (c_len)
+ if (decimals > MAX_DATETIME_PRECISION)
{
- ulong decoded_size;
- errno= 0;
- decoded_size= strtoul(c_len, NULL, 10);
- if (errno != 0)
- {
- my_error(ER_TOO_BIG_PRECISION, MYF(0), c_len, a->name,
- DECIMAL_MAX_PRECISION);
- return NULL;
- }
- len= decoded_size;
- }
-
- if (c_dec)
- {
- ulong decoded_size;
- errno= 0;
- decoded_size= strtoul(c_dec, NULL, 10);
- if ((errno != 0) || (decoded_size > UINT_MAX))
- {
- my_error(ER_TOO_BIG_SCALE, MYF(0), c_dec, a->name,
- DECIMAL_MAX_SCALE);
- return NULL;
- }
- dec= decoded_size;
- }
- my_decimal_trim(&len, &dec);
- if (len < dec)
- {
- my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
+ wrong_precision_error(ER_TOO_BIG_PRECISION, a, decimals,
+ MAX_DATETIME_PRECISION);
return 0;
}
- if (len > DECIMAL_MAX_PRECISION)
+ res= new (thd->mem_root) Item_time_typecast(a, (uint) decimals);
+ break;
+ case ITEM_CAST_DATETIME:
+ if (decimals > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
- DECIMAL_MAX_PRECISION);
+ wrong_precision_error(ER_TOO_BIG_PRECISION, a, decimals,
+ MAX_DATETIME_PRECISION);
return 0;
}
- if (dec > DECIMAL_MAX_SCALE)
+ res= new (thd->mem_root) Item_datetime_typecast(a, (uint) decimals);
+ break;
+ case ITEM_CAST_DECIMAL:
+ {
+ ulong len;
+ uint dec;
+ if (get_length_and_scale(length, decimals, &len, &dec,
+ DECIMAL_MAX_PRECISION, DECIMAL_MAX_SCALE,
+ a))
+ return NULL;
+ res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
+ break;
+ }
+ case ITEM_CAST_DOUBLE:
+ {
+ ulong len;
+ uint dec;
+
+ if (!c_len)
{
- my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
- DECIMAL_MAX_SCALE);
- return 0;
+ length= DBL_DIG+7;
+ decimals= NOT_FIXED_DEC;
}
- res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
+ else if (get_length_and_scale(length, decimals, &len, &dec,
+ DECIMAL_MAX_PRECISION, NOT_FIXED_DEC-1,
+ a))
+ return NULL;
+ res= new (thd->mem_root) Item_double_typecast(a, (uint) length,
+ (uint) decimals);
break;
}
case ITEM_CAST_CHAR:
@@ -5466,15 +5528,15 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection);
if (c_len)
{
- ulong decoded_size;
- errno= 0;
- decoded_size= strtoul(c_len, NULL, 10);
- if ((errno != 0) || (decoded_size > MAX_FIELD_BLOBLENGTH))
+ if (length > MAX_FIELD_BLOBLENGTH)
{
- my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH);
+ char buff[1024];
+ String buf(buff, sizeof(buff), system_charset_info);
+ my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), item_name(a, &buf),
+ MAX_FIELD_BLOBLENGTH);
return NULL;
}
- len= (int) decoded_size;
+ len= (int) length;
}
res= new (thd->mem_root) Item_char_typecast(a, len, real_cs);
break;
@@ -5488,3 +5550,95 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
}
return res;
}
+
+
+static List<Item> *create_func_dyncol_prepare(THD *thd,
+ DYNCALL_CREATE_DEF **dfs,
+ List<DYNCALL_CREATE_DEF> &list)
+{
+ DYNCALL_CREATE_DEF *def;
+ List_iterator_fast<DYNCALL_CREATE_DEF> li(list);
+ List<Item> *args= new (thd->mem_root) List<Item>;
+
+ *dfs= (DYNCALL_CREATE_DEF *)alloc_root(thd->mem_root,
+ sizeof(DYNCALL_CREATE_DEF) *
+ list.elements);
+
+ if (!args || !*dfs)
+ return NULL;
+
+ for (uint i= 0; (def= li++) ;)
+ {
+ dfs[0][i++]= *def;
+ args->push_back(def->num);
+ args->push_back(def->value);
+ }
+ return args;
+}
+
+Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list)
+{
+ List<Item> *args;
+ DYNCALL_CREATE_DEF *dfs;
+ if (!(args= create_func_dyncol_prepare(thd, &dfs, list)))
+ return NULL;
+
+ return new (thd->mem_root) Item_func_dyncol_create(*args, dfs);
+}
+
+
+Item *create_func_dyncol_add(THD *thd, Item *str,
+ List<DYNCALL_CREATE_DEF> &list)
+{
+ List<Item> *args;
+ DYNCALL_CREATE_DEF *dfs;
+
+ if (!(args= create_func_dyncol_prepare(thd, &dfs, list)))
+ return NULL;
+
+ args->push_back(str);
+
+ return new (thd->mem_root) Item_func_dyncol_add(*args, dfs);
+}
+
+
+
+Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums)
+{
+ DYNCALL_CREATE_DEF *dfs;
+ Item *num;
+ List_iterator_fast<Item> it(nums);
+ List<Item> *args= new (thd->mem_root) List<Item>;
+
+ dfs= (DYNCALL_CREATE_DEF *)alloc_root(thd->mem_root,
+ sizeof(DYNCALL_CREATE_DEF) *
+ nums.elements);
+ if (!args || !dfs)
+ return NULL;
+
+ for (uint i= 0; (num= it++); i++)
+ {
+ dfs[i].num= num;
+ dfs[i].value= new Item_null();
+ dfs[i].type= DYN_COL_INT;
+ args->push_back(dfs[i].num);
+ args->push_back(dfs[i].value);
+ }
+
+ args->push_back(str);
+
+ return new (thd->mem_root) Item_func_dyncol_add(*args, dfs);
+}
+
+
+Item *create_func_dyncol_get(THD *thd, Item *str, Item *num,
+ Cast_target cast_type,
+ const char *c_len, const char *c_dec,
+ CHARSET_INFO *cs)
+{
+ Item *res;
+
+ if (!(res= new (thd->mem_root) Item_dyncol_get(str, num)))
+ return res; // Return NULL
+ return create_func_cast(thd, res, cast_type, c_len, c_dec, cs);
+}
diff --git a/sql/item_create.h b/sql/item_create.h
index e9824a71132..c075302dd1d 100644
--- a/sql/item_create.h
+++ b/sql/item_create.h
@@ -164,5 +164,15 @@ Item *
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
const char *len, const char *dec,
CHARSET_INFO *cs);
+
+Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list);
+Item *create_func_dyncol_add(THD *thd, Item *str,
+ List<DYNCALL_CREATE_DEF> &list);
+Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums);
+Item *create_func_dyncol_get(THD *thd, Item *num, Item *str,
+ Cast_target cast_type,
+ const char *c_len, const char *c_dec,
+ CHARSET_INFO *cs);
+
#endif
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 63b8419aaaa..54c60ea03e1 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -202,7 +202,6 @@ Item_func::fix_fields(THD *thd, Item **ref)
with_sum_func= with_sum_func || item->with_sum_func;
with_field= with_field || item->with_field;
used_tables_cache|= item->used_tables();
- not_null_tables_cache|= item->not_null_tables();
const_item_cache&= item->const_item();
with_subselect|= item->with_subselect;
}
@@ -231,6 +230,21 @@ Item_func::quick_fix_field()
}
+bool
+Item_func::eval_not_null_tables(uchar *opt_arg)
+{
+ Item **arg,**arg_end;
+ if (arg_count)
+ {
+ for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
+ {
+ not_null_tables_cache|= (*arg)->not_null_tables();
+ }
+ }
+ return FALSE;
+}
+
+
void Item_func::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
Item **arg,**arg_end;
@@ -352,6 +366,8 @@ Item *Item_func::transform(Item_transformer transformer, uchar *argument)
the old item is substituted for a new one.
After this the transformer is applied to the root node
of the Item_func object.
+ The compile function is not called if the analyzer returns NULL
+ in the parameter arg_p.
@param analyzer the analyzer callback function to be applied to the
nodes of the tree of the object
@@ -369,7 +385,7 @@ Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p,
{
if (!(this->*analyzer)(arg_p))
return 0;
- if (arg_count)
+ if (*arg_p && arg_count)
{
Item **arg,**arg_end;
for (arg= args, arg_end= args+arg_count; arg != arg_end; arg++)
@@ -377,7 +393,7 @@ Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p,
/*
The same parameter value of arg_p must be passed
to analyze any argument of the condition formula.
- */
+ */
uchar *arg_v= *arg_p;
Item *new_item= (*arg)->compile(analyzer, &arg_v, transformer, arg_t);
if (new_item && *arg != new_item)
@@ -503,7 +519,8 @@ Field *Item_func::tmp_table_field(TABLE *table)
field= Field_new_decimal::create_from_item(this);
break;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
// This case should never be chosen
DBUG_ASSERT(0);
field= 0;
@@ -524,7 +541,10 @@ bool Item_func::is_expensive_processor(uchar *arg)
my_decimal *Item_func::val_decimal(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed);
- int2my_decimal(E_DEC_FATAL_ERROR, val_int(), unsigned_flag, decimal_value);
+ longlong nr= val_int();
+ if (null_value)
+ return 0; /* purecov: inspected */
+ int2my_decimal(E_DEC_FATAL_ERROR, nr, unsigned_flag, decimal_value);
return decimal_value;
}
@@ -706,8 +726,8 @@ void Item_num_op::find_num_type(void)
DBUG_ENTER("Item_num_op::find_num_type");
DBUG_PRINT("info", ("name %s", func_name()));
DBUG_ASSERT(arg_count == 2);
- Item_result r0= args[0]->result_type();
- Item_result r1= args[1]->result_type();
+ Item_result r0= args[0]->cast_to_int_type();
+ Item_result r1= args[1]->cast_to_int_type();
if (r0 == REAL_RESULT || r1 == REAL_RESULT ||
r0 == STRING_RESULT || r1 ==STRING_RESULT)
@@ -716,7 +736,8 @@ void Item_num_op::find_num_type(void)
max_length= float_length(decimals);
hybrid_type= REAL_RESULT;
}
- else if (r0 == DECIMAL_RESULT || r1 == DECIMAL_RESULT)
+ else if (r0 == DECIMAL_RESULT || r1 == DECIMAL_RESULT ||
+ r0 == TIME_RESULT || r1 == TIME_RESULT)
{
hybrid_type= DECIMAL_RESULT;
result_precision();
@@ -747,7 +768,7 @@ void Item_func_num1::find_num_type()
{
DBUG_ENTER("Item_func_num1::find_num_type");
DBUG_PRINT("info", ("name %s", func_name()));
- switch (hybrid_type= args[0]->result_type()) {
+ switch (hybrid_type= args[0]->cast_to_int_type()) {
case INT_RESULT:
unsigned_flag= args[0]->unsigned_flag;
break;
@@ -756,9 +777,12 @@ void Item_func_num1::find_num_type()
hybrid_type= REAL_RESULT;
max_length= float_length(decimals);
break;
+ case TIME_RESULT:
+ hybrid_type= DECIMAL_RESULT;
case DECIMAL_RESULT:
break;
- default:
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
DBUG_PRINT("info", ("Type: %s",
@@ -815,7 +839,9 @@ String *Item_func_numhybrid::val_str(String *str)
}
case STRING_RESULT:
return str_op(&str_value);
- default:
+ case TIME_RESULT:
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
return str;
@@ -850,7 +876,9 @@ double Item_func_numhybrid::val_real()
return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
&end_not_used, &err_not_used) : 0.0);
}
- default:
+ case TIME_RESULT:
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
return 0.0;
@@ -882,10 +910,12 @@ longlong Item_func_numhybrid::val_int()
return 0;
char *end= (char*) res->ptr() + res->length();
- CHARSET_INFO *cs= str_value.charset();
+ CHARSET_INFO *cs= res->charset();
return (*(cs->cset->strtoll10))(cs, res->ptr(), &end, &err_not_used);
}
- default:
+ case TIME_RESULT:
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
return 0;
@@ -923,7 +953,8 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
break;
}
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
return val;
@@ -982,21 +1013,32 @@ longlong Item_func_signed::val_int()
longlong value;
int error;
- if (args[0]->cast_to_int_type() != STRING_RESULT ||
- args[0]->result_as_longlong())
+ if (args[0]->cast_to_int_type() != STRING_RESULT)
{
value= args[0]->val_int();
null_value= args[0]->null_value;
return value;
}
+ else if (args[0]->dynamic_result())
+ {
+ /* We come here when argument has an unknown type */
+ args[0]->unsigned_flag= 0; // Mark that we want to have a signed value
+ value= args[0]->val_int();
+ null_value= args[0]->null_value;
+ if (!null_value && args[0]->unsigned_flag && value < 0)
+ goto err; // Warn about overflow
+ return value;
+ }
value= val_int_from_str(&error);
if (value < 0 && error == 0)
- {
- push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
- "Cast to signed converted positive out-of-range integer to "
- "it's negative complement");
- }
+ goto err;
+ return value;
+
+err:
+ push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
+ "Cast to signed converted positive out-of-range integer to "
+ "it's negative complement");
return value;
}
@@ -1024,19 +1066,35 @@ longlong Item_func_unsigned::val_int()
value= 0;
return value;
}
- else if (args[0]->cast_to_int_type() != STRING_RESULT ||
- args[0]->result_as_longlong())
+ else if (args[0]->dynamic_result())
{
+ /* We come here when argument has an unknown type */
+ args[0]->unsigned_flag= 1; // Mark that we want to have an unsigned value
value= args[0]->val_int();
null_value= args[0]->null_value;
+ if (!null_value && args[0]->unsigned_flag == 0 && value < 0)
+ goto err; // Warn about overflow
+ return value;
+ }
+ else if (args[0]->cast_to_int_type() != STRING_RESULT)
+ {
+ value= args[0]->val_int();
+ null_value= args[0]->null_value;
+ if (!null_value && args[0]->unsigned_flag == 0 && value < 0)
+ goto err; // Warn about overflow
return value;
}
value= val_int_from_str(&error);
if (error < 0)
- push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
- "Cast to unsigned converted negative integer to it's "
- "positive complement");
+ goto err;
+
+ return value;
+
+err:
+ push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
+ "Cast to unsigned converted negative integer to it's "
+ "positive complement");
return value;
}
@@ -1134,6 +1192,51 @@ void Item_decimal_typecast::print(String *str, enum_query_type query_type)
}
+double Item_double_typecast::val_real()
+{
+ int error;
+ double tmp= args[0]->val_real();
+ if ((null_value= args[0]->null_value))
+ return 0.0;
+
+ if ((error= truncate_double(&tmp, max_length, decimals, 0, DBL_MAX)))
+ {
+ push_warning_printf(current_thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_DATA_OUT_OF_RANGE,
+ ER(ER_WARN_DATA_OUT_OF_RANGE),
+ name, 1);
+ if (error < 0)
+ {
+ null_value= 1; // Illegal value
+ tmp= 0.0;
+ }
+ }
+ return tmp;
+}
+
+
+void Item_double_typecast::print(String *str, enum_query_type query_type)
+{
+ char len_buf[20*3 + 1];
+ char *end;
+
+ str->append(STRING_WITH_LEN("cast("));
+ args[0]->print(str, query_type);
+ str->append(STRING_WITH_LEN(" as double"));
+ if (decimals != NOT_FIXED_DEC)
+ {
+ str->append('(');
+ end= int10_to_str(max_length, len_buf,10);
+ str->append(len_buf, (uint32) (end - len_buf));
+ str->append(',');
+ end= int10_to_str(decimals, len_buf,10);
+ str->append(len_buf, (uint32) (end - len_buf));
+ str->append(')');
+ }
+ str->append(')');
+}
+
double Item_func_plus::real_op()
{
double value= args[0]->val_real() + args[1]->val_real();
@@ -1366,7 +1469,7 @@ void Item_func_div::fix_length_and_dec()
DBUG_ENTER("Item_func_div::fix_length_and_dec");
prec_increment= current_thd->variables.div_precincrement;
Item_num_op::fix_length_and_dec();
- switch(hybrid_type) {
+ switch (hybrid_type) {
case REAL_RESULT:
{
decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
@@ -1389,7 +1492,10 @@ void Item_func_div::fix_length_and_dec()
case DECIMAL_RESULT:
result_precision();
break;
- default:
+ case STRING_RESULT:
+ case ROW_RESULT:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
maybe_null= 1; // devision by zero
@@ -1845,9 +1951,10 @@ void Item_func_integer::fix_length_and_dec()
void Item_func_int_val::fix_num_length_and_dec()
{
- max_length= args[0]->max_length - (args[0]->decimals ?
- args[0]->decimals + 1 :
- 0) + 2;
+ ulonglong tmp_max_length= (ulonglong ) args[0]->max_length -
+ (args[0]->decimals ? args[0]->decimals + 1 : 0) + 2;
+ max_length= tmp_max_length > (ulonglong) max_field_size ?
+ max_field_size : (uint32) tmp_max_length;
uint tmp= float_length(decimals);
set_if_smaller(max_length,tmp);
decimals= 0;
@@ -1858,7 +1965,7 @@ void Item_func_int_val::find_num_type()
{
DBUG_ENTER("Item_func_int_val::find_num_type");
DBUG_PRINT("info", ("name %s", func_name()));
- switch(hybrid_type= args[0]->result_type())
+ switch (hybrid_type= args[0]->cast_to_int_type())
{
case STRING_RESULT:
case REAL_RESULT:
@@ -1866,6 +1973,7 @@ void Item_func_int_val::find_num_type()
max_length= float_length(decimals);
break;
case INT_RESULT:
+ case TIME_RESULT:
case DECIMAL_RESULT:
/*
-2 because in most high position can't be used any digit for longlong
@@ -1882,7 +1990,8 @@ void Item_func_int_val::find_num_type()
hybrid_type= INT_RESULT;
}
break;
- default:
+ case ROW_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
DBUG_PRINT("info", ("Type: %s",
@@ -2058,7 +2167,9 @@ void Item_func_round::fix_length_and_dec()
unsigned_flag);
break;
}
- default:
+ case ROW_RESULT:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); /* This result type isn't handled */
}
}
@@ -2162,10 +2273,7 @@ my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
if (!(null_value= (args[0]->null_value || args[1]->null_value ||
my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
truncate, decimal_value) > 1)))
- {
- decimal_value->frac= decimals;
return decimal_value;
- }
return 0;
}
@@ -2269,10 +2377,10 @@ double Item_func_units::val_real()
void Item_func_min_max::fix_length_and_dec()
{
int max_int_part=0;
- bool datetime_found= FALSE;
decimals=0;
max_length=0;
maybe_null=0;
+ thd= current_thd;
cmp_type=args[0]->result_type();
for (uint i=0 ; i < arg_count ; i++)
@@ -2281,85 +2389,87 @@ void Item_func_min_max::fix_length_and_dec()
set_if_bigger(decimals, args[i]->decimals);
set_if_bigger(max_int_part, args[i]->decimal_int_part());
if (args[i]->maybe_null)
- maybe_null=1;
- cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
- if (args[i]->result_type() != ROW_RESULT && args[i]->is_datetime())
- {
- datetime_found= TRUE;
- if (!datetime_item || args[i]->field_type() == MYSQL_TYPE_DATETIME)
- datetime_item= args[i];
- }
+ maybe_null= 1;
+ cmp_type= item_cmp_type(cmp_type,args[i]->result_type());
}
if (cmp_type == STRING_RESULT)
- {
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1);
- if (datetime_found)
- {
- thd= current_thd;
- compare_as_dates= TRUE;
- }
- }
else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT))
max_length= my_decimal_precision_to_length_no_truncation(max_int_part +
decimals, decimals,
unsigned_flag);
else if (cmp_type == REAL_RESULT)
max_length= float_length(decimals);
- cached_field_type= agg_field_type(args, arg_count);
+
+ compare_as_dates= find_date_time_item(args, arg_count, 0);
+ if (compare_as_dates)
+ {
+ cached_field_type= compare_as_dates->field_type();
+ if (mysql_type_to_time_type(cached_field_type) == MYSQL_TIMESTAMP_DATE)
+ decimals= 0;
+ else
+ set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
+ }
+ else
+ cached_field_type= agg_field_type(args, arg_count);
}
/*
Compare item arguments in the DATETIME context.
- SYNOPSIS
- cmp_datetimes()
- value [out] found least/greatest DATE/DATETIME value
-
DESCRIPTION
Compare item arguments as DATETIME values and return the index of the
least/greatest argument in the arguments array.
- The correct integer DATE/DATETIME value of the found argument is
+ The correct DATE/DATETIME value of the found argument is
stored to the value pointer, if latter is provided.
RETURN
- 0 If one of arguments is NULL or there was a execution error
- # index of the least/greatest argument
+ 1 If one of arguments is NULL or there was a execution error
+ 0 Otherwise
*/
-uint Item_func_min_max::cmp_datetimes(ulonglong *value)
+bool Item_func_min_max::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
longlong UNINIT_VAR(min_max);
- uint min_max_idx= 0;
+ DBUG_ASSERT(fixed == 1);
+
+ /*
+ just like ::val_int() method of an string item can be called,
+ for example, SELECT CONCAT("10", "12") + 1,
+ ::get_date() can be called for non-temporal values,
+ for example, SELECT MONTH(GREATEST("2011-11-21", "2010-10-09"))
+
+ */
+ if (!compare_as_dates)
+ return Item_func::get_date(ltime, fuzzy_date);
+
+ null_value= 0;
for (uint i=0; i < arg_count ; i++)
{
Item **arg= args + i;
bool is_null;
- longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
+ longlong res= get_datetime_value(thd, &arg, 0, compare_as_dates, &is_null);
- /* Check if we need to stop (because of error or KILL) and stop the loop */
- if (thd->is_error())
+ /* Check if we need to stop (because of error or KILL) and stop the loop */
+ if (thd->is_error() || args[i]->null_value)
{
null_value= 1;
- return 0;
+ return 1;
}
- if ((null_value= args[i]->null_value))
- return 0;
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
- {
min_max= res;
- min_max_idx= i;
- }
}
- if (value)
+ unpack_time(min_max, ltime);
+ if (compare_as_dates->field_type() == MYSQL_TYPE_DATE)
{
- *value= min_max;
- if (datetime_item->field_type() == MYSQL_TYPE_DATE)
- *value/= 1000000L;
+ ltime->time_type= MYSQL_TIMESTAMP_DATE;
+ ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
}
- return min_max_idx;
+
+ return 0;
}
@@ -2367,46 +2477,14 @@ String *Item_func_min_max::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
if (compare_as_dates)
- {
- String *str_res;
- uint min_max_idx= cmp_datetimes(NULL);
- if (null_value)
- return 0;
- str_res= args[min_max_idx]->val_str(str);
- if (args[min_max_idx]->null_value)
- {
- // check if the call to val_str() above returns a NULL value
- null_value= 1;
- return NULL;
- }
- str_res->set_charset(collation.collation);
- return str_res;
- }
+ return val_string_from_date(str);
switch (cmp_type) {
case INT_RESULT:
- {
- longlong nr=val_int();
- if (null_value)
- return 0;
- str->set_int(nr, unsigned_flag, &my_charset_bin);
- return str;
- }
+ return val_string_from_int(str);
case DECIMAL_RESULT:
- {
- my_decimal dec_buf, *dec_val= val_decimal(&dec_buf);
- if (null_value)
- return 0;
- my_decimal2string(E_DEC_FATAL_ERROR, dec_val, 0, 0, 0, str);
- return str;
- }
+ return val_string_from_decimal(str);
case REAL_RESULT:
- {
- double nr= val_real();
- if (null_value)
- return 0; /* purecov: inspected */
- str->set_real(nr,decimals,&my_charset_bin);
- return str;
- }
+ return val_string_from_real(str);
case STRING_RESULT:
{
String *UNINIT_VAR(res);
@@ -2432,9 +2510,9 @@ String *Item_func_min_max::val_str(String *str)
return res;
}
case ROW_RESULT:
- default:
- // This case should never be chosen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
return 0;
}
return 0; // Keep compiler happy
@@ -2447,9 +2525,11 @@ double Item_func_min_max::val_real()
double value=0.0;
if (compare_as_dates)
{
- ulonglong result= 0;
- (void)cmp_datetimes(&result);
- return (double)result;
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, TIME_FUZZY_DATE))
+ return 0;
+
+ return TIME_to_double(&ltime);
}
for (uint i=0; i < arg_count ; i++)
{
@@ -2474,9 +2554,11 @@ longlong Item_func_min_max::val_int()
longlong value=0;
if (compare_as_dates)
{
- ulonglong result= 0;
- (void)cmp_datetimes(&result);
- return (longlong)result;
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, TIME_FUZZY_DATE))
+ return 0;
+
+ return TIME_to_ulonglong(&ltime);
}
for (uint i=0; i < arg_count ; i++)
{
@@ -2502,10 +2584,11 @@ my_decimal *Item_func_min_max::val_decimal(my_decimal *dec)
if (compare_as_dates)
{
- ulonglong value= 0;
- (void)cmp_datetimes(&value);
- ulonglong2decimal(value, dec);
- return dec;
+ MYSQL_TIME ltime;
+ if (get_date(&ltime, TIME_FUZZY_DATE))
+ return 0;
+
+ return date2my_decimal(&ltime, dec);
}
for (uint i=0; i < arg_count ; i++)
{
@@ -2988,8 +3071,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
if (arguments[i]->const_item())
{
- switch (arguments[i]->result_type())
- {
+ switch (arguments[i]->result_type()) {
case STRING_RESULT:
case DECIMAL_RESULT:
{
@@ -3015,9 +3097,9 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
to+= ALIGN_SIZE(sizeof(double));
break;
case ROW_RESULT:
- default:
- // This case should never be chosen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
break;
}
}
@@ -3090,9 +3172,9 @@ bool udf_handler::get_arguments()
}
break;
case ROW_RESULT:
- default:
- // This case should never be chosen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
break;
}
}
@@ -3712,9 +3794,9 @@ longlong Item_func_benchmark::val_int()
(void) args[1]->val_decimal(&tmp_decimal);
break;
case ROW_RESULT:
- default:
- // This case should never be chosen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
return 0;
}
}
@@ -3892,6 +3974,21 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
entry->collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
collation.set(entry->collation.collation, DERIVATION_IMPLICIT);
cached_result_type= args[0]->result_type();
+ if (thd->lex->current_select)
+ {
+ /*
+ When this function is used in a derived table/view force the derived
+ table to be materialized to preserve possible side-effect of setting a
+ user variable.
+ */
+ SELECT_LEX_UNIT *unit= thd->lex->current_select->master_unit();
+ TABLE_LIST *derived;
+ for (derived= unit->derived;
+ derived;
+ derived= derived->select_lex->master_unit()->derived)
+ derived->set_materialized_derived();
+ }
+
return FALSE;
}
@@ -3902,6 +3999,7 @@ Item_func_set_user_var::fix_length_and_dec()
maybe_null=args[0]->maybe_null;
max_length=args[0]->max_length;
decimals=args[0]->decimals;
+ unsigned_flag= args[0]->unsigned_flag;
collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
}
@@ -4067,6 +4165,7 @@ double user_var_entry::val_real(bool *null_value)
case STRING_RESULT:
return my_atof(value); // This is null terminated
case ROW_RESULT:
+ case TIME_RESULT:
case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
@@ -4099,6 +4198,7 @@ longlong user_var_entry::val_int(bool *null_value) const
return my_strtoll10(value, (char**) 0, &error);// String is null terminated
}
case ROW_RESULT:
+ case TIME_RESULT:
case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
@@ -4133,6 +4233,7 @@ String *user_var_entry::val_str(bool *null_value, String *str,
str= 0; // EOM error
break;
case ROW_RESULT:
+ case TIME_RESULT:
case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
@@ -4161,6 +4262,7 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
break;
case ROW_RESULT:
+ case TIME_RESULT:
case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
@@ -4200,8 +4302,9 @@ Item_func_set_user_var::check(bool use_result_field)
{
save_result.vint= use_result_field ? result_field->val_int() :
args[0]->val_int();
- unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
- args[0]->unsigned_flag;
+ unsigned_flag= (use_result_field ?
+ ((Field_num*)result_field)->unsigned_flag:
+ args[0]->unsigned_flag);
break;
}
case STRING_RESULT:
@@ -4218,9 +4321,9 @@ Item_func_set_user_var::check(bool use_result_field)
break;
}
case ROW_RESULT:
- default:
- // This case should never be chosen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
break;
}
DBUG_RETURN(FALSE);
@@ -4253,9 +4356,9 @@ void Item_func_set_user_var::save_item_result(Item *item)
save_result.vdec= item->val_decimal_result(&decimal_buff);
break;
case ROW_RESULT:
- default:
- // Should never happen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
break;
}
DBUG_VOID_RETURN;
@@ -4321,9 +4424,9 @@ Item_func_set_user_var::update()
break;
}
case ROW_RESULT:
- default:
- // This case should never be chosen
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
break;
}
DBUG_RETURN(res);
@@ -4756,7 +4859,7 @@ void Item_func_get_user_var::fix_length_and_dec()
max_length= var_entry->length;
collation.set(var_entry->collation);
- switch(m_cached_result_type) {
+ switch (m_cached_result_type) {
case REAL_RESULT:
max_length= DBL_DIG + 8;
break;
@@ -4772,8 +4875,9 @@ void Item_func_get_user_var::fix_length_and_dec()
decimals= DECIMAL_MAX_SCALE;
break;
case ROW_RESULT: // Keep compiler happy
- default:
- DBUG_ASSERT(0);
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
+ DBUG_ASSERT(0); // This case should never be chosen
break;
}
}
diff --git a/sql/item_func.h b/sql/item_func.h
index 5c5ea33f247..63056f9079e 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -190,6 +191,7 @@ public:
Item_transformer transformer, uchar *arg_t);
void traverse_cond(Cond_traverser traverser,
void * arg, traverse_order order);
+ bool eval_not_null_tables(uchar *opt_arg);
// bool is_expensive_processor(uchar *arg);
// virtual bool is_expensive() { return 0; }
inline double fix_result(double value)
@@ -251,6 +253,21 @@ public:
}
/*
+ By default only substitution for a field whose two different values
+ are never equal is allowed in the arguments of a function.
+ This is overruled for the direct arguments of comparison functions.
+ */
+ bool subst_argument_checker(uchar **arg)
+ {
+ if (*arg)
+ {
+ *arg= (uchar *) Item::IDENTITY_SUBST;
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ /*
We assume the result of any function that has a TIMESTAMP argument to be
timezone-dependent, since a TIMESTAMP value in both numeric and string
contexts is interpreted according to the current timezone.
@@ -307,6 +324,8 @@ class Item_func_numhybrid: public Item_func
protected:
Item_result hybrid_type;
public:
+ Item_func_numhybrid() :Item_func(), hybrid_type(REAL_RESULT)
+ {}
Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
{}
Item_func_numhybrid(Item *a,Item *b)
@@ -460,7 +479,7 @@ class Item_decimal_typecast :public Item_func
public:
Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a)
{
- decimals= dec;
+ decimals= (uint8) dec;
max_length= my_decimal_precision_to_length_no_truncation(len, dec,
unsigned_flag);
}
@@ -470,12 +489,29 @@ public:
my_decimal *val_decimal(my_decimal*);
enum Item_result result_type () const { return DECIMAL_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
- void fix_length_and_dec() {};
+ void fix_length_and_dec() {}
const char *func_name() const { return "decimal_typecast"; }
virtual void print(String *str, enum_query_type query_type);
};
+class Item_double_typecast :public Item_real_func
+{
+public:
+ Item_double_typecast(Item *a, int len, int dec) :Item_real_func(a)
+ {
+ decimals= (uint8) dec;
+ max_length= (uint32) len;
+ }
+ double val_real();
+ enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
+ void fix_length_and_dec() { maybe_null= 1; }
+ const char *func_name() const { return "double_typecast"; }
+ virtual void print(String *str, enum_query_type query_type);
+};
+
+
+
class Item_func_additive_op :public Item_num_op
{
public:
@@ -835,25 +871,21 @@ class Item_func_min_max :public Item_func
Item_result cmp_type;
String tmp_value;
int cmp_sign;
- /* TRUE <=> arguments should be compared in the DATETIME context. */
- bool compare_as_dates;
/* An item used for issuing warnings while string to DATETIME conversion. */
- Item *datetime_item;
+ Item *compare_as_dates;
THD *thd;
protected:
enum_field_types cached_field_type;
public:
Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list),
- cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE),
- datetime_item(0) {}
+ cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(FALSE) {}
double val_real();
longlong val_int();
String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void fix_length_and_dec();
enum Item_result result_type () const { return cmp_type; }
- bool result_as_longlong() { return compare_as_dates; };
- uint cmp_datetimes(ulonglong *value);
enum_field_types field_type() const { return cached_field_type; }
};
@@ -1682,14 +1714,7 @@ public:
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
bool check_vcol_func_processor(uchar *int_arg)
{
-#if 0
- DBUG_ENTER("Item_func_is_free_lock::check_vcol_func_processor");
- DBUG_PRINT("info",
- ("check_vcol_func_processor returns TRUE: unsupported function"));
- DBUG_RETURN(TRUE);
-#else
return trace_unsupported_by_check_vcol_func_processor(func_name());
-#endif
}
};
@@ -1713,7 +1738,7 @@ enum Cast_target
{
ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR,
- ITEM_CAST_DECIMAL
+ ITEM_CAST_DECIMAL, ITEM_CAST_DOUBLE
};
@@ -1877,4 +1902,3 @@ public:
return trace_unsupported_by_check_vcol_func_processor(func_name());
}
};
-
diff --git a/sql/item_row.h b/sql/item_row.h
index c7fb8d59220..0b43309391d 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -66,6 +66,7 @@ public:
table_map used_tables() const { return used_tables_cache; };
bool const_item() const { return const_item_cache; };
enum Item_result result_type() const { return ROW_RESULT; }
+ Item_result cmp_type() const { return ROW_RESULT; }
void update_used_tables();
table_map not_null_tables() const { return not_null_tables_cache; }
virtual void print(String *str, enum_query_type query_type);
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 39776643ddd..453773478d8 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -39,6 +39,9 @@ C_MODE_START
#include "../mysys/my_static.h" // For soundex_map
C_MODE_END
+/**
+ @todo Remove this. It is not safe to use a shared String object.
+ */
String my_empty_string("",default_charset_info);
@@ -116,7 +119,6 @@ String *Item_func_md5::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String * sptr= args[0]->val_str(str);
- str->set_charset(&my_charset_bin);
if (sptr)
{
uchar digest[16];
@@ -129,6 +131,7 @@ String *Item_func_md5::val_str(String *str)
return 0;
}
array_to_hex((char *) str->ptr(), (const char*) digest, 16);
+ str->set_charset(&my_charset_bin);
str->length((uint) 32);
return str;
}
@@ -155,7 +158,6 @@ String *Item_func_sha::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String * sptr= args[0]->val_str(str);
- str->set_charset(&my_charset_bin);
if (sptr) /* If we got value different from NULL */
{
SHA1_CONTEXT context; /* Context used to generate SHA1 hash */
@@ -165,11 +167,13 @@ String *Item_func_sha::val_str(String *str)
/* No need to check error as the only case would be too long message */
mysql_sha1_input(&context,
(const uchar *) sptr->ptr(), sptr->length());
+
/* Ensure that memory is free and we got result */
if (!( str->alloc(SHA1_HASH_SIZE*2) ||
(mysql_sha1_result(&context,digest))))
{
array_to_hex((char *) str->ptr(), (const char*) digest, SHA1_HASH_SIZE);
+ str->set_charset(&my_charset_bin);
str->length((uint) SHA1_HASH_SIZE*2);
null_value=0;
return str;
@@ -461,7 +465,7 @@ String *Item_func_des_encrypt::val_str(String *str)
if ((null_value= args[0]->null_value))
return 0; // ENCRYPT(NULL) == NULL
if ((res_length=res->length()) == 0)
- return &my_empty_string;
+ return make_empty_result();
if (arg_count == 1)
{
@@ -517,6 +521,7 @@ String *Item_func_des_encrypt::val_str(String *str)
tmp_arg[res_length-1]=tail; // save extra length
tmp_value.realloc(res_length+1);
tmp_value.length(res_length+1);
+ tmp_value.set_charset(&my_charset_bin);
tmp_value[0]=(char) (128 | key_number);
// Real encryption
bzero((char*) &ivec,sizeof(ivec));
@@ -604,6 +609,7 @@ String *Item_func_des_decrypt::val_str(String *str)
if ((tail=(uint) (uchar) tmp_value[length-2]) > 8)
goto wrong_key; // Wrong key
tmp_value.length(length-1-tail);
+ tmp_value.set_charset(&my_charset_bin);
return &tmp_value;
error:
@@ -641,7 +647,7 @@ String *Item_func_concat_ws::val_str(String *str)
use_as_buff= &tmp_value;
str->length(0); // QQ; Should be removed
- res=str;
+ res=str; // If 0 arg_count
// Skip until non-null argument is found.
// If not, return the empty string
@@ -653,7 +659,7 @@ String *Item_func_concat_ws::val_str(String *str)
}
if (i == arg_count)
- return &my_empty_string;
+ return make_empty_result();
for (i++; i < arg_count ; i++)
{
@@ -804,7 +810,7 @@ String *Item_func_reverse::val_str(String *str)
return 0;
/* An empty string is a special case as the string pointer may be null */
if (!res->length())
- return &my_empty_string;
+ return make_empty_result();
if (tmp_value.alloced_length() < res->length() &&
tmp_value.realloc(res->length()))
{
@@ -1144,8 +1150,7 @@ String *Item_func_left::val_str(String *str)
/* if "unsigned_flag" is set, we have a *huge* positive number. */
if ((length <= 0) && (!args[1]->unsigned_flag))
- return &my_empty_string;
-
+ return make_empty_result();
if ((res->length() <= (ulonglong) length) ||
(res->length() <= (char_pos= res->charpos((int) length))))
return res;
@@ -1188,7 +1193,7 @@ String *Item_func_right::val_str(String *str)
/* if "unsigned_flag" is set, we have a *huge* positive number. */
if ((length <= 0) && (!args[1]->unsigned_flag))
- return &my_empty_string; /* purecov: inspected */
+ return make_empty_result(); /* purecov: inspected */
if (res->length() <= (ulonglong) length)
return res; /* purecov: inspected */
@@ -1227,7 +1232,7 @@ String *Item_func_substr::val_str(String *str)
/* Negative or zero length, will return empty string. */
if ((arg_count == 3) && (length <= 0) &&
(length == 0 || !args[2]->unsigned_flag))
- return &my_empty_string;
+ return make_empty_result();
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
@@ -1238,12 +1243,12 @@ String *Item_func_substr::val_str(String *str)
/* Assumes that the maximum length of a String is < INT_MAX32. */
if ((!args[1]->unsigned_flag && (start < INT_MIN32 || start > INT_MAX32)) ||
(args[1]->unsigned_flag && ((ulonglong) start > INT_MAX32)))
- return &my_empty_string;
+ return make_empty_result();
start= ((start < 0) ? res->numchars() + start : start - 1);
start= res->charpos((int) start);
if ((start < 0) || ((uint) start + 1 > res->length()))
- return &my_empty_string;
+ return make_empty_result();
length= res->charpos((int) length, (uint32) start);
tmp_length= res->length() - start;
@@ -1306,7 +1311,7 @@ String *Item_func_substr_index::val_str(String *str)
null_value=0;
uint delimiter_length= delimiter->length();
if (!res->length() || !delimiter_length || !count)
- return &my_empty_string; // Wrong parameters
+ return make_empty_result(); // Wrong parameters
res->set_charset(collation.collation);
@@ -1655,7 +1660,7 @@ String *Item_func_password::val_str(String *str)
if ((null_value=args[0]->null_value))
return 0;
if (res->length() == 0)
- return &my_empty_string;
+ return make_empty_result();
my_make_scrambled_password(tmp_value, res->ptr(), res->length());
str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, res->charset());
return str;
@@ -1679,7 +1684,7 @@ String *Item_func_old_password::val_str(String *str)
if ((null_value=args[0]->null_value))
return 0;
if (res->length() == 0)
- return &my_empty_string;
+ return make_empty_result();
my_make_scrambled_password_323(tmp_value, res->ptr(), res->length());
str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, res->charset());
return str;
@@ -1707,8 +1712,7 @@ String *Item_func_encrypt::val_str(String *str)
if ((null_value=args[0]->null_value))
return 0;
if (res->length() == 0)
- return &my_empty_string;
-
+ return make_empty_result();
if (arg_count == 1)
{ // generate random salt
time_t timestamp=current_thd->query_start();
@@ -1968,7 +1972,7 @@ String *Item_func_soundex::val_str(String *str)
for ( ; ; ) /* Skip pre-space */
{
if ((rc= cs->cset->mb_wc(cs, &wc, (uchar*) from, (uchar*) end)) <= 0)
- return &my_empty_string; /* EOL or invalid byte sequence */
+ return make_empty_result(); /* EOL or invalid byte sequence */
if (rc == 1 && cs->ctype)
{
@@ -1993,7 +1997,7 @@ String *Item_func_soundex::val_str(String *str)
{
/* Extra safety - should not really happen */
DBUG_ASSERT(false);
- return &my_empty_string;
+ return make_empty_result();
}
to+= rc;
break;
@@ -2291,7 +2295,7 @@ String *Item_func_make_set::val_str(String *str)
else
{
if (tmp_str.copy(*res)) // Don't use 'str'
- return &my_empty_string;
+ return make_empty_result();
result= &tmp_str;
}
}
@@ -2301,11 +2305,11 @@ String *Item_func_make_set::val_str(String *str)
{ // Copy data to tmp_str
if (tmp_str.alloc(result->length()+res->length()+1) ||
tmp_str.copy(*result))
- return &my_empty_string;
+ return make_empty_result();
result= &tmp_str;
}
if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) || tmp_str.append(*res))
- return &my_empty_string;
+ return make_empty_result();
}
}
}
@@ -2444,7 +2448,7 @@ String *Item_func_repeat::val_str(String *str)
null_value= 0;
if (count <= 0 && (count == 0 || !args[1]->unsigned_flag))
- return &my_empty_string;
+ return make_empty_result();
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Bounds check on count: If this is triggered, we will error. */
@@ -2752,7 +2756,7 @@ String *Item_func_conv::val_str(String *str)
ptr= longlong2str(dec, ans, to_base, 1);
if (str->copy(ans, (uint32) (ptr-ans), default_charset()))
- return &my_empty_string;
+ return make_empty_result();
return str;
}
@@ -2762,22 +2766,16 @@ String *Item_func_conv_charset::val_str(String *str)
DBUG_ASSERT(fixed == 1);
if (use_cached_value)
return null_value ? 0 : &str_value;
- /*
- Here we don't pass 'str' as a parameter to args[0]->val_str()
- as 'str' may point to 'str_value' (e.g. see Item::save_in_field()),
- which we use below to convert string.
- Use argument's 'str_value' instead.
- */
- String *arg= args[0]->val_str(&args[0]->str_value);
+ String *arg= args[0]->val_str(str);
uint dummy_errors;
if (!arg)
{
null_value=1;
return 0;
}
- null_value= str_value.copy(arg->ptr(),arg->length(),arg->charset(),
+ null_value= tmp_value.copy(arg->ptr(), arg->length(), arg->charset(),
conv_charset, &dummy_errors);
- return null_value ? 0 : check_well_formed_result(&str_value);
+ return null_value ? 0 : check_well_formed_result(&tmp_value);
}
void Item_func_conv_charset::fix_length_and_dec()
@@ -2919,7 +2917,7 @@ String *Item_func_hex::val_str(String *str)
return 0;
ptr= longlong2str(dec,ans,16,1);
if (str->copy(ans,(uint32) (ptr-ans),default_charset()))
- return &my_empty_string; // End of memory
+ return make_empty_result(); // End of memory
return str;
}
@@ -3219,14 +3217,68 @@ String *Item_func_quote::val_str(String *str)
}
arg_length= arg->length();
- new_length= arg_length+2; /* for beginning and ending ' signs */
- for (from= (char*) arg->ptr(), end= from + arg_length; from < end; from++)
- new_length+= get_esc_bit(escmask, (uchar) *from);
+ if (collation.collation->mbmaxlen == 1)
+ {
+ new_length= arg_length + 2; /* for beginning and ending ' signs */
+ for (from= (char*) arg->ptr(), end= from + arg_length; from < end; from++)
+ new_length+= get_esc_bit(escmask, (uchar) *from);
+ }
+ else
+ {
+ new_length= (arg_length * 2) + /* For string characters */
+ (2 * collation.collation->mbmaxlen); /* For quotes */
+ }
if (tmp_value.alloc(new_length))
goto null;
+ if (collation.collation->mbmaxlen > 1)
+ {
+ CHARSET_INFO *cs= collation.collation;
+ int mblen;
+ uchar *to_end;
+ to= (char*) tmp_value.ptr();
+ to_end= (uchar*) to + new_length;
+
+ /* Put leading quote */
+ if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0)
+ goto null;
+ to+= mblen;
+
+ for (start= (char*) arg->ptr(), end= start + arg_length; start < end; )
+ {
+ my_wc_t wc;
+ bool escape;
+ if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) start, (uchar*) end)) <= 0)
+ goto null;
+ start+= mblen;
+ switch (wc) {
+ case 0: escape= 1; wc= '0'; break;
+ case '\032': escape= 1; wc= 'Z'; break;
+ case '\'': escape= 1; break;
+ case '\\': escape= 1; break;
+ default: escape= 0; break;
+ }
+ if (escape)
+ {
+ if ((mblen= cs->cset->wc_mb(cs, '\\', (uchar*) to, to_end)) <= 0)
+ goto null;
+ to+= mblen;
+ }
+ if ((mblen= cs->cset->wc_mb(cs, wc, (uchar*) to, to_end)) <= 0)
+ goto null;
+ to+= mblen;
+ }
+
+ /* Put trailing quote */
+ if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0)
+ goto null;
+ to+= mblen;
+ new_length= to - tmp_value.ptr();
+ goto ret;
+ }
+
/*
We replace characters from the end to the beginning
*/
@@ -3258,6 +3310,8 @@ String *Item_func_quote::val_str(String *str)
}
}
*to= '\'';
+
+ret:
tmp_value.length(new_length);
tmp_value.set_charset(collation.collation);
null_value= 0;
@@ -3451,3 +3505,768 @@ String *Item_func_uuid::val_str(String *str)
return str;
}
+
+
+Item_func_dyncol_create::Item_func_dyncol_create(List<Item> &args,
+ DYNCALL_CREATE_DEF *dfs)
+ : Item_str_func(args), defs(dfs), vals(0), nums(0)
+{
+ DBUG_ASSERT((args.elements & 0x1) == 0); // even number of arguments
+}
+
+
+bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref)
+{
+ bool res= Item_func::fix_fields(thd, ref); // no need Item_str_func here
+ vals= (DYNAMIC_COLUMN_VALUE *) alloc_root(thd->mem_root,
+ sizeof(DYNAMIC_COLUMN_VALUE) *
+ (arg_count / 2));
+ nums= (uint *) alloc_root(thd->mem_root,
+ sizeof(uint) * (arg_count / 2));
+ return res || vals == 0 || nums == 0;
+}
+
+
+void Item_func_dyncol_create::fix_length_and_dec()
+{
+ maybe_null= TRUE;
+ collation.set(&my_charset_bin);
+ decimals= 0;
+}
+
+void Item_func_dyncol_create::prepare_arguments()
+{
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String *res, tmp(buff, sizeof(buff), &my_charset_bin);
+ uint column_count= (arg_count / 2);
+ uint i;
+ my_decimal dtmp, *dres;
+
+ /* get values */
+ for (i= 0; i < column_count; i++)
+ {
+ uint valpos= i * 2 + 1;
+ DYNAMIC_COLUMN_TYPE type= defs[i].type;
+ if (type == DYN_COL_NULL) // auto detect
+ {
+ /*
+ We don't have a default here to ensure we get a warning if
+ one adds a new not handled MYSQL_TYPE_...
+ */
+ switch (args[valpos]->field_type()) {
+ case MYSQL_TYPE_DECIMAL:
+ case MYSQL_TYPE_NEWDECIMAL:
+ type= DYN_COL_DECIMAL;
+ break;
+ case MYSQL_TYPE_TINY:
+ case MYSQL_TYPE_SHORT:
+ case MYSQL_TYPE_LONG:
+ case MYSQL_TYPE_LONGLONG:
+ case MYSQL_TYPE_INT24:
+ case MYSQL_TYPE_YEAR:
+ case MYSQL_TYPE_BIT:
+ type= args[valpos]->unsigned_flag ? DYN_COL_UINT : DYN_COL_INT;
+ break;
+ case MYSQL_TYPE_FLOAT:
+ case MYSQL_TYPE_DOUBLE:
+ type= DYN_COL_DOUBLE;
+ break;
+ case MYSQL_TYPE_NULL:
+ type= DYN_COL_NULL;
+ break;
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATETIME:
+ type= DYN_COL_DATETIME;
+ break;
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_NEWDATE:
+ type= DYN_COL_DATE;
+ break;
+ case MYSQL_TYPE_TIME:
+ type= DYN_COL_TIME;
+ break;
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_ENUM:
+ case MYSQL_TYPE_SET:
+ case MYSQL_TYPE_TINY_BLOB:
+ case MYSQL_TYPE_MEDIUM_BLOB:
+ case MYSQL_TYPE_LONG_BLOB:
+ case MYSQL_TYPE_BLOB:
+ case MYSQL_TYPE_VAR_STRING:
+ case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_GEOMETRY:
+ type= DYN_COL_STRING;
+ break;
+ }
+ }
+ nums[i]= (uint) args[i * 2]->val_int();
+ vals[i].type= type;
+ switch (type) {
+ case DYN_COL_NULL:
+ DBUG_ASSERT(args[valpos]->field_type() == MYSQL_TYPE_NULL);
+ break;
+ case DYN_COL_INT:
+ vals[i].long_value= args[valpos]->val_int();
+ break;
+ case DYN_COL_UINT:
+ vals[i].ulong_value= args[valpos]->val_int();
+ break;
+ case DYN_COL_DOUBLE:
+ vals[i].double_value= args[valpos]->val_real();
+ break;
+ case DYN_COL_STRING:
+ res= args[valpos]->val_str(&tmp);
+ if (res &&
+ (vals[i].string_value.str= my_strndup(res->ptr(), res->length(),
+ MYF(MY_WME))))
+ {
+ vals[i].string_value.length= res->length();
+ vals[i].charset= res->charset();
+ }
+ else
+ {
+ args[valpos]->null_value= 1; // In case of out of memory
+ vals[i].string_value.str= NULL;
+ vals[i].string_value.length= 0; // just to be safe
+ }
+ break;
+ case DYN_COL_DECIMAL:
+ if ((dres= args[valpos]->val_decimal(&dtmp)))
+ {
+ dynamic_column_prepare_decimal(&vals[i]);
+ DBUG_ASSERT(vals[i].decimal_value.len == dres->len);
+ vals[i].decimal_value.intg= dres->intg;
+ vals[i].decimal_value.frac= dres->frac;
+ vals[i].decimal_value.sign= dres->sign();
+ memcpy(vals[i].decimal_buffer, dres->buf,
+ sizeof(vals[i].decimal_buffer));
+ }
+ else
+ {
+ dynamic_column_prepare_decimal(&vals[i]); // just to be safe
+ DBUG_ASSERT(args[valpos]->null_value);
+ }
+ break;
+ case DYN_COL_DATETIME:
+ args[valpos]->get_date(&vals[i].time_value, TIME_FUZZY_DATE);
+ break;
+ case DYN_COL_DATE:
+ args[valpos]->get_date(&vals[i].time_value, TIME_FUZZY_DATE);
+ break;
+ case DYN_COL_TIME:
+ args[valpos]->get_time(&vals[i].time_value);
+ break;
+ default:
+ DBUG_ASSERT(0);
+ vals[i].type= DYN_COL_NULL;
+ }
+ if (vals[i].type != DYN_COL_NULL && args[valpos]->null_value)
+ {
+ if (vals[i].type == DYN_COL_STRING)
+ my_free(vals[i].string_value.str, MYF(MY_ALLOW_ZERO_PTR));
+ vals[i].type= DYN_COL_NULL;
+ }
+ }
+}
+
+void Item_func_dyncol_create::cleanup_arguments()
+{
+ uint column_count= (arg_count / 2);
+ uint i;
+
+ for (i= 0; i < column_count; i++)
+ {
+ if (vals[i].type == DYN_COL_STRING)
+ my_free(vals[i].string_value.str, MYF(MY_ALLOW_ZERO_PTR));
+ }
+}
+
+String *Item_func_dyncol_create::val_str(String *str)
+{
+ DYNAMIC_COLUMN col;
+ String *res;
+ uint column_count= (arg_count / 2);
+ enum enum_dyncol_func_result rc;
+ DBUG_ASSERT((arg_count & 0x1) == 0); // even number of arguments
+
+ prepare_arguments();
+
+ if ((rc= dynamic_column_create_many(&col, column_count, nums, vals)))
+ {
+ dynamic_column_error_message(rc);
+ dynamic_column_column_free(&col);
+ res= NULL;
+ null_value= TRUE;
+ }
+ else
+ {
+ /* Move result from DYNAMIC_COLUMN to str_value */
+ char *ptr;
+ size_t length, alloc_length;
+ dynamic_column_reassociate(&col, &ptr, &length, &alloc_length);
+ str_value.reassociate(ptr, (uint32) length, (uint32) alloc_length,
+ &my_charset_bin);
+ res= &str_value;
+ null_value= FALSE;
+ }
+
+ /* cleanup */
+ cleanup_arguments();
+
+ return res;
+}
+
+void Item_func_dyncol_create::print_arguments(String *str,
+ enum_query_type query_type)
+{
+ uint i;
+ uint column_count= (arg_count / 2);
+ for (i= 0; i < column_count; i++)
+ {
+ args[i*2]->print(str, query_type);
+ str->append(',');
+ args[i*2 + 1]->print(str, query_type);
+ switch (defs[i].type) {
+ case DYN_COL_NULL: // automatic type => write nothing
+ break;
+ case DYN_COL_INT:
+ str->append(STRING_WITH_LEN(" AS int"));
+ break;
+ case DYN_COL_UINT:
+ str->append(STRING_WITH_LEN(" AS unsigned int"));
+ break;
+ case DYN_COL_DOUBLE:
+ str->append(STRING_WITH_LEN(" AS double"));
+ break;
+ case DYN_COL_STRING:
+ str->append(STRING_WITH_LEN(" AS char"));
+ if (defs[i].cs)
+ {
+ str->append(STRING_WITH_LEN(" charset "));
+ str->append(defs[i].cs->csname);
+ str->append(' ');
+ }
+ break;
+ case DYN_COL_DECIMAL:
+ str->append(STRING_WITH_LEN(" AS decimal"));
+ break;
+ case DYN_COL_DATETIME:
+ str->append(STRING_WITH_LEN(" AS datetime"));
+ break;
+ case DYN_COL_DATE:
+ str->append(STRING_WITH_LEN(" AS date"));
+ break;
+ case DYN_COL_TIME:
+ str->append(STRING_WITH_LEN(" AS time"));
+ break;
+ }
+ if (i < column_count - 1)
+ str->append(',');
+ }
+}
+
+
+void Item_func_dyncol_create::print(String *str,
+ enum_query_type query_type)
+{
+ DBUG_ASSERT((arg_count & 0x1) == 0); // even number of arguments
+ str->append(STRING_WITH_LEN("column_create("));
+ print_arguments(str, query_type);
+ str->append(')');
+}
+
+
+String *Item_func_dyncol_add::val_str(String *str)
+{
+ DYNAMIC_COLUMN col;
+ String *res;
+ uint column_count= (arg_count / 2);
+ enum enum_dyncol_func_result rc;
+ DBUG_ASSERT((arg_count & 0x1) == 1); // odd number of arguments
+
+ /* We store the packed data last */
+ res= args[arg_count - 1]->val_str(str);
+ if (args[arg_count - 1]->null_value)
+ goto null;
+ init_dynamic_string(&col, NULL, res->length() + STRING_BUFFER_USUAL_SIZE,
+ STRING_BUFFER_USUAL_SIZE);
+
+ col.length= res->length();
+ memcpy(col.str, res->ptr(), col.length);
+
+ prepare_arguments();
+
+ if ((rc= dynamic_column_update_many(&col, column_count, nums, vals)))
+ {
+ dynamic_column_error_message(rc);
+ dynamic_column_column_free(&col);
+ cleanup_arguments();
+ goto null;
+ }
+
+ {
+ /* Move result from DYNAMIC_COLUMN to str */
+ char *ptr;
+ size_t length, alloc_length;
+ dynamic_column_reassociate(&col, &ptr, &length, &alloc_length);
+ str->reassociate(ptr, (uint32) length, (uint32) alloc_length,
+ &my_charset_bin);
+ null_value= FALSE;
+ }
+
+ /* cleanup */
+ dynamic_column_column_free(&col);
+ cleanup_arguments();
+
+ return str;
+
+null:
+ null_value= TRUE;
+ return NULL;
+}
+
+
+void Item_func_dyncol_add::print(String *str,
+ enum_query_type query_type)
+{
+ DBUG_ASSERT((arg_count & 0x1) == 1); // odd number of arguments
+ str->append(STRING_WITH_LEN("column_create("));
+ args[arg_count - 1]->print(str, query_type);
+ str->append(',');
+ print_arguments(str, query_type);
+ str->append(')');
+}
+
+
+/**
+ Get value for a column stored in a dynamic column
+
+ @notes
+ This function ensures that null_value is set correctly
+*/
+
+bool Item_dyncol_get::get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp)
+{
+ DYNAMIC_COLUMN dyn_str;
+ String *res;
+ longlong num;
+ enum enum_dyncol_func_result rc;
+
+ num= args[1]->val_int();
+ if (args[1]->null_value || num < 0 || num > INT_MAX)
+ {
+ null_value= 1;
+ return 1;
+ }
+
+ res= args[0]->val_str(tmp);
+ if (args[0]->null_value)
+ {
+ null_value= 1;
+ return 1;
+ }
+
+ dyn_str.str= (char*) res->ptr();
+ dyn_str.length= res->length();
+ if ((rc= dynamic_column_get(&dyn_str, (uint) num, val)))
+ {
+ dynamic_column_error_message(rc);
+ null_value= 1;
+ return 1;
+ }
+
+ null_value= 0;
+ return 0; // ok
+}
+
+
+String *Item_dyncol_get::val_str(String *str_result)
+{
+ DYNAMIC_COLUMN_VALUE val;
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String tmp(buff, sizeof(buff), &my_charset_bin);
+
+ if (get_dyn_value(&val, &tmp))
+ return NULL;
+
+ switch (val.type) {
+ case DYN_COL_NULL:
+ goto null;
+ case DYN_COL_INT:
+ case DYN_COL_UINT:
+ str_result->set_int(val.long_value, test(val.type == DYN_COL_UINT),
+ &my_charset_latin1);
+ break;
+ case DYN_COL_DOUBLE:
+ str_result->set_real(val.double_value, NOT_FIXED_DEC, &my_charset_latin1);
+ break;
+ case DYN_COL_STRING:
+ if ((char*) tmp.ptr() <= val.string_value.str &&
+ (char*) tmp.ptr() + tmp.length() >= val.string_value.str)
+ {
+ /* value is allocated in tmp buffer; We have to make a copy */
+ str_result->copy(val.string_value.str, val.string_value.length,
+ val.charset);
+ }
+ else
+ {
+ /*
+ It's safe to use the current value because it's either pointing
+ into a field or in a buffer for another item and this buffer
+ is not going to be deleted during expression evaluation
+ */
+ str_result->set(val.string_value.str, val.string_value.length,
+ val.charset);
+ }
+ break;
+ case DYN_COL_DECIMAL:
+ {
+ int res;
+ int length=
+ my_decimal_string_length((const my_decimal*)&val.decimal_value);
+ if (str_result->alloc(length))
+ goto null;
+ if ((res= decimal2string(&val.decimal_value, (char*) str_result->ptr(),
+ &length, 0, 0, ' ')) != E_DEC_OK)
+ {
+ char buff[40];
+ int len= sizeof(buff);
+ DBUG_ASSERT(length < (int)sizeof(buff));
+ decimal2string(&val.decimal_value, buff, &len, 0, 0, ' ');
+ decimal_operation_results(res, buff, "CHAR");
+ }
+ str_result->set_charset(&my_charset_latin1);
+ str_result->length(length);
+ break;
+ }
+ case DYN_COL_DATETIME:
+ case DYN_COL_DATE:
+ case DYN_COL_TIME:
+ {
+ int length;
+ /*
+ We use AUTO_SEC_PART_DIGITS here to ensure that we do not loose
+ any microseconds from the data. This is safe to do as we are
+ asked to return the time argument as a string.
+ */
+ if (str_result->alloc(MAX_DATE_STRING_REP_LENGTH) ||
+ !(length= my_TIME_to_str(&val.time_value, (char*) str_result->ptr(),
+ AUTO_SEC_PART_DIGITS)))
+ goto null;
+ str_result->set_charset(&my_charset_latin1);
+ str_result->length(length);
+ break;
+ }
+ }
+ return str_result;
+
+null:
+ null_value= TRUE;
+ return 0;
+}
+
+
+longlong Item_dyncol_get::val_int()
+{
+ DYNAMIC_COLUMN_VALUE val;
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String tmp(buff, sizeof(buff), &my_charset_bin);
+
+ if (get_dyn_value(&val, &tmp))
+ return 0;
+
+ switch (val.type) {
+ case DYN_COL_NULL:
+ goto null;
+ case DYN_COL_UINT:
+ unsigned_flag= 1; // Make it possible for caller to detect sign
+ return val.long_value;
+ case DYN_COL_INT:
+ unsigned_flag= 0; // Make it possible for caller to detect sign
+ return val.long_value;
+ case DYN_COL_DOUBLE:
+ {
+ bool error;
+ longlong num;
+
+ num= double_to_longlong(val.double_value, unsigned_flag, &error);
+ if (error)
+ {
+ char buff[30];
+ sprintf(buff, "%lg", val.double_value);
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_DATA_OVERFLOW,
+ ER(ER_DATA_OVERFLOW),
+ buff,
+ unsigned_flag ? "UNSIGNED INT" : "INT");
+ }
+ return num;
+ }
+ case DYN_COL_STRING:
+ {
+ int error;
+ longlong num;
+ char *end= val.string_value.str + val.string_value.length, *org_end= end;
+
+ num= my_strtoll10(val.string_value.str, &end, &error);
+ if (end != org_end || error > 0)
+ {
+ char buff[80];
+ strmake(buff, val.string_value.str, min(sizeof(buff)-1,
+ val.string_value.length));
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_BAD_DATA,
+ ER(ER_BAD_DATA),
+ buff,
+ unsigned_flag ? "UNSIGNED INT" : "INT");
+ }
+ unsigned_flag= error >= 0;
+ return num;
+ }
+ case DYN_COL_DECIMAL:
+ {
+ longlong num;
+ my_decimal2int(E_DEC_FATAL_ERROR, &val.decimal_value, unsigned_flag,
+ &num);
+ return num;
+ }
+ case DYN_COL_DATETIME:
+ case DYN_COL_DATE:
+ case DYN_COL_TIME:
+ unsigned_flag= !val.time_value.neg;
+ if (unsigned_flag)
+ return TIME_to_ulonglong(&val.time_value);
+ else
+ return -(longlong)TIME_to_ulonglong(&val.time_value);
+ }
+
+null:
+ null_value= TRUE;
+ return 0;
+}
+
+
+double Item_dyncol_get::val_real()
+{
+ DYNAMIC_COLUMN_VALUE val;
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String tmp(buff, sizeof(buff), &my_charset_bin);
+
+ if (get_dyn_value(&val, &tmp))
+ return 0.0;
+
+ switch (val.type) {
+ case DYN_COL_NULL:
+ goto null;
+ case DYN_COL_UINT:
+ return ulonglong2double(val.ulong_value);
+ case DYN_COL_INT:
+ return (double) val.long_value;
+ case DYN_COL_DOUBLE:
+ return (double) val.double_value;
+ case DYN_COL_STRING:
+ {
+ int error;
+ char *end;
+ double res= my_strntod(val.charset, (char*) val.string_value.str,
+ val.string_value.length, &end, &error);
+
+ if (end != (char*) val.string_value.str + val.string_value.length ||
+ error)
+ {
+ char buff[80];
+ strmake(buff, val.string_value.str, min(sizeof(buff)-1,
+ val.string_value.length));
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_BAD_DATA,
+ ER(ER_BAD_DATA),
+ buff, "DOUBLE");
+ }
+ return res;
+ }
+ case DYN_COL_DECIMAL:
+ {
+ double res;
+ /* This will always succeed */
+ decimal2double(&val.decimal_value, &res);
+ return res;
+ }
+ case DYN_COL_DATETIME:
+ case DYN_COL_DATE:
+ case DYN_COL_TIME:
+ return TIME_to_double(&val.time_value);
+ }
+
+null:
+ null_value= TRUE;
+ return 0.0;
+}
+
+
+my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value)
+{
+ DYNAMIC_COLUMN_VALUE val;
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String tmp(buff, sizeof(buff), &my_charset_bin);
+
+ if (get_dyn_value(&val, &tmp))
+ return NULL;
+
+ switch (val.type) {
+ case DYN_COL_NULL:
+ goto null;
+ case DYN_COL_UINT:
+ int2my_decimal(E_DEC_FATAL_ERROR, val.long_value, TRUE, decimal_value);
+ break;
+ case DYN_COL_INT:
+ int2my_decimal(E_DEC_FATAL_ERROR, val.long_value, FALSE, decimal_value);
+ break;
+ case DYN_COL_DOUBLE:
+ double2my_decimal(E_DEC_FATAL_ERROR, val.double_value, decimal_value);
+ break;
+ case DYN_COL_STRING:
+ {
+ int rc;
+ rc= str2my_decimal(0, val.string_value.str, val.string_value.length,
+ val.charset, decimal_value);
+ char buff[80];
+ strmake(buff, val.string_value.str, min(sizeof(buff)-1,
+ val.string_value.length));
+ if (rc != E_DEC_OK)
+ {
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_BAD_DATA,
+ ER(ER_BAD_DATA),
+ buff, "DECIMAL");
+ }
+ break;
+ }
+ case DYN_COL_DECIMAL:
+ decimal2my_decimal(&val.decimal_value, decimal_value);
+ break;
+ case DYN_COL_DATETIME:
+ case DYN_COL_DATE:
+ case DYN_COL_TIME:
+ decimal_value= seconds2my_decimal(val.time_value.neg,
+ TIME_to_ulonglong(&val.time_value),
+ val.time_value.second_part,
+ decimal_value);
+ break;
+ }
+ return decimal_value;
+
+null:
+ null_value= TRUE;
+ return 0;
+}
+
+
+bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
+{
+ DYNAMIC_COLUMN_VALUE val;
+ char buff[STRING_BUFFER_USUAL_SIZE];
+ String tmp(buff, sizeof(buff), &my_charset_bin);
+ bool signed_value= 0;
+
+ if (get_dyn_value(&val, &tmp))
+ return 1; // Error
+
+ switch (val.type) {
+ case DYN_COL_NULL:
+ goto null;
+ case DYN_COL_INT:
+ signed_value= 1; // For error message
+ /* fall_trough */
+ case DYN_COL_UINT:
+ if (signed_value || val.ulong_value <= LONGLONG_MAX)
+ {
+ if (int_to_datetime_with_warn(val.ulong_value, ltime, fuzzy_date,
+ 0 /* TODO */))
+ goto null;
+ return 0;
+ }
+ /* let double_to_datetime_with_warn() issue the warning message */
+ val.double_value= static_cast<double>(ULONGLONG_MAX);
+ /* fall_trough */
+ case DYN_COL_DOUBLE:
+ if (double_to_datetime_with_warn(val.double_value, ltime, fuzzy_date,
+ 0 /* TODO */))
+ goto null;
+ return 0;
+ case DYN_COL_DECIMAL:
+ if (decimal_to_datetime_with_warn((my_decimal*)&val.decimal_value, ltime,
+ fuzzy_date, 0 /* TODO */))
+ goto null;
+ return 0;
+ case DYN_COL_STRING:
+ if (str_to_datetime_with_warn(val.string_value.str,
+ val.string_value.length,
+ ltime, fuzzy_date) <= MYSQL_TIMESTAMP_ERROR)
+ goto null;
+ return 0;
+ case DYN_COL_DATETIME:
+ case DYN_COL_DATE:
+ case DYN_COL_TIME:
+ *ltime= val.time_value;
+ return 0;
+ }
+
+null:
+ null_value= TRUE;
+ return 1;
+}
+
+
+void Item_dyncol_get::print(String *str, enum_query_type query_type)
+{
+ str->append(STRING_WITH_LEN("column_get("));
+ args[0]->print(str, query_type);
+ str->append(',');
+ args[1]->print(str, query_type);
+ str->append(')');
+}
+
+
+String *Item_func_dyncol_list::val_str(String *str)
+{
+ uint i;
+ enum enum_dyncol_func_result rc;
+ DYNAMIC_ARRAY arr;
+ DYNAMIC_COLUMN col;
+ String *res= args[0]->val_str(str);
+
+ if (args[0]->null_value)
+ goto null;
+ col.length= res->length();
+ /* We do not change the string, so could do this trick */
+ col.str= (char *)res->ptr();
+ if ((rc= dynamic_column_list(&col, &arr)))
+ {
+ dynamic_column_error_message(rc);
+ delete_dynamic(&arr);
+ goto null;
+ }
+
+ /*
+ We support elements from 0 - 65536, so max size for one element is
+ 6 (including ,).
+ */
+ if (str->alloc(arr.elements * 6))
+ goto null;
+
+ str->length(0);
+ for (i= 0; i < arr.elements; i++)
+ {
+ str->qs_append(*dynamic_element(&arr, i, uint*));
+ if (i < arr.elements - 1)
+ str->qs_append(',');
+ }
+
+ null_value= FALSE;
+ delete_dynamic(&arr);
+ return str;
+
+null:
+ null_value= TRUE;
+ return NULL;
+}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 53219e70973..1958d3edfc6 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -22,6 +22,23 @@
class Item_str_func :public Item_func
{
+protected:
+ /**
+ Sets the result value of the function an empty string, using the current
+ character set. No memory is allocated.
+ @retval A pointer to the str_value member.
+ */
+ String *make_empty_result()
+ {
+ /*
+ Reset string length to an empty string. We don't use str_value.set() as
+ we don't want to free and potentially have to reallocate the buffer
+ for each call.
+ */
+ str_value.length(0);
+ str_value.set_charset(collation.collation);
+ return &str_value;
+ }
public:
Item_str_func() :Item_func() { decimals=NOT_FIXED_DEC; }
Item_str_func(Item *a) :Item_func(a) {decimals=NOT_FIXED_DEC; }
@@ -707,15 +724,17 @@ public:
String *val_str(String *);
void fix_length_and_dec()
{
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + 2;
- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
collation.set(args[0]->collation);
+ ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
+ 2 * collation.collation->mbmaxlen;
+ max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
}
};
class Item_func_conv_charset :public Item_str_func
{
bool use_cached_value;
+ String tmp_value;
public:
bool safe;
CHARSET_INFO *conv_charset; // keep it public
@@ -871,3 +890,71 @@ public:
}
};
+
+class Item_func_dyncol_create: public Item_str_func
+{
+protected:
+ DYNCALL_CREATE_DEF *defs;
+ DYNAMIC_COLUMN_VALUE *vals;
+ uint *nums;
+ void prepare_arguments();
+ void cleanup_arguments();
+ void print_arguments(String *str, enum_query_type query_type);
+public:
+ Item_func_dyncol_create(List<Item> &args, DYNCALL_CREATE_DEF *dfs);
+ bool fix_fields(THD *thd, Item **ref);
+ void fix_length_and_dec();
+ const char *func_name() const{ return "column_create"; }
+ String *val_str(String *);
+ virtual void print(String *str, enum_query_type query_type);
+};
+
+
+class Item_func_dyncol_add: public Item_func_dyncol_create
+{
+public:
+ Item_func_dyncol_add(List<Item> &args, DYNCALL_CREATE_DEF *dfs)
+ :Item_func_dyncol_create(args, dfs)
+ {}
+ const char *func_name() const{ return "column_add"; }
+ String *val_str(String *);
+ virtual void print(String *str, enum_query_type query_type);
+};
+
+
+/*
+ The following functions is always called from an Item_cast function
+*/
+
+class Item_dyncol_get: public Item_str_func
+{
+public:
+ Item_dyncol_get(Item *str, Item *num)
+ :Item_str_func(str, num)
+ {
+ max_length= MAX_DYNAMIC_COLUMN_LENGTH;
+ }
+ void fix_length_and_dec()
+ { maybe_null= 1; }
+ /* Mark that collation can change between calls */
+ bool dynamic_result() { return 1; }
+
+ const char *func_name() const { return "column_get"; }
+ String *val_str(String *);
+ longlong val_int();
+ double val_real();
+ my_decimal *val_decimal(my_decimal *);
+ bool get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ void print(String *str, enum_query_type query_type);
+};
+
+
+class Item_func_dyncol_list: public Item_str_func
+{
+public:
+ Item_func_dyncol_list(Item *str) :Item_str_func(str) {};
+ void fix_length_and_dec() { maybe_null= 1; max_length= MAX_BLOB_WIDTH; };
+ const char *func_name() const{ return "column_list"; }
+ String *val_str(String *);
+};
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 854b328f862..32e94d3226f 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -31,14 +31,18 @@
#include "mysql_priv.h"
#include "sql_select.h"
+double get_post_group_estimate(JOIN* join, double join_op_rows);
+
Item_subselect::Item_subselect():
- Item_result_field(), value_assigned(0), thd(0), substitution(0),
- expr_cache(0), engine(0), old_engine(0), used_tables_cache(0),
- have_to_be_excluded(0), const_item_cache(1), inside_first_fix_fields(0),
- done_first_fix_fields(FALSE), eliminated(FALSE), engine_changed(0),
- changed(0), is_correlated(FALSE)
-{
+ Item_result_field(), value_assigned(0), own_engine(0), thd(0), old_engine(0),
+ used_tables_cache(0), have_to_be_excluded(0), const_item_cache(1),
+ inside_first_fix_fields(0), done_first_fix_fields(FALSE),
+ substitution(0), expr_cache(0), engine(0), forced_const(FALSE), eliminated(FALSE),
+ engine_changed(0), changed(0), is_correlated(FALSE)
+{
+ DBUG_ENTER("Item_subselect::Item_subselect");
+ DBUG_PRINT("enter", ("this: 0x%lx", (ulong) this));
with_subselect= 1;
reset();
/*
@@ -46,6 +50,7 @@ Item_subselect::Item_subselect():
(i.e. some rows will be found returned)
*/
null_value= TRUE;
+ DBUG_VOID_RETURN;
}
@@ -58,7 +63,8 @@ void Item_subselect::init(st_select_lex *select_lex,
*/
DBUG_ENTER("Item_subselect::init");
- DBUG_PRINT("enter", ("select_lex: 0x%lx", (long) select_lex));
+ DBUG_PRINT("enter", ("select_lex: 0x%lx this: 0x%lx",
+ (ulong) select_lex, (ulong) this));
unit= select_lex->master_unit();
thd= unit->thd;
@@ -69,15 +75,14 @@ void Item_subselect::init(st_select_lex *select_lex,
=> we do not copy old_engine here
*/
engine= unit->item->engine;
+ own_engine= FALSE;
parsing_place= unit->item->parsing_place;
- unit->item->engine= 0;
- unit->item= this;
- engine->change_result(this, result);
+ thd->change_item_tree((Item**)&unit->item, this);
+ engine->change_result(this, result, TRUE);
}
else
{
SELECT_LEX *outer_select= unit->outer_select();
- DBUG_ASSERT(thd);
/*
do not take into account expression inside aggregate functions because
they can access original table fields
@@ -97,6 +102,7 @@ void Item_subselect::init(st_select_lex *select_lex,
/* The subquery is an expression cache candidate */
upper->expr_cache_may_be_used[upper->parsing_place]= TRUE;
}
+ DBUG_PRINT("info", ("engine: 0x%lx", (ulong)engine));
DBUG_VOID_RETURN;
}
@@ -123,6 +129,7 @@ void Item_subselect::cleanup()
reset();
value_assigned= 0;
expr_cache= 0;
+ forced_const= FALSE;
DBUG_VOID_RETURN;
}
@@ -146,21 +153,30 @@ void Item_in_subselect::cleanup()
left_expr_cache= NULL;
}
first_execution= TRUE;
- is_constant= FALSE;
+ if (in_strategy & SUBS_MATERIALIZATION)
+ in_strategy= 0;
+ pushed_cond_guards= NULL;
Item_subselect::cleanup();
DBUG_VOID_RETURN;
}
Item_subselect::~Item_subselect()
{
- delete engine;
+ DBUG_ENTER("Item_subselect::~Item_subselect");
+ DBUG_PRINT("enter", ("this: 0x%lx", (ulong) this));
+ if (own_engine)
+ delete engine;
+ else
+ engine->cleanup();
+ engine= NULL;
+ DBUG_VOID_RETURN;
}
-Item_subselect::trans_res
+bool
Item_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_subselect::select_transformer");
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
}
@@ -195,11 +211,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
{
// all transformation is done (used by prepared statements)
changed= 1;
- inside_first_fix_fields= FALSE;
-
-
- // all transformation is done (used by prepared statements)
- changed= 1;
+ inside_first_fix_fields= FALSE;
/*
Substitute the current item with an Item_in_optimizer that was
@@ -209,11 +221,14 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
*/
if (substitution)
{
- // did we changed top item of WHERE condition
+ /*
+ If the top item of the WHERE/HAVING condition changed,
+ set correct WHERE/HAVING for PS.
+ */
if (unit->outer_select()->where == (*ref))
- unit->outer_select()->where= substitution; // correct WHERE for PS
+ unit->outer_select()->where= substitution;
else if (unit->outer_select()->having == (*ref))
- unit->outer_select()->having= substitution; // correct HAVING for PS
+ unit->outer_select()->having= substitution;
(*ref)= substitution;
substitution->name= name;
@@ -224,13 +239,13 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
if (!(*ref)->fixed)
res= (*ref)->fix_fields(thd, ref);
goto end;
-//psergey-merge: done_first_fix_fields= FALSE;
+
}
// Is it one field subselect?
if (engine->cols() > max_columns)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
-//psergey-merge: done_first_fix_fields= FALSE;
+
goto end;
}
fix_length_and_dec();
@@ -248,6 +263,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
end:
done_first_fix_fields= FALSE;
+ inside_first_fix_fields= FALSE;
thd->where= save_where;
return res;
}
@@ -273,6 +289,69 @@ bool Item_subselect::mark_as_eliminated_processor(uchar *arg)
}
+/**
+ Remove a subselect item from its unit so that the unit no longer
+ represents a subquery.
+
+ @param arg unused parameter
+
+ @return
+ FALSE to force the evaluation of the processor for the subsequent items.
+*/
+
+bool Item_subselect::eliminate_subselect_processor(uchar *arg)
+{
+ unit->item= NULL;
+ unit->exclude_from_tree();
+ eliminated= TRUE;
+ return FALSE;
+}
+
+
+/**
+ Adjust the master select of the subquery to be the fake_select which
+ represents the whole UNION right above the subquery, instead of the
+ last query of the UNION.
+
+ @param arg pointer to the fake select
+
+ @return
+ FALSE to force the evaluation of the processor for the subsequent items.
+*/
+
+bool Item_subselect::set_fake_select_as_master_processor(uchar *arg)
+{
+ SELECT_LEX *fake_select= (SELECT_LEX*) arg;
+ /*
+ Move the st_select_lex_unit of a subquery from a global ORDER BY clause to
+ become a direct child of the fake_select of a UNION. In this way the
+ ORDER BY that is applied to the temporary table that contains the result of
+ the whole UNION, and all columns in the subquery are resolved against this
+ table. The transformation is applied only for immediate child subqueries of
+ a UNION query.
+ */
+ if (unit->outer_select()->master_unit()->fake_select_lex == fake_select)
+ {
+ /*
+ Set the master of the subquery to be the fake select (i.e. the whole
+ UNION), instead of the last query in the UNION.
+ */
+ fake_select->add_slave(unit);
+ DBUG_ASSERT(unit->outer_select() == fake_select);
+ /* Adjust the name resolution context hierarchy accordingly. */
+ for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
+ sl->context.outer_context= &(fake_select->context);
+ /*
+ Undo Item_subselect::eliminate_subselect_processor because at that phase
+ we don't know yet that the ORDER clause will be moved to the fake select.
+ */
+ unit->item= this;
+ eliminated= FALSE;
+ }
+ return FALSE;
+}
+
+
bool Item_subselect::mark_as_dependent(THD *thd, st_select_lex *select,
Item *item)
{
@@ -479,6 +558,55 @@ bool Item_subselect::exec()
}
+int Item_in_subselect::optimize(double *out_rows, double *cost)
+{
+ int res;
+ DBUG_ENTER("Item_in_subselect::optimize");
+ SELECT_LEX *save_select= thd->lex->current_select;
+ JOIN *join= unit->first_select()->join;
+
+ thd->lex->current_select= join->select_lex;
+ if ((res= join->optimize()))
+ DBUG_RETURN(res);
+
+ /* Calculate #rows and cost of join execution */
+ join->get_partial_cost_and_fanout(join->table_count - join->const_tables,
+ table_map(-1),
+ cost, out_rows);
+
+ /*
+ Adjust join output cardinality. There can be these cases:
+ - Have no GROUP BY and no aggregate funcs: we won't get into this
+ function because such join will be processed as a merged semi-join
+ (TODO: does it really mean we don't need to handle such cases here at
+ all? put ASSERT)
+ - Have no GROUP BY but have aggregate funcs: output is 1 record.
+ - Have GROUP BY and have (or not) aggregate funcs: need to adjust output
+ cardinality.
+ */
+ thd->lex->current_select= save_select;
+ if (!join->group_list && !join->group_optimized_away &&
+ join->tmp_table_param.sum_func_count)
+ {
+ DBUG_PRINT("info",("Materialized join will have only 1 row (it has "
+ "aggregates but no GROUP BY"));
+ *out_rows= 1;
+ }
+
+ /* Now with grouping */
+ if (join->group_list)
+ {
+ DBUG_PRINT("info",("Materialized join has grouping, trying to estimate it"));
+ double output_rows= get_post_group_estimate(join, *out_rows);
+ DBUG_PRINT("info",("Got value of %g", output_rows));
+ *out_rows= output_rows;
+ }
+
+ DBUG_RETURN(res);
+
+}
+
+
/**
Check if an expression cache is needed for this subquery
@@ -548,7 +676,7 @@ bool Item_in_subselect::exec()
- on a cost-based basis, that takes into account the cost of a cache
lookup, the cache hit rate, and the savings per cache hit.
*/
- if (!left_expr_cache && exec_method == MATERIALIZATION)
+ if (!left_expr_cache && (in_strategy & SUBS_MATERIALIZATION))
init_left_expr_cache();
/*
@@ -601,12 +729,15 @@ Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
void Item_subselect::update_used_tables()
{
- recalc_used_tables(parent_select, FALSE);
- if (!engine->uncacheable())
+ if (!forced_const)
{
- // did all used tables become static?
- if (!(used_tables_cache & ~engine->upper_select_const_tables()))
- const_item_cache= 1;
+ recalc_used_tables(parent_select, FALSE);
+ if (!engine->uncacheable())
+ {
+ // did all used tables become static?
+ if (!(used_tables_cache & ~engine->upper_select_const_tables()))
+ const_item_cache= 1;
+ }
}
}
@@ -672,7 +803,7 @@ Item_maxmin_subselect::Item_maxmin_subselect(THD *thd_param,
of Items belonged to subquery, which will be not repeated
*/
used_tables_cache= parent->get_used_tables_cache();
- const_item_cache= parent->get_const_item_cache();
+ const_item_cache= parent->const_item();
/*
this subquery always creates during preparation, so we can assign
@@ -710,8 +841,7 @@ void Item_maxmin_subselect::print(String *str, enum_query_type query_type)
void Item_singlerow_subselect::reset()
{
- eliminated= FALSE;
- null_value= TRUE;
+ Item_subselect::reset();
if (value)
value->null_value= TRUE;
}
@@ -726,13 +856,17 @@ void Item_singlerow_subselect::reset()
- switch off this optimization for prepare statement,
because we do not rollback this changes.
Make rollback for it, or special name resolving mode in 5.0.
+
+ @param join Join object of the subquery (i.e. 'child' join).
+
+ @retval false The subquery was transformed
*/
-Item_subselect::trans_res
+bool
Item_singlerow_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_singlerow_subselect::select_transformer");
if (changed)
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
SELECT_LEX *select_lex= join->select_lex;
Query_arena *arena= thd->stmt_arena;
@@ -759,7 +893,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
!arena->is_stmt_prepare_or_first_sp_execute()
)
{
-
have_to_be_excluded= 1;
if (thd->lex->describe)
{
@@ -775,18 +908,14 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
*/
substitution->walk(&Item::remove_dependence_processor, 0,
(uchar *) select_lex->outer_select());
- DBUG_RETURN(RES_REDUCE);
}
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
}
void Item_singlerow_subselect::store(uint i, Item *item)
{
row[i]->store(item);
- //psergey-merge: can do without that: row[i]->cache_value();
- //psergey-backport-timours: ^ really, without that ^
- //psergey-try-merge-again:
row[i]->cache_value();
}
@@ -1008,11 +1137,13 @@ bool Item_in_subselect::test_limit(st_select_lex_unit *unit_arg)
Item_in_subselect::Item_in_subselect(Item * left_exp,
st_select_lex *select_lex):
Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
- is_constant(FALSE), optimizer(0), pushed_cond_guards(NULL),
- exec_method(NOT_TRANSFORMED), upper_item(0)
+ optimizer(0), pushed_cond_guards(NULL), in_strategy(0),
+ is_jtbm_merged(FALSE), is_flattenable_semijoin(FALSE),
+ upper_item(0)
{
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
left_expr= left_exp;
+ func= &eq_creator;
init(select_lex, new select_exists_subselect(this));
max_columns= UINT_MAX;
maybe_null= 1;
@@ -1047,13 +1178,42 @@ Item_allany_subselect::Item_allany_subselect(Item * left_exp,
}
+/**
+ Initialize length and decimals for EXISTS and inherited (IN/ALL/ANY)
+ subqueries
+*/
+
+void Item_exists_subselect::init_length_and_dec()
+{
+ decimals= 0;
+ max_length= 1;
+ max_columns= engine->cols();
+}
+
+
void Item_exists_subselect::fix_length_and_dec()
{
- decimals= 0;
- max_length= 1;
- max_columns= engine->cols();
- /* We need only 1 row to determine existence */
+ DBUG_ENTER("Item_exists_subselect::fix_length_and_dec");
+ init_length_and_dec();
+ /*
+ We need only 1 row to determine existence (i.e. any EXISTS that is not
+ an IN always requires LIMIT 1)
+ */
unit->global_parameters->select_limit= new Item_int((int32) 1);
+ DBUG_PRINT("info", ("Set limit to 1"));
+ DBUG_VOID_RETURN;
+}
+
+
+void Item_in_subselect::fix_length_and_dec()
+{
+ DBUG_ENTER("Item_in_subselect::fix_length_and_dec");
+ init_length_and_dec();
+ /*
+ Unlike Item_exists_subselect, LIMIT 1 is set later for
+ Item_in_subselect, depending on the chosen strategy.
+ */
+ DBUG_VOID_RETURN;
}
@@ -1239,7 +1399,7 @@ bool Item_in_subselect::val_bool()
{
DBUG_ASSERT(fixed == 1);
null_value= was_null= FALSE;
- if (is_constant)
+ if (forced_const)
return value;
if (exec())
{
@@ -1272,59 +1432,27 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value)
}
-/*
- Rewrite a single-column IN/ALL/ANY subselect
-
- SYNOPSIS
- Item_in_subselect::single_value_transformer()
- join Join object of the subquery (i.e. 'child' join).
- func Subquery comparison creator
-
- DESCRIPTION
- Rewrite a single-column subquery using rule-based approach. The subquery
-
- oe $cmp$ (SELECT ie FROM ... WHERE subq_where ... HAVING subq_having)
-
- First, try to convert the subquery to scalar-result subquery in one of
- the forms:
-
- - oe $cmp$ (SELECT MAX(...) ) // handled by Item_singlerow_subselect
- - oe $cmp$ <max>(SELECT ...) // handled by Item_maxmin_subselect
-
- If that fails, the subquery will be handled with class Item_in_optimizer,
- Inject the predicates into subquery, i.e. convert it to:
+/**
+ Prepare a single-column IN/ALL/ANY subselect for rewriting.
- - If the subquery has aggregates, GROUP BY, or HAVING, convert to
+ @param join Join object of the subquery (i.e. 'child' join).
- SELECT ie FROM ... HAVING subq_having AND
- trigcond(oe $cmp$ ref_or_null_helper<ie>)
-
- the addition is wrapped into trigger only when we want to distinguish
- between NULL and FALSE results.
-
- - Otherwise (no aggregates/GROUP BY/HAVING) convert it to one of the
- following:
+ @details
- = If we don't need to distinguish between NULL and FALSE subquery:
-
- SELECT 1 FROM ... WHERE (oe $cmp$ ie) AND subq_where
+ Prepare a single-column subquery to be rewritten. Given the subquery.
- = If we need to distinguish between those:
+ If the subquery has no tables it will be turned to an expression between
+ left part and SELECT list.
- SELECT 1 FROM ...
- WHERE subq_where AND trigcond((oe $cmp$ ie) OR (ie IS NULL))
- HAVING trigcond(<is_not_null_test>(ie))
+ In other cases the subquery will be wrapped with Item_in_optimizer which
+ allow later to turn it to EXISTS or MAX/MIN.
- RETURN
- RES_OK Either subquery was transformed, or appopriate
- predicates where injected into it.
- RES_REDUCE The subquery was reduced to non-subquery
- RES_ERROR Error
+ @retval false The subquery was transformed
+ @retval true Error
*/
-Item_subselect::trans_res
-Item_in_subselect::single_value_transformer(JOIN *join,
- Comp_creator *func)
+bool
+Item_in_subselect::single_value_transformer(JOIN *join)
{
SELECT_LEX *select_lex= join->select_lex;
DBUG_ENTER("Item_in_subselect::single_value_transformer");
@@ -1337,95 +1465,42 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (select_lex->item_list.elements > 1)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
- /*
- If this is an ALL/ANY single-value subselect, try to rewrite it with
- a MIN/MAX subselect. We can do that if a possible NULL result of the
- subselect can be ignored.
- E.g. SELECT * FROM t1 WHERE b > ANY (SELECT a FROM t2) can be rewritten
- with SELECT * FROM t1 WHERE b > (SELECT MAX(a) FROM t2).
- We can't check that this optimization is safe if it's not a top-level
- item of the WHERE clause (e.g. because the WHERE clause can contain IS
- NULL/IS NOT NULL functions). If so, we rewrite ALL/ANY with NOT EXISTS
- later in this method.
- */
- if ((abort_on_null || (upper_item && upper_item->top_level())) &&
- !select_lex->master_unit()->uncacheable && !func->eqne_op())
+ Item* join_having= join->having ? join->having : join->tmp_having;
+ if (!(join_having || select_lex->with_sum_func ||
+ select_lex->group_list.elements) &&
+ select_lex->table_list.elements == 0 &&
+ !select_lex->master_unit()->is_union())
{
- if (substitution)
- {
- // It is second (third, ...) SELECT of UNION => All is done
- DBUG_RETURN(RES_OK);
- }
-
- Item *subs;
- if (!select_lex->group_list.elements &&
- !select_lex->having &&
- !select_lex->with_sum_func &&
- !(select_lex->next_select()) &&
- select_lex->table_list.elements)
- {
- Item_sum_hybrid *item;
- nesting_map save_allow_sum_func;
- if (func->l_op())
- {
- /*
- (ALL && (> || =>)) || (ANY && (< || =<))
- for ALL condition is inverted
- */
- item= new Item_sum_max(*select_lex->ref_pointer_array);
- }
- else
- {
- /*
- (ALL && (< || =<)) || (ANY && (> || =>))
- for ALL condition is inverted
- */
- item= new Item_sum_min(*select_lex->ref_pointer_array);
- }
- if (upper_item)
- upper_item->set_sum_test(item);
- *select_lex->ref_pointer_array= item;
- {
- List_iterator<Item> it(select_lex->item_list);
- it++;
- it.replace(item);
- }
-
- save_allow_sum_func= thd->lex->allow_sum_func;
- thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
- /*
- Item_sum_(max|min) can't substitute other item => we can use 0 as
- reference, also Item_sum_(max|min) can't be fixed after creation, so
- we do not check item->fixed
- */
- if (item->fix_fields(thd, 0))
- DBUG_RETURN(RES_ERROR);
- thd->lex->allow_sum_func= save_allow_sum_func;
- /* we added aggregate function => we have to change statistic */
- count_field_types(select_lex, &join->tmp_table_param, join->all_fields,
- 0);
-
- subs= new Item_singlerow_subselect(select_lex);
- }
- else
+ Item *where_item= (Item*) select_lex->item_list.head();
+ /*
+ it is single select without tables => possible optimization
+ remove the dependence mark since the item is moved to upper
+ select and is not outer anymore.
+ */
+ where_item->walk(&Item::remove_dependence_processor, 0,
+ (uchar *) select_lex->outer_select());
+ substitution= func->create(left_expr, where_item);
+ have_to_be_excluded= 1;
+ if (thd->lex->describe)
{
- Item_maxmin_subselect *item;
- subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op());
- if (upper_item)
- upper_item->set_sub_test(item);
+ char warn_buff[MYSQL_ERRMSG_SIZE];
+ sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number);
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_SELECT_REDUCED, warn_buff);
}
- /* fix fields is already called for left expression */
- substitution= func->create(left_expr, subs);
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
}
+ /*
+ Wrap the current IN predicate in an Item_in_optimizer. The actual
+ substitution in the Item tree takes place in Item_subselect::fix_fields.
+ */
if (!substitution)
{
/* We're invoked for the 1st (or the only) SELECT in the subquery UNION */
- SELECT_LEX_UNIT *master_unit= select_lex->master_unit();
substitution= optimizer;
SELECT_LEX *current= thd->lex->current_select;
@@ -1435,7 +1510,7 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (!optimizer || optimizer->fix_left(thd, 0))
{
thd->lex->current_select= current;
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
thd->lex->current_select= current;
@@ -1451,41 +1526,157 @@ Item_in_subselect::single_value_transformer(JOIN *join,
(char *)"<no matter>",
(char *)in_left_expr_name);
+ }
+
+ DBUG_RETURN(false);
+}
+
+
+/**
+ Apply transformation max/min transwormation to ALL/ANY subquery if it is
+ possible.
+
+ @param join Join object of the subquery (i.e. 'child' join).
+
+ @details
+
+ If this is an ALL/ANY single-value subselect, try to rewrite it with
+ a MIN/MAX subselect. We can do that if a possible NULL result of the
+ subselect can be ignored.
+ E.g. SELECT * FROM t1 WHERE b > ANY (SELECT a FROM t2) can be rewritten
+ with SELECT * FROM t1 WHERE b > (SELECT MAX(a) FROM t2).
+ We can't check that this optimization is safe if it's not a top-level
+ item of the WHERE clause (e.g. because the WHERE clause can contain IS
+ NULL/IS NOT NULL functions). If so, we rewrite ALL/ANY with NOT EXISTS
+ later in this method.
+
+ @retval false The subquery was transformed
+ @retval true Error
+*/
+
+bool Item_allany_subselect::transform_into_max_min(JOIN *join)
+{
+ DBUG_ENTER("Item_allany_subselect::transform_into_max_min");
+ if (!(in_strategy & SUBS_MAXMIN))
+ DBUG_RETURN(false);
+ Item **place= optimizer->arguments() + 1;
+ THD *thd= join->thd;
+ SELECT_LEX *select_lex= join->select_lex;
+ Item *subs;
+
+ /*
+ */
+ DBUG_ASSERT(!substitution);
+
+ if (!select_lex->group_list.elements &&
+ !select_lex->having &&
+ !select_lex->with_sum_func &&
+ !(select_lex->next_select()) &&
+ select_lex->table_list.elements)
+ {
+ Item_sum_hybrid *item;
+ nesting_map save_allow_sum_func;
+ if (func->l_op())
+ {
+ /*
+ (ALL && (> || =>)) || (ANY && (< || =<))
+ for ALL condition is inverted
+ */
+ item= new Item_sum_max(*select_lex->ref_pointer_array);
+ }
+ else
+ {
+ /*
+ (ALL && (< || =<)) || (ANY && (> || =>))
+ for ALL condition is inverted
+ */
+ item= new Item_sum_min(*select_lex->ref_pointer_array);
+ }
+ if (upper_item)
+ upper_item->set_sum_test(item);
+ thd->change_item_tree(select_lex->ref_pointer_array, item);
+ {
+ List_iterator<Item> it(select_lex->item_list);
+ it++;
+ thd->change_item_tree(it.ref(), item);
+ }
+
+ save_allow_sum_func= thd->lex->allow_sum_func;
+ thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
/*
- The uncacheable property controls a number of actions, e.g. whether to
- save/restore (via init_save_join_tab/restore_tmp) the original JOIN for
- plans with a temp table where the original JOIN was overriden by
- make_simple_join. The UNCACHEABLE_EXPLAIN is ignored by EXPLAIN, thus
- non-correlated subqueries will not appear as such to EXPLAIN.
+ Item_sum_(max|min) can't substitute other item => we can use 0 as
+ reference, also Item_sum_(max|min) can't be fixed after creation, so
+ we do not check item->fixed
*/
- master_unit->uncacheable|= UNCACHEABLE_EXPLAIN;
- select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
+ if (item->fix_fields(thd, 0))
+ DBUG_RETURN(true);
+ thd->lex->allow_sum_func= save_allow_sum_func;
+ /* we added aggregate function => we have to change statistic */
+ count_field_types(select_lex, &join->tmp_table_param, join->all_fields,
+ 0);
+ if (join->prepare_stage2())
+ DBUG_RETURN(true);
+ subs= new Item_singlerow_subselect(select_lex);
}
-
- if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
+ else
{
- if (!(pushed_cond_guards= (bool*)join->thd->alloc(sizeof(bool))))
- DBUG_RETURN(RES_ERROR);
- pushed_cond_guards[0]= TRUE;
+ Item_maxmin_subselect *item;
+ subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op());
+ if (upper_item)
+ upper_item->set_sub_test(item);
}
+ /* fix fields is already called for left expression */
+ subs= func->create(left_expr, subs);
+ thd->change_item_tree(place, subs);
+ if (subs->fix_fields(thd, &subs))
+ DBUG_RETURN(true);
+ DBUG_ASSERT(subs == (*place)); // There was no substitutions
+ select_lex->master_unit()->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
+ select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
/*
- If this IN predicate can be computed via materialization, do not
- perform the IN -> EXISTS transformation.
+ Remove other strategies if there was (we already changed the query and
+ can't apply other strategy).
*/
- if (exec_method == MATERIALIZATION)
- DBUG_RETURN(RES_OK);
+ in_strategy= SUBS_MAXMIN;
- /* Perform the IN=>EXISTS transformation. */
- DBUG_RETURN(single_value_in_to_exists_transformer(join, func));
+ DBUG_RETURN(false);
+}
+
+
+bool Item_in_subselect::fix_having(Item *having, SELECT_LEX *select_lex)
+{
+ bool fix_res= 0;
+ if (!having->fixed)
+ {
+ select_lex->having_fix_field= 1;
+ fix_res= having->fix_fields(thd, 0);
+ select_lex->having_fix_field= 0;
+ }
+ return fix_res;
+}
+
+bool Item_allany_subselect::is_maxmin_applicable(JOIN *join)
+{
+ /*
+ Check if max/min optimization applicable: It is top item of
+ WHERE condition.
+ */
+ return (abort_on_null || (upper_item && upper_item->top_level())) &&
+ !join->select_lex->master_unit()->uncacheable && !func->eqne_op();
}
/**
- Transofrm an IN predicate into EXISTS via predicate injection.
+ Create the predicates needed to transform a single-column IN/ALL/ANY
+ subselect into a correlated EXISTS via predicate injection.
+
+ @param join[in] Join object of the subquery (i.e. 'child' join).
+ @param where_item[out] the in-to-exists addition to the where clause
+ @param having_item[out] the in-to-exists addition to the having clause
- @details The transformation injects additional predicates into the subquery
- (and makes the subquery correlated) as follows.
+ @details
+ The correlated predicates are created as follows:
- If the subquery has aggregates, GROUP BY, or HAVING, convert to
@@ -1500,37 +1691,38 @@ Item_in_subselect::single_value_transformer(JOIN *join,
= If we don't need to distinguish between NULL and FALSE subquery:
- SELECT 1 FROM ... WHERE (oe $cmp$ ie) AND subq_where
+ SELECT ie FROM ... WHERE subq_where AND (oe $cmp$ ie)
= If we need to distinguish between those:
- SELECT 1 FROM ...
+ SELECT ie FROM ...
WHERE subq_where AND trigcond((oe $cmp$ ie) OR (ie IS NULL))
HAVING trigcond(<is_not_null_test>(ie))
- @param join Join object of the subquery (i.e. 'child' join).
- @param func Subquery comparison creator
-
- @retval RES_OK Either subquery was transformed, or appopriate
- predicates where injected into it.
- @retval RES_REDUCE The subquery was reduced to non-subquery
- @retval RES_ERROR Error
+ @retval false If the new conditions were created successfully
+ @retval true Error
*/
-Item_subselect::trans_res
-Item_in_subselect::single_value_in_to_exists_transformer(JOIN * join, Comp_creator *func)
+bool
+Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
+ Item **where_item,
+ Item **having_item)
{
SELECT_LEX *select_lex= join->select_lex;
- DBUG_ENTER("Item_in_subselect::single_value_in_to_exists_transformer");
-
/*
- The IN=>EXISTS transformation makes non-correlated subqueries correlated.
+ The non-transformed HAVING clause of 'join' may be stored in two ways
+ during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
*/
- select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
- if (join->having || select_lex->with_sum_func ||
+ Item* join_having= join->having ? join->having : join->tmp_having;
+
+ DBUG_ENTER("Item_in_subselect::create_single_in_to_exists_cond");
+
+ *where_item= NULL;
+ *having_item= NULL;
+
+ if (join_having || select_lex->with_sum_func ||
select_lex->group_list.elements)
{
- bool tmp;
Item *item= func->create(expr,
new Item_ref_null_helper(&select_lex->context,
this,
@@ -1546,24 +1738,12 @@ Item_in_subselect::single_value_in_to_exists_transformer(JOIN * join, Comp_creat
*/
item= new Item_func_trig_cond(item, get_cond_guard(0));
}
-
- /*
- AND and comparison functions can't be changed during fix_fields()
- we can assign select_lex->having here, and pass 0 as last
- argument (reference) to fix_fields()
- */
- select_lex->having= join->having= and_items(join->having, item);
- if (join->having == item)
- item->name= (char*)in_having_cond;
- select_lex->having_fix_field= 1;
- /*
- we do not check join->having->fixed, because Item_and (from and_items)
- or comparison function (from func->create) can't be fixed after creation
- */
- tmp= join->having->fix_fields(thd, 0);
- select_lex->having_fix_field= 0;
- if (tmp)
- DBUG_RETURN(RES_ERROR);
+
+ if (!join_having)
+ item->name= (char*) in_having_cond;
+ if (fix_having(item, select_lex))
+ DBUG_RETURN(true);
+ *having_item= item;
}
else
{
@@ -1571,13 +1751,8 @@ Item_in_subselect::single_value_in_to_exists_transformer(JOIN * join, Comp_creat
if (select_lex->table_list.elements)
{
- bool tmp;
- Item *having= item, *orig_item= item;
- select_lex->item_list.empty();
- select_lex->item_list.push_back(new Item_int("Not_used",
- (longlong) 1,
- MY_INT64_NUM_DECIMAL_DIGITS));
- select_lex->ref_pointer_array[0]= select_lex->item_list.head();
+ Item *having= item;
+ Item *orig_item= item;
item= func->create(expr, item);
if (!abort_on_null && orig_item->maybe_null)
@@ -1587,25 +1762,13 @@ Item_in_subselect::single_value_in_to_exists_transformer(JOIN * join, Comp_creat
{
if (!(having= new Item_func_trig_cond(having,
get_cond_guard(0))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
- /*
- Item_is_not_null_test can't be changed during fix_fields()
- we can assign select_lex->having here, and pass 0 as last
- argument (reference) to fix_fields()
- */
- having->name= (char*)in_having_cond;
- select_lex->having= join->having= having;
- select_lex->having_fix_field= 1;
- /*
- we do not check join->having->fixed, because Item_and (from
- and_items) or comparison function (from func->create) can't be
- fixed after creation
- */
- tmp= join->having->fix_fields(thd, 0);
- select_lex->having_fix_field= 0;
- if (tmp)
- DBUG_RETURN(RES_ERROR);
+ having->name= (char*) in_having_cond;
+ if (fix_having(having, select_lex))
+ DBUG_RETURN(true);
+ *having_item= having;
+
item= new Item_cond_or(item,
new Item_func_isnull(orig_item));
}
@@ -1616,39 +1779,23 @@ Item_in_subselect::single_value_in_to_exists_transformer(JOIN * join, Comp_creat
if (!abort_on_null && left_expr->maybe_null)
{
if (!(item= new Item_func_trig_cond(item, get_cond_guard(0))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
+
/*
TODO: figure out why the following is done here in
single_value_transformer but there is no corresponding action in
row_value_transformer?
*/
- item->name= (char *)in_additional_cond;
-
- /*
- AND can't be changed during fix_fields()
- we can assign select_lex->having here, and pass 0 as last
- argument (reference) to fix_fields()
- */
- select_lex->where= join->conds= and_items(join->conds, item);
- select_lex->where->top_level_item();
- /*
- we do not check join->conds->fixed, because Item_and can't be fixed
- after creation
- */
- if (join->conds->fix_fields(thd, 0))
- DBUG_RETURN(RES_ERROR);
+ item->name= (char *) in_additional_cond;
+ if (!item->fixed && item->fix_fields(thd, 0))
+ DBUG_RETURN(true);
+ *where_item= item;
}
else
{
- bool tmp;
if (select_lex->master_unit()->is_union())
{
- /*
- comparison functions can't be changed during fix_fields()
- we can assign select_lex->having here, and pass 0 as last
- argument (reference) to fix_fields()
- */
Item *new_having=
func->create(expr,
new Item_ref_null_helper(&select_lex->context, this,
@@ -1659,49 +1806,40 @@ Item_in_subselect::single_value_in_to_exists_transformer(JOIN * join, Comp_creat
{
if (!(new_having= new Item_func_trig_cond(new_having,
get_cond_guard(0))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
- new_having->name= (char*)in_having_cond;
- select_lex->having= join->having= new_having;
- select_lex->having_fix_field= 1;
-
- /*
- we do not check join->having->fixed, because comparison function
- (from func->create) can't be fixed after creation
- */
- tmp= join->having->fix_fields(thd, 0);
- select_lex->having_fix_field= 0;
- if (tmp)
- DBUG_RETURN(RES_ERROR);
+
+ new_having->name= (char*) in_having_cond;
+ if (fix_having(new_having, select_lex))
+ DBUG_RETURN(true);
+ *having_item= new_having;
}
else
- {
- // it is single select without tables => possible optimization
- // remove the dependence mark since the item is moved to upper
- // select and is not outer anymore.
- item->walk(&Item::remove_dependence_processor, 0,
- (uchar *) select_lex->outer_select());
- item= func->create(left_expr, item);
- // fix_field of item will be done in time of substituting
- substitution= item;
- have_to_be_excluded= 1;
- if (thd->lex->describe)
- {
- char warn_buff[MYSQL_ERRMSG_SIZE];
- sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number);
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
- ER_SELECT_REDUCED, warn_buff);
- }
- DBUG_RETURN(RES_REDUCE);
- }
+ DBUG_ASSERT(false);
}
}
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
}
-Item_subselect::trans_res
+/**
+ Wrap a multi-column IN/ALL/ANY subselect into an Item_in_optimizer.
+
+ @param join Join object of the subquery (i.e. 'child' join).
+
+ @details
+ The subquery predicate is wrapped into an Item_in_optimizer. Later the query
+ optimization phase chooses whether the subquery under the Item_in_optimizer
+ will be further transformed into an equivalent correlated EXISTS by injecting
+ additional predicates, or will be executed via subquery materialization in its
+ unmodified form.
+
+ @retval false The subquery was transformed
+ @retval true Error
+*/
+
+bool
Item_in_subselect::row_value_transformer(JOIN *join)
{
SELECT_LEX *select_lex= join->select_lex;
@@ -1713,7 +1851,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
if (select_lex->item_list.elements != cols_num)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), cols_num);
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
/*
@@ -1732,7 +1870,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
if (!optimizer || optimizer->fix_left(thd, 0))
{
thd->lex->current_select= current;
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
// we will refer to upper level cache array => we have to save it in PS
@@ -1748,89 +1886,97 @@ Item_in_subselect::row_value_transformer(JOIN *join)
*/
master_unit->uncacheable|= UNCACHEABLE_EXPLAIN;
select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
-
- if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
- {
- if (!(pushed_cond_guards= (bool*)join->thd->alloc(sizeof(bool) *
- left_expr->cols())))
- DBUG_RETURN(RES_ERROR);
- for (uint i= 0; i < cols_num; i++)
- pushed_cond_guards[i]= TRUE;
- }
}
- /*
- If this IN predicate can be computed via materialization, do not
- perform the IN -> EXISTS transformation.
- */
- if (exec_method == MATERIALIZATION)
- DBUG_RETURN(RES_OK);
-
- /* Perform the IN=>EXISTS transformation. */
- DBUG_RETURN(row_value_in_to_exists_transformer(join));
+ DBUG_RETURN(false);
}
/**
- Tranform a (possibly non-correlated) IN subquery into a correlated EXISTS.
+ Create the predicates needed to transform a multi-column IN/ALL/ANY
+ subselect into a correlated EXISTS via predicate injection.
- @todo
- The IF-ELSE below can be refactored so that there is no duplication of the
- statements that create the new conditions. For this we have to invert the IF
- and the FOR statements as this:
- for (each left operand)
- create the equi-join condition
- if (is_having_used || !abort_on_null)
- create the "is null" and is_not_null_test items
- if (is_having_used)
- add the equi-join and the null tests to HAVING
- else
- add the equi-join and the "is null" to WHERE
- add the is_not_null_test to HAVING
+ @details
+ The correlated predicates are created as follows:
+
+ - If the subquery has aggregates, GROUP BY, or HAVING, convert to
+
+ (l1, l2, l3) IN (SELECT v1, v2, v3 ... HAVING having)
+ =>
+ EXISTS (SELECT ... HAVING having and
+ (l1 = v1 or is null v1) and
+ (l2 = v2 or is null v2) and
+ (l3 = v3 or is null v3) and
+ is_not_null_test(v1) and
+ is_not_null_test(v2) and
+ is_not_null_test(v3))
+
+ where is_not_null_test used to register nulls in case if we have
+ not found matching to return correct NULL value.
+
+ - Otherwise (no aggregates/GROUP BY/HAVING) convert the subquery as follows:
+
+ (l1, l2, l3) IN (SELECT v1, v2, v3 ... WHERE where)
+ =>
+ EXISTS (SELECT ... WHERE where and
+ (l1 = v1 or is null v1) and
+ (l2 = v2 or is null v2) and
+ (l3 = v3 or is null v3)
+ HAVING is_not_null_test(v1) and
+ is_not_null_test(v2) and
+ is_not_null_test(v3))
+ where is_not_null_test registers NULLs values but reject rows.
+
+ in case when we do not need correct NULL, we have simplier construction:
+ EXISTS (SELECT ... WHERE where and
+ (l1 = v1) and
+ (l2 = v2) and
+ (l3 = v3)
+
+ @param join[in] Join object of the subquery (i.e. 'child' join).
+ @param where_item[out] the in-to-exists addition to the where clause
+ @param having_item[out] the in-to-exists addition to the having clause
+
+ @retval false If the new conditions were created successfully
+ @retval true Error
*/
-Item_subselect::trans_res
-Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
+bool
+Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
+ Item **where_item,
+ Item **having_item)
{
SELECT_LEX *select_lex= join->select_lex;
- Item *having_item= 0;
uint cols_num= left_expr->cols();
- bool is_having_used= (join->having || select_lex->with_sum_func ||
+ /*
+ The non-transformed HAVING clause of 'join' may be stored in two ways
+ during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
+ */
+ Item* join_having= join->having ? join->having : join->tmp_having;
+ bool is_having_used= (join_having || select_lex->with_sum_func ||
select_lex->group_list.first ||
!select_lex->table_list.elements);
- DBUG_ENTER("Item_in_subselect::row_value_in_to_exists_transformer");
+ DBUG_ENTER("Item_in_subselect::create_row_in_to_exists_cond");
+
+ *where_item= NULL;
+ *having_item= NULL;
- /*
- The IN=>EXISTS transformation makes non-correlated subqueries correlated.
- */
- select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
if (is_having_used)
{
- /*
- (l1, l2, l3) IN (SELECT v1, v2, v3 ... HAVING having) =>
- EXISTS (SELECT ... HAVING having and
- (l1 = v1 or is null v1) and
- (l2 = v2 or is null v2) and
- (l3 = v3 or is null v3) and
- is_not_null_test(v1) and
- is_not_null_test(v2) and
- is_not_null_test(v3))
- where is_not_null_test used to register nulls in case if we have
- not found matching to return correct NULL value
- TODO: say here explicitly if the order of AND parts matters or not.
- */
+ /* TODO: say here explicitly if the order of AND parts matters or not. */
Item *item_having_part2= 0;
for (uint i= 0; i < cols_num; i++)
{
DBUG_ASSERT((left_expr->fixed &&
+
select_lex->ref_pointer_array[i]->fixed) ||
(select_lex->ref_pointer_array[i]->type() == REF_ITEM &&
((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() ==
Item_ref::OUTER_REF));
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols()))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
Item *item_eq=
new Item_func_eq(new
Item_ref(&select_lex->context,
@@ -1842,23 +1988,21 @@ Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
Item_ref(&select_lex->context,
select_lex->ref_pointer_array + i,
(char *)"<no matter>",
- (char *)"<list ref>")
- );
+ (char *)"<list ref>"));
Item *item_isnull=
new Item_func_isnull(new
Item_ref(&select_lex->context,
select_lex->ref_pointer_array+i,
(char *)"<no matter>",
- (char *)"<list ref>")
- );
+ (char *)"<list ref>"));
Item *col_item= new Item_cond_or(item_eq, item_isnull);
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
- having_item= and_items(having_item, col_item);
-
+ *having_item= and_items(*having_item, col_item);
+
Item *item_nnull_test=
new Item_is_not_null_test(this,
new Item_ref(&select_lex->context,
@@ -1870,34 +2014,15 @@ Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
{
if (!(item_nnull_test=
new Item_func_trig_cond(item_nnull_test, get_cond_guard(i))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
item_having_part2= and_items(item_having_part2, item_nnull_test);
item_having_part2->top_level_item();
}
- having_item= and_items(having_item, item_having_part2);
- having_item->top_level_item();
+ *having_item= and_items(*having_item, item_having_part2);
}
else
{
- /*
- (l1, l2, l3) IN (SELECT v1, v2, v3 ... WHERE where) =>
- EXISTS (SELECT ... WHERE where and
- (l1 = v1 or is null v1) and
- (l2 = v2 or is null v2) and
- (l3 = v3 or is null v3)
- HAVING is_not_null_test(v1) and
- is_not_null_test(v2) and
- is_not_null_test(v3))
- where is_not_null_test register NULLs values but reject rows
-
- in case when we do not need correct NULL, we have simplier construction:
- EXISTS (SELECT ... WHERE where and
- (l1 = v1) and
- (l2 = v2) and
- (l3 = v3)
- */
- Item *where_item= 0;
for (uint i= 0; i < cols_num; i++)
{
Item *item, *item_isnull;
@@ -1908,7 +2033,7 @@ Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
Item_ref::OUTER_REF));
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols()))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
item=
new Item_func_eq(new
Item_direct_ref(&select_lex->context,
@@ -1921,8 +2046,7 @@ Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
- (char *)"<list ref>")
- );
+ (char *)"<list ref>"));
if (!abort_on_null)
{
Item *having_col_item=
@@ -1940,8 +2064,7 @@ Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
- (char *)"<list ref>")
- );
+ (char *)"<list ref>"));
item= new Item_cond_or(item, item_isnull);
/*
TODO: why we create the above for cases where the right part
@@ -1950,104 +2073,211 @@ Item_in_subselect::row_value_in_to_exists_transformer(JOIN * join)
if (left_expr->element_index(i)->maybe_null)
{
if (!(item= new Item_func_trig_cond(item, get_cond_guard(i))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
if (!(having_col_item=
new Item_func_trig_cond(having_col_item, get_cond_guard(i))))
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
- having_item= and_items(having_item, having_col_item);
+ *having_item= and_items(*having_item, having_col_item);
}
- where_item= and_items(where_item, item);
+ *where_item= and_items(*where_item, item);
}
- /*
- AND can't be changed during fix_fields()
- we can assign select_lex->where here, and pass 0 as last
- argument (reference) to fix_fields()
- */
- select_lex->where= join->conds= and_items(join->conds, where_item);
- select_lex->where->top_level_item();
- if (join->conds->fix_fields(thd, 0))
- DBUG_RETURN(RES_ERROR);
}
- if (having_item)
+
+ if (*where_item)
{
- bool res;
- select_lex->having= join->having= and_items(join->having, having_item);
- if (having_item == select_lex->having)
- having_item->name= (char*)in_having_cond;
- select_lex->having->top_level_item();
- /*
- AND can't be changed during fix_fields()
- we can assign select_lex->having here, and pass 0 as last
- argument (reference) to fix_fields()
- */
- select_lex->having_fix_field= 1;
- res= join->having->fix_fields(thd, 0);
- select_lex->having_fix_field= 0;
- if (res)
- {
- DBUG_RETURN(RES_ERROR);
- }
+ if (!(*where_item)->fixed && (*where_item)->fix_fields(thd, 0))
+ DBUG_RETURN(true);
+ (*where_item)->top_level_item();
+ }
+
+ if (*having_item)
+ {
+ if (!join_having)
+ (*having_item)->name= (char*) in_having_cond;
+ if (fix_having(*having_item, select_lex))
+ DBUG_RETURN(true);
+ (*having_item)->top_level_item();
}
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
}
-Item_subselect::trans_res
+bool
Item_in_subselect::select_transformer(JOIN *join)
{
- return select_in_like_transformer(join, &eq_creator);
+ return select_in_like_transformer(join);
}
/**
- Prepare IN/ALL/ANY/SOME subquery transformation and call appropriate
- transformation function.
+ Create the predicates needed to transform an IN/ALL/ANY subselect into a
+ correlated EXISTS via predicate injection.
+
+ @param join_arg Join object of the subquery.
+
+ @retval FALSE ok
+ @retval TRUE error
+*/
+
+bool Item_in_subselect::create_in_to_exists_cond(JOIN *join_arg)
+{
+ bool res;
- To decide which transformation procedure (scalar or row) applicable here
- we have to call fix_fields() for left expression to be able to call
- cols() method on it. Also this method make arena management for
- underlying transformation methods.
+ DBUG_ASSERT(engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE ||
+ engine->engine_type() == subselect_engine::UNION_ENGINE);
+ /*
+ TODO: the call to init_cond_guards allocates and initializes an
+ array of booleans that may not be used later because we may choose
+ materialization.
+ The two calls below to create_XYZ_cond depend on this boolean array.
+ If the dependency is removed, the call can be moved to a later phase.
+ */
+ init_cond_guards();
+ if (left_expr->cols() == 1)
+ res= create_single_in_to_exists_cond(join_arg,
+ &(join_arg->in_to_exists_where),
+ &(join_arg->in_to_exists_having));
+ else
+ res= create_row_in_to_exists_cond(join_arg,
+ &(join_arg->in_to_exists_where),
+ &(join_arg->in_to_exists_having));
+
+ /*
+ The IN=>EXISTS transformation makes non-correlated subqueries correlated.
+ */
+ join_arg->select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
+ /*
+ The uncacheable property controls a number of actions, e.g. whether to
+ save/restore (via init_save_join_tab/restore_tmp) the original JOIN for
+ plans with a temp table where the original JOIN was overriden by
+ make_simple_join. The UNCACHEABLE_EXPLAIN is ignored by EXPLAIN, thus
+ non-correlated subqueries will not appear as such to EXPLAIN.
+ */
+ join_arg->select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
+ join_arg->select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
+ return (res);
+}
+
+
+/**
+ Transform an IN/ALL/ANY subselect into a correlated EXISTS via injecting
+ correlated in-to-exists predicates.
+
+ @param join_arg Join object of the subquery.
+
+ @retval FALSE ok
+ @retval TRUE error
+*/
+
+bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
+{
+ SELECT_LEX *select_lex= join_arg->select_lex;
+ Item *where_item= join_arg->in_to_exists_where;
+ Item *having_item= join_arg->in_to_exists_having;
+
+ DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
+
+ if (where_item)
+ {
+ List<Item> *and_args= NULL;
+ /*
+ If the top-level Item of the WHERE clause is an AND, detach the multiple
+ equality list that was attached to the end of the AND argument list by
+ build_equal_items_for_cond(). The multiple equalities must be detached
+ because fix_fields merges lower level AND arguments into the upper AND.
+ As a result, the arguments from lower-level ANDs are concatenated after
+ the multiple equalities. When the multiple equality list is treated as
+ such, it turns out that it contains non-Item_equal object which is wrong.
+ */
+ if (join_arg->conds && join_arg->conds->type() == Item::COND_ITEM &&
+ ((Item_cond*) join_arg->conds)->functype() == Item_func::COND_AND_FUNC)
+ {
+ and_args= ((Item_cond*) join_arg->conds)->argument_list();
+ if (join_arg->cond_equal)
+ and_args->disjoin((List<Item> *) &join_arg->cond_equal->current_level);
+ }
+
+ where_item= and_items(join_arg->conds, where_item);
+ if (!where_item->fixed && where_item->fix_fields(thd, 0))
+ DBUG_RETURN(true);
+ // TIMOUR TODO: call optimize_cond() for the new where clause
+ thd->change_item_tree(&select_lex->where, where_item);
+ select_lex->where->top_level_item();
+ join_arg->conds= select_lex->where;
+
+ /* Attach back the list of multiple equalities to the new top-level AND. */
+ if (and_args && join_arg->cond_equal)
+ {
+ /* The argument list of the top-level AND may change after fix fields. */
+ and_args= ((Item_cond*) join_arg->conds)->argument_list();
+ and_args->concat((List<Item> *) &join_arg->cond_equal->current_level);
+ }
+ }
+
+ if (having_item)
+ {
+ Item* join_having= join_arg->having ? join_arg->having:join_arg->tmp_having;
+ having_item= and_items(join_having, having_item);
+ if (fix_having(having_item, select_lex))
+ DBUG_RETURN(true);
+ // TIMOUR TODO: call optimize_cond() for the new having clause
+ thd->change_item_tree(&select_lex->having, having_item);
+ select_lex->having->top_level_item();
+ join_arg->having= select_lex->having;
+ }
+ join_arg->thd->change_item_tree(&unit->global_parameters->select_limit,
+ new Item_int((int32) 1));
+ unit->select_limit_cnt= 1;
+
+ DBUG_RETURN(false);
+}
+
+
+/**
+ Prepare IN/ALL/ANY/SOME subquery transformation and call the appropriate
+ transformation function.
@param join JOIN object of transforming subquery
- @param func creator of condition function of subquery
- @retval
- RES_OK OK
- @retval
- RES_REDUCE OK, and current subquery was reduced during
- transformation
- @retval
- RES_ERROR Error
+ @notes
+ To decide which transformation procedure (scalar or row) applicable here
+ we have to call fix_fields() for the left expression to be able to call
+ cols() method on it. Also this method makes arena management for
+ underlying transformation methods.
+
+ @retval false OK
+ @retval true Error
*/
-Item_subselect::trans_res
-Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
+bool
+Item_in_subselect::select_in_like_transformer(JOIN *join)
{
Query_arena *arena, backup;
SELECT_LEX *current= thd->lex->current_select;
const char *save_where= thd->where;
- Item_subselect::trans_res res= RES_ERROR;
+ bool trans_res= true;
bool result;
DBUG_ENTER("Item_in_subselect::select_in_like_transformer");
+ /*
+ IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it
+ ORDER BY clause becomes meaningless thus we drop it here.
+ */
+ for (SELECT_LEX *sl= current->master_unit()->first_select();
+ sl; sl= sl->next_select())
{
- /*
- IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it
- ORDER BY clause becomes meaningless thus we drop it here.
- */
- SELECT_LEX *sl= current->master_unit()->first_select();
- for (; sl; sl= sl->next_select())
+ if (sl->join)
{
- if (sl->join)
- sl->join->order= 0;
+ sl->join->order= 0;
+ sl->join->skip_sort_order= 1;
}
}
if (changed)
- DBUG_RETURN(RES_OK);
+ DBUG_RETURN(false);
thd->where= "IN/ALL/ANY subquery";
@@ -2079,22 +2309,15 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
goto err;
/*
- If we didn't choose an execution method up to this point, we choose
- the IN=>EXISTS transformation.
- */
- if (exec_method == NOT_TRANSFORMED)
- exec_method= IN_TO_EXISTS;
- arena= thd->activate_stmt_arena_if_needed(&backup);
-
- /*
Both transformers call fix_fields() only for Items created inside them,
and all that items do not make permanent changes in current item arena
which allow to us call them with changed arena (if we do not know nature
of Item, we have to call fix_fields() for it only with original arena to
avoid memory leack)
*/
+ arena= thd->activate_stmt_arena_if_needed(&backup);
if (left_expr->cols() == 1)
- res= single_value_transformer(join, func);
+ trans_res= single_value_transformer(join);
else
{
/* we do not support row operation for ALL/ANY/SOME */
@@ -2103,21 +2326,21 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
if (arena)
thd->restore_active_arena(arena, &backup);
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
- DBUG_RETURN(RES_ERROR);
+ DBUG_RETURN(true);
}
- res= row_value_transformer(join);
+ trans_res= row_value_transformer(join);
}
if (arena)
thd->restore_active_arena(arena, &backup);
err:
thd->where= save_where;
- DBUG_RETURN(res);
+ DBUG_RETURN(trans_res);
}
void Item_in_subselect::print(String *str, enum_query_type query_type)
{
- if (exec_method == IN_TO_EXISTS)
+ if (in_strategy & SUBS_IN_TO_EXISTS)
str->append(STRING_WITH_LEN("<exists>"));
else
{
@@ -2133,7 +2356,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
uint outer_cols_num;
List<Item> *inner_cols;
- if (exec_method == SEMI_JOIN)
+ if (in_strategy & SUBS_SEMI_JOIN)
return !( (*ref)= new Item_int(1));
/*
@@ -2206,99 +2429,48 @@ void Item_in_subselect::update_used_tables()
used_tables_cache |= left_expr->used_tables();
}
+
/**
- Try to create an engine to compute the subselect via materialization,
- and if this fails, revert to execution via the IN=>EXISTS transformation.
+ Try to create and initialize an engine to compute a subselect via
+ materialization.
@details
- The purpose of this method is to hide the implementation details
- of this Item's execution. The method creates a new engine for
- materialized execution, and initializes the engine.
-
- If this initialization fails
- - either because it wasn't possible to create the needed temporary table
- and its index,
- - or because of a memory allocation error,
- then we revert back to execution via the IN=>EXISTS tranformation.
-
- The initialization of the new engine is divided in two parts - a permanent
- one that lives across prepared statements, and one that is repeated for each
- execution.
+ The method creates a new engine for materialized execution, and initializes
+ the engine. The initialization may fail
+ - either because it wasn't possible to create the needed temporary table
+ and its index,
+ - or because of a memory allocation error,
@returns
@retval TRUE memory allocation error occurred
@retval FALSE an execution method was chosen successfully
*/
-bool Item_in_subselect::setup_engine()
+bool Item_in_subselect::setup_mat_engine()
{
- subselect_hash_sj_engine *new_engine= NULL;
- bool res= FALSE;
-
- DBUG_ENTER("Item_in_subselect::setup_engine");
-
- if (engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE)
- {
- /* Create/initialize objects in permanent memory. */
- subselect_single_select_engine *old_engine;
- Query_arena *arena= thd->stmt_arena, backup;
+ subselect_hash_sj_engine *mat_engine= NULL;
+ subselect_single_select_engine *select_engine;
- old_engine= (subselect_single_select_engine*) engine;
+ DBUG_ENTER("Item_in_subselect::setup_mat_engine");
- if (arena->is_conventional())
- arena= 0;
- else
- thd->set_n_backup_active_arena(arena, &backup);
-
- if (!(new_engine= new subselect_hash_sj_engine(thd, this,
- old_engine)) ||
- new_engine->init_permanent(unit->get_unit_column_types()))
- {
- Item_subselect::trans_res trans_res;
- /*
- If for some reason we cannot use materialization for this IN predicate,
- delete all materialization-related objects, and apply the IN=>EXISTS
- transformation.
- */
- delete new_engine;
- new_engine= NULL;
- exec_method= NOT_TRANSFORMED;
- if (left_expr->cols() == 1)
- trans_res= single_value_in_to_exists_transformer(old_engine->join,
- &eq_creator);
- else
- trans_res= row_value_in_to_exists_transformer(old_engine->join);
- res= (trans_res != Item_subselect::RES_OK);
- }
- if (new_engine)
- engine= new_engine;
+ /*
+ The select_engine (that executes transformed IN=>EXISTS subselects) is
+ pre-created at parse time, and is stored in statment memory (preserved
+ across PS executions).
+ */
+ DBUG_ASSERT(engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE);
+ select_engine= (subselect_single_select_engine*) engine;
- if (arena)
- thd->restore_active_arena(arena, &backup);
- }
- else
- {
- DBUG_ASSERT(engine->engine_type() == subselect_engine::HASH_SJ_ENGINE);
- new_engine= (subselect_hash_sj_engine*) engine;
- }
+ /* Create/initialize execution objects. */
+ if (!(mat_engine= new subselect_hash_sj_engine(thd, this, select_engine)))
+ DBUG_RETURN(TRUE);
- /* Initilizations done in runtime memory, repeated for each execution. */
- if (new_engine)
- {
- /*
- Reset the LIMIT 1 set in Item_exists_subselect::fix_length_and_dec.
- TODO:
- Currently we set the subquery LIMIT to infinity, and this is correct
- because we forbid at parse time LIMIT inside IN subqueries (see
- Item_in_subselect::test_limit). However, once we allow this, here
- we should set the correct limit if given in the query.
- */
- unit->global_parameters->select_limit= NULL;
- if ((res= new_engine->init_runtime()))
- DBUG_RETURN(res);
- }
+ if (mat_engine->init(&select_engine->join->fields_list,
+ engine->get_identifier()))
+ DBUG_RETURN(TRUE);
- DBUG_RETURN(res);
+ engine= mat_engine;
+ DBUG_RETURN(FALSE);
}
@@ -2323,7 +2495,7 @@ bool Item_in_subselect::init_left_expr_cache()
An IN predicate might be evaluated in a query for which all tables have
been optimzied away.
*/
- if (!outer_join || !outer_join->tables || !outer_join->tables_list)
+ if (!outer_join || !outer_join->table_count || !outer_join->tables_list)
return TRUE;
if (!(left_expr_cache= new List<Cached_item>))
@@ -2341,39 +2513,35 @@ bool Item_in_subselect::init_left_expr_cache()
}
-/*
- Callback to test if an IN predicate is expensive.
-
- @details
- IN predicates are considered expensive only if they will be executed via
- materialization. The return value affects the behavior of
- make_cond_for_table() in such a way that it is unchanged when we use
- the IN=>EXISTS transformation to compute IN.
-
- @retval TRUE if the predicate is expensive
- @retval FALSE otherwise
-*/
-
-bool Item_in_subselect::is_expensive_processor(uchar *arg)
+bool Item_in_subselect::init_cond_guards()
{
- return exec_method == MATERIALIZATION;
+ uint cols_num= left_expr->cols();
+ if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
+ {
+ if (!(pushed_cond_guards= (bool*)thd->alloc(sizeof(bool) * cols_num)))
+ return TRUE;
+ for (uint i= 0; i < cols_num; i++)
+ pushed_cond_guards[i]= TRUE;
+ }
+ return FALSE;
}
-Item_subselect::trans_res
+bool
Item_allany_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_allany_subselect::select_transformer");
- exec_method= IN_TO_EXISTS;
+ DBUG_ASSERT((in_strategy & ~(SUBS_MAXMIN | SUBS_IN_TO_EXISTS)) == 0);
+ in_strategy|= SUBS_IN_TO_EXISTS;
if (upper_item)
upper_item->show= 1;
- DBUG_RETURN(select_in_like_transformer(join, func));
+ DBUG_RETURN(select_in_like_transformer(join));
}
void Item_allany_subselect::print(String *str, enum_query_type query_type)
{
- if (exec_method == IN_TO_EXISTS)
+ if (in_strategy & SUBS_IN_TO_EXISTS)
str->append(STRING_WITH_LEN("<exists>"));
else
{
@@ -2415,6 +2583,7 @@ void subselect_single_select_engine::cleanup()
prepared= executed= 0;
join= 0;
result->cleanup();
+ select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
DBUG_VOID_RETURN;
}
@@ -2424,6 +2593,9 @@ void subselect_union_engine::cleanup()
DBUG_ENTER("subselect_union_engine::cleanup");
unit->reinit_exec_mechanism();
result->cleanup();
+ unit->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
+ for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
+ sl->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
DBUG_VOID_RETURN;
}
@@ -2708,9 +2880,9 @@ int subselect_single_select_engine::exec()
pushed down into the subquery. Those optimizations are ref[_or_null]
acceses. Change them to be full table scans.
*/
- for (uint i=join->const_tables ; i < join->tables ; i++)
+ for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES); tab;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
- JOIN_TAB *tab=join->join_tab+i;
if (tab && tab->keyuse)
{
for (uint i= 0; i < tab->ref.key_parts; i++)
@@ -3032,6 +3204,9 @@ int subselect_uniquesubquery_engine::exec()
DBUG_RETURN(0);
}
+ if (!tab->preread_init_done && tab->preread_init())
+ DBUG_RETURN(1);
+
if (null_keypart)
DBUG_RETURN(scan_table());
@@ -3164,7 +3339,7 @@ subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine()
int subselect_indexsubquery_engine::exec()
{
- DBUG_ENTER("subselect_indexsubquery_engine::exec");
+ DBUG_ENTER("subselect_indexsubquery_engine");
int error;
bool null_finding= 0;
TABLE *table= tab->table;
@@ -3195,6 +3370,9 @@ int subselect_indexsubquery_engine::exec()
DBUG_RETURN(0);
}
+ if (!tab->preread_init_done && tab->preread_init())
+ DBUG_RETURN(1);
+
if (null_keypart)
DBUG_RETURN(scan_table());
@@ -3296,10 +3474,13 @@ void subselect_uniquesubquery_engine::exclude()
}
-table_map subselect_engine::calc_const_tables(TABLE_LIST *table)
+table_map subselect_engine::calc_const_tables(List<TABLE_LIST> &list)
{
table_map map= 0;
- for (; table; table= table->next_leaf)
+ List_iterator<TABLE_LIST> ti(list);
+ TABLE_LIST *table;
+ //for (; table; table= table->next_leaf)
+ while ((table= ti++))
{
TABLE *tbl= table->table;
if (tbl && tbl->const_table)
@@ -3416,6 +3597,7 @@ void subselect_indexsubquery_engine::print(String *str,
@param si new subselect Item
@param res new select_result object
+ @param temp temporary assignment
@retval
FALSE OK
@@ -3423,12 +3605,32 @@ void subselect_indexsubquery_engine::print(String *str,
TRUE error
*/
-bool subselect_single_select_engine::change_result(Item_subselect *si,
- select_result_interceptor *res)
+bool
+subselect_single_select_engine::change_result(Item_subselect *si,
+ select_result_interceptor *res,
+ bool temp)
{
item= si;
- result= res;
- return select_lex->join->change_result(result);
+ if (temp)
+ {
+ /*
+ Here we reuse change_item_tree to roll back assignment. It has
+ nothing special about Item* pointer so it is safe conversion. We do
+ not change the interface to be compatible with MySQL.
+ */
+ thd->change_item_tree((Item**) &result, (Item*)res);
+ }
+ else
+ result= res;
+
+ /*
+ We can't use 'result' below as gcc 4.2.4's alias optimization
+ assumes that result was not changed by thd->change_item_tree().
+ I tried to find a solution to make gcc happy, but could not find anything
+ that would not require a lot of extra code that would be harder to manage
+ than the current code.
+ */
+ return select_lex->join->change_result(res);
}
@@ -3445,11 +3647,15 @@ bool subselect_single_select_engine::change_result(Item_subselect *si,
*/
bool subselect_union_engine::change_result(Item_subselect *si,
- select_result_interceptor *res)
+ select_result_interceptor *res,
+ bool temp)
{
item= si;
int rc= unit->change_result(res, result);
- result= res;
+ if (temp)
+ thd->change_item_tree((Item**) &result, (Item*)res);
+ else
+ result= res;
return rc;
}
@@ -3466,8 +3672,11 @@ bool subselect_union_engine::change_result(Item_subselect *si,
TRUE error
*/
-bool subselect_uniquesubquery_engine::change_result(Item_subselect *si,
- select_result_interceptor *res)
+bool
+subselect_uniquesubquery_engine::change_result(Item_subselect *si,
+ select_result_interceptor *res,
+ bool temp
+ __attribute__((unused)))
{
DBUG_ASSERT(0);
return TRUE;
@@ -3794,6 +4003,8 @@ bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root)
reexecution.
@param tmp_columns the items that produce the data for the temp table
+ @param subquery_id subquery's identifier (to make "<subquery%d>" name for
+ EXPLAIN)
@details
- Create a temporary table to store the result of the IN subquery. The
@@ -3809,13 +4020,14 @@ bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root)
@retval FALSE otherwise
*/
-bool subselect_hash_sj_engine::init_permanent(List<Item> *tmp_columns)
+bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
{
+ select_union *result_sink;
/* Options to create_tmp_table. */
ulonglong tmp_create_options= thd->options | TMP_TABLE_ALL_COLUMNS;
/* | TMP_TABLE_FORCE_MYISAM; TIMOUR: force MYISAM */
- DBUG_ENTER("subselect_hash_sj_engine::init_permanent");
+ DBUG_ENTER("subselect_hash_sj_engine::init");
if (bitmap_init_memroot(&non_null_key_parts, tmp_columns->elements,
thd->mem_root) ||
@@ -3844,15 +4056,24 @@ bool subselect_hash_sj_engine::init_permanent(List<Item> *tmp_columns)
DBUG_RETURN(TRUE);
}
*/
- if (!(result= new select_materialize_with_stats))
+ if (!(result_sink= new select_materialize_with_stats))
DBUG_RETURN(TRUE);
+
+ char buf[32];
+ uint len= my_snprintf(buf, sizeof(buf), "<subquery%d>", subquery_id);
+ char *name;
+ if (!(name= (char*)thd->alloc(len + 1)))
+ DBUG_RETURN(TRUE);
+ memcpy(name, buf, len+1);
- if (((select_union*) result)->create_result_table(
- thd, tmp_columns, TRUE, tmp_create_options,
- "materialized subselect", TRUE))
+ result_sink->get_tmp_table_param()->materialized_subquery= true;
+ if (result_sink->create_result_table(thd, tmp_columns, TRUE,
+ tmp_create_options,
+ name, TRUE, TRUE))
DBUG_RETURN(TRUE);
- tmp_table= ((select_union*) result)->table;
+ tmp_table= result_sink->table;
+ result= result_sink;
/*
If the subquery has blobs, or the total key lenght is bigger than
@@ -3889,6 +4110,17 @@ bool subselect_hash_sj_engine::init_permanent(List<Item> *tmp_columns)
!(lookup_engine= make_unique_engine()))
DBUG_RETURN(TRUE);
+ /*
+ Repeat name resolution for 'cond' since cond is not part of any
+ clause of the query, and it is not 'fixed' during JOIN::prepare.
+ */
+ if (semi_join_conds && !semi_join_conds->fixed &&
+ semi_join_conds->fix_fields(thd, (Item**)&semi_join_conds))
+ DBUG_RETURN(TRUE);
+ /* Let our engine reuse this query plan for materialization. */
+ materialize_join= materialize_engine->join;
+ materialize_join->change_result(result);
+
DBUG_RETURN(FALSE);
}
@@ -3930,13 +4162,14 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
if (!(tmp_table_ref= (TABLE_LIST*) thd->alloc(sizeof(TABLE_LIST))))
DBUG_RETURN(TRUE);
- tmp_table_ref->init_one_table("", "materialized subselect", TL_READ);
+ tmp_table_ref->init_one_table("", tmp_table->alias.c_ptr(), TL_READ);
tmp_table_ref->table= tmp_table;
context= new Name_resolution_context;
context->init();
context->first_name_resolution_table=
context->last_name_resolution_table= tmp_table_ref;
+ semi_join_conds_context= context;
for (uint i= 0; i < item_in->left_expr->cols(); i++)
{
@@ -3994,6 +4227,7 @@ subselect_hash_sj_engine::make_unique_engine()
DBUG_RETURN(NULL);
tab->table= tmp_table;
+ tab->preread_init_done= FALSE;
tab->ref.tmp_table_index_lookup_init(thd, tmp_key, it, FALSE);
DBUG_RETURN(new subselect_uniquesubquery_engine(thd, tab, item,
@@ -4001,41 +4235,22 @@ subselect_hash_sj_engine::make_unique_engine()
}
-/**
- Initialize members of the engine that need to be re-initilized at each
- execution.
+subselect_hash_sj_engine::~subselect_hash_sj_engine()
+{
+ delete lookup_engine;
+ delete result;
+ if (tmp_table)
+ free_tmp_table(thd, tmp_table);
+}
- @retval TRUE if a memory allocation error occurred
- @retval FALSE if success
-*/
-bool subselect_hash_sj_engine::init_runtime()
+int subselect_hash_sj_engine::prepare()
{
/*
Create and optimize the JOIN that will be used to materialize
the subquery if not yet created.
*/
- materialize_engine->prepare();
- /*
- Repeat name resolution for 'cond' since cond is not part of any
- clause of the query, and it is not 'fixed' during JOIN::prepare.
- */
- if (semi_join_conds && !semi_join_conds->fixed &&
- semi_join_conds->fix_fields(thd, (Item**)&semi_join_conds))
- return TRUE;
- /* Let our engine reuse this query plan for materialization. */
- materialize_join= materialize_engine->join;
- materialize_join->change_result(result);
- return FALSE;
-}
-
-
-subselect_hash_sj_engine::~subselect_hash_sj_engine()
-{
- delete lookup_engine;
- delete result;
- if (tmp_table)
- free_tmp_table(thd, tmp_table);
+ return materialize_engine->prepare();
}
@@ -4056,6 +4271,12 @@ void subselect_hash_sj_engine::cleanup()
count_null_only_columns= 0;
strategy= UNDEFINED;
materialize_engine->cleanup();
+ /*
+ Restore the original Item_in_subselect engine. This engine is created once
+ at parse time and stored across executions, while all other materialization
+ related engines are created and chosen for each execution.
+ */
+ ((Item_in_subselect *) item)->engine= materialize_engine;
if (lookup_engine_type == TABLE_SCAN_ENGINE ||
lookup_engine_type == ROWID_MERGE_ENGINE)
{
@@ -4072,6 +4293,206 @@ void subselect_hash_sj_engine::cleanup()
DBUG_ASSERT(lookup_engine->engine_type() == UNIQUESUBQUERY_ENGINE);
lookup_engine->cleanup();
result->cleanup(); /* Resets the temp table as well. */
+ DBUG_ASSERT(tmp_table);
+ free_tmp_table(thd, tmp_table);
+ tmp_table= NULL;
+}
+
+
+/*
+ Get fanout produced by tables specified in the table_map
+*/
+
+double get_fanout_with_deps(JOIN *join, table_map tset)
+{
+ /* Handle the case of "Impossible WHERE" */
+ if (join->table_count == 0)
+ return 0.0;
+
+ /* First, recursively get all tables we depend on */
+ table_map deps_to_check= tset;
+ table_map checked_deps= 0;
+ table_map further_deps;
+ do
+ {
+ further_deps= 0;
+ Table_map_iterator tm_it(deps_to_check);
+ int tableno;
+ while ((tableno = tm_it.next_bit()) != Table_map_iterator::BITMAP_END)
+ {
+ /* get tableno's dependency tables that are not in needed_set */
+ further_deps |= join->map2table[tableno]->ref.depend_map & ~checked_deps;
+ }
+
+ checked_deps |= deps_to_check;
+ deps_to_check= further_deps;
+ } while (further_deps != 0);
+
+
+ /* Now, walk the join order and calculate the fanout */
+ double fanout= 1;
+ for (JOIN_TAB *tab= first_top_level_tab(join, WITHOUT_CONST_TABLES); tab;
+ tab= next_top_level_tab(join, tab))
+ {
+ if ((tab->table->map & checked_deps) && !tab->emb_sj_nest &&
+ tab->records_read != 0)
+ {
+ fanout *= rows2double(tab->records_read);
+ }
+ }
+ return fanout;
+}
+
+
+#if 0
+void check_out_index_stats(JOIN *join)
+{
+ ORDER *order;
+ uint n_order_items;
+
+ /*
+ First, collect the keys that we can use in each table.
+ We can use a key if
+ - all tables refer to it.
+ */
+ key_map key_start_use[MAX_TABLES];
+ key_map key_infix_use[MAX_TABLES];
+ table_map key_used=0;
+ table_map non_key_used= 0;
+
+ bzero(&key_start_use, sizeof(key_start_use)); //psergey-todo: safe initialization!
+ bzero(&key_infix_use, sizeof(key_infix_use));
+
+ for (order= join->group_list; order; order= order->next)
+ {
+ Item *item= order->item[0];
+
+ if (item->real_type() == Item::FIELD_ITEM)
+ {
+ if (item->used_tables() & OUTER_REF_TABLE_BIT)
+ continue; /* outside references are like constants for us */
+
+ Field *field= ((Item_field*)item->real_item())->field;
+ uint table_no= field->table->tablenr;
+ if (!(non_key_used && table_map(1) << table_no) &&
+ !field->part_of_key.is_clear_all())
+ {
+ key_map infix_map= field->part_of_key;
+ infix_map.subtract(field->key_start);
+ key_start_use[table_no].merge(field->key_start);
+ key_infix_use[table_no].merge(infix_map);
+ key_used |= table_no;
+ }
+ continue;
+ }
+ /*
+ Note: the below will cause clauses like GROUP BY YEAR(date) not to be
+ handled.
+ */
+ non_key_used |= item->used_tables();
+ }
+
+ Table_map_iterator tm_it(key_used & ~non_key_used);
+ int tableno;
+ while ((tableno = tm_it.next_bit()) != Table_map_iterator::BITMAP_END)
+ {
+ key_map::iterator key_it(key_start_use);
+ int keyno;
+ while ((keyno = tm_it.next_bit()) != key_map::iterator::BITMAP_END)
+ {
+ for (order= join->group_list; order; order= order->next)
+ {
+ Item *item= order->item[0];
+ if (item->used_tables() & (table_map(1) << tableno))
+ {
+ DBUG_ASSERT(item->real_type() == Item::FIELD_ITEM);
+ }
+ }
+ /*
+ if (continuation)
+ {
+ walk through list and find which key parts are occupied;
+ // note that the above can't be made any faster.
+ }
+ else
+ use rec_per_key[0];
+
+ find out the cardinality.
+ check if cardinality decreases if we use it;
+ */
+ }
+ }
+}
+#endif
+
+
+/*
+ Get an estimate of how many records will be produced after the GROUP BY
+ operation.
+
+ @param join Join we're operating on
+ @param join_op_rows How many records will be produced by the join
+ operations (this is what join optimizer produces)
+
+ @seealso
+ See also optimize_semijoin_nests(), grep for "Adjust output cardinality
+ estimates". Very similar code there that is not joined with this one
+ because we operate on different data structs and too much effort is
+ needed to abstract them out.
+
+ @return
+ Number of records we expect to get after the GROUP BY operation
+*/
+
+double get_post_group_estimate(JOIN* join, double join_op_rows)
+{
+ table_map tables_in_group_list= table_map(0);
+
+ /* Find out which tables are used in GROUP BY list */
+ for (ORDER *order= join->group_list; order; order= order->next)
+ {
+ Item *item= order->item[0];
+ if (item->used_tables() & RAND_TABLE_BIT)
+ {
+ /* Each join output record will be in its own group */
+ return join_op_rows;
+ }
+ tables_in_group_list|= item->used_tables();
+ }
+ tables_in_group_list &= ~PSEUDO_TABLE_BITS;
+
+ /*
+ Use join fanouts to calculate the max. number of records in the group-list
+ */
+ double fanout_rows[MAX_KEY];
+ bzero(&fanout_rows, sizeof(fanout_rows));
+ double out_rows;
+
+ out_rows= get_fanout_with_deps(join, tables_in_group_list);
+
+#if 0
+ /* The following will be needed when making use of index stats: */
+ /*
+ Also generate max. number of records for each of the tables mentioned
+ in the group-list. We'll use that a baseline number that we'll try to
+ reduce by using
+ - #table-records
+ - index statistics.
+ */
+ Table_map_iterator tm_it(tables_in_group_list);
+ int tableno;
+ while ((tableno = tm_it.next_bit()) != Table_map_iterator::BITMAP_END)
+ {
+ fanout_rows[tableno]= get_fanout_with_deps(join, table_map(1) << tableno);
+ }
+
+ /*
+ Try to bring down estimates using index statistics.
+ */
+ //check_out_index_stats(join);
+#endif
+
+ return out_rows;
}
@@ -4100,9 +4521,8 @@ int subselect_hash_sj_engine::exec()
the subquery predicate.
*/
thd->lex->current_select= materialize_engine->select_lex;
- if ((res= materialize_join->optimize()))
- goto err; /* purecov: inspected */
- DBUG_ASSERT(!is_materialized); /* We should materialize only once. */
+ /* The subquery should be optimized, and materialized only once. */
+ DBUG_ASSERT(materialize_join->optimized && !is_materialized);
materialize_join->exec();
if ((res= test(materialize_join->error || thd->is_fatal_error)))
goto err;
@@ -4126,11 +4546,10 @@ int subselect_hash_sj_engine::exec()
tmp_table->file->info(HA_STATUS_VARIABLE);
if (!tmp_table->file->stats.records)
{
- item_in->value= FALSE;
/* The value of IN will not change during this execution. */
- item_in->is_constant= TRUE;
+ item_in->reset();
+ item_in->make_const();
item_in->set_first_execution();
- /* TIMOUR: check if we need this: item_in->null_value= FALSE; */
DBUG_RETURN(FALSE);
}
@@ -4257,7 +4676,8 @@ bool subselect_hash_sj_engine::no_tables()
}
bool subselect_hash_sj_engine::change_result(Item_subselect *si,
- select_result_interceptor *res)
+ select_result_interceptor *res,
+ bool temp __attribute__((unused)))
{
DBUG_ASSERT(FALSE);
return TRUE;
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 3b43d75f43f..5342e4e754e 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -32,10 +32,27 @@ class Cached_item;
class Item_subselect :public Item_result_field
{
- bool value_assigned; /* value already assigned to subselect */
+ bool value_assigned; /* value already assigned to subselect */
+ bool own_engine; /* the engine was not taken from other Item_subselect */
protected:
/* thread handler, will be assigned in fix_fields only */
THD *thd;
+ /* old engine if engine was changed */
+ subselect_engine *old_engine;
+ /* cache of used external tables */
+ table_map used_tables_cache;
+ /* allowed number of columns (1 for single value subqueries) */
+ uint max_columns;
+ /* where subquery is placed */
+ enum_parsing_place parsing_place;
+ /* work with 'substitution' */
+ bool have_to_be_excluded;
+ /* cache of constant state */
+ bool const_item_cache;
+
+ bool inside_first_fix_fields;
+ bool done_first_fix_fields;
+public:
/*
Used inside Item_subselect::fix_fields() according to this scenario:
> Item_subselect::fix_fields
@@ -46,32 +63,22 @@ protected:
< child_join->prepare
< engine->prepare
*ref= substitution;
+ substitution= NULL;
< Item_subselect::fix_fields
*/
Item *substitution;
-public:
/* unit of subquery */
st_select_lex_unit *unit;
-protected:
Item *expr_cache;
/* engine that perform execution of subselect (single select or union) */
subselect_engine *engine;
- /* old engine if engine was changed */
- subselect_engine *old_engine;
- /* cache of used external tables */
- table_map used_tables_cache;
- /* allowed number of columns (1 for single value subqueries) */
- uint max_columns;
- /* where subquery is placed */
- enum_parsing_place parsing_place;
- /* work with 'substitution' */
- bool have_to_be_excluded;
- /* cache of constant state */
- bool const_item_cache;
-
- bool inside_first_fix_fields;
- bool done_first_fix_fields;
-public:
+ /*
+ Set to TRUE if at optimization or execution time we determine that this
+ item's value is a constant. We need this member because it is not possible
+ to substitute 'this' with a constant item.
+ */
+ bool forced_const;
+
/* A reference from inside subquery predicate to somewhere outside of it */
class Ref_to_outside : public Sql_alloc
{
@@ -112,13 +119,18 @@ public:
/* TRUE <=> The underlying SELECT is correlated w.r.t some ancestor select */
bool is_correlated;
- enum trans_res {RES_OK, RES_REDUCE, RES_ERROR};
enum subs_type {UNKNOWN_SUBS, SINGLEROW_SUBS,
EXISTS_SUBS, IN_SUBS, ALL_SUBS, ANY_SUBS};
Item_subselect();
virtual subs_type substype() { return UNKNOWN_SUBS; }
+ bool is_in_predicate()
+ {
+ return (substype() == Item_subselect::IN_SUBS ||
+ substype() == Item_subselect::ALL_SUBS ||
+ substype() == Item_subselect::ANY_SUBS);
+ }
/*
We need this method, because some compilers do not allow 'this'
@@ -135,7 +147,7 @@ public:
eliminated= FALSE;
null_value= 1;
}
- virtual trans_res select_transformer(JOIN *join);
+ virtual bool select_transformer(JOIN *join);
bool assigned() { return value_assigned; }
void assigned(bool a) { value_assigned= a; }
enum Type type() const;
@@ -149,12 +161,21 @@ public:
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
void recalc_used_tables(st_select_lex *new_parent, bool after_pullout);
virtual bool exec();
+ /*
+ If subquery optimization or execution determines that the subquery has
+ an empty result, mark the subquery predicate as a constant value.
+ */
+ void make_const()
+ {
+ used_tables_cache= 0;
+ const_item_cache= 0;
+ forced_const= TRUE;
+ }
virtual void fix_length_and_dec();
table_map used_tables() const;
table_map not_null_tables() const { return 0; }
bool const_item() const;
inline table_map get_used_tables_cache() { return used_tables_cache; }
- inline bool get_const_item_cache() { return const_item_cache; }
Item *get_tmp_table_item(THD *thd);
void update_used_tables();
virtual void print(String *str, enum_query_type query_type);
@@ -172,6 +193,7 @@ public:
*/
bool is_evaluated() const;
bool is_uncacheable() const;
+ bool is_expensive() { return TRUE; }
/*
Used by max/min subquery to initialize value presence registration
@@ -181,12 +203,23 @@ public:
enum_parsing_place place() { return parsing_place; }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
bool mark_as_eliminated_processor(uchar *arg);
+ bool eliminate_subselect_processor(uchar *arg);
+ bool set_fake_select_as_master_processor(uchar *arg);
bool enumerate_field_refs_processor(uchar *arg);
bool check_vcol_func_processor(uchar *int_arg)
{
return trace_unsupported_by_check_vcol_func_processor("subselect");
}
+ /**
+ Callback to test if an IN predicate is expensive.
+
+ @notes
+ The return value affects the behavior of make_cond_for_table().
+ @retval TRUE if the predicate is expensive
+ @retval FALSE otherwise
+ */
+ bool is_expensive_processor(uchar *arg) { return TRUE; }
/**
Get the SELECT_LEX structure associated with this Item.
@return the SELECT_LEX structure associated with this Item
@@ -223,7 +256,7 @@ public:
subs_type substype() { return SINGLEROW_SUBS; }
void reset();
- trans_res select_transformer(JOIN *join);
+ bool select_transformer(JOIN *join);
void store(uint i, Item* item);
double val_real();
longlong val_int ();
@@ -284,6 +317,8 @@ class Item_exists_subselect :public Item_subselect
protected:
bool value; /* value of this item (boolean: exists/not-exists) */
+ void init_length_and_dec();
+
public:
Item_exists_subselect(st_select_lex *select_lex);
Item_exists_subselect(): Item_subselect() {}
@@ -312,6 +347,23 @@ public:
};
+TABLE_LIST * const NO_JOIN_NEST=(TABLE_LIST*)0x1;
+
+/*
+ Possible methods to execute an IN predicate. These are set by the optimizer
+ based on user-set optimizer switches, semantic analysis and cost comparison.
+*/
+#define SUBS_NOT_TRANSFORMED 0 /* No execution method was chosen for this IN. */
+#define SUBS_SEMI_JOIN 1 /* IN was converted to semi-join. */
+#define SUBS_IN_TO_EXISTS 2 /* IN was converted to correlated EXISTS. */
+#define SUBS_MATERIALIZATION 4 /* Execute IN via subquery materialization. */
+/* Partial matching substrategies of MATERIALIZATION. */
+#define SUBS_PARTIAL_MATCH_ROWID_MERGE 8
+#define SUBS_PARTIAL_MATCH_TABLE_SCAN 16
+/* ALL/ANY will be transformed with max/min optimization */
+#define SUBS_MAXMIN 32
+
+
/**
Representation of IN subquery predicates of the form
"left_expr IN (SELECT ...)".
@@ -329,8 +381,6 @@ public:
class Item_in_subselect :public Item_exists_subselect
{
-public:
- Item *left_expr;
protected:
/*
Cache of the left operand of the subquery predicate. Allocated in the
@@ -338,43 +388,47 @@ protected:
*/
List<Cached_item> *left_expr_cache;
bool first_execution;
- /*
- Set to TRUE if at query execution time we determine that this item's
- value is a constant during this execution. We need this member because
- it is not possible to substitute 'this' with a constant item.
- */
- bool is_constant;
/*
expr & optimizer used in subselect rewriting to store Item for
all JOIN in UNION
*/
Item *expr;
- Item_in_optimizer *optimizer;
bool was_null;
bool abort_on_null;
public:
+ Item_in_optimizer *optimizer;
+protected:
/* Used to trigger on/off conditions that were pushed down to subselect */
bool *pushed_cond_guards;
-
+ Comp_creator *func;
+
+protected:
+ bool init_cond_guards();
+ bool select_in_like_transformer(JOIN *join);
+ bool single_value_transformer(JOIN *join);
+ bool row_value_transformer(JOIN * join);
+ bool fix_having(Item *having, st_select_lex *select_lex);
+ bool create_single_in_to_exists_cond(JOIN * join,
+ Item **where_item,
+ Item **having_item);
+ bool create_row_in_to_exists_cond(JOIN * join,
+ Item **where_item,
+ Item **having_item);
+public:
+ Item *left_expr;
/* Priority of this predicate in the convert-to-semi-join-nest process. */
int sj_convert_priority;
/*
Used by subquery optimizations to keep track about in which clause this
subquery predicate is located:
- (TABLE_LIST*) 1 - the predicate is an AND-part of the WHERE
+ NO_JOIN_NEST - the predicate is an AND-part of the WHERE
join nest pointer - the predicate is an AND-part of ON expression
of a join nest
NULL - for all other locations
See also THD::emb_on_expr_nest.
*/
TABLE_LIST *emb_on_expr_nest;
- /*
- Location of the subquery predicate. It is either
- - pointer to join nest if the subquery predicate is in the ON expression
- - (TABLE_LIST*)1 if the predicate is in the WHERE.
- */
- TABLE_LIST *expr_join_nest;
/*
Types of left_expr and subquery's select list allow to perform subquery
materialization. Currently, we set this to FALSE when it as well could
@@ -386,16 +440,31 @@ public:
Same as above, but they also allow to scan the materialized table.
*/
bool sjm_scan_allowed;
+ double jtbm_read_time;
+ double jtbm_record_count;
- /* The method chosen to execute the IN predicate. */
- enum enum_exec_method {
- NOT_TRANSFORMED, /* No execution method was chosen for this IN. */
- SEMI_JOIN, /* IN was converted to semi-join nest and should be removed. */
- IN_TO_EXISTS, /* IN was converted to correlated EXISTS. */
- MATERIALIZATION /* IN will be executed via subquery materialization. */
- };
- enum_exec_method exec_method;
+ /* A bitmap of possible execution strategies for an IN predicate. */
+ uchar in_strategy;
+
+ bool is_jtbm_merged;
+
+ /*
+ TRUE<=>this is a flattenable semi-join, false overwise.
+ */
+ bool is_flattenable_semijoin;
+ /*
+ Used to determine how this subselect item is represented in the item tree,
+ in case there is a need to locate it there and replace with something else.
+ Two options are possible:
+ 1. This item is there 'as-is'.
+ 1. This item is wrapped within Item_in_optimizer.
+ */
+ Item *original_item()
+ {
+ return is_flattenable_semijoin ? (Item*)this : (Item*)optimizer;
+ }
+
bool *get_cond_guard(int i)
{
return pushed_cond_guards ? pushed_cond_guards + i : NULL;
@@ -412,9 +481,11 @@ public:
Item_in_subselect(Item * left_expr, st_select_lex *select_lex);
Item_in_subselect()
:Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
- is_constant(FALSE), optimizer(0), abort_on_null(0),
- pushed_cond_guards(NULL), exec_method(NOT_TRANSFORMED), upper_item(0)
- {}
+ abort_on_null(0), optimizer(0),
+ pushed_cond_guards(NULL), func(NULL), in_strategy(SUBS_NOT_TRANSFORMED),
+ is_jtbm_merged(FALSE),
+ upper_item(0)
+ {}
void cleanup();
subs_type substype() { return IN_SUBS; }
void reset()
@@ -424,13 +495,10 @@ public:
null_value= 0;
was_null= 0;
}
- trans_res select_transformer(JOIN *join);
- trans_res select_in_like_transformer(JOIN *join, Comp_creator *func);
- trans_res single_value_transformer(JOIN *join, Comp_creator *func);
- trans_res row_value_transformer(JOIN * join);
- trans_res single_value_in_to_exists_transformer(JOIN * join,
- Comp_creator *func);
- trans_res row_value_in_to_exists_transformer(JOIN * join);
+ bool select_transformer(JOIN *join);
+ bool create_in_to_exists_cond(JOIN *join_arg);
+ bool inject_in_to_exists_cond(JOIN *join_arg);
+
virtual bool exec();
longlong val_int();
double val_real();
@@ -443,15 +511,16 @@ public:
bool test_limit(st_select_lex_unit *unit);
virtual void print(String *str, enum_query_type query_type);
bool fix_fields(THD *thd, Item **ref);
+ void fix_length_and_dec();
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
void update_used_tables();
- bool setup_engine();
+ bool setup_mat_engine();
bool init_left_expr_cache();
/* Inform 'this' that it was computed, and contains a valid result. */
void set_first_execution() { if (first_execution) first_execution= FALSE; }
- bool is_expensive_processor(uchar *arg);
bool expr_cache_is_needed(THD *thd);
+ int optimize(double *out_rows, double *cost);
/*
Return the identifier that we could use to identify the subquery for the
user.
@@ -471,7 +540,6 @@ class Item_allany_subselect :public Item_in_subselect
{
public:
chooser_compare_func_creator func_creator;
- Comp_creator *func;
bool all;
Item_allany_subselect(Item * left_expr, chooser_compare_func_creator fc,
@@ -479,8 +547,11 @@ public:
// only ALL subquery has upper not
subs_type substype() { return all?ALL_SUBS:ANY_SUBS; }
- trans_res select_transformer(JOIN *join);
+ bool select_transformer(JOIN *join);
+ void create_comp_func(bool invert) { func= func_creator(invert); }
virtual void print(String *str, enum_query_type query_type);
+ bool is_maxmin_applicable(JOIN *join);
+ bool transform_into_max_min(JOIN *join);
};
@@ -550,9 +621,11 @@ public:
virtual bool may_be_null() { return maybe_null; };
virtual table_map upper_select_const_tables()= 0;
static table_map calc_const_tables(TABLE_LIST *);
+ static table_map calc_const_tables(List<TABLE_LIST> &list);
virtual void print(String *str, enum_query_type query_type)= 0;
virtual bool change_result(Item_subselect *si,
- select_result_interceptor *result)= 0;
+ select_result_interceptor *result,
+ bool temp= FALSE)= 0;
virtual bool no_tables()= 0;
virtual bool is_executed() const { return FALSE; }
/* Check if subquery produced any rows during last query execution */
@@ -567,7 +640,6 @@ protected:
class subselect_single_select_engine: public subselect_engine
{
bool prepared; /* simple subselect is prepared */
- bool optimized; /* simple subselect is optimized */
bool executed; /* simple subselect is executed */
st_select_lex *select_lex; /* corresponding select_lex */
JOIN * join; /* corresponding JOIN structure */
@@ -584,7 +656,9 @@ public:
void exclude();
table_map upper_select_const_tables();
virtual void print (String *str, enum_query_type query_type);
- bool change_result(Item_subselect *si, select_result_interceptor *result);
+ bool change_result(Item_subselect *si,
+ select_result_interceptor *result,
+ bool temp);
bool no_tables();
bool may_be_null();
bool is_executed() const { return executed; }
@@ -613,7 +687,9 @@ public:
void exclude();
table_map upper_select_const_tables();
virtual void print (String *str, enum_query_type query_type);
- bool change_result(Item_subselect *si, select_result_interceptor *result);
+ bool change_result(Item_subselect *si,
+ select_result_interceptor *result,
+ bool temp= FALSE);
bool no_tables();
bool is_executed() const;
bool no_rows();
@@ -665,11 +741,13 @@ public:
void fix_length_and_dec(Item_cache** row);
int exec();
uint cols() { return 1; }
- uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; }
+ uint8 uncacheable() { return UNCACHEABLE_DEPENDENT_INJECTED; }
void exclude();
table_map upper_select_const_tables() { return 0; }
virtual void print (String *str, enum_query_type query_type);
- bool change_result(Item_subselect *si, select_result_interceptor *result);
+ bool change_result(Item_subselect *si,
+ select_result_interceptor *result,
+ bool temp= FALSE);
bool no_tables();
int index_lookup(); /* TIMOUR: this method needs refactoring. */
int scan_table();
@@ -751,7 +829,7 @@ inline bool Item_subselect::is_uncacheable() const
class subselect_hash_sj_engine : public subselect_engine
{
-protected:
+public:
/* The table into which the subquery is materialized. */
TABLE *tmp_table;
/* TRUE if the subquery was materialized into a temp table. */
@@ -763,64 +841,34 @@ protected:
of subselect_single_select_engine::[prepare | cols].
*/
subselect_single_select_engine *materialize_engine;
- /* The engine used to compute the IN predicate. */
- subselect_engine *lookup_engine;
/*
QEP to execute the subquery and materialize its result into a
temporary table. Created during the first call to exec().
*/
JOIN *materialize_join;
-
- /* Keyparts of the only non-NULL composite index in a rowid merge. */
- MY_BITMAP non_null_key_parts;
- /* Keyparts of the single column indexes with NULL, one keypart per index. */
- MY_BITMAP partial_match_key_parts;
- uint count_partial_match_columns;
- uint count_null_only_columns;
/*
A conjunction of all the equality condtions between all pairs of expressions
that are arguments of an IN predicate. We need these to post-filter some
IN results because index lookups sometimes match values that are actually
not equal to the search key in SQL terms.
- */
+ */
Item_cond_and *semi_join_conds;
- /* Possible execution strategies that can be used to compute hash semi-join.*/
- enum exec_strategy {
- UNDEFINED,
- COMPLETE_MATCH, /* Use regular index lookups. */
- PARTIAL_MATCH, /* Use some partial matching strategy. */
- PARTIAL_MATCH_MERGE, /* Use partial matching through index merging. */
- PARTIAL_MATCH_SCAN, /* Use partial matching through table scan. */
- IMPOSSIBLE /* Subquery materialization is not applicable. */
- };
- /* The chosen execution strategy. Computed after materialization. */
- exec_strategy strategy;
-protected:
- exec_strategy get_strategy_using_schema();
- exec_strategy get_strategy_using_data();
- ulonglong rowid_merge_buff_size(bool has_non_null_key,
- bool has_covering_null_row,
- MY_BITMAP *partial_match_key_parts);
- void choose_partial_match_strategy(bool has_non_null_key,
- bool has_covering_null_row,
- MY_BITMAP *partial_match_key_parts);
- bool make_semi_join_conds();
- subselect_uniquesubquery_engine* make_unique_engine();
+ Name_resolution_context *semi_join_conds_context;
+
-public:
subselect_hash_sj_engine(THD *thd, Item_subselect *in_predicate,
subselect_single_select_engine *old_engine)
- :subselect_engine(thd, in_predicate, NULL), tmp_table(NULL),
- is_materialized(FALSE), materialize_engine(old_engine), lookup_engine(NULL),
- materialize_join(NULL), count_partial_match_columns(0),
- count_null_only_columns(0), semi_join_conds(NULL), strategy(UNDEFINED)
+ : subselect_engine(thd, in_predicate, NULL),
+ tmp_table(NULL), is_materialized(FALSE), materialize_engine(old_engine),
+ materialize_join(NULL), semi_join_conds(NULL), lookup_engine(NULL),
+ count_partial_match_columns(0), count_null_only_columns(0),
+ strategy(UNDEFINED)
{}
~subselect_hash_sj_engine();
- bool init_permanent(List<Item> *tmp_columns);
- bool init_runtime();
+ bool init(List<Item> *tmp_columns, uint subquery_id);
void cleanup();
- int prepare() { return 0; } /* Override virtual function in base class. */
+ int prepare();
int exec();
virtual void print(String *str, enum_query_type query_type);
uint cols()
@@ -838,8 +886,42 @@ public:
void fix_length_and_dec(Item_cache** row);//=>base class
void exclude(); //=>base class
//=>base class
- bool change_result(Item_subselect *si, select_result_interceptor *result);
+ bool change_result(Item_subselect *si,
+ select_result_interceptor *result,
+ bool temp= FALSE);
bool no_tables();//=>base class
+
+protected:
+ /* The engine used to compute the IN predicate. */
+ subselect_engine *lookup_engine;
+ /* Keyparts of the only non-NULL composite index in a rowid merge. */
+ MY_BITMAP non_null_key_parts;
+ /* Keyparts of the single column indexes with NULL, one keypart per index. */
+ MY_BITMAP partial_match_key_parts;
+ uint count_partial_match_columns;
+ uint count_null_only_columns;
+ /* Possible execution strategies that can be used to compute hash semi-join.*/
+ enum exec_strategy {
+ UNDEFINED,
+ COMPLETE_MATCH, /* Use regular index lookups. */
+ PARTIAL_MATCH, /* Use some partial matching strategy. */
+ PARTIAL_MATCH_MERGE, /* Use partial matching through index merging. */
+ PARTIAL_MATCH_SCAN, /* Use partial matching through table scan. */
+ IMPOSSIBLE /* Subquery materialization is not applicable. */
+ };
+ /* The chosen execution strategy. Computed after materialization. */
+ exec_strategy strategy;
+ exec_strategy get_strategy_using_schema();
+ exec_strategy get_strategy_using_data();
+ ulonglong rowid_merge_buff_size(bool has_non_null_key,
+ bool has_covering_null_row,
+ MY_BITMAP *partial_match_key_parts);
+ void choose_partial_match_strategy(bool has_non_null_key,
+ bool has_covering_null_row,
+ MY_BITMAP *partial_match_key_parts);
+ bool make_semi_join_conds();
+ subselect_uniquesubquery_engine* make_unique_engine();
+
};
@@ -1065,7 +1147,9 @@ public:
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; }
void exclude() {}
table_map upper_select_const_tables() { return 0; }
- bool change_result(Item_subselect*, select_result_interceptor*)
+ bool change_result(Item_subselect*,
+ select_result_interceptor*,
+ bool temp= FALSE)
{ DBUG_ASSERT(FALSE); return false; }
bool no_tables() { return false; }
bool no_rows()
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 7de02d726fa..e7fe2095481 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -482,7 +482,7 @@ bool Item_sum::walk (Item_processor processor, bool walk_subquery,
Field *Item_sum::create_tmp_field(bool group, TABLE *table,
uint convert_blob_length)
{
- Field *field;
+ Field *UNINIT_VAR(field);
switch (result_type()) {
case REAL_RESULT:
field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
@@ -502,7 +502,8 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table,
field= Field_new_decimal::create_from_item(this);
break;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
// This case should never be choosen
DBUG_ASSERT(0);
return 0;
@@ -609,19 +610,16 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
switch (hybrid_type= item->result_type()) {
case INT_RESULT:
- max_length= 20;
- break;
case DECIMAL_RESULT:
+ case STRING_RESULT:
max_length= item->max_length;
break;
case REAL_RESULT:
max_length= float_length(decimals);
break;
- case STRING_RESULT:
- max_length= item->max_length;
- break;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
};
setup_hybrid(args[0], NULL);
@@ -656,17 +654,31 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
Setup cache/comparator of MIN/MAX functions. When called by the
copy_or_same function value_arg parameter contains calculated value
of the original MIN/MAX object and it is saved in this object's cache.
+
+ We mark the value and arg_cache with 'RAND_TABLE_BIT' to ensure
+ that Arg_comparator::compare_datetime() doesn't allocate new
+ item inside of Arg_comparator. This would cause compare_datetime()
+ and Item_sum_min::add() to use different values!
*/
void Item_sum_hybrid::setup_hybrid(Item *item, Item *value_arg)
{
- value= Item_cache::get_cache(item);
+ if (!(value= Item_cache::get_cache(item)))
+ return;
value->setup(item);
value->store(value_arg);
- arg_cache= Item_cache::get_cache(item);
+ /* Don't cache value, as it will change */
+ if (!item->const_item())
+ value->set_used_tables(RAND_TABLE_BIT);
+ if (!(arg_cache= Item_cache::get_cache(item, item->cmp_type())))
+ return;
arg_cache->setup(item);
+ /* Don't cache value, as it will change */
+ if (!item->const_item())
+ arg_cache->set_used_tables(RAND_TABLE_BIT);
cmp= new Arg_comparator();
- cmp->set_cmp_func(this, (Item**)&arg_cache, (Item**)&value, FALSE);
+ if (cmp)
+ cmp->set_cmp_func(this, (Item**)&arg_cache, (Item**)&value, FALSE);
collation.set(item->collation);
}
@@ -691,14 +703,17 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table,
*/
switch (args[0]->field_type()) {
case MYSQL_TYPE_DATE:
- field= new Field_newdate(maybe_null, name, collation.collation);
+ field= new Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
+ name, collation.collation);
break;
case MYSQL_TYPE_TIME:
- field= new Field_time(maybe_null, name, collation.collation);
+ field= new_Field_time(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
+ name, decimals, collation.collation);
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
- field= new Field_datetime(maybe_null, name, collation.collation);
+ field= new_Field_datetime(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
+ name, decimals, collation.collation);
break;
default:
return Item_sum::create_tmp_field(group, table, convert_blob_length);
@@ -757,13 +772,14 @@ void Item_sum_sum::fix_length_and_dec()
DBUG_ENTER("Item_sum_sum::fix_length_and_dec");
maybe_null=null_value=1;
decimals= args[0]->decimals;
- switch (args[0]->result_type()) {
+ switch (args[0]->cast_to_int_type()) {
case REAL_RESULT:
case STRING_RESULT:
hybrid_type= REAL_RESULT;
sum= 0.0;
break;
case INT_RESULT:
+ case TIME_RESULT:
case DECIMAL_RESULT:
{
/* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
@@ -777,7 +793,7 @@ void Item_sum_sum::fix_length_and_dec()
break;
}
case ROW_RESULT:
- default:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
DBUG_PRINT("info", ("Type: %s (%d, %d)",
@@ -966,7 +982,8 @@ void Item_sum_distinct::fix_length_and_dec()
table_field_type= MYSQL_TYPE_NEWDECIMAL;
break;
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
val.traits->fix_length_and_dec(this, args[0]);
@@ -1053,9 +1070,10 @@ bool Item_sum_distinct::unique_walk_function(void *element)
void Item_sum_distinct::clear()
{
DBUG_ENTER("Item_sum_distinct::clear");
- DBUG_ASSERT(tree != 0); /* we always have a tree */
+ /* During EXPLAIN there is no tree because it is created during execution. */
+ if (tree != 0)
+ tree->reset();
null_value= 1;
- tree->reset();
is_evaluated= FALSE;
DBUG_VOID_RETURN;
}
@@ -1417,7 +1435,8 @@ void Item_sum_variance::fix_length_and_dec()
break;
}
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
DBUG_PRINT("info", ("Type: REAL_RESULT (%d, %d)", max_length, (int)decimals));
@@ -1842,7 +1861,8 @@ void Item_sum_hybrid::reset_field()
break;
}
case ROW_RESULT:
- default:
+ case TIME_RESULT:
+ case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
}
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 8e8f8ac99d2..851b77ddeae 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -354,6 +354,7 @@ public:
forced_const= TRUE;
}
virtual bool const_item() const { return forced_const; }
+ virtual bool const_during_execution() const { return false; }
virtual void print(String *str, enum_query_type query_type);
void fix_num_length_and_dec();
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 9cf56148994..b080f2e9707 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -35,193 +35,6 @@
/** Day number for Dec 31st, 9999. */
#define MAX_DAY_NUMBER 3652424L
-/**
- @todo
- OPTIMIZATION
- - Replace the switch with a function that should be called for each
- date type.
- - Remove sprintf and opencode the conversion, like we do in
- Field_datetime.
-
- The reason for this functions existence is that as we don't have a
- way to know if a datetime/time value has microseconds in them
- we are now only adding microseconds to the output if the
- value has microseconds.
-
- We can't use a standard make_date_time() for this as we don't know
- if someone will use %f in the format specifier in which case we would get
- the microseconds twice.
-*/
-
-static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime,
- String *str)
-{
- char *buff;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length= MAX_DATE_STRING_REP_LENGTH;
-
- if (str->alloc(length))
- return 1;
- buff= (char*) str->ptr();
-
- switch (format) {
- case TIME_ONLY:
- length= cs->cset->snprintf(cs, buff, length, "%s%02d:%02d:%02d",
- ltime->neg ? "-" : "",
- ltime->hour, ltime->minute, ltime->second);
- break;
- case TIME_MICROSECOND:
- length= cs->cset->snprintf(cs, buff, length, "%s%02d:%02d:%02d.%06ld",
- ltime->neg ? "-" : "",
- ltime->hour, ltime->minute, ltime->second,
- ltime->second_part);
- break;
- case DATE_ONLY:
- length= cs->cset->snprintf(cs, buff, length, "%04d-%02d-%02d",
- ltime->year, ltime->month, ltime->day);
- break;
- case DATE_TIME:
- length= cs->cset->snprintf(cs, buff, length,
- "%04d-%02d-%02d %02d:%02d:%02d",
- ltime->year, ltime->month, ltime->day,
- ltime->hour, ltime->minute, ltime->second);
- break;
- case DATE_TIME_MICROSECOND:
- length= cs->cset->snprintf(cs, buff, length,
- "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
- ltime->year, ltime->month, ltime->day,
- ltime->hour, ltime->minute, ltime->second,
- ltime->second_part);
- break;
- }
-
- str->length(length);
- str->set_charset(cs);
- return 0;
-}
-
-
-/*
- Wrapper over make_datetime() with validation of the input MYSQL_TIME value
-
- NOTE
- see make_datetime() for more information
-
- RETURN
- 1 if there was an error during converion
- 0 otherwise
-*/
-
-static bool make_datetime_with_warn(date_time_format_types format, MYSQL_TIME *ltime,
- String *str)
-{
- int warning= 0;
-
- if (make_datetime(format, ltime, str))
- return 1;
- if (check_time_range(ltime, &warning))
- return 1;
- if (!warning)
- return 0;
-
- make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- str->ptr(), str->length(),
- MYSQL_TIMESTAMP_TIME, NullS);
- return make_datetime(format, ltime, str);
-}
-
-
-/*
- Wrapper over make_time() with validation of the input MYSQL_TIME value
-
- NOTE
- see make_time() for more info
-
- RETURN
- 1 if there was an error during conversion
- 0 otherwise
-*/
-
-static bool make_time_with_warn(const DATE_TIME_FORMAT *format,
- MYSQL_TIME *l_time, String *str)
-{
- int warning= 0;
- make_time(format, l_time, str);
- if (check_time_range(l_time, &warning))
- return 1;
- if (warning)
- {
- make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- str->ptr(), str->length(),
- MYSQL_TIMESTAMP_TIME, NullS);
- make_time(format, l_time, str);
- }
-
- return 0;
-}
-
-
-/*
- Convert seconds to MYSQL_TIME value with overflow checking
-
- SYNOPSIS:
- sec_to_time()
- seconds number of seconds
- unsigned_flag 1, if 'seconds' is unsigned, 0, otherwise
- ltime output MYSQL_TIME value
-
- DESCRIPTION
- If the 'seconds' argument is inside MYSQL_TIME data range, convert it to a
- corresponding value.
- Otherwise, truncate the resulting value to the nearest endpoint, and
- produce a warning message.
-
- RETURN
- 1 if the value was truncated during conversion
- 0 otherwise
-*/
-
-static bool sec_to_time(longlong seconds, bool unsigned_flag, MYSQL_TIME *ltime)
-{
- uint sec;
-
- bzero((char *)ltime, sizeof(*ltime));
-
- if (seconds < 0)
- {
- if (unsigned_flag)
- goto overflow;
- ltime->neg= 1;
- if (seconds < -3020399)
- goto overflow;
- seconds= -seconds;
- }
- else if (seconds > 3020399)
- goto overflow;
-
- sec= (uint) ((ulonglong) seconds % 3600);
- ltime->hour= (uint) (seconds/3600);
- ltime->minute= sec/60;
- ltime->second= sec % 60;
-
- return 0;
-
-overflow:
- ltime->hour= TIME_MAX_HOUR;
- ltime->minute= TIME_MAX_MINUTE;
- ltime->second= TIME_MAX_SECOND;
-
- char buf[22];
- int len= (int)(longlong10_to_str(seconds, buf, unsigned_flag ? 10 : -10)
- - buf);
- make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- buf, len, MYSQL_TIMESTAMP_TIME,
- NullS);
-
- return 1;
-}
-
-
/*
Date formats corresponding to compound %r and %T conversion specifiers
@@ -270,7 +83,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
const char *val, uint length, MYSQL_TIME *l_time,
timestamp_type cached_timestamp_type,
const char **sub_pattern_end,
- const char *date_time_type)
+ const char *date_time_type,
+ uint fuzzy_date)
{
int weekday= 0, yearday= 0, daypart= 0;
int week_number= -1;
@@ -291,11 +105,13 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
if (!sub_pattern_end)
bzero((char*) l_time, sizeof(*l_time));
+ l_time->time_type= cached_timestamp_type;
+
for (; ptr != end && val != val_end; ptr++)
{
/* Skip pre-space between each argument */
- while (val != val_end && my_isspace(cs, *val))
- val++;
+ if ((val+= cs->cset->scan(cs, val, val_end, MY_SEQ_SPACES)) >= val_end)
+ break;
if (*ptr == '%' && ptr+1 != end)
{
@@ -464,7 +280,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
*/
if (extract_date_time(&time_ampm_format, val,
(uint)(val_end - val), l_time,
- cached_timestamp_type, &val, "time"))
+ cached_timestamp_type, &val, "time", fuzzy_date))
DBUG_RETURN(1);
break;
@@ -472,7 +288,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
case 'T':
if (extract_date_time(&time_24hrs_format, val,
(uint)(val_end - val), l_time,
- cached_timestamp_type, &val, "time"))
+ cached_timestamp_type, &val, "time", fuzzy_date))
DBUG_RETURN(1);
break;
@@ -579,6 +395,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
l_time->minute > 59 || l_time->second > 59)
goto err;
+ if ((fuzzy_date & TIME_NO_ZERO_DATE) &&
+ (l_time->year == 0 || l_time->month == 0 || l_time->day == 0))
+ goto err;
+
if (val != val_end)
{
do
@@ -649,7 +469,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
system_charset_info);
break;
case 'W':
- if (type == MYSQL_TIMESTAMP_TIME)
+ if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
return 1;
weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),0);
@@ -658,7 +478,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
system_charset_info);
break;
case 'a':
- if (type == MYSQL_TIMESTAMP_TIME)
+ if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
return 1;
weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),0);
@@ -823,7 +643,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
}
break;
case 'w':
- if (type == MYSQL_TIMESTAMP_TIME)
+ if (type == MYSQL_TIMESTAMP_TIME || !(l_time->month || l_time->year))
return 1;
weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),1);
@@ -1025,7 +845,7 @@ longlong Item_func_dayofyear::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
- if (get_arg0_date(&ltime,TIME_NO_ZERO_DATE))
+ if (get_arg0_date(&ltime, TIME_NO_ZERO_IN_DATE | TIME_NO_ZERO_DATE))
return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day) -
calc_daynr(ltime.year,1,1) + 1;
@@ -1294,21 +1114,23 @@ longlong Item_func_year::val_int_endpoint(bool left_endp, bool *incl_endp)
}
-longlong Item_func_unix_timestamp::val_int()
+bool Item_func_unix_timestamp::get_timestamp_value(my_time_t *seconds,
+ ulong *second_part)
{
- MYSQL_TIME ltime;
- my_bool not_used;
-
DBUG_ASSERT(fixed == 1);
- if (arg_count == 0)
- return (longlong) current_thd->query_start();
if (args[0]->type() == FIELD_ITEM)
{ // Optimize timestamp field
Field *field=((Item_field*) args[0])->field;
if (field->type() == MYSQL_TYPE_TIMESTAMP)
- return ((Field_timestamp*) field)->get_timestamp(&null_value);
+ {
+ if ((null_value= field->is_null()))
+ return 1;
+ *seconds= ((Field_timestamp*)field)->get_timestamp(second_part);
+ return 0;
+ }
}
-
+
+ MYSQL_TIME ltime;
if (get_arg0_date(&ltime, 0))
{
/*
@@ -1317,24 +1139,66 @@ longlong Item_func_unix_timestamp::val_int()
this case).
*/
null_value= args[0]->null_value;
- return 0;
+ return 1;
}
+
+ uint error_code;
+ *seconds= TIME_to_timestamp(current_thd, &ltime, &error_code);
+ *second_part= ltime.second_part;
+ return (null_value= (error_code == ER_WARN_DATA_OUT_OF_RANGE));
+}
+
+
+longlong Item_func_unix_timestamp::int_op()
+{
+ if (arg_count == 0)
+ return (longlong) current_thd->query_start();
- return (longlong) TIME_to_timestamp(current_thd, &ltime, &not_used);
+ ulong second_part;
+ my_time_t seconds;
+ if (get_timestamp_value(&seconds, &second_part))
+ return 0;
+
+ return seconds;
}
-longlong Item_func_time_to_sec::val_int()
+my_decimal *Item_func_unix_timestamp::decimal_op(my_decimal* buf)
+{
+ ulong second_part;
+ my_time_t seconds;
+ if (get_timestamp_value(&seconds, &second_part))
+ return 0;
+
+ return seconds2my_decimal(seconds < 0, seconds < 0 ? -seconds : seconds,
+ second_part, buf);
+}
+
+
+longlong Item_func_time_to_sec::int_op()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
- longlong seconds;
- (void) get_arg0_time(&ltime);
- seconds=ltime.hour*3600L+ltime.minute*60+ltime.second;
+ if (get_arg0_time(&ltime))
+ return 0;
+
+ longlong seconds=ltime.hour*3600L+ltime.minute*60+ltime.second;
return ltime.neg ? -seconds : seconds;
}
+my_decimal *Item_func_time_to_sec::decimal_op(my_decimal* buf)
+{
+ DBUG_ASSERT(fixed == 1);
+ MYSQL_TIME ltime;
+ if (get_arg0_time(&ltime))
+ return 0;
+
+ longlong seconds= ltime.hour*3600L+ltime.minute*60+ltime.second;
+ return seconds2my_decimal(ltime.neg, seconds, ltime.second_part, buf);
+}
+
+
/**
Convert a string to a interval value.
@@ -1493,29 +1357,30 @@ bool get_interval_value(Item *args,interval_type int_type,
}
-String *Item_date::val_str(String *str)
+String *Item_temporal_func::val_str(String *str)
+{
+ DBUG_ASSERT(fixed == 1);
+ return val_string_from_date(str);
+}
+
+
+longlong Item_temporal_func::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
- return (String *) 0;
- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
- {
- null_value= 1;
- return (String *) 0;
- }
- make_date((DATE_TIME_FORMAT *) 0, &ltime, str);
- return str;
+ return 0;
+ return (longlong)TIME_to_ulonglong(&ltime);
}
-longlong Item_date::val_int()
+double Item_temporal_func::val_real()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
- return (longlong) (ltime.year*10000L+ltime.month*100+ltime.day);
+ return TIME_to_double(&ltime);
}
@@ -1533,28 +1398,13 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
void Item_func_curdate::fix_length_and_dec()
{
- collation.set(&my_charset_bin);
- decimals=0;
- max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
-
store_now_in_TIME(&ltime);
/* We don't need to set second_part and neg because they already 0 */
ltime.hour= ltime.minute= ltime.second= 0;
ltime.time_type= MYSQL_TIMESTAMP_DATE;
- value= (longlong) TIME_to_ulonglong_date(&ltime);
-}
-
-String *Item_func_curdate::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
- {
- null_value= 1;
- return (String *) 0;
- }
- make_date((DATE_TIME_FORMAT *) 0, &ltime, str);
- return str;
+ Item_datefunc::fix_length_and_dec();
+ maybe_null= false;
}
/**
@@ -1564,8 +1414,7 @@ String *Item_func_curdate::val_str(String *str)
void Item_func_curdate_local::store_now_in_TIME(MYSQL_TIME *now_time)
{
THD *thd= current_thd;
- thd->variables.time_zone->gmt_sec_to_TIME(now_time,
- (my_time_t)thd->query_start());
+ thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->query_start());
thd->time_zone_used= 1;
}
@@ -1576,8 +1425,8 @@ void Item_func_curdate_local::store_now_in_TIME(MYSQL_TIME *now_time)
*/
void Item_func_curdate_utc::store_now_in_TIME(MYSQL_TIME *now_time)
{
- my_tz_UTC->gmt_sec_to_TIME(now_time,
- (my_time_t)(current_thd->query_start()));
+ THD *thd= current_thd;
+ my_tz_UTC->gmt_sec_to_TIME(now_time, thd->query_start());
/*
We are not flagging this query as using time zone, since it uses fixed
UTC-SYSTEM time-zone.
@@ -1593,26 +1442,35 @@ bool Item_func_curdate::get_date(MYSQL_TIME *res,
}
-String *Item_func_curtime::val_str(String *str)
+bool Item_func_curtime::fix_fields(THD *thd, Item **items)
{
- DBUG_ASSERT(fixed == 1);
- str_value.set(buff, buff_length, &my_charset_bin);
- return &str_value;
+ if (decimals > TIME_SECOND_PART_DIGITS)
+ {
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), decimals, func_name(),
+ TIME_SECOND_PART_DIGITS);
+ return 1;
+ }
+ return Item_timefunc::fix_fields(thd, items);
}
-
-void Item_func_curtime::fix_length_and_dec()
+bool Item_func_curtime::get_date(MYSQL_TIME *res,
+ uint fuzzy_date __attribute__((unused)))
{
- MYSQL_TIME ltime;
-
- decimals= DATETIME_DEC;
- collation.set(&my_charset_bin);
- store_now_in_TIME(&ltime);
- value= TIME_to_ulonglong_time(&ltime);
- buff_length= (uint) my_time_to_str(&ltime, buff);
- max_length= buff_length;
+ *res= ltime;
+ return 0;
}
+static void set_sec_part(ulong sec_part, MYSQL_TIME *ltime, Item *item)
+{
+ DBUG_ASSERT(item->decimals == AUTO_SEC_PART_DIGITS ||
+ item->decimals <= TIME_SECOND_PART_DIGITS);
+ if (item->decimals)
+ {
+ ltime->second_part= sec_part;
+ if (item->decimals < TIME_SECOND_PART_DIGITS)
+ ltime->second_part= sec_part_truncate(ltime->second_part, item->decimals);
+ }
+}
/**
Converts current time in my_time_t to MYSQL_TIME represenatation for local
@@ -1621,8 +1479,10 @@ void Item_func_curtime::fix_length_and_dec()
void Item_func_curtime_local::store_now_in_TIME(MYSQL_TIME *now_time)
{
THD *thd= current_thd;
- thd->variables.time_zone->gmt_sec_to_TIME(now_time,
- (my_time_t)thd->query_start());
+ thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->query_start());
+ now_time->year= now_time->month= now_time->day= 0;
+ now_time->time_type= MYSQL_TIMESTAMP_TIME;
+ set_sec_part(thd->query_start_sec_part(), now_time, this);
thd->time_zone_used= 1;
}
@@ -1633,36 +1493,28 @@ void Item_func_curtime_local::store_now_in_TIME(MYSQL_TIME *now_time)
*/
void Item_func_curtime_utc::store_now_in_TIME(MYSQL_TIME *now_time)
{
- my_tz_UTC->gmt_sec_to_TIME(now_time,
- (my_time_t)(current_thd->query_start()));
+ THD *thd= current_thd;
+ my_tz_UTC->gmt_sec_to_TIME(now_time, thd->query_start());
+ now_time->year= now_time->month= now_time->day= 0;
+ now_time->time_type= MYSQL_TIMESTAMP_TIME;
+ set_sec_part(thd->query_start_sec_part(), now_time, this);
/*
We are not flagging this query as using time zone, since it uses fixed
UTC-SYSTEM time-zone.
*/
}
-
-String *Item_func_now::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- str_value.set(buff,buff_length, &my_charset_bin);
- return &str_value;
-}
-
-
-void Item_func_now::fix_length_and_dec()
+bool Item_func_now::fix_fields(THD *thd, Item **items)
{
- decimals= DATETIME_DEC;
- collation.set(&my_charset_bin);
-
- store_now_in_TIME(&ltime);
- value= (longlong) TIME_to_ulonglong_datetime(&ltime);
-
- buff_length= (uint) my_datetime_to_str(&ltime, buff);
- max_length= buff_length;
+ if (decimals > TIME_SECOND_PART_DIGITS)
+ {
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), decimals, func_name(),
+ TIME_SECOND_PART_DIGITS);
+ return 1;
+ }
+ return Item_temporal_func::fix_fields(thd, items);
}
-
/**
Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole NOW function.
@@ -1670,8 +1522,8 @@ void Item_func_now::fix_length_and_dec()
void Item_func_now_local::store_now_in_TIME(MYSQL_TIME *now_time)
{
THD *thd= current_thd;
- thd->variables.time_zone->gmt_sec_to_TIME(now_time,
- (my_time_t)thd->query_start());
+ thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->query_start());
+ set_sec_part(thd->query_start_sec_part(), now_time, this);
thd->time_zone_used= 1;
}
@@ -1682,8 +1534,9 @@ void Item_func_now_local::store_now_in_TIME(MYSQL_TIME *now_time)
*/
void Item_func_now_utc::store_now_in_TIME(MYSQL_TIME *now_time)
{
- my_tz_UTC->gmt_sec_to_TIME(now_time,
- (my_time_t)(current_thd->query_start()));
+ THD *thd= current_thd;
+ my_tz_UTC->gmt_sec_to_TIME(now_time, thd->query_start());
+ set_sec_part(thd->query_start_sec_part(), now_time, this);
/*
We are not flagging this query as using time zone, since it uses fixed
UTC-SYSTEM time-zone.
@@ -1699,13 +1552,6 @@ bool Item_func_now::get_date(MYSQL_TIME *res,
}
-int Item_func_now::save_in_field(Field *to, bool no_conversions)
-{
- to->set_notnull();
- return to->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
-}
-
-
/**
Converts current time in my_time_t to MYSQL_TIME represenatation for local
time zone. Defines time zone (local) used for whole SYSDATE function.
@@ -1713,99 +1559,62 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions)
void Item_func_sysdate_local::store_now_in_TIME(MYSQL_TIME *now_time)
{
THD *thd= current_thd;
- thd->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) my_time(0));
+ my_hrtime_t now= my_hrtime();
+ thd->variables.time_zone->gmt_sec_to_TIME(now_time, hrtime_to_my_time(now));
+ set_sec_part(hrtime_sec_part(now), now_time, this);
thd->time_zone_used= 1;
}
-String *Item_func_sysdate_local::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- store_now_in_TIME(&ltime);
- buff_length= (uint) my_datetime_to_str(&ltime, buff);
- str_value.set(buff, buff_length, &my_charset_bin);
- return &str_value;
-}
-
-
-longlong Item_func_sysdate_local::val_int()
-{
- DBUG_ASSERT(fixed == 1);
- store_now_in_TIME(&ltime);
- return (longlong) TIME_to_ulonglong_datetime(&ltime);
-}
-
-
-double Item_func_sysdate_local::val_real()
-{
- DBUG_ASSERT(fixed == 1);
- store_now_in_TIME(&ltime);
- return ulonglong2double(TIME_to_ulonglong_datetime(&ltime));
-}
-
-
-void Item_func_sysdate_local::fix_length_and_dec()
-{
- decimals= 0;
- collation.set(&my_charset_bin);
- max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
-}
-
-
bool Item_func_sysdate_local::get_date(MYSQL_TIME *res,
uint fuzzy_date __attribute__((unused)))
{
- store_now_in_TIME(&ltime);
- *res= ltime;
- return 0;
-}
-
-
-int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions)
-{
- store_now_in_TIME(&ltime);
- to->set_notnull();
- to->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
+ store_now_in_TIME(res);
return 0;
}
-
-String *Item_func_sec_to_time::val_str(String *str)
+bool Item_func_sec_to_time::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- longlong arg_val= args[0]->val_int();
+ bool sign;
+ ulonglong sec;
+ ulong sec_part;
- if ((null_value=args[0]->null_value) ||
- str->alloc(MAX_DATE_STRING_REP_LENGTH))
- {
- null_value= 1;
- return (String*) 0;
- }
+ bzero((char *)ltime, sizeof(*ltime));
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
- sec_to_time(arg_val, args[0]->unsigned_flag, &ltime);
-
- make_time((DATE_TIME_FORMAT *) 0, &ltime, str);
- return str;
-}
+ sign= args[0]->get_seconds(&sec, &sec_part);
+ if ((null_value= args[0]->null_value))
+ return 1;
-longlong Item_func_sec_to_time::val_int()
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- longlong arg_val= args[0]->val_int();
+ ltime->neg= sign;
+ if (sec > TIME_MAX_VALUE_SECONDS)
+ goto overflow;
+
+ DBUG_ASSERT(sec_part <= TIME_MAX_SECOND_PART);
- if ((null_value=args[0]->null_value))
- return 0;
+ ltime->hour= (uint) (sec/3600);
+ ltime->minute= (uint) (sec % 3600) /60;
+ ltime->second= (uint) sec % 60;
+ ltime->second_part= sec_part;
+
+ return 0;
- sec_to_time(arg_val, args[0]->unsigned_flag, &ltime);
+overflow:
+ /* use check_time_range() to set ltime to the max value depending on dec */
+ int unused;
+ char buf[100];
+ String tmp(buf, sizeof(buf), &my_charset_bin), *err= args[0]->val_str(&tmp);
- return (ltime.neg ? -1 : 1) *
- ((ltime.hour)*10000 + ltime.minute*100 + ltime.second);
+ ltime->hour= TIME_MAX_HOUR+1;
+ check_time_range(ltime, decimals, &unused);
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ err->ptr(), err->length(),
+ MYSQL_TIMESTAMP_TIME, NullS);
+ return 0;
}
-
void Item_func_date_format::fix_length_and_dec()
{
THD* thd= current_thd;
@@ -1941,24 +1750,12 @@ String *Item_func_date_format::val_str(String *str)
String *format;
MYSQL_TIME l_time;
uint size;
+ int is_time_flag = is_time_format ? TIME_TIME_ONLY : 0;
DBUG_ASSERT(fixed == 1);
-
- if (!is_time_format)
- {
- if (get_arg0_date(&l_time, TIME_FUZZY_DATE))
- return 0;
- }
- else
- {
- String *res;
- if (!(res=args[0]->val_str(str)) ||
- (str_to_time_with_warn(res->ptr(), res->length(), &l_time)))
- goto null_date;
-
- l_time.year=l_time.month=l_time.day=0;
- null_value=0;
- }
-
+
+ if (get_arg0_date(&l_time, TIME_FUZZY_DATE | is_time_flag))
+ return 0;
+
if (!(format = args[1]->val_str(str)) || !format->length())
goto null_date;
@@ -1996,100 +1793,39 @@ null_date:
void Item_func_from_unixtime::fix_length_and_dec()
{
thd= current_thd;
- collation.set(&my_charset_bin);
- decimals= DATETIME_DEC;
- max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null= 1;
thd->time_zone_used= 1;
+ decimals= args[0]->decimals;
+ Item_temporal_func::fix_length_and_dec();
}
-String *Item_func_from_unixtime::val_str(String *str)
-{
- MYSQL_TIME time_tmp;
-
- DBUG_ASSERT(fixed == 1);
-
- if (get_date(&time_tmp, 0))
- return 0;
-
- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
- {
- null_value= 1;
- return 0;
- }
-
- make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
-
- return str;
-}
-
-
-longlong Item_func_from_unixtime::val_int()
-{
- MYSQL_TIME time_tmp;
-
- DBUG_ASSERT(fixed == 1);
-
- if (get_date(&time_tmp, 0))
- return 0;
-
- return (longlong) TIME_to_ulonglong_datetime(&time_tmp);
-}
-
bool Item_func_from_unixtime::get_date(MYSQL_TIME *ltime,
uint fuzzy_date __attribute__((unused)))
{
- ulonglong tmp= (ulonglong)(args[0]->val_int());
- /*
- "tmp > TIMESTAMP_MAX_VALUE" check also covers case of negative
- from_unixtime() argument since tmp is unsigned.
- */
- if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
- return 1;
-
- thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)tmp);
-
- return 0;
-}
-
-
-void Item_func_convert_tz::fix_length_and_dec()
-{
- collation.set(&my_charset_bin);
- decimals= 0;
- max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null= 1;
-}
+ bool sign;
+ ulonglong sec;
+ ulong sec_part;
+ bzero((char *)ltime, sizeof(*ltime));
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
-String *Item_func_convert_tz::val_str(String *str)
-{
- MYSQL_TIME time_tmp;
+ sign= args[0]->get_seconds(&sec, &sec_part);
- if (get_date(&time_tmp, 0))
- return 0;
+ if (args[0]->null_value || sign || sec > TIMESTAMP_MAX_VALUE)
+ return (null_value= 1);
- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
- {
- null_value= 1;
- return 0;
- }
+ thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)sec);
- make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
+ ltime->second_part= sec_part;
- return str;
+ return (null_value= 0);
}
-longlong Item_func_convert_tz::val_int()
+void Item_func_convert_tz::fix_length_and_dec()
{
- MYSQL_TIME time_tmp;
-
- if (get_date(&time_tmp, 0))
- return 0;
-
- return (longlong)TIME_to_ulonglong_datetime(&time_tmp);
+ decimals= args[0]->decimals;
+ Item_temporal_func::fix_length_and_dec();
}
@@ -2112,18 +1848,22 @@ bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime,
to_tz_cached= args[2]->const_item();
}
- if (from_tz==0 || to_tz==0 || get_arg0_date(ltime, TIME_NO_ZERO_DATE))
+ if (from_tz==0 || to_tz==0 ||
+ get_arg0_date(ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
{
null_value= 1;
return 1;
}
{
- my_bool not_used;
+ uint not_used;
my_time_tmp= from_tz->TIME_to_gmt_sec(ltime, &not_used);
+ ulong sec_part= ltime->second_part;
/* my_time_tmp is guranteed to be in the allowed range */
if (my_time_tmp)
to_tz->gmt_sec_to_TIME(ltime, my_time_tmp);
+ /* we rely on the fact that no timezone conversion can change sec_part */
+ ltime->second_part= sec_part;
}
null_value= 0;
@@ -2134,7 +1874,7 @@ bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime,
void Item_func_convert_tz::cleanup()
{
from_tz_cached= to_tz_cached= 0;
- Item_date_func::cleanup();
+ Item_temporal_func::cleanup();
}
@@ -2142,21 +1882,20 @@ void Item_date_add_interval::fix_length_and_dec()
{
enum_field_types arg0_field_type;
- collation.set(&my_charset_bin);
- maybe_null=1;
- max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- value.alloc(max_length);
-
/*
The field type for the result of an Item_date function is defined as
follows:
- If first arg is a MYSQL_TYPE_DATETIME result is MYSQL_TYPE_DATETIME
- If first arg is a MYSQL_TYPE_DATE and the interval type uses hours,
- minutes or seconds then type is MYSQL_TYPE_DATETIME.
+ minutes or seconds then type is MYSQL_TYPE_DATETIME
+ otherwise it's MYSQL_TYPE_DATE
+ - if first arg is a MYSQL_TYPE_TIME and the interval type isn't using
+ anything larger than days, then the result is MYSQL_TYPE_TIME,
+ otherwise - MYSQL_TYPE_DATETIME.
- Otherwise the result is MYSQL_TYPE_STRING
- (This is because you can't know if the string contains a DATE, MYSQL_TIME or
- DATETIME argument)
+ (This is because you can't know if the string contains a DATE,
+ MYSQL_TIME or DATETIME argument)
*/
cached_field_type= MYSQL_TYPE_STRING;
arg0_field_type= args[0]->field_type();
@@ -2170,6 +1909,20 @@ void Item_date_add_interval::fix_length_and_dec()
else
cached_field_type= MYSQL_TYPE_DATETIME;
}
+ else if (arg0_field_type == MYSQL_TYPE_TIME)
+ {
+ if (int_type >= INTERVAL_DAY && int_type != INTERVAL_YEAR_MONTH)
+ cached_field_type= arg0_field_type;
+ else
+ cached_field_type= MYSQL_TYPE_DATETIME;
+ }
+ if (int_type == INTERVAL_MICROSECOND || int_type >= INTERVAL_DAY_MICROSECOND)
+ decimals= 6;
+ else
+ decimals= args[0]->decimals;
+
+ Item_temporal_func::fix_length_and_dec();
+ value.alloc(max_length);
}
@@ -2179,7 +1932,7 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
INTERVAL interval;
- if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE) ||
+ if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE | TIME_FUZZY_DATE) ||
get_interval_value(args[1], int_type, &value, &interval))
return (null_value=1);
@@ -2192,44 +1945,6 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
}
-String *Item_date_add_interval::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- enum date_time_format_types format;
-
- if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
- return 0;
-
- if (ltime.time_type == MYSQL_TIMESTAMP_DATE)
- format= DATE_ONLY;
- else if (ltime.second_part)
- format= DATE_TIME_MICROSECOND;
- else
- format= DATE_TIME;
-
- if (!make_datetime(format, &ltime, str))
- return str;
-
- null_value=1;
- return 0;
-}
-
-
-longlong Item_date_add_interval::val_int()
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- longlong date;
- if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
- return (longlong) 0;
- date = (ltime.year*100L + ltime.month)*100L + ltime.day;
- return ltime.time_type == MYSQL_TIMESTAMP_DATE ? date :
- ((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
-}
-
-
-
bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const
{
Item_date_add_interval *other= (Item_date_add_interval*) item;
@@ -2311,25 +2026,12 @@ longlong Item_extract::val_int()
uint year;
ulong week_format;
long neg;
- if (date_value)
- {
- if (get_arg0_date(&ltime, TIME_FUZZY_DATE))
- return 0;
- neg=1;
- }
- else
- {
- char buf[40];
- String value(buf, sizeof(buf), &my_charset_bin);;
- String *res= args[0]->val_str(&value);
- if (!res || str_to_time_with_warn(res->ptr(), res->length(), &ltime))
- {
- null_value=1;
- return 0;
- }
- neg= ltime.neg ? -1 : 1;
- null_value=0;
- }
+ int is_time_flag = date_value ? 0 : TIME_TIME_ONLY;
+
+ if (get_arg0_date(&ltime, TIME_FUZZY_DATE | is_time_flag))
+ return 0;
+ neg= ltime.neg ? -1 : 1;
+
switch (int_type) {
case INTERVAL_YEAR: return ltime.year;
case INTERVAL_YEAR_MONTH: return ltime.year*100L+ltime.month;
@@ -2412,12 +2114,19 @@ bool Item_char_typecast::eq(const Item *item, bool binary_cmp) const
return 1;
}
-void Item_typecast::print(String *str, enum_query_type query_type)
+void Item_temporal_typecast::print(String *str, enum_query_type query_type)
{
+ char buf[32];
str->append(STRING_WITH_LEN("cast("));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as "));
str->append(cast_type());
+ if (decimals)
+ {
+ str->append('(');
+ str->append(llstr(decimals, buf));
+ str->append(')');
+ }
str->append(')');
}
@@ -2427,13 +2136,13 @@ void Item_char_typecast::print(String *str, enum_query_type query_type)
str->append(STRING_WITH_LEN("cast("));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as char"));
- if (cast_length >= 0)
+ if (cast_length != ~0U)
{
str->append('(');
char buffer[20];
// my_charset_bin is good enough for numbers
String st(buffer, sizeof(buffer), &my_charset_bin);
- st.set((ulonglong)cast_length, &my_charset_bin);
+ st.set(static_cast<ulonglong>(cast_length), &my_charset_bin);
str->append(st);
str->append(')');
}
@@ -2461,10 +2170,15 @@ String *Item_char_typecast::val_str(String *str)
}
else
{
- // Convert character set if differ
+ /*
+ Convert character set if differ
+ from_cs is 0 in the case where the result set may vary between calls,
+ for example with dynamic columns.
+ */
uint dummy_errors;
if (!(res= args[0]->val_str(str)) ||
- tmp_value.copy(res->ptr(), res->length(), from_cs,
+ tmp_value.copy(res->ptr(), res->length(),
+ from_cs ? from_cs : res->charset(),
cast_cs, &dummy_errors))
{
null_value= 1;
@@ -2480,7 +2194,7 @@ String *Item_char_typecast::val_str(String *str)
and the result is longer than cast length, e.g.
CAST('string' AS CHAR(1))
*/
- if (cast_length >= 0)
+ if (cast_length != ~0U)
{
if (res->length() > (length= (uint32) res->charpos(cast_length)))
{ // Safe even if const arg
@@ -2500,16 +2214,15 @@ String *Item_char_typecast::val_str(String *str)
res->c_ptr_safe());
res->length((uint) length);
}
- else if (cast_cs == &my_charset_bin && res->length() < (uint) cast_length)
+ else if (cast_cs == &my_charset_bin && res->length() < cast_length)
{
- if (res->alloced_length() < (uint) cast_length)
+ if (res->alloced_length() < cast_length)
{
str_value.alloc(cast_length);
str_value.copy(*res);
res= &str_value;
}
- bzero((char*) res->ptr() + res->length(),
- (uint) cast_length - res->length());
+ bzero((char*) res->ptr() + res->length(), cast_length - res->length());
res->length(cast_length);
}
}
@@ -2542,150 +2255,106 @@ void Item_char_typecast::fix_length_and_dec()
and thus avoid unnecessary character set conversion.
- If the argument is not a number, then from_cs is set to
the argument's charset.
+ - If argument has a dynamic collation (can change from call to call)
+ we set from_cs to 0 as a marker that we have to take the collation
+ from the result string.
Note (TODO): we could use repertoire technique here.
*/
- from_cs= (args[0]->result_type() == INT_RESULT ||
- args[0]->result_type() == DECIMAL_RESULT ||
- args[0]->result_type() == REAL_RESULT) ?
- (cast_cs->mbminlen == 1 ? cast_cs : &my_charset_latin1) :
- args[0]->collation.collation;
- charset_conversion= (cast_cs->mbmaxlen > 1) ||
+ from_cs= ((args[0]->result_type() == INT_RESULT ||
+ args[0]->result_type() == DECIMAL_RESULT ||
+ args[0]->result_type() == REAL_RESULT) ?
+ (cast_cs->mbminlen == 1 ? cast_cs : &my_charset_latin1) :
+ args[0]->dynamic_result() ? 0 :
+ args[0]->collation.collation);
+ charset_conversion= !from_cs || (cast_cs->mbmaxlen > 1) ||
(!my_charset_same(from_cs, cast_cs) &&
from_cs != &my_charset_bin &&
cast_cs != &my_charset_bin);
collation.set(cast_cs, DERIVATION_IMPLICIT);
- char_length= (cast_length >= 0) ? cast_length :
+ char_length= ((cast_length != ~0U) ? cast_length :
args[0]->max_length /
- (cast_cs == &my_charset_bin ? 1 : args[0]->collation.collation->mbmaxlen);
+ (cast_cs == &my_charset_bin ? 1 :
+ args[0]->collation.collation->mbmaxlen));
max_length= char_length * cast_cs->mbmaxlen;
}
-String *Item_datetime_typecast::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
-
- if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
- !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME,
- &ltime, str))
- return str;
-
- null_value=1;
- return 0;
-}
-
-
-longlong Item_datetime_typecast::val_int()
+bool Item_time_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- if (get_arg0_date(&ltime,1))
- {
- null_value= 1;
- return 0;
- }
-
- return TIME_to_ulonglong_datetime(&ltime);
-}
-
-
-bool Item_time_typecast::get_time(MYSQL_TIME *ltime)
-{
- bool res= get_arg0_time(ltime);
+ if (get_arg0_time(ltime))
+ return 1;
+ if (decimals < TIME_SECOND_PART_DIGITS)
+ ltime->second_part= sec_part_truncate(ltime->second_part, decimals);
/*
- For MYSQL_TIMESTAMP_TIME value we can have non-zero day part,
+ MYSQL_TIMESTAMP_TIME value can have non-zero day part,
which we should not lose.
*/
- if (ltime->time_type == MYSQL_TIMESTAMP_DATETIME)
+ if (ltime->time_type != MYSQL_TIMESTAMP_TIME)
ltime->year= ltime->month= ltime->day= 0;
ltime->time_type= MYSQL_TIMESTAMP_TIME;
- return res;
-}
-
-
-longlong Item_time_typecast::val_int()
-{
- MYSQL_TIME ltime;
- if (get_time(&ltime))
- {
- null_value= 1;
- return 0;
- }
- return ltime.hour * 10000L + ltime.minute * 100 + ltime.second;
-}
-
-String *Item_time_typecast::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
-
- if (!get_arg0_time(&ltime) &&
- !make_datetime(ltime.second_part ? TIME_MICROSECOND : TIME_ONLY,
- &ltime, str))
- return str;
-
- null_value=1;
return 0;
}
bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
- bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
+ if (get_arg0_date(ltime, fuzzy_date & ~TIME_TIME_ONLY))
+ return 1;
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
ltime->time_type= MYSQL_TIMESTAMP_DATE;
- return res;
+ return 0;
}
-bool Item_date_typecast::get_time(MYSQL_TIME *ltime)
+bool Item_datetime_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
- bzero((char *)ltime, sizeof(MYSQL_TIME));
- return args[0]->null_value;
-}
+ if (get_arg0_date(ltime, fuzzy_date & ~TIME_TIME_ONLY))
+ return 1;
+ if (decimals < TIME_SECOND_PART_DIGITS)
+ ltime->second_part= sec_part_truncate(ltime->second_part, decimals);
-String *Item_date_typecast::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
- !str->alloc(MAX_DATE_STRING_REP_LENGTH))
+ /*
+ ltime is valid MYSQL_TYPE_TIME (according to fuzzy_date).
+ But not every valid TIME value is a valid DATETIME value!
+ */
+ if (ltime->time_type == MYSQL_TIMESTAMP_TIME)
{
- make_date((DATE_TIME_FORMAT *) 0, &ltime, str);
- return str;
+ if (ltime->neg)
+ {
+ Lazy_string_time str(ltime);
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ &str, MYSQL_TIMESTAMP_DATETIME, 0);
+ return (null_value= 1);
+ }
+
+ uint day= ltime->hour/24;
+ ltime->hour %= 24;
+ ltime->month= day / 31;
+ ltime->day= day % 31;
}
- null_value=1;
+ ltime->time_type= MYSQL_TIMESTAMP_DATETIME;
return 0;
}
-longlong Item_date_typecast::val_int()
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
- if ((null_value= args[0]->get_date(&ltime, TIME_FUZZY_DATE)))
- return 0;
- return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day);
-}
/**
MAKEDATE(a,b) is a date function that creates a date value
from a year and day value.
NOTES:
- As arguments are integers, we can't know if the year is a 2 digit or 4 digit year.
- In this case we treat all years < 100 as 2 digit years. Ie, this is not safe
- for dates between 0000-01-01 and 0099-12-31
+ As arguments are integers, we can't know if the year is a 2 digit
+ or 4 digit year. In this case we treat all years < 100 as 2 digit
+ years. Ie, this is not safe for dates between 0000-01-01 and
+ 0099-12-31
*/
-String *Item_func_makedate::val_str(String *str)
+bool Item_func_makedate::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DBUG_ASSERT(fixed == 1);
- MYSQL_TIME l_time;
long daynr= (long) args[1]->val_int();
long year= (long) args[0]->val_int();
long days;
@@ -2701,66 +2370,21 @@ String *Item_func_makedate::val_str(String *str)
/* Day number from year 0 to 9999-12-31 */
if (days >= 0 && days <= MAX_DAY_NUMBER)
{
- null_value=0;
- get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
- goto err;
- make_date((DATE_TIME_FORMAT *) 0, &l_time, str);
- return str;
- }
-
-err:
- null_value=1;
- return 0;
-}
-
-
-/*
- MAKEDATE(a,b) is a date function that creates a date value
- from a year and day value.
-
- NOTES:
- As arguments are integers, we can't know if the year is a 2 digit or 4 digit year.
- In this case we treat all years < 100 as 2 digit years. Ie, this is not safe
- for dates between 0000-01-01 and 0099-12-31
-*/
-
-longlong Item_func_makedate::val_int()
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME l_time;
- long daynr= (long) args[1]->val_int();
- long year= (long) args[0]->val_int();
- long days;
-
- if (args[0]->null_value || args[1]->null_value ||
- year < 0 || daynr <= 0)
- goto err;
-
- if (year < 100)
- year= year_2000_handling(year);
-
- days= calc_daynr(year,1,1) + daynr - 1;
- /* Day number from year 0 to 9999-12-31 */
- if (days >= 0 && days < MAX_DAY_NUMBER)
- {
- null_value=0;
- get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
- return (longlong) (l_time.year * 10000L + l_time.month * 100 + l_time.day);
+ bzero(ltime, sizeof(*ltime));
+ ltime->time_type= MYSQL_TIMESTAMP_DATE;
+ get_date_from_daynr(days, &ltime->year, &ltime->month, &ltime->day);
+ return (null_value= 0);
}
err:
- null_value= 1;
- return 0;
+ return (null_value= 1);
}
void Item_func_add_time::fix_length_and_dec()
{
enum_field_types arg0_field_type;
- decimals=0;
- max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- maybe_null= 1;
+ decimals= max(args[0]->decimals, args[1]->decimals);
/*
The field type for the result of an Item_func_add_time function is defined
@@ -2780,6 +2404,7 @@ void Item_func_add_time::fix_length_and_dec()
cached_field_type= MYSQL_TYPE_DATETIME;
else if (arg0_field_type == MYSQL_TYPE_TIME)
cached_field_type= MYSQL_TYPE_TIME;
+ Item_temporal_func::fix_length_and_dec();
}
/**
@@ -2792,38 +2417,38 @@ void Item_func_add_time::fix_length_and_dec()
Result: Time value or datetime value
*/
-String *Item_func_add_time::val_str(String *str)
+bool Item_func_add_time::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DBUG_ASSERT(fixed == 1);
- MYSQL_TIME l_time1, l_time2, l_time3;
+ MYSQL_TIME l_time1, l_time2;
bool is_time= 0;
long days, microseconds;
longlong seconds;
- int l_sign= sign;
+ int l_sign= sign, was_cut= 0;
+ uint dec= decimals;
- null_value=0;
if (is_date) // TIMESTAMP function
{
if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) ||
args[1]->get_time(&l_time2) ||
l_time1.time_type == MYSQL_TIMESTAMP_TIME ||
l_time2.time_type != MYSQL_TIMESTAMP_TIME)
- goto null_date;
+ return (null_value= 1);
}
else // ADDTIME function
{
if (args[0]->get_time(&l_time1) ||
args[1]->get_time(&l_time2) ||
l_time2.time_type == MYSQL_TIMESTAMP_DATETIME)
- goto null_date;
+ return (null_value= 1);
is_time= (l_time1.time_type == MYSQL_TIMESTAMP_TIME);
}
if (l_time1.neg != l_time2.neg)
l_sign= -l_sign;
- bzero((char *)&l_time3, sizeof(l_time3));
+ bzero(ltime, sizeof(*ltime));
- l_time3.neg= calc_time_diff(&l_time1, &l_time2, -l_sign,
+ ltime->neg= calc_time_diff(&l_time1, &l_time2, -l_sign,
&seconds, &microseconds);
/*
@@ -2831,35 +2456,40 @@ String *Item_func_add_time::val_str(String *str)
is non-zero we need to swap sign to get proper result.
*/
if (l_time1.neg && (seconds || microseconds))
- l_time3.neg= 1-l_time3.neg; // Swap sign of result
+ ltime->neg= 1-ltime->neg; // Swap sign of result
- if (!is_time && l_time3.neg)
- goto null_date;
+ if (!is_time && ltime->neg)
+ return (null_value= 1);
days= (long)(seconds/86400L);
- calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds);
+ calc_time_from_sec(ltime, (long)(seconds%86400L), microseconds);
+
+ ltime->time_type= is_time ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATETIME;
+
+ if (cached_field_type == MYSQL_TYPE_STRING &&
+ (l_time1.second_part || l_time2.second_part))
+ dec= TIME_SECOND_PART_DIGITS;
if (!is_time)
{
- get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day);
- if (l_time3.day &&
- !make_datetime(l_time1.second_part || l_time2.second_part ?
- DATE_TIME_MICROSECOND : DATE_TIME,
- &l_time3, str))
- return str;
- goto null_date;
+ get_date_from_daynr(days,&ltime->year,&ltime->month,&ltime->day);
+ if (!ltime->day)
+ return (null_value= 1);
+ return (null_value= 0);
}
- l_time3.hour+= days*24;
- if (!make_datetime_with_warn(l_time1.second_part || l_time2.second_part ?
- TIME_MICROSECOND : TIME_ONLY,
- &l_time3, str))
- return str;
+ ltime->hour+= days*24;
-null_date:
- null_value=1;
- return 0;
+ MYSQL_TIME copy= *ltime;
+ Lazy_string_time str(&copy);
+
+ check_time_range(ltime, decimals, &was_cut);
+ if (was_cut)
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ &str, MYSQL_TIMESTAMP_TIME, NullS);
+
+ return (null_value= 0);
}
@@ -2892,15 +2522,19 @@ void Item_func_add_time::print(String *str, enum_query_type query_type)
Result: Time value
*/
-String *Item_func_timediff::val_str(String *str)
+bool Item_func_timediff::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DBUG_ASSERT(fixed == 1);
longlong seconds;
long microseconds;
- int l_sign= 1;
- MYSQL_TIME l_time1 ,l_time2, l_time3;
+ int l_sign= 1, was_cut= 0;
+ MYSQL_TIME l_time1,l_time2,l_time3;
+ Lazy_string_time str(&l_time3);
+
+ /* the following may be true in, for example, date_add(timediff(...), ... */
+ if (fuzzy_date & TIME_NO_ZERO_IN_DATE)
+ goto null_date;
- null_value= 0;
if (args[0]->get_time(&l_time1) ||
args[1]->get_time(&l_time2) ||
l_time1.time_type != l_time2.time_type)
@@ -2922,16 +2556,30 @@ String *Item_func_timediff::val_str(String *str)
if (l_time1.neg && (seconds || microseconds))
l_time3.neg= 1-l_time3.neg; // Swap sign of result
+ /*
+ seconds is longlong, when casted to long it may become a small number
+ even if the original seconds value was too large and invalid.
+ as a workaround we limit seconds by a large invalid long number
+ ("invalid" means > TIME_MAX_SECOND)
+ */
+ set_if_smaller(seconds, INT_MAX32);
+
calc_time_from_sec(&l_time3, (long) seconds, microseconds);
- if (!make_datetime_with_warn(l_time1.second_part || l_time2.second_part ?
- TIME_MICROSECOND : TIME_ONLY,
- &l_time3, str))
- return str;
+ if ((fuzzy_date & TIME_NO_ZERO_DATE) && (seconds == 0) &&
+ (microseconds == 0))
+ goto null_date;
+
+ *ltime= l_time3;
+ check_time_range(ltime, decimals, &was_cut);
+
+ if (was_cut)
+ make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ &str, MYSQL_TIMESTAMP_TIME, NullS);
+ return (null_value= 0);
null_date:
- null_value=1;
- return 0;
+ return (null_value= 1);
}
/**
@@ -2940,10 +2588,9 @@ null_date:
Result: Time value
*/
-String *Item_func_maketime::val_str(String *str)
+bool Item_func_maketime::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
bool overflow= 0;
longlong hour= args[0]->val_int();
@@ -2954,12 +2601,11 @@ String *Item_func_maketime::val_str(String *str)
args[1]->null_value ||
args[2]->null_value ||
minute < 0 || minute > 59 ||
- second < 0 || second > 59 ||
- str->alloc(MAX_DATE_STRING_REP_LENGTH))))
- return 0;
+ second < 0 || second > 59)))
+ return 1;
- bzero((char *)&ltime, sizeof(ltime));
- ltime.neg= 0;
+ bzero(ltime, sizeof(*ltime));
+ ltime->time_type= MYSQL_TIMESTAMP_TIME;
/* Check for integer overflows */
if (hour < 0)
@@ -2967,22 +2613,22 @@ String *Item_func_maketime::val_str(String *str)
if (args[0]->unsigned_flag)
overflow= 1;
else
- ltime.neg= 1;
+ ltime->neg= 1;
}
- if (-hour > UINT_MAX || hour > UINT_MAX)
+ if (-hour > TIME_MAX_HOUR || hour > TIME_MAX_HOUR)
overflow= 1;
if (!overflow)
{
- ltime.hour= (uint) ((hour < 0 ? -hour : hour));
- ltime.minute= (uint) minute;
- ltime.second= (uint) second;
+ ltime->hour= (uint) ((hour < 0 ? -hour : hour));
+ ltime->minute= (uint) minute;
+ ltime->second= (uint) second;
}
else
{
- ltime.hour= TIME_MAX_HOUR;
- ltime.minute= TIME_MAX_MINUTE;
- ltime.second= TIME_MAX_SECOND;
+ ltime->hour= TIME_MAX_HOUR;
+ ltime->minute= TIME_MAX_MINUTE;
+ ltime->second= TIME_MAX_SECOND;
char buf[28];
char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
int len = (int)(ptr - buf) +
@@ -2992,12 +2638,7 @@ String *Item_func_maketime::val_str(String *str)
NullS);
}
- if (make_time_with_warn((DATE_TIME_FORMAT *) 0, &ltime, str))
- {
- null_value= 1;
- return 0;
- }
- return str;
+ return 0;
}
@@ -3013,7 +2654,7 @@ longlong Item_func_microsecond::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
- if (!get_arg0_time(&ltime))
+ if (!get_arg0_date(&ltime, TIME_TIME_ONLY))
return ltime.second_part;
return 0;
}
@@ -3028,8 +2669,8 @@ longlong Item_func_timestamp_diff::val_int()
int neg= 1;
null_value= 0;
- if (args[0]->get_date(&ltime1, TIME_NO_ZERO_DATE) ||
- args[1]->get_date(&ltime2, TIME_NO_ZERO_DATE))
+ if (args[0]->get_date(&ltime1, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE) ||
+ args[1]->get_date(&ltime2, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
goto null_date;
if (calc_time_diff(&ltime2,&ltime1, 1,
@@ -3279,9 +2920,9 @@ get_date_time_result_type(const char *format, uint length)
have all types of date-time components and can end our search.
*/
return DATE_TIME_MICROSECOND;
+ }
}
}
- }
/* We don't have all three types of date-time components */
if (frac_second_used)
@@ -3298,39 +2939,39 @@ get_date_time_result_type(const char *format, uint length)
void Item_func_str_to_date::fix_length_and_dec()
{
- maybe_null= 1;
- decimals=0;
cached_field_type= MYSQL_TYPE_DATETIME;
- max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
+ decimals= NOT_FIXED_DEC;
if ((const_item= args[1]->const_item()))
{
char format_buff[64];
String format_str(format_buff, sizeof(format_buff), &my_charset_bin);
String *format= args[1]->val_str(&format_str);
+ decimals= 0;
if (!args[1]->null_value)
{
- cached_format_type= get_date_time_result_type(format->ptr(),
- format->length());
+ date_time_format_types cached_format_type=
+ get_date_time_result_type(format->ptr(), format->length());
switch (cached_format_type) {
case DATE_ONLY:
- cached_timestamp_type= MYSQL_TIMESTAMP_DATE;
cached_field_type= MYSQL_TYPE_DATE;
- max_length= MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
break;
- case TIME_ONLY:
case TIME_MICROSECOND:
- cached_timestamp_type= MYSQL_TIMESTAMP_TIME;
+ decimals= 6;
+ /* fall through */
+ case TIME_ONLY:
cached_field_type= MYSQL_TYPE_TIME;
- max_length= MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
break;
- default:
- cached_timestamp_type= MYSQL_TIMESTAMP_DATETIME;
+ case DATE_TIME_MICROSECOND:
+ decimals= 6;
+ /* fall through */
+ case DATE_TIME:
cached_field_type= MYSQL_TYPE_DATETIME;
break;
}
}
}
+ cached_timestamp_type= mysql_type_to_time_type(cached_field_type);
+ Item_temporal_func::fix_length_and_dec();
}
@@ -3339,21 +2980,19 @@ bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
DATE_TIME_FORMAT date_time_format;
char val_buff[64], format_buff[64];
String val_string(val_buff, sizeof(val_buff), &my_charset_bin), *val;
- String format_str(format_buff, sizeof(format_buff), &my_charset_bin), *format;
+ String format_str(format_buff, sizeof(format_buff), &my_charset_bin),
+ *format;
val= args[0]->val_str(&val_string);
format= args[1]->val_str(&format_str);
if (args[0]->null_value || args[1]->null_value)
goto null_date;
- null_value= 0;
- bzero((char*) ltime, sizeof(*ltime));
date_time_format.format.str= (char*) format->ptr();
date_time_format.format.length= format->length();
if (extract_date_time(&date_time_format, val->ptr(), val->length(),
- ltime, cached_timestamp_type, 0, "datetime") ||
- ((fuzzy_date & TIME_NO_ZERO_DATE) &&
- (ltime->year == 0 || ltime->month == 0 || ltime->day == 0)))
+ ltime, cached_timestamp_type, 0, "datetime",
+ fuzzy_date))
goto null_date;
if (cached_timestamp_type == MYSQL_TIMESTAMP_TIME && ltime->day)
{
@@ -3365,6 +3004,7 @@ bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
ltime->hour+= ltime->day*24;
ltime->day= 0;
}
+ null_value= 0;
return 0;
null_date:
@@ -3372,22 +3012,6 @@ null_date:
}
-String *Item_func_str_to_date::val_str(String *str)
-{
- DBUG_ASSERT(fixed == 1);
- MYSQL_TIME ltime;
-
- if (Item_func_str_to_date::get_date(&ltime, TIME_FUZZY_DATE))
- return 0;
-
- if (!make_datetime((const_item ? cached_format_type :
- (ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME)),
- &ltime, str))
- return str;
- return 0;
-}
-
-
bool Item_func_last_day::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 87af384923e..d0c6c206ad4 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -108,8 +109,11 @@ public:
{ DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
- str->set(val_int(), &my_charset_bin);
- return null_value ? 0 : str;
+ longlong nr= val_int();
+ if (null_value)
+ return 0;
+ str->set(nr, &my_charset_bin);
+ return str;
}
const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; }
@@ -354,15 +358,37 @@ class Item_func_dayname :public Item_func_weekday
};
-class Item_func_unix_timestamp :public Item_int_func
+class Item_func_seconds_hybrid: public Item_func_numhybrid
{
- String value;
public:
- Item_func_unix_timestamp() :Item_int_func() {}
- Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
- longlong val_int();
+ Item_func_seconds_hybrid() :Item_func_numhybrid() {}
+ Item_func_seconds_hybrid(Item *a) :Item_func_numhybrid(a) {}
+ void fix_num_length_and_dec()
+ {
+ if (arg_count)
+ decimals= args[0]->decimals;
+ set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
+ max_length=17 + (decimals ? decimals + 1 : 0);
+ }
+ void find_num_type() { hybrid_type= decimals ? DECIMAL_RESULT : INT_RESULT; }
+ double real_op() { DBUG_ASSERT(0); return 0; }
+ String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
+};
+
+
+class Item_func_unix_timestamp :public Item_func_seconds_hybrid
+{
+ bool get_timestamp_value(my_time_t *seconds, ulong *second_part);
+public:
+ Item_func_unix_timestamp() :Item_func_seconds_hybrid() {}
+ Item_func_unix_timestamp(Item *a) :Item_func_seconds_hybrid(a) {}
const char *func_name() const { return "unix_timestamp"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
+ void fix_num_length_and_dec()
+ {
+ maybe_null= false;
+ Item_func_seconds_hybrid::fix_num_length_and_dec();
+ }
/*
UNIX_TIMESTAMP() depends on the current timezone
(and thus may not be used as a partitioning function)
@@ -372,11 +398,6 @@ public:
{
return !has_timestamp_args();
}
- void fix_length_and_dec()
- {
- decimals=0;
- max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
- }
bool check_vcol_func_processor(uchar *int_arg)
{
/*
@@ -385,20 +406,21 @@ public:
*/
return trace_unsupported_by_check_vcol_func_processor(func_name());
}
+ longlong int_op();
+ my_decimal *decimal_op(my_decimal* buf);
};
-class Item_func_time_to_sec :public Item_int_func
+
+class Item_func_time_to_sec :public Item_func_seconds_hybrid
{
public:
- Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
- longlong val_int();
+ Item_func_time_to_sec(Item *item) :Item_func_seconds_hybrid(item) {}
const char *func_name() const { return "time_to_sec"; }
- void fix_length_and_dec()
+ void fix_num_length_and_dec()
{
- maybe_null= TRUE;
- decimals=0;
- max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
+ maybe_null= true;
+ Item_func_seconds_hybrid::fix_num_length_and_dec();
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -406,126 +428,98 @@ public:
{
return !has_time_args();
}
+ longlong int_op();
+ my_decimal *decimal_op(my_decimal* buf);
};
-/*
- This can't be a Item_str_func, because the val_real() functions are special
-*/
-
-class Item_date :public Item_func
+class Item_temporal_func: public Item_func
{
public:
- Item_date() :Item_func() {}
- Item_date(Item *a) :Item_func(a) {}
+ Item_temporal_func() :Item_func() {}
+ Item_temporal_func(Item *a) :Item_func(a) {}
+ Item_temporal_func(Item *a, Item *b) :Item_func(a,b) {}
+ Item_temporal_func(Item *a, Item *b, Item *c) :Item_func(a,b,c) {}
enum Item_result result_type () const { return STRING_RESULT; }
- enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
+ enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
String *val_str(String *str);
longlong val_int();
- double val_real() { return val_real_from_decimal(); }
- const char *func_name() const { return "date"; }
- void fix_length_and_dec()
- {
- collation.set(&my_charset_bin);
- decimals=0;
- max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- bool result_as_longlong() { return TRUE; }
+ double val_real();
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date) { DBUG_ASSERT(0); return 1; }
my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- return val_decimal_from_date(decimal_value);
- }
+ { return val_decimal_from_date(decimal_value); }
+ Field *tmp_table_field(TABLE *table)
+ { return tmp_table_field_from_field_type(table, 0); }
int save_in_field(Field *field, bool no_conversions)
- {
- return save_date_in_field(field);
+ { return save_date_in_field(field); }
+ void fix_length_and_dec()
+ {
+ static const uint max_time_type_width[5]=
+ { MAX_DATETIME_WIDTH, MAX_DATETIME_WIDTH, MAX_DATE_WIDTH,
+ MAX_DATETIME_WIDTH, MIN_TIME_WIDTH };
+
+ maybe_null= true;
+ max_length= max_time_type_width[mysql_type_to_time_type(field_type())+2];
+ if (decimals)
+ {
+ if (decimals == NOT_FIXED_DEC)
+ max_length+= TIME_SECOND_PART_DIGITS + 1;
+ else
+ {
+ set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
+ max_length+= decimals + 1;
+ }
+ }
+ /*
+ We set maybe_null to 1 as default as any bad argument with date or
+ time can get us to return NULL.
+ */
+ maybe_null= 1;
}
};
-class Item_date_func :public Item_str_func
+class Item_datefunc :public Item_temporal_func
{
public:
- Item_date_func() :Item_str_func() {}
- Item_date_func(Item *a) :Item_str_func(a) {}
- Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
- Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
- enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- bool result_as_longlong() { return TRUE; }
- double val_real() { return (double) val_int(); }
- my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- return val_decimal_from_date(decimal_value);
- }
- int save_in_field(Field *field, bool no_conversions)
- {
- return save_date_in_field(field);
- }
+ Item_datefunc() :Item_temporal_func() { }
+ Item_datefunc(Item *a) :Item_temporal_func(a) { }
+ enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
};
-class Item_str_timefunc :public Item_str_func
+class Item_timefunc :public Item_temporal_func
{
public:
- Item_str_timefunc() :Item_str_func() {}
- Item_str_timefunc(Item *a) :Item_str_func(a) {}
- Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
- Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
+ Item_timefunc() :Item_temporal_func() {}
+ Item_timefunc(Item *a) :Item_temporal_func(a) {}
+ Item_timefunc(Item *a,Item *b) :Item_temporal_func(a,b) {}
+ Item_timefunc(Item *a, Item *b, Item *c) :Item_temporal_func(a, b ,c) {}
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
- void fix_length_and_dec()
- {
- decimals= DATETIME_DEC;
- max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- double val_real() { return val_real_from_decimal(); }
- my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- return val_decimal_from_time(decimal_value);
- }
- int save_in_field(Field *field, bool no_conversions)
- {
- return save_time_in_field(field);
- }
- longlong val_int() { return val_int_from_decimal(); }
- bool result_as_longlong() { return TRUE; }
};
/* Abstract CURTIME function. Children should define what time zone is used */
-class Item_func_curtime :public Item_str_timefunc
+class Item_func_curtime :public Item_timefunc
{
- longlong value;
- char buff[9*2+32];
- uint buff_length;
+ MYSQL_TIME ltime;
public:
- Item_func_curtime() :Item_str_timefunc() {}
- Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
- double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
- String *val_str(String *str);
- void fix_length_and_dec();
+ Item_func_curtime(uint dec) :Item_timefunc() { decimals= dec; }
+ bool fix_fields(THD *, Item **);
+ void fix_length_and_dec()
+ {
+ store_now_in_TIME(&ltime);
+ Item_timefunc::fix_length_and_dec();
+ maybe_null= false;
+ }
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
/*
Abstract method that defines which time zone is used for conversion.
Converts time current time in my_time_t representation to broken-down
MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
*/
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
- bool result_as_longlong() { return TRUE; }
bool check_vcol_func_processor(uchar *int_arg)
{
return trace_unsupported_by_check_vcol_func_processor(func_name());
@@ -536,8 +530,7 @@ public:
class Item_func_curtime_local :public Item_func_curtime
{
public:
- Item_func_curtime_local() :Item_func_curtime() {}
- Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
+ Item_func_curtime_local(uint dec) :Item_func_curtime(dec) {}
const char *func_name() const { return "curtime"; }
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -546,8 +539,7 @@ public:
class Item_func_curtime_utc :public Item_func_curtime
{
public:
- Item_func_curtime_utc() :Item_func_curtime() {}
- Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
+ Item_func_curtime_utc(uint dec) :Item_func_curtime(dec) {}
const char *func_name() const { return "utc_time"; }
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -555,14 +547,11 @@ public:
/* Abstract CURDATE function. See also Item_func_curtime. */
-class Item_func_curdate :public Item_date
+class Item_func_curdate :public Item_datefunc
{
- longlong value;
MYSQL_TIME ltime;
public:
- Item_func_curdate() :Item_date() {}
- longlong val_int() { DBUG_ASSERT(fixed == 1); return (value) ; }
- String *val_str(String *str);
+ Item_func_curdate() :Item_datefunc() {}
void fix_length_and_dec();
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
@@ -593,21 +582,19 @@ public:
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
-class Item_func_now :public Item_date_func
+
+class Item_func_now :public Item_temporal_func
{
-protected:
- longlong value;
- char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
- uint buff_length;
MYSQL_TIME ltime;
public:
- Item_func_now() :Item_date_func() {}
- Item_func_now(Item *a) :Item_date_func(a) {}
- enum Item_result result_type () const { return STRING_RESULT; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
- int save_in_field(Field *to, bool no_conversions);
- String *val_str(String *str);
- void fix_length_and_dec();
+ Item_func_now(uint dec) :Item_temporal_func() { decimals= dec; }
+ bool fix_fields(THD *, Item **);
+ void fix_length_and_dec()
+ {
+ store_now_in_TIME(&ltime);
+ Item_temporal_func::fix_length_and_dec();
+ maybe_null= false;
+ }
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
bool check_vcol_func_processor(uchar *int_arg)
@@ -620,8 +607,7 @@ public:
class Item_func_now_local :public Item_func_now
{
public:
- Item_func_now_local() :Item_func_now() {}
- Item_func_now_local(Item *a) :Item_func_now(a) {}
+ Item_func_now_local(uint dec) :Item_func_now(dec) {}
const char *func_name() const { return "now"; }
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
virtual enum Functype functype() const { return NOW_FUNC; }
@@ -631,8 +617,7 @@ public:
class Item_func_now_utc :public Item_func_now
{
public:
- Item_func_now_utc() :Item_func_now() {}
- Item_func_now_utc(Item *a) :Item_func_now(a) {}
+ Item_func_now_utc(uint dec) :Item_func_now(dec) {}
const char *func_name() const { return "utc_timestamp"; }
virtual void store_now_in_TIME(MYSQL_TIME *now_time);
};
@@ -645,16 +630,10 @@ public:
class Item_func_sysdate_local :public Item_func_now
{
public:
- Item_func_sysdate_local() :Item_func_now() {}
- Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
+ Item_func_sysdate_local(uint dec) :Item_func_now(dec) {}
bool const_item() const { return 0; }
const char *func_name() const { return "sysdate"; }
void store_now_in_TIME(MYSQL_TIME *now_time);
- double val_real();
- longlong val_int();
- int save_in_field(Field *to, bool no_conversions);
- String *val_str(String *str);
- void fix_length_and_dec();
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void update_used_tables()
{
@@ -664,10 +643,10 @@ public:
};
-class Item_func_from_days :public Item_date
+class Item_func_from_days :public Item_datefunc
{
public:
- Item_func_from_days(Item *a) :Item_date(a) {}
+ Item_func_from_days(Item *a) :Item_datefunc(a) {}
const char *func_name() const { return "from_days"; }
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
@@ -696,13 +675,11 @@ public:
};
-class Item_func_from_unixtime :public Item_date_func
+class Item_func_from_unixtime :public Item_temporal_func
{
THD *thd;
public:
- Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
- longlong val_int();
- String *val_str(String *str);
+ Item_func_from_unixtime(Item *a) :Item_temporal_func(a) {}
const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec();
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
@@ -723,7 +700,7 @@ class Time_zone;
tables can be used during this function calculation for loading time zone
descriptions.
*/
-class Item_func_convert_tz :public Item_date_func
+class Item_func_convert_tz :public Item_temporal_func
{
/*
If time zone parameters are constants we are caching objects that
@@ -735,9 +712,7 @@ class Item_func_convert_tz :public Item_date_func
Time_zone *from_tz, *to_tz;
public:
Item_func_convert_tz(Item *a, Item *b, Item *c):
- Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
- longlong val_int();
- String *val_str(String *str);
+ Item_temporal_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
const char *func_name() const { return "convert_tz"; }
void fix_length_and_dec();
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
@@ -745,29 +720,21 @@ class Item_func_convert_tz :public Item_date_func
};
-class Item_func_sec_to_time :public Item_str_timefunc
+class Item_func_sec_to_time :public Item_timefunc
{
public:
- Item_func_sec_to_time(Item *item) :Item_str_timefunc(item) {}
- double val_real()
- {
- DBUG_ASSERT(fixed == 1);
- return (double) Item_func_sec_to_time::val_int();
- }
- longlong val_int();
- String *val_str(String *);
+ Item_func_sec_to_time(Item *item) :Item_timefunc(item) {}
+ bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void fix_length_and_dec()
- {
- Item_str_timefunc::fix_length_and_dec();
- collation.set(&my_charset_bin);
- maybe_null=1;
+ {
+ decimals= args[0]->decimals;
+ Item_timefunc::fix_length_and_dec();
}
const char *func_name() const { return "sec_to_time"; }
- bool result_as_longlong() { return TRUE; }
};
-class Item_date_add_interval :public Item_date_func
+class Item_date_add_interval :public Item_temporal_func
{
String value;
enum_field_types cached_field_type;
@@ -776,12 +743,10 @@ public:
const interval_type int_type; // keep it public
const bool date_sub_interval; // keep it public
Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
- :Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
- String *val_str(String *);
+ :Item_temporal_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
const char *func_name() const { return "date_add_interval"; }
void fix_length_and_dec();
enum_field_types field_type() const { return cached_field_type; }
- longlong val_int();
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const;
virtual void print(String *str, enum_query_type query_type);
@@ -842,177 +807,84 @@ class Item_extract :public Item_int_func
};
-class Item_typecast :public Item_str_func
-{
-public:
- Item_typecast(Item *a) :Item_str_func(a) {}
- String *val_str(String *a)
- {
- DBUG_ASSERT(fixed == 1);
- String *tmp=args[0]->val_str(a);
- null_value=args[0]->null_value;
- if (tmp)
- tmp->set_charset(collation.collation);
- return tmp;
- }
- void fix_length_and_dec()
- {
- collation.set(&my_charset_bin);
- max_length=args[0]->max_length;
- }
- virtual const char* cast_type() const= 0;
- virtual void print(String *str, enum_query_type query_type);
-};
-
-
-class Item_typecast_maybe_null :public Item_typecast
+class Item_char_typecast :public Item_str_func
{
-public:
- Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
- void fix_length_and_dec()
- {
- collation.set(&my_charset_bin);
- max_length=args[0]->max_length;
- maybe_null= 1;
- }
-};
-
-
-class Item_char_typecast :public Item_typecast
-{
- int cast_length;
+ uint cast_length;
CHARSET_INFO *cast_cs, *from_cs;
bool charset_conversion;
String tmp_value;
public:
- Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg)
- :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
+ Item_char_typecast(Item *a, uint length_arg, CHARSET_INFO *cs_arg)
+ :Item_str_func(a), cast_length(length_arg), cast_cs(cs_arg) {}
enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
bool eq(const Item *item, bool binary_cmp) const;
const char *func_name() const { return "cast_as_char"; }
- const char* cast_type() const { return "char"; };
String *val_str(String *a);
void fix_length_and_dec();
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type);
};
-class Item_date_typecast :public Item_typecast_maybe_null
+class Item_temporal_typecast: public Item_temporal_func
{
public:
- Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
+ Item_temporal_typecast(Item *a) :Item_temporal_func(a) {}
+ virtual const char *cast_type() const = 0;
+ void print(String *str, enum_query_type query_type);
+ void fix_length_and_dec()
+ {
+ if (decimals == NOT_FIXED_DEC)
+ decimals= args[0]->decimals;
+ Item_temporal_func::fix_length_and_dec();
+ }
+};
+
+class Item_date_typecast :public Item_temporal_typecast
+{
+public:
+ Item_date_typecast(Item *a) :Item_temporal_typecast(a) {}
const char *func_name() const { return "cast_as_date"; }
- String *val_str(String *str);
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
- bool get_time(MYSQL_TIME *ltime);
const char *cast_type() const { return "date"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- void fix_length_and_dec()
- {
- collation.set(&my_charset_bin);
- max_length= 10;
- maybe_null= 1;
- }
- bool result_as_longlong() { return TRUE; }
- longlong val_int();
- double val_real() { return (double) val_int(); }
- my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- return val_decimal_from_date(decimal_value);
- }
- int save_in_field(Field *field, bool no_conversions)
- {
- return save_date_in_field(field);
- }
};
-class Item_time_typecast :public Item_typecast_maybe_null
+class Item_time_typecast :public Item_temporal_typecast
{
public:
- Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
+ Item_time_typecast(Item *a, uint dec_arg)
+ :Item_temporal_typecast(a) { decimals= dec_arg; }
const char *func_name() const { return "cast_as_time"; }
- String *val_str(String *str);
- bool get_time(MYSQL_TIME *ltime);
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
const char *cast_type() const { return "time"; }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- bool result_as_longlong() { return TRUE; }
- longlong val_int();
- double val_real() { return val_real_from_decimal(); }
- my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- return val_decimal_from_time(decimal_value);
- }
- int save_in_field(Field *field, bool no_conversions)
- {
- return save_time_in_field(field);
- }
};
-class Item_datetime_typecast :public Item_typecast_maybe_null
+class Item_datetime_typecast :public Item_temporal_typecast
{
public:
- Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
+ Item_datetime_typecast(Item *a, uint dec_arg)
+ :Item_temporal_typecast(a) { decimals= dec_arg; }
const char *func_name() const { return "cast_as_datetime"; }
- String *val_str(String *str);
const char *cast_type() const { return "datetime"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
- void fix_length_and_dec()
- {
- collation.set(&my_charset_bin);
- maybe_null= 1;
- max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
- decimals= DATETIME_DEC;
- }
- bool result_as_longlong() { return TRUE; }
- longlong val_int();
- double val_real() { return val_real_from_decimal(); }
- double val() { return (double) val_int(); }
- my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- return val_decimal_from_date(decimal_value);
- }
- int save_in_field(Field *field, bool no_conversions)
- {
- return save_date_in_field(field);
- }
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
};
-class Item_func_makedate :public Item_date_func
+
+class Item_func_makedate :public Item_temporal_func
{
public:
- Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
- String *val_str(String *str);
+ Item_func_makedate(Item *a,Item *b) :Item_temporal_func(a,b) {}
const char *func_name() const { return "makedate"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
- void fix_length_and_dec()
- {
- decimals=0;
- max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
- /* It returns NULL when the second argument is less or equal to 0 */
- maybe_null= 1;
- }
- longlong val_int();
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
};
-class Item_func_add_time :public Item_str_func
+class Item_func_add_time :public Item_temporal_func
{
const bool is_date;
int sign;
@@ -1020,63 +892,39 @@ class Item_func_add_time :public Item_str_func
public:
Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
- :Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
- String *val_str(String *str);
+ :Item_temporal_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
enum_field_types field_type() const { return cached_field_type; }
void fix_length_and_dec();
-
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 0);
- }
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
virtual void print(String *str, enum_query_type query_type);
const char *func_name() const { return "add_time"; }
- double val_real() { return val_real_from_decimal(); }
- my_decimal *val_decimal(my_decimal *decimal_value)
- {
- DBUG_ASSERT(fixed == 1);
- if (cached_field_type == MYSQL_TYPE_TIME)
- return val_decimal_from_time(decimal_value);
- if (cached_field_type == MYSQL_TYPE_DATETIME)
- return val_decimal_from_date(decimal_value);
- return Item_str_func::val_decimal(decimal_value);
- }
- int save_in_field(Field *field, bool no_conversions)
- {
- if (cached_field_type == MYSQL_TYPE_TIME)
- return save_time_in_field(field);
- if (cached_field_type == MYSQL_TYPE_DATETIME)
- return save_date_in_field(field);
- return Item_str_func::save_in_field(field, no_conversions);
- }
};
-class Item_func_timediff :public Item_str_timefunc
+class Item_func_timediff :public Item_timefunc
{
public:
Item_func_timediff(Item *a, Item *b)
- :Item_str_timefunc(a, b) {}
- String *val_str(String *str);
+ :Item_timefunc(a, b) {}
const char *func_name() const { return "timediff"; }
void fix_length_and_dec()
{
- Item_str_timefunc::fix_length_and_dec();
- maybe_null= 1;
+ decimals= max(args[0]->decimals, args[1]->decimals);
+ Item_timefunc::fix_length_and_dec();
}
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
};
-class Item_func_maketime :public Item_str_timefunc
+class Item_func_maketime :public Item_timefunc
{
public:
Item_func_maketime(Item *a, Item *b, Item *c)
- :Item_str_timefunc(a, b, c)
- {
- maybe_null= TRUE;
- }
- String *val_str(String *str);
+ :Item_timefunc(a, b, c)
+ {}
const char *func_name() const { return "maketime"; }
+ bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
};
+
class Item_func_microsecond :public Item_int_func
{
public:
@@ -1138,32 +986,26 @@ public:
};
-class Item_func_str_to_date :public Item_str_func
+class Item_func_str_to_date :public Item_temporal_func
{
enum_field_types cached_field_type;
- date_time_format_types cached_format_type;
timestamp_type cached_timestamp_type;
bool const_item;
public:
Item_func_str_to_date(Item *a, Item *b)
- :Item_str_func(a, b), const_item(false)
+ :Item_temporal_func(a, b), const_item(false)
{}
- String *val_str(String *str);
bool get_date(MYSQL_TIME *ltime, uint fuzzy_date);
const char *func_name() const { return "str_to_date"; }
enum_field_types field_type() const { return cached_field_type; }
void fix_length_and_dec();
- Field *tmp_table_field(TABLE *table)
- {
- return tmp_table_field_from_field_type(table, 1);
- }
};
-class Item_func_last_day :public Item_date
+class Item_func_last_day :public Item_datefunc
{
public:
- Item_func_last_day(Item *a) :Item_date(a) {}
+ Item_func_last_day(Item *a) :Item_datefunc(a) {}
const char *func_name() const { return "last_day"; }
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
};
diff --git a/sql/key.cc b/sql/key.cc
index f7966140cdf..7f484bee32b 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -761,6 +761,7 @@ bool key_buf_cmp(KEY *key_info, uint used_key_parts,
LINT_INIT(cs);
LINT_INIT(length1);
LINT_INIT(length2);
+ LINT_INIT(pack_length);
key1+= key_part->length;
key2+= key_part->length;
diff --git a/sql/lex.h b/sql/lex.h
index e763b0325ea..6ab234f8d81 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -116,6 +116,12 @@ static SYMBOL symbols[] = {
{ "COLLATION", SYM(COLLATION_SYM)},
{ "COLUMN", SYM(COLUMN_SYM)},
{ "COLUMNS", SYM(COLUMNS)},
+ { "COLUMN_ADD", SYM(COLUMN_ADD_SYM)},
+ { "COLUMN_CREATE", SYM(COLUMN_CREATE_SYM)},
+ { "COLUMN_DELETE", SYM(COLUMN_DELETE_SYM)},
+ { "COLUMN_EXISTS", SYM(COLUMN_EXISTS_SYM)},
+ { "COLUMN_GET", SYM(COLUMN_GET_SYM)},
+ { "COLUMN_LIST", SYM(COLUMN_LIST_SYM)},
{ "COMMENT", SYM(COMMENT_SYM)},
{ "COMMIT", SYM(COMMIT_SYM)},
{ "COMMITTED", SYM(COMMITTED_SYM)},
diff --git a/sql/log.cc b/sql/log.cc
index 53c9843ebbc..d345d0f6102 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -68,6 +68,7 @@ static LEX_STRING const write_error_msg=
{ C_STRING_WITH_LEN("error writing to the binary log") };
static my_bool opt_optimize_thread_scheduling= TRUE;
+ulong binlog_checksum_options;
#ifndef DBUG_OFF
static ulong opt_binlog_dbug_fsync_sleep= 0;
#endif
@@ -395,7 +396,7 @@ void Log_to_csv_event_handler::cleanup()
*/
bool Log_to_csv_event_handler::
- log_general(THD *thd, time_t event_time, const char *user_host,
+ log_general(THD *thd, my_hrtime_t event_time, const char *user_host,
uint user_host_len, int thread_id,
const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len,
@@ -477,8 +478,8 @@ bool Log_to_csv_event_handler::
DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP);
- ((Field_timestamp*) table->field[0])->store_timestamp((my_time_t)
- event_time);
+ ((Field_timestamp*) table->field[0])->store_TIME(
+ hrtime_to_my_time(event_time), hrtime_sec_part(event_time));
/* do a write */
if (table->field[1]->store(user_host, user_host_len, client_cs) ||
@@ -542,7 +543,6 @@ err:
log_slow()
thd THD of the query
current_time current timestamp
- query_start_arg command start timestamp
user_host the pointer to the string with user@host info
user_host_len length of the user_host string. this is computed once
and passed to all general log event handlers
@@ -565,7 +565,7 @@ err:
*/
bool Log_to_csv_event_handler::
- log_slow(THD *thd, time_t current_time, time_t query_start_arg,
+ log_slow(THD *thd, my_hrtime_t current_time,
const char *user_host, uint user_host_len,
ulonglong query_utime, ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len)
@@ -579,6 +579,11 @@ bool Log_to_csv_event_handler::
Open_tables_state open_tables_backup;
CHARSET_INFO *client_cs= thd->variables.character_set_client;
bool save_time_zone_used;
+ long query_time= (long) min(query_utime/1000000, TIME_MAX_VALUE_SECONDS);
+ long lock_time= (long) min(lock_utime/1000000, TIME_MAX_VALUE_SECONDS);
+ long query_time_micro= (long) (query_utime % 1000000);
+ long lock_time_micro= (long) (lock_utime % 1000000);
+
DBUG_ENTER("Log_to_csv_event_handler::log_slow");
thd->push_internal_handler(& error_handler);
@@ -620,45 +625,34 @@ bool Log_to_csv_event_handler::
/* store the time and user values */
DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP);
- ((Field_timestamp*) table->field[0])->store_timestamp((my_time_t)
- current_time);
+ ((Field_timestamp*) table->field[0])->store_TIME(
+ hrtime_to_my_time(current_time), hrtime_sec_part(current_time));
if (table->field[1]->store(user_host, user_host_len, client_cs))
goto err;
- if (query_start_arg)
- {
- longlong query_time= (longlong) (query_utime/1000000);
- longlong lock_time= (longlong) (lock_utime/1000000);
- /*
- A TIME field can not hold the full longlong range; query_time or
- lock_time may be truncated without warning here, if greater than
- 839 hours (~35 days)
- */
- MYSQL_TIME t;
- t.neg= 0;
+ /*
+ A TIME field can not hold the full longlong range; query_time or
+ lock_time may be truncated without warning here, if greater than
+ 839 hours (~35 days)
+ */
+ MYSQL_TIME t;
+ t.neg= 0;
+
+ /* fill in query_time field */
+ calc_time_from_sec(&t, query_time, query_time_micro);
+ if (table->field[2]->store_time(&t))
+ goto err;
+ /* lock_time */
+ calc_time_from_sec(&t, lock_time, lock_time_micro);
+ if (table->field[3]->store_time(&t))
+ goto err;
+ /* rows_sent */
+ if (table->field[4]->store((longlong) thd->sent_row_count, TRUE))
+ goto err;
+ /* rows_examined */
+ if (table->field[5]->store((longlong) thd->examined_row_count, TRUE))
+ goto err;
- /* fill in query_time field */
- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
- if (table->field[4]->store((longlong) thd->sent_row_count, TRUE))
- goto err;
- /* rows_examined */
- if (table->field[5]->store((longlong) thd->examined_row_count, TRUE))
- goto err;
- }
- else
- {
- table->field[2]->set_null();
- table->field[3]->set_null();
- table->field[4]->set_null();
- table->field[5]->set_null();
- }
/* fill database field */
if (thd->db)
{
@@ -795,14 +789,14 @@ void Log_to_file_event_handler::init_pthread_objects()
/** Wrapper around MYSQL_LOG::write() for slow log. */
bool Log_to_file_event_handler::
- log_slow(THD *thd, time_t current_time, time_t query_start_arg,
+ log_slow(THD *thd, my_hrtime_t current_time,
const char *user_host, uint user_host_len,
ulonglong query_utime, ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len)
{
Silence_log_table_errors error_handler;
thd->push_internal_handler(&error_handler);
- bool retval= mysql_slow_log.write(thd, current_time, query_start_arg,
+ bool retval= mysql_slow_log.write(thd, hrtime_to_my_time(current_time),
user_host, user_host_len,
query_utime, lock_utime, is_command,
sql_text, sql_text_len);
@@ -817,7 +811,7 @@ bool Log_to_file_event_handler::
*/
bool Log_to_file_event_handler::
- log_general(THD *thd, time_t event_time, const char *user_host,
+ log_general(THD *thd, my_hrtime_t event_time, const char *user_host,
uint user_host_len, int thread_id,
const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len,
@@ -825,7 +819,8 @@ bool Log_to_file_event_handler::
{
Silence_log_table_errors error_handler;
thd->push_internal_handler(&error_handler);
- bool retval= mysql_log.write(event_time, user_host, user_host_len,
+ bool retval= mysql_log.write(hrtime_to_time(event_time), user_host,
+ user_host_len,
thread_id, command_type, command_type_len,
sql_text, sql_text_len);
thd->pop_internal_handler();
@@ -1034,8 +1029,6 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
if (*slow_log_handler_list)
{
- time_t current_time;
-
/* do not log slow queries from replication threads */
if (thd->slave_thread && !opt_log_slow_slave_statements)
return 0;
@@ -1055,16 +1048,12 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
sctx->ip ? sctx->ip : "", "]", NullS) -
user_host_buff);
- current_time= my_time_possible_from_micro(current_utime);
- if (thd->start_utime)
- {
- query_utime= (current_utime - thd->start_utime);
- lock_utime= (thd->utime_after_lock - thd->start_utime);
- }
- else
- {
- query_utime= lock_utime= 0;
- }
+ DBUG_ASSERT(thd->start_utime);
+ DBUG_ASSERT(thd->start_time);
+ query_utime= (current_utime - thd->start_utime);
+ lock_utime= (thd->utime_after_lock - thd->start_utime);
+ my_hrtime_t current_time= { hrtime_from_time(thd->start_time) +
+ thd->start_time_sec_part + query_utime };
if (!query)
{
@@ -1085,7 +1074,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
}
for (current_handler= slow_log_handler_list; *current_handler ;)
- error= (*current_handler++)->log_slow(thd, current_time, thd->start_time,
+ error= (*current_handler++)->log_slow(thd, current_time,
user_host_buff, user_host_len,
query_utime, lock_utime, is_command,
query, query_length) || error;
@@ -1103,7 +1092,7 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
char user_host_buff[MAX_USER_HOST_SIZE + 1];
Security_context *sctx= thd->security_ctx;
uint user_host_len= 0;
- time_t current_time;
+ my_hrtime_t current_time;
DBUG_ASSERT(thd);
@@ -1120,7 +1109,7 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
sctx->ip ? sctx->ip : "", "]", NullS) -
user_host_buff;
- current_time= my_time(0);
+ current_time= my_hrtime();
while (*current_handler)
error|= (*current_handler++)->
log_general(thd, current_time, user_host_buff,
@@ -2366,7 +2355,6 @@ err:
thd THD of the query
current_time current timestamp
- query_start_arg command start timestamp
user_host the pointer to the string with user@host info
user_host_len length of the user_host string. this is computed once
and passed to all general log event handlers
@@ -2388,7 +2376,7 @@ err:
*/
bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
- time_t query_start_arg, const char *user_host,
+ const char *user_host,
uint user_host_len, ulonglong query_utime,
ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len)
@@ -2568,6 +2556,8 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG()
group_commit_queue(0), group_commit_queue_busy(FALSE),
num_commits(0), num_group_commits(0),
is_relay_log(0),
+ checksum_alg_reset(BINLOG_CHECKSUM_ALG_UNDEF),
+ relay_log_checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF),
description_event_for_exec(0), description_event_for_queue(0)
{
/*
@@ -2803,10 +2793,23 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
as we won't be able to reset it later
*/
if (io_cache_type == WRITE_CACHE)
- s.flags|= LOG_EVENT_BINLOG_IN_USE_F;
+ s.flags |= LOG_EVENT_BINLOG_IN_USE_F;
+ s.checksum_alg= is_relay_log ?
+ /* relay-log */
+ /* inherit master's A descriptor if one has been received */
+ (relay_log_checksum_alg=
+ (relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF) ?
+ relay_log_checksum_alg :
+ /* otherwise use slave's local preference of RL events verification */
+ (opt_slave_sql_verify_checksum == 0) ?
+ (uint8) BINLOG_CHECKSUM_ALG_OFF : (uint8) binlog_checksum_options):
+ /* binlog */
+ (uint8) binlog_checksum_options;
+ DBUG_ASSERT(s.checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
if (!s.is_valid())
goto err;
s.dont_set_created= null_created_arg;
+ s.pre_55_writing_direct();
if (s.write(&log_file))
goto err;
bytes_written+= s.data_written;
@@ -2838,6 +2841,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
/* Don't set log_pos in event header */
description_event_for_queue->set_artificial_event();
+ description_event_for_queue->pre_55_writing_direct();
if (description_event_for_queue->write(&log_file))
goto err;
bytes_written+= description_event_for_queue->data_written;
@@ -3977,8 +3981,16 @@ int MYSQL_BIN_LOG::new_file_impl(bool need_lock)
We log the whole file name for log file as the user may decide
to change base names at some point.
*/
- Rotate_log_event r(new_name+dirname_length(new_name),
- 0, LOG_EVENT_OFFSET, is_relay_log ? Rotate_log_event::RELAY_LOG : 0);
+ Rotate_log_event r(new_name+dirname_length(new_name), 0, LOG_EVENT_OFFSET,
+ is_relay_log ? Rotate_log_event::RELAY_LOG : 0);
+ /*
+ The current relay-log's closing Rotate event must have checksum
+ value computed with an algorithm of the last relay-logged FD event.
+ */
+ if (is_relay_log)
+ r.checksum_alg= relay_log_checksum_alg;
+ r.pre_55_writing_direct();
+ DBUG_ASSERT(!is_relay_log || relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
if(DBUG_EVALUATE_IF("fault_injection_new_file_rotate_event", (error=close_on_error=TRUE), FALSE) ||
(error= r.write(&log_file)))
{
@@ -3999,7 +4011,12 @@ int MYSQL_BIN_LOG::new_file_impl(bool need_lock)
old_name=name;
name=0; // Don't free name
close(LOG_CLOSE_TO_BE_OPENED | LOG_CLOSE_INDEX);
-
+ if (log_type == LOG_BIN && checksum_alg_reset != BINLOG_CHECKSUM_ALG_UNDEF)
+ {
+ DBUG_ASSERT(!is_relay_log);
+ DBUG_ASSERT(binlog_checksum_options != checksum_alg_reset);
+ binlog_checksum_options= checksum_alg_reset;
+ }
/*
Note that at this point, log_state != LOG_CLOSED (important for is_open()).
*/
@@ -4078,6 +4095,7 @@ bool MYSQL_BIN_LOG::append(Log_event* ev)
Log_event::write() is smart enough to use my_b_write() or
my_b_append() depending on the kind of cache we have.
*/
+ ev->pre_55_writing_direct();
if (ev->write(&log_file))
{
error=1;
@@ -4473,6 +4491,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
{
/* Write directly to log file. */
pthread_mutex_lock(&LOCK_log);
+ pending->pre_55_writing_direct();
if (pending->write(&log_file))
{
pthread_mutex_unlock(&LOCK_log);
@@ -4515,6 +4534,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
{
THD *thd= event_info->thd;
bool error= 1;
+ uint16 cache_type;
DBUG_ENTER("MYSQL_BIN_LOG::write(Log_event *)");
if (thd->binlog_evt_union.do_union)
@@ -4618,8 +4638,11 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
pthread_mutex_unlock(&LOCK_log);
DBUG_RETURN(error);
}
+ event_info->pre_55_writing_direct();
}
+ cache_type= event_info->cache_type;
+
/*
No check for auto events flag here - this write method should
never be called if auto-events are enabled
@@ -4633,7 +4656,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
if (with_annotate && *with_annotate)
{
DBUG_ASSERT(event_info->get_type_code() == TABLE_MAP_EVENT);
- Annotate_rows_log_event anno(thd);
+ Annotate_rows_log_event anno(thd, cache_type);
/* Annotate event should be written not more than once */
*with_annotate= 0;
if (anno.write(file))
@@ -4647,10 +4670,12 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
{
if (!thd->current_stmt_binlog_row_based)
{
+
if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
{
Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT,
- thd->first_successful_insert_id_in_prev_stmt_for_binlog);
+ thd->first_successful_insert_id_in_prev_stmt_for_binlog,
+ cache_type);
if (e.write(file))
goto err_unlock;
}
@@ -4661,13 +4686,14 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
nb_elements()));
Intvar_log_event e(thd, (uchar) INSERT_ID_EVENT,
thd->auto_inc_intervals_in_cur_stmt_for_binlog.
- minimum());
+ minimum(), cache_type);
if (e.write(file))
goto err_unlock;
}
if (thd->rand_used)
{
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
+ Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2,
+ cache_type);
if (e.write(file))
goto err_unlock;
}
@@ -4682,7 +4708,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
user_var_event->value,
user_var_event->length,
user_var_event->type,
- user_var_event->charset_number);
+ user_var_event->charset_number,
+ cache_type);
if (e.write(file))
goto err_unlock;
}
@@ -4838,6 +4865,8 @@ int MYSQL_BIN_LOG::rotate_and_purge(uint flags)
#ifdef HAVE_REPLICATION
check_purge= true;
#endif
+ if (flags & RP_BINLOG_CHECKSUM_ALG_CHANGE)
+ checksum_alg_reset= BINLOG_CHECKSUM_ALG_UNDEF; // done
}
if (!(flags & RP_LOCK_LOG_IS_ALREADY_LOCKED))
pthread_mutex_unlock(&LOCK_log);
@@ -4866,6 +4895,33 @@ uint MYSQL_BIN_LOG::next_file_id()
}
+/**
+ Calculate checksum of possibly a part of an event containing at least
+ the whole common header.
+
+ @param buf the pointer to trans cache's buffer
+ @param off the offset of the beginning of the event in the buffer
+ @param event_len no-checksum length of the event
+ @param length the current size of the buffer
+
+ @param crc [in-out] the checksum
+
+ Event size in incremented by @c BINLOG_CHECKSUM_LEN.
+
+ @return 0 or number of unprocessed yet bytes of the event excluding
+ the checksum part.
+*/
+ static ulong fix_log_event_crc(uchar *buf, uint off, uint event_len,
+ uint length, ha_checksum *crc)
+{
+ ulong ret;
+ uchar *event_begin= buf + off;
+
+ ret= length >= off + event_len ? 0 : off + event_len - length;
+ *crc= my_checksum(*crc, event_begin, event_len - ret);
+ return ret;
+}
+
/*
Write the contents of a cache to the binary log.
@@ -4877,7 +4933,11 @@ uint MYSQL_BIN_LOG::next_file_id()
DESCRIPTION
Write the contents of the cache to the binary log. The cache will
be reset as a READ_CACHE to be able to read the contents from it.
- */
+
+ Reading from the trans cache with possible (per @c binlog_checksum_options)
+ adding checksum value and then fixing the length and the end_log_pos of
+ events prior to fill in the binlog cache.
+*/
int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
{
@@ -4885,8 +4945,17 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
return ER_ERROR_ON_WRITE;
uint length= my_b_bytes_in_cache(cache), group, carry, hdr_offs;
+ ulong remains= 0; // part of unprocessed yet netto length of the event
long val;
+ ulong end_log_pos_inc= 0; // each event processed adds BINLOG_CHECKSUM_LEN 2 t
uchar header[LOG_EVENT_HEADER_LEN];
+ ha_checksum crc= 0, crc_0= 0; // assignments to keep compiler happy
+ my_bool do_checksum= (binlog_checksum_options != BINLOG_CHECKSUM_ALG_OFF);
+ uchar buf[BINLOG_CHECKSUM_LEN];
+
+ // while there is just one alg the following must hold:
+ DBUG_ASSERT(!do_checksum ||
+ binlog_checksum_options == BINLOG_CHECKSUM_ALG_CRC32);
/*
The events in the buffer have incorrect end_log_pos data
@@ -4904,6 +4973,8 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
group= (uint)my_b_tell(&log_file);
hdr_offs= carry= 0;
+ if (do_checksum)
+ crc= crc_0= my_checksum(0L, NULL, 0);
do
{
@@ -4917,12 +4988,21 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
DBUG_ASSERT(carry < LOG_EVENT_HEADER_LEN);
/* assemble both halves */
- memcpy(&header[carry], (char *)cache->read_pos, LOG_EVENT_HEADER_LEN - carry);
+ memcpy(&header[carry], (char *)cache->read_pos,
+ LOG_EVENT_HEADER_LEN - carry);
/* fix end_log_pos */
- val= uint4korr(&header[LOG_POS_OFFSET]) + group;
+ val= uint4korr(&header[LOG_POS_OFFSET]) + group +
+ (end_log_pos_inc+= (do_checksum ? BINLOG_CHECKSUM_LEN : 0));
int4store(&header[LOG_POS_OFFSET], val);
+ if (do_checksum)
+ {
+ ulong len= uint4korr(&header[EVENT_LEN_OFFSET]);
+ /* fix len */
+ int4store(&header[EVENT_LEN_OFFSET], len + BINLOG_CHECKSUM_LEN);
+ }
+
/* write the first half of the split header */
if (my_b_write(&log_file, header, carry))
return ER_ERROR_ON_WRITE;
@@ -4932,11 +5012,20 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
copy fixed second half of header to cache so the correct
version will be written later.
*/
- memcpy((char *)cache->read_pos, &header[carry], LOG_EVENT_HEADER_LEN - carry);
+ memcpy((char *)cache->read_pos, &header[carry],
+ LOG_EVENT_HEADER_LEN - carry);
/* next event header at ... */
- hdr_offs = uint4korr(&header[EVENT_LEN_OFFSET]) - carry;
+ hdr_offs= uint4korr(&header[EVENT_LEN_OFFSET]) - carry -
+ (do_checksum ? BINLOG_CHECKSUM_LEN : 0);
+ if (do_checksum)
+ {
+ DBUG_ASSERT(crc == crc_0 && remains == 0);
+ crc= my_checksum(crc, header, carry);
+ remains= uint4korr(header + EVENT_LEN_OFFSET) - carry -
+ BINLOG_CHECKSUM_LEN;
+ }
carry= 0;
}
@@ -4951,6 +5040,25 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
very next iteration, just "eventually").
*/
+ /* crc-calc the whole buffer */
+ if (do_checksum && hdr_offs >= length)
+ {
+
+ DBUG_ASSERT(remains != 0 && crc != crc_0);
+
+ crc= my_checksum(crc, cache->read_pos, length);
+ remains -= length;
+ if (my_b_write(&log_file, cache->read_pos, length))
+ return ER_ERROR_ON_WRITE;
+ if (remains == 0)
+ {
+ int4store(buf, crc);
+ if (my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
+ return ER_ERROR_ON_WRITE;
+ crc= crc_0;
+ }
+ }
+
while (hdr_offs < length)
{
/*
@@ -4958,6 +5066,26 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
we get the rest.
*/
+ if (do_checksum)
+ {
+ if (remains != 0)
+ {
+ /*
+ finish off with remains of the last event that crawls
+ from previous into the current buffer
+ */
+ DBUG_ASSERT(crc != crc_0);
+ crc= my_checksum(crc, cache->read_pos, hdr_offs);
+ int4store(buf, crc);
+ remains -= hdr_offs;
+ DBUG_ASSERT(remains == 0);
+ if (my_b_write(&log_file, cache->read_pos, hdr_offs) ||
+ my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
+ return ER_ERROR_ON_WRITE;
+ crc= crc_0;
+ }
+ }
+
if (hdr_offs + LOG_EVENT_HEADER_LEN > length)
{
carry= length - hdr_offs;
@@ -4967,17 +5095,38 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
else
{
/* we've got a full event-header, and it came in one piece */
-
- uchar *log_pos= (uchar *)cache->read_pos + hdr_offs + LOG_POS_OFFSET;
+ uchar *ev= (uchar *)cache->read_pos + hdr_offs;
+ uint event_len= uint4korr(ev + EVENT_LEN_OFFSET); // netto len
+ uchar *log_pos= ev + LOG_POS_OFFSET;
/* fix end_log_pos */
- val= uint4korr(log_pos) + group;
+ val= uint4korr(log_pos) + group +
+ (end_log_pos_inc += (do_checksum ? BINLOG_CHECKSUM_LEN : 0));
int4store(log_pos, val);
+ /* fix CRC */
+ if (do_checksum)
+ {
+ /* fix length */
+ int4store(ev + EVENT_LEN_OFFSET, event_len + BINLOG_CHECKSUM_LEN);
+ remains= fix_log_event_crc(cache->read_pos, hdr_offs, event_len,
+ length, &crc);
+ if (my_b_write(&log_file, ev,
+ remains == 0 ? event_len : length - hdr_offs))
+ return ER_ERROR_ON_WRITE;
+ if (remains == 0)
+ {
+ int4store(buf, crc);
+ if (my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
+ return ER_ERROR_ON_WRITE;
+ crc= crc_0; // crc is complete
+ }
+ }
+
/* next event header at ... */
- log_pos= (uchar *)cache->read_pos + hdr_offs + EVENT_LEN_OFFSET;
- hdr_offs += uint4korr(log_pos);
+ hdr_offs += event_len; // incr by the netto len
+ DBUG_ASSERT(!do_checksum || remains == 0 || hdr_offs >= length);
}
}
@@ -4995,14 +5144,17 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
/* Write data to the binary log file */
DBUG_EXECUTE_IF("fail_binlog_write_1",
errno= 28; return ER_ERROR_ON_WRITE;);
- if (my_b_write(&log_file, cache->read_pos, length))
- return ER_ERROR_ON_WRITE;
+ if (!do_checksum)
+ if (my_b_write(&log_file, cache->read_pos, length))
+ return ER_ERROR_ON_WRITE;
status_var_add(thd->status_var.binlog_bytes_written, length);
cache->read_pos=cache->read_end; // Mark buffer used up
} while ((length= my_b_fill(cache)));
DBUG_ASSERT(carry == 0);
+ DBUG_ASSERT(!do_checksum || remains == 0);
+ DBUG_ASSERT(!do_checksum || crc == crc_0);
return 0; // All OK
}
@@ -5046,6 +5198,7 @@ bool MYSQL_BIN_LOG::write_incident_already_locked(THD *thd)
if (likely(is_open()))
{
+ ev.pre_55_writing_direct();
error= ev.write(&log_file);
status_var_add(thd->status_var.binlog_bytes_written, ev.data_written);
}
@@ -5436,6 +5589,7 @@ MYSQL_BIN_LOG::write_transaction(group_commit_entry *entry)
binlog_trx_data *trx_data= entry->trx_data;
IO_CACHE *cache= &trx_data->trans_log;
+ entry->begin_event->pre_55_writing_direct();
if (entry->begin_event->write(&log_file))
return ER_ERROR_ON_WRITE;
status_var_add(entry->thd->status_var.binlog_bytes_written,
@@ -5455,13 +5609,18 @@ MYSQL_BIN_LOG::write_transaction(group_commit_entry *entry)
if (write_cache(entry->thd, cache))
return ER_ERROR_ON_WRITE;
+ entry->end_event->pre_55_writing_direct();
if (entry->end_event->write(&log_file))
return ER_ERROR_ON_WRITE;
status_var_add(entry->thd->status_var.binlog_bytes_written,
entry->end_event->data_written);
- if (entry->incident_event && entry->incident_event->write(&log_file))
- return ER_ERROR_ON_WRITE;
+ if (entry->incident_event)
+ {
+ entry->incident_event->pre_55_writing_direct();
+ if (entry->incident_event->write(&log_file))
+ return ER_ERROR_ON_WRITE;
+ }
if (cache->error) // Error on read
return ER_ERROR_ON_READ;
@@ -5525,6 +5684,12 @@ void MYSQL_BIN_LOG::close(uint exiting)
(exiting & LOG_CLOSE_STOP_EVENT))
{
Stop_log_event s;
+ // the checksumming rule for relay-log case is similar to Rotate
+ s.checksum_alg= is_relay_log ?
+ (uint8) relay_log_checksum_alg : (uint8) binlog_checksum_options;
+ DBUG_ASSERT(!is_relay_log ||
+ relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
+ s.pre_55_writing_direct();
s.write(&log_file);
bytes_written+= s.data_written;
signal_update();
@@ -5640,9 +5805,23 @@ static bool test_if_number(register const char *str,
void sql_perror(const char *message)
{
-#ifdef HAVE_STRERROR
+#if defined(_WIN32)
+ char* buf;
+ DWORD dw= GetLastError();
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL ) > 0)
+ {
+ sql_print_error("%s: %s",message, buf);
+ LocalFree((HLOCAL)buf);
+ }
+ else
+ {
+ sql_print_error("%s", message);
+ }
+#elif defined(HAVE_STRERROR)
sql_print_error("%s: %s",message, strerror(errno));
-#else
+#else
perror(message);
#endif
}
@@ -6612,7 +6791,8 @@ int TC_LOG_BINLOG::open(const char *opt_name)
goto err;
}
- if ((ev= Log_event::read_log_event(&log, 0, &fdle)) &&
+ if ((ev= Log_event::read_log_event(&log, 0, &fdle,
+ opt_master_verify_checksum)) &&
ev->get_type_code() == FORMAT_DESCRIPTION_EVENT &&
ev->flags & LOG_EVENT_BINLOG_IN_USE_F)
{
@@ -6751,7 +6931,9 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle)
fdle->flags&= ~LOG_EVENT_BINLOG_IN_USE_F; // abort on the first error
- while ((ev= Log_event::read_log_event(log,0,fdle)) && ev->is_valid())
+ while ((ev= Log_event::read_log_event(log, 0, fdle,
+ opt_master_verify_checksum))
+ && ev->is_valid())
{
if (ev->get_type_code() == XID_EVENT)
{
@@ -6831,6 +7013,32 @@ mysql_bin_log_commit_pos(THD *thd, ulonglong *out_pos, const char **out_file)
#endif /* INNODB_COMPATIBILITY_HOOKS */
+static void
+binlog_checksum_update(MYSQL_THD thd, struct st_mysql_sys_var *var,
+ void *var_ptr, const void *save)
+{
+ ulong value= *((ulong *)save);
+
+ pthread_mutex_lock(mysql_bin_log.get_log_lock());
+ if(mysql_bin_log.is_open())
+ {
+ uint flags= RP_FORCE_ROTATE | RP_LOCK_LOG_IS_ALREADY_LOCKED |
+ (binlog_checksum_options != (uint) value?
+ RP_BINLOG_CHECKSUM_ALG_CHANGE : 0);
+ if (flags & RP_BINLOG_CHECKSUM_ALG_CHANGE)
+ mysql_bin_log.checksum_alg_reset= (uint8) value;
+ mysql_bin_log.rotate_and_purge(flags);
+ }
+ else
+ {
+ binlog_checksum_options= value;
+ }
+ DBUG_ASSERT((ulong) binlog_checksum_options == value);
+ DBUG_ASSERT(mysql_bin_log.checksum_alg_reset == BINLOG_CHECKSUM_ALG_UNDEF);
+ pthread_mutex_unlock(mysql_bin_log.get_log_lock());
+}
+
+
static int show_binlog_vars(THD *thd, SHOW_VAR *var, char *buff)
{
mysql_bin_log.set_status_variables(thd);
@@ -6857,6 +7065,18 @@ static MYSQL_SYSVAR_BOOL(
NULL,
1);
+static MYSQL_SYSVAR_ENUM(
+ checksum,
+ binlog_checksum_options,
+ PLUGIN_VAR_RQCMDARG,
+ "Type of BINLOG_CHECKSUM_ALG. Include checksum for "
+ "log events in the binary log. Possible values are NONE and CRC32; "
+ "default is NONE.",
+ NULL,
+ binlog_checksum_update,
+ BINLOG_CHECKSUM_ALG_OFF,
+ &binlog_checksum_typelib);
+
#ifndef DBUG_OFF
static MYSQL_SYSVAR_ULONG(
dbug_fsync_sleep,
@@ -6874,6 +7094,7 @@ static MYSQL_SYSVAR_ULONG(
static struct st_mysql_sys_var *binlog_sys_vars[]=
{
MYSQL_SYSVAR(optimize_thread_scheduling),
+ MYSQL_SYSVAR(checksum),
#ifndef DBUG_OFF
MYSQL_SYSVAR(dbug_fsync_sleep),
#endif
diff --git a/sql/log.h b/sql/log.h
index 503e94df981..3a6c484a55b 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -281,7 +281,7 @@ public:
uint user_host_len, int thread_id,
const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len);
- bool write(THD *thd, time_t current_time, time_t query_start_arg,
+ bool write(THD *thd, time_t current_time,
const char *user_host, uint user_host_len,
ulonglong query_utime, ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len);
@@ -403,7 +403,41 @@ public:
/* This is relay log */
bool is_relay_log;
-
+ uint8 checksum_alg_reset; // to contain a new value when binlog is rotated
+ /*
+ Holds the last seen in Relay-Log FD's checksum alg value.
+ The initial value comes from the slave's local FD that heads
+ the very first Relay-Log file. In the following the value may change
+ with each received master's FD_m.
+ Besides to be used in verification events that IO thread receives
+ (except the 1st fake Rotate, see @c Master_info:: checksum_alg_before_fd),
+ the value specifies if/how to compute checksum for slave's local events
+ and the first fake Rotate (R_f^1) coming from the master.
+ R_f^1 needs logging checksum-compatibly with the RL's heading FD_s.
+
+ Legends for the checksum related comments:
+
+ FD - Format-Description event,
+ R - Rotate event
+ R_f - the fake Rotate event
+ E - an arbirary event
+
+ The underscore indexes for any event
+ `_s' indicates the event is generated by Slave
+ `_m' - by Master
+
+ Two special underscore indexes of FD:
+ FD_q - Format Description event for queuing (relay-logging)
+ FD_e - Format Description event for executing (relay-logging)
+
+ Upper indexes:
+ E^n - n:th event is a sequence
+
+ RL - Relay Log
+ (A) - checksum algorithm descriptor value
+ FD.(A) - the value of (A) in FD
+ */
+ uint8 relay_log_checksum_alg;
/*
These describe the log's format. This is used only for relay logs.
_for_exec is used by the SQL thread, _for_queue by the I/O thread. It's
@@ -547,14 +581,14 @@ public:
virtual bool init()= 0;
virtual void cleanup()= 0;
- virtual bool log_slow(THD *thd, time_t current_time,
- time_t query_start_arg, const char *user_host,
+ virtual bool log_slow(THD *thd, my_hrtime_t current_time,
+ const char *user_host,
uint user_host_len, ulonglong query_utime,
ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len)= 0;
virtual bool log_error(enum loglevel level, const char *format,
va_list args)= 0;
- virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
+ virtual bool log_general(THD *thd, my_hrtime_t event_time, const char *user_host,
uint user_host_len, int thread_id,
const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len,
@@ -576,14 +610,14 @@ public:
virtual bool init();
virtual void cleanup();
- virtual bool log_slow(THD *thd, time_t current_time,
- time_t query_start_arg, const char *user_host,
+ virtual bool log_slow(THD *thd, my_hrtime_t current_time,
+ const char *user_host,
uint user_host_len, ulonglong query_utime,
ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len);
virtual bool log_error(enum loglevel level, const char *format,
va_list args);
- virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
+ virtual bool log_general(THD *thd, my_hrtime_t event_time, const char *user_host,
uint user_host_len, int thread_id,
const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len,
@@ -608,14 +642,14 @@ public:
virtual bool init();
virtual void cleanup();
- virtual bool log_slow(THD *thd, time_t current_time,
- time_t query_start_arg, const char *user_host,
+ virtual bool log_slow(THD *thd, my_hrtime_t current_time,
+ const char *user_host,
uint user_host_len, ulonglong query_utime,
ulonglong lock_utime, bool is_command,
const char *sql_text, uint sql_text_len);
virtual bool log_error(enum loglevel level, const char *format,
va_list args);
- virtual bool log_general(THD *thd, time_t event_time, const char *user_host,
+ virtual bool log_general(THD *thd, my_hrtime_t event_time, const char *user_host,
uint user_host_len, int thread_id,
const char *command_type, uint command_type_len,
const char *sql_text, uint sql_text_len,
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 0259ff762ad..3dad0c87e00 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -38,6 +38,31 @@
#include <base64.h>
#include <my_bitmap.h>
+
+/**
+ BINLOG_CHECKSUM variable.
+*/
+const char *binlog_checksum_type_names[]= {
+ "NONE",
+ "CRC32",
+ NullS
+};
+
+unsigned int binlog_checksum_type_length[]= {
+ sizeof("NONE") - 1,
+ sizeof("CRC32") - 1,
+ 0
+};
+
+TYPELIB binlog_checksum_typelib=
+{
+ array_elements(binlog_checksum_type_names) - 1, "",
+ binlog_checksum_type_names,
+ binlog_checksum_type_length
+};
+
+
+
#define log_cs &my_charset_latin1
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
@@ -51,6 +76,24 @@
*/
#define FMT_G_BUFSIZE(PREC) (3 + (PREC) + 5 + 1)
+/*
+ replication event checksum is introduced in the following "checksum-home" version.
+ The checksum-aware servers extract FD's version to decide whether the FD event
+ carries checksum info.
+
+ TODO: correct the constant when it has been determined
+ (which main tree to push and when)
+*/
+const uchar checksum_version_split_mysql[3]= {5, 6, 1};
+const ulong checksum_version_product_mysql=
+ (checksum_version_split_mysql[0] * 256 +
+ checksum_version_split_mysql[1]) * 256 +
+ checksum_version_split_mysql[2];
+const uchar checksum_version_split_mariadb[3]= {5, 3, 0};
+const ulong checksum_version_product_mariadb=
+ (checksum_version_split_mariadb[0] * 256 +
+ checksum_version_split_mariadb[1]) * 256 +
+ checksum_version_split_mariadb[2];
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD* thd);
@@ -610,7 +653,6 @@ static void print_set_option(IO_CACHE* file, uint32 bits_changed,
}
}
#endif
-
/**************************************************************************
Log_event methods (= the parent class of all events)
**************************************************************************/
@@ -666,10 +708,13 @@ const char* Log_event::get_type_str()
#ifndef MYSQL_CLIENT
Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
- :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg), thd(thd_arg)
+ :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg),
+ cache_type(EVENT_INVALID_CACHE), crc(0), thd(thd_arg),
+ checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF)
{
server_id= thd->server_id;
- when= thd->start_time;
+ when= thd->start_time;
+ when_sec_part=thd->start_time_sec_part;
cache_stmt= using_trans;
}
@@ -683,14 +728,16 @@ Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
Log_event::Log_event()
:temp_buf(0), exec_time(0), flags(0), cache_stmt(0),
- thd(0)
+ cache_type(EVENT_INVALID_CACHE), crc(0),
+ thd(0), checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF)
{
server_id= ::server_id;
/*
We can't call my_time() here as this would cause a call before
my_init() is called
*/
- when= 0;
+ when= 0;
+ when_sec_part=0;
log_pos= 0;
}
#endif /* !MYSQL_CLIENT */
@@ -702,12 +749,14 @@ Log_event::Log_event()
Log_event::Log_event(const char* buf,
const Format_description_log_event* description_event)
- :temp_buf(0), cache_stmt(0)
+ :temp_buf(0), cache_stmt(0), cache_type(EVENT_INVALID_CACHE),
+ crc(0), checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF)
{
#ifndef MYSQL_CLIENT
thd = 0;
#endif
when = uint4korr(buf);
+ when_sec_part= 0;
server_id = uint4korr(buf + SERVER_ID_OFFSET);
data_written= uint4korr(buf + EVENT_LEN_OFFSET);
if (description_event->binlog_version==1)
@@ -796,21 +845,13 @@ int Log_event::do_update_pos(Relay_log_info *rli)
DBUG_EXECUTE_IF("let_first_flush_log_change_timestamp",
if (debug_not_change_ts_if_art_event == 1
&& is_artificial_event())
- {
- debug_not_change_ts_if_art_event= 0;
- });
-#ifndef DBUG_OFF
- rli->stmt_done(log_pos,
- is_artificial_event() &&
- debug_not_change_ts_if_art_event > 0 ? 0 : when);
-#else
- rli->stmt_done(log_pos, is_artificial_event()? 0 : when);
-#endif
+ debug_not_change_ts_if_art_event= 0; );
+ rli->stmt_done(log_pos, is_artificial_event()
+ IF_DBUG(&& debug_not_change_ts_if_art_event > 0) ?
+ 0 : when);
DBUG_EXECUTE_IF("let_first_flush_log_change_timestamp",
if (debug_not_change_ts_if_art_event == 0)
- {
- debug_not_change_ts_if_art_event= 2;
- });
+ debug_not_change_ts_if_art_event= 2; );
}
return 0; // Cannot fail currently
}
@@ -887,6 +928,105 @@ void Log_event::init_show_field_list(List<Item>* field_list)
field_list->push_back(new Item_empty_string("Info", 20));
}
+/**
+ A decider of whether to trigger checksum computation or not.
+ To be invoked in Log_event::write() stack.
+ The decision is positive
+
+ S,M) if it's been marked for checksumming with @c checksum_alg
+
+ M) otherwise, if @@global.binlog_checksum is not NONE and the event is
+ directly written to the binlog file.
+ The to-be-cached event decides at @c write_cache() time.
+
+ Otherwise the decision is negative.
+
+ @note A side effect of the method is altering Log_event::checksum_alg
+ it the latter was undefined at calling.
+
+ @return true (positive) or false (negative)
+*/
+my_bool Log_event::need_checksum()
+{
+ DBUG_ENTER("Log_event::need_checksum");
+ my_bool ret;
+ /*
+ few callers of Log_event::write
+ (incl FD::write, FD constructing code on the slave side, Rotate relay log
+ and Stop event)
+ provides their checksum alg preference through Log_event::checksum_alg.
+ */
+ ret= ((checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF) ?
+ (checksum_alg != BINLOG_CHECKSUM_ALG_OFF) :
+ ((binlog_checksum_options != BINLOG_CHECKSUM_ALG_OFF) &&
+ (cache_type == Log_event::EVENT_NO_CACHE)) ?
+ test(binlog_checksum_options) : FALSE);
+
+ /*
+ FD calls the methods before data_written has been calculated.
+ The following invariant claims if the current is not the first
+ call (and therefore data_written is not zero) then `ret' must be
+ TRUE. It may not be null because FD is always checksummed.
+ */
+
+ DBUG_ASSERT(get_type_code() != FORMAT_DESCRIPTION_EVENT || ret ||
+ data_written == 0);
+
+ if (checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF)
+ checksum_alg= ret ? // calculated value stored
+ (uint8) binlog_checksum_options : (uint8) BINLOG_CHECKSUM_ALG_OFF;
+
+ DBUG_ASSERT(!ret ||
+ ((checksum_alg == binlog_checksum_options ||
+ /*
+ Stop event closes the relay-log and its checksum alg
+ preference is set by the caller can be different
+ from the server's binlog_checksum_options.
+ */
+ get_type_code() == STOP_EVENT ||
+ /*
+ Rotate:s can be checksummed regardless of the server's
+ binlog_checksum_options. That applies to both
+ the local RL's Rotate and the master's Rotate
+ which IO thread instantiates via queue_binlog_ver_3_event.
+ */
+ get_type_code() == ROTATE_EVENT
+ || /* FD is always checksummed */
+ get_type_code() == FORMAT_DESCRIPTION_EVENT) &&
+ checksum_alg != BINLOG_CHECKSUM_ALG_OFF));
+
+ DBUG_ASSERT(checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
+
+ DBUG_ASSERT(((get_type_code() != ROTATE_EVENT &&
+ get_type_code() != STOP_EVENT) ||
+ get_type_code() != FORMAT_DESCRIPTION_EVENT) ||
+ cache_type == Log_event::EVENT_NO_CACHE);
+
+ DBUG_RETURN(ret);
+}
+
+bool Log_event::wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong size)
+{
+ if (need_checksum() && size != 0)
+ crc= my_checksum(crc, buf, size);
+
+ return my_b_safe_write(file, buf, size);
+}
+
+bool Log_event::write_footer(IO_CACHE* file)
+{
+ /*
+ footer contains the checksum-algorithm descriptor
+ followed by the checksum value
+ */
+ if (need_checksum())
+ {
+ uchar buf[BINLOG_CHECKSUM_LEN];
+ int4store(buf, crc);
+ return (my_b_safe_write(file, (uchar*) buf, sizeof(buf)));
+ }
+ return 0;
+}
/*
Log_event::write()
@@ -896,11 +1036,18 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
{
uchar header[LOG_EVENT_HEADER_LEN];
ulong now;
+ bool ret;
DBUG_ENTER("Log_event::write_header");
/* Store number of bytes that will be written by this event */
data_written= event_data_length + sizeof(header);
+ if (need_checksum())
+ {
+ crc= my_checksum(0L, NULL, 0);
+ data_written += BINLOG_CHECKSUM_LEN;
+ }
+
/*
log_pos != 0 if this is relay-log event. In this case we should not
change the position
@@ -945,7 +1092,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
log_pos= my_b_safe_tell(file)+data_written;
}
- now= (ulong) get_time(); // Query start time
+ now= get_time(); // Query start time
/*
Header will be of size LOG_EVENT_HEADER_LEN for all events, except for
@@ -959,9 +1106,36 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
int4store(header+ SERVER_ID_OFFSET, server_id);
int4store(header+ EVENT_LEN_OFFSET, data_written);
int4store(header+ LOG_POS_OFFSET, log_pos);
- int2store(header+ FLAGS_OFFSET, flags);
-
- DBUG_RETURN(my_b_safe_write(file, header, sizeof(header)) != 0);
+ /*
+ recording checksum of FD event computed with dropped
+ possibly active LOG_EVENT_BINLOG_IN_USE_F flag.
+ Similar step at verication: the active flag is dropped before
+ checksum computing.
+ */
+ if (header[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT ||
+ !need_checksum() || !(flags & LOG_EVENT_BINLOG_IN_USE_F))
+ {
+ int2store(header+ FLAGS_OFFSET, flags);
+ ret= wrapper_my_b_safe_write(file, header, sizeof(header)) != 0;
+ }
+ else
+ {
+ ret= (wrapper_my_b_safe_write(file, header, FLAGS_OFFSET) != 0);
+ if (!ret)
+ {
+ flags &= ~LOG_EVENT_BINLOG_IN_USE_F;
+ int2store(header + FLAGS_OFFSET, flags);
+ crc= my_checksum(crc, header + FLAGS_OFFSET, sizeof(flags));
+ flags |= LOG_EVENT_BINLOG_IN_USE_F;
+ int2store(header + FLAGS_OFFSET, flags);
+ ret= (my_b_safe_write(file, header + FLAGS_OFFSET, sizeof(flags)) != 0);
+ }
+ if (!ret)
+ ret= (wrapper_my_b_safe_write(file, header + FLAGS_OFFSET + sizeof(flags),
+ sizeof(header)
+ - (FLAGS_OFFSET + sizeof(flags))) != 0);
+ }
+ DBUG_RETURN( ret);
}
@@ -971,11 +1145,13 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
*/
int Log_event::read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock)
+ pthread_mutex_t* log_lock,
+ uint8 checksum_alg_arg)
{
ulong data_len;
int result=0;
char buf[LOG_EVENT_MINIMAL_HEADER_LEN];
+ uchar ev_offset= packet->length();
DBUG_ENTER("Log_event::read_log_event");
if (log_lock)
@@ -1033,6 +1209,31 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
(file->error >= 0 ? LOG_READ_TRUNC: LOG_READ_IO));
/* Implicit goto end; */
}
+ else
+ {
+ /* Corrupt the event for Dump thread*/
+ DBUG_EXECUTE_IF("corrupt_read_log_event2",
+ uchar *debug_event_buf_c = (uchar*) packet->ptr() + ev_offset;
+ if (debug_event_buf_c[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT)
+ {
+ int debug_cor_pos = rand() % (data_len + sizeof(buf) - BINLOG_CHECKSUM_LEN);
+ debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
+ DBUG_PRINT("info", ("Corrupt the event at Log_event::read_log_event: byte on position %d", debug_cor_pos));
+ DBUG_SET("-d,corrupt_read_log_event2");
+ }
+ );
+ /*
+ CRC verification of the Dump thread
+ */
+ if (opt_master_verify_checksum &&
+ event_checksum_test((uchar*) packet->ptr() + ev_offset,
+ data_len + sizeof(buf),
+ checksum_alg_arg))
+ {
+ result= LOG_READ_CHECKSUM_FAILURE;
+ goto end;
+ }
+ }
}
end:
@@ -1058,11 +1259,13 @@ end:
Log_event* Log_event::read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock,
const Format_description_log_event
- *description_event)
+ *description_event,
+ my_bool crc_check)
#else
Log_event* Log_event::read_log_event(IO_CACHE* file,
const Format_description_log_event
- *description_event)
+ *description_event,
+ my_bool crc_check)
#endif
{
DBUG_ENTER("Log_event::read_log_event");
@@ -1126,7 +1329,7 @@ failed my_b_read"));
error = "read error";
goto err;
}
- if ((res= read_log_event(buf, data_len, &error, description_event)))
+ if ((res= read_log_event(buf, data_len, &error, description_event, crc_check)))
res->register_temp_buf(buf, TRUE);
err:
@@ -1159,9 +1362,11 @@ err:
Log_event* Log_event::read_log_event(const char* buf, uint event_len,
const char **error,
- const Format_description_log_event *description_event)
+ const Format_description_log_event *description_event,
+ my_bool crc_check)
{
Log_event* ev;
+ uint8 alg;
DBUG_ENTER("Log_event::read_log_event(char*,...)");
DBUG_ASSERT(description_event != 0);
DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version));
@@ -1177,6 +1382,60 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
}
uint event_type= (uchar)buf[EVENT_TYPE_OFFSET];
+ // all following START events in the current file are without checksum
+ if (event_type == START_EVENT_V3)
+ (const_cast< Format_description_log_event *>(description_event))->checksum_alg= BINLOG_CHECKSUM_ALG_OFF;
+ /*
+ CRC verification by SQL and Show-Binlog-Events master side.
+ The caller has to provide @description_event->checksum_alg to
+ be the last seen FD's (A) descriptor.
+ If event is FD the descriptor is in it.
+ Notice, FD of the binlog can be only in one instance and therefore
+ Show-Binlog-Events executing master side thread needs just to know
+ the only FD's (A) value - whereas RL can contain more.
+ In the RL case, the alg is kept in FD_e (@description_event) which is reset
+ to the newer read-out event after its execution with possibly new alg descriptor.
+ Therefore in a typical sequence of RL:
+ {FD_s^0, FD_m, E_m^1} E_m^1
+ will be verified with (A) of FD_m.
+
+ See legends definition on MYSQL_BIN_LOG::relay_log_checksum_alg docs
+ lines (log.h).
+
+ Notice, a pre-checksum FD version forces alg := BINLOG_CHECKSUM_ALG_UNDEF.
+ */
+ alg= (event_type != FORMAT_DESCRIPTION_EVENT) ?
+ description_event->checksum_alg : get_checksum_alg(buf, event_len);
+ // Emulate the corruption during reading an event
+ DBUG_EXECUTE_IF("corrupt_read_log_event_char",
+ if (event_type != FORMAT_DESCRIPTION_EVENT)
+ {
+ char *debug_event_buf_c = (char *)buf;
+ int debug_cor_pos = rand() % (event_len - BINLOG_CHECKSUM_LEN);
+ debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
+ DBUG_PRINT("info", ("Corrupt the event at Log_event::read_log_event(char*,...): byte on position %d", debug_cor_pos));
+ DBUG_SET("-d,corrupt_read_log_event_char");
+ }
+ );
+ if (crc_check &&
+ event_checksum_test((uchar *) buf, event_len, alg))
+ {
+#ifdef MYSQL_CLIENT
+ *error= "Event crc check failed! Most likely there is event corruption.";
+ if (force_opt)
+ {
+ ev= new Unknown_log_event(buf, description_event);
+ DBUG_RETURN(ev);
+ }
+ else
+ DBUG_RETURN(NULL);
+#else
+ *error= ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE);
+ sql_print_error("%s", ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE));
+ DBUG_RETURN(NULL);
+#endif
+ }
+
if (event_type > description_event->number_of_event_types &&
event_type != FORMAT_DESCRIPTION_EVENT)
{
@@ -1215,6 +1474,11 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
event_type= description_event->event_type_permutation[event_type];
}
+ if (alg != BINLOG_CHECKSUM_ALG_UNDEF &&
+ (event_type == FORMAT_DESCRIPTION_EVENT ||
+ alg != BINLOG_CHECKSUM_ALG_OFF))
+ event_len= event_len - BINLOG_CHECKSUM_LEN;
+
switch(event_type) {
case QUERY_EVENT:
ev = new Query_log_event(buf, event_len, description_event, QUERY_EVENT);
@@ -1309,6 +1573,14 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
}
}
+ if (ev)
+ {
+ ev->checksum_alg= alg;
+ if (ev->checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ ev->checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ ev->crc= uint4korr(buf + (event_len));
+ }
+
DBUG_PRINT("read_event", ("%s(type_code: %d; event_len: %d)",
ev ? ev->get_type_str() : "<unknown>",
buf[EVENT_TYPE_OFFSET],
@@ -1363,6 +1635,18 @@ void Log_event::print_header(IO_CACHE* file,
my_b_printf(file, " server id %lu end_log_pos %s ", (ulong) server_id,
llstr(log_pos,llbuff));
+ /* print the checksum */
+
+ if (checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ {
+ char checksum_buf[BINLOG_CHECKSUM_LEN * 2 + 4]; // to fit to "0x%lx "
+ size_t const bytes_written=
+ my_snprintf(checksum_buf, sizeof(checksum_buf), "0x%08lx ", (ulong) crc);
+ my_b_printf(file, "%s ", get_type(&binlog_checksum_typelib, checksum_alg));
+ my_b_printf(file, checksum_buf, bytes_written);
+ }
+
/* mysqlbinlog --hexdump */
if (print_event_info->hexdump_from)
{
@@ -1731,6 +2015,7 @@ beg:
uint64 i64= uint8korr(ptr); /* YYYYMMDDhhmmss */
d= (ulong) (i64 / 1000000);
t= (ulong) (i64 % 1000000);
+
my_b_printf(file, "%04d-%02d-%02d %02d:%02d:%02d",
(int) (d / 10000), (int) (d % 10000) / 100, (int) (d % 100),
(int) (t / 10000), (int) (t % 10000) / 100, (int) t % 100);
@@ -1986,12 +2271,10 @@ end:
delete td;
}
-#ifdef MYSQL_CLIENT
void free_table_map_log_event(Table_map_log_event *event)
{
delete event;
}
-#endif
void Log_event::print_base64(IO_CACHE* file,
PRINT_EVENT_INFO* print_event_info,
@@ -2028,6 +2311,9 @@ void Log_event::print_base64(IO_CACHE* file,
if (print_event_info->verbose)
{
Rows_log_event *ev= NULL;
+ if (checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF &&
+ checksum_alg != BINLOG_CHECKSUM_ALG_OFF)
+ size-= BINLOG_CHECKSUM_LEN; // checksum is displayed through the header
if (ptr[4] == TABLE_MAP_EVENT)
{
@@ -2071,15 +2357,13 @@ void Log_event::print_base64(IO_CACHE* file,
void Log_event::print_timestamp(IO_CACHE* file, time_t* ts)
{
struct tm *res;
+ time_t my_when= when;
DBUG_ENTER("Log_event::print_timestamp");
if (!ts)
- ts = &when;
-#ifdef MYSQL_SERVER // This is always false
- struct tm tm_tmp;
- localtime_r(ts,(res= &tm_tmp));
-#else
+ {
+ ts = &my_when;
+ }
res=localtime(ts);
-#endif
my_b_printf(file,"%02d%02d%02d %2d:%02d:%02d",
res->tm_year % 100,
@@ -2363,6 +2647,15 @@ bool Query_log_event::write(IO_CACHE* file)
memcpy(start, host.str, host.length);
start+= host.length;
}
+
+ }
+
+ if (thd && thd->query_start_sec_part_used)
+ {
+ *start++= Q_HRNOW;
+ get_time();
+ int3store(start, when_sec_part);
+ start+= 3;
}
/*
NOTE: When adding new status vars, please don't forget to update
@@ -2390,12 +2683,13 @@ bool Query_log_event::write(IO_CACHE* file)
event_length= (uint) (start-buf) + get_post_header_size_for_derived() + db_len + 1 + q_len;
return (write_header(file, event_length) ||
- my_b_safe_write(file, (uchar*) buf, QUERY_HEADER_LEN) ||
+ wrapper_my_b_safe_write(file, (uchar*) buf, QUERY_HEADER_LEN) ||
write_post_header_for_derived(file) ||
- my_b_safe_write(file, (uchar*) start_of_status,
+ wrapper_my_b_safe_write(file, (uchar*) start_of_status,
(uint) (start-start_of_status)) ||
- my_b_safe_write(file, (db) ? (uchar*) db : (uchar*)"", db_len + 1) ||
- my_b_safe_write(file, (uchar*) query, q_len)) ? 1 : 0;
+ wrapper_my_b_safe_write(file, (db) ? (uchar*) db : (uchar*)"", db_len + 1) ||
+ wrapper_my_b_safe_write(file, (uchar*) query, q_len) ||
+ write_footer(file)) ? 1 : 0;
}
/**
@@ -2455,7 +2749,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
error_code= errcode;
- time(&end_time);
+ end_time= my_time(0);
exec_time = (ulong) (end_time - thd_arg->start_time);
/**
@todo this means that if we have no catalog, then it is replicated
@@ -2590,6 +2884,7 @@ code_name(int code)
case Q_CHARSET_DATABASE_CODE: return "Q_CHARSET_DATABASE_CODE";
case Q_TABLE_MAP_FOR_UPDATE_CODE: return "Q_TABLE_MAP_FOR_UPDATE_CODE";
case Q_MASTER_DATA_WRITTEN_CODE: return "Q_MASTER_DATA_WRITTEN_CODE";
+ case Q_HRNOW: return "Q_HRNOW";
}
sprintf(buf, "CODE#%d", code);
return buf;
@@ -2806,6 +3101,14 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
CHECK_SPACE(pos, end, host.length);
host.str= (char *)pos;
pos+= host.length;
+ break;
+ }
+ case Q_HRNOW:
+ {
+ CHECK_SPACE(pos, end, 3);
+ when_sec_part= uint3korr(pos);
+ pos+= 3;
+ break;
}
default:
/* That's why you must write status vars in growing order of code */
@@ -2885,7 +3188,7 @@ void Query_log_event::print_query_header(IO_CACHE* file,
PRINT_EVENT_INFO* print_event_info)
{
// TODO: print the catalog ??
- char buff[40],*end; // Enough for SET TIMESTAMP
+ char buff[64], *end; // Enough for SET TIMESTAMP
bool different_db= 1;
uint32 tmp;
@@ -2912,6 +3215,11 @@ void Query_log_event::print_query_header(IO_CACHE* file,
}
end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
+ if (when_sec_part)
+ {
+ *end++= '.';
+ end=int10_to_str(when_sec_part, end, 10);
+ }
end= strmov(end, print_event_info->delimiter);
*end++='\n';
my_b_write(file, (uchar*) buff, (uint) (end-buff));
@@ -3173,7 +3481,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
*/
if (is_trans_keyword() || rpl_filter->db_ok(thd->db))
{
- thd->set_time((time_t)when);
+ thd->set_time(when, when_sec_part);
thd->set_query((char*)query_arg, q_len_arg);
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id = next_query_id();
@@ -3620,10 +3928,11 @@ bool Start_log_event_v3::write(IO_CACHE* file)
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
memcpy(buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
if (!dont_set_created)
- created= when= get_time();
+ created= get_time(); // this sets when and when_sec_part as a side effect
int4store(buff + ST_CREATED_OFFSET,created);
return (write_header(file, sizeof(buff)) ||
- my_b_safe_write(file, (uchar*) buff, sizeof(buff)));
+ wrapper_my_b_safe_write(file, (uchar*) buff, sizeof(buff)) ||
+ write_footer(file));
}
#endif
@@ -3725,6 +4034,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
old 4.0 (binlog version 2) is not supported;
it should not be used for replication with
5.0.
+ @param server_ver a string containing the server version.
*/
Format_description_log_event::
@@ -3740,9 +4050,9 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
common_header_len= LOG_EVENT_HEADER_LEN;
number_of_event_types= LOG_EVENT_TYPES;
/* we'll catch my_malloc() error in is_valid() */
- post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8),
+ post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8)
+ + BINLOG_CHECKSUM_ALG_DESC_LEN,
MYF(0));
-
/*
This long list of assignments is not beautiful, but I see no way to
make it nicer, as the right members are #defines, not array members, so
@@ -3866,6 +4176,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
break;
}
calc_server_version_split();
+ checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_UNDEF;
}
@@ -3900,14 +4211,26 @@ Format_description_log_event(const char* buf,
if ((common_header_len=buf[ST_COMMON_HEADER_LEN_OFFSET]) < OLD_HEADER_LEN)
DBUG_VOID_RETURN; /* sanity check */
number_of_event_types=
- event_len-(LOG_EVENT_MINIMAL_HEADER_LEN+ST_COMMON_HEADER_LEN_OFFSET+1);
+ event_len - (LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET + 1);
DBUG_PRINT("info", ("common_header_len=%d number_of_event_types=%d",
common_header_len, number_of_event_types));
/* If alloc fails, we'll detect it in is_valid() */
+
post_header_len= (uint8*) my_memdup((uchar*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
number_of_event_types*
- sizeof(*post_header_len), MYF(0));
+ sizeof(*post_header_len),
+ MYF(0));
calc_server_version_split();
+ if (!is_version_before_checksum(&server_version_split))
+ {
+ /* the last bytes are the checksum alg desc and value (or value's room) */
+ number_of_event_types -= BINLOG_CHECKSUM_ALG_DESC_LEN;
+ checksum_alg= post_header_len[number_of_event_types];
+ }
+ else
+ {
+ checksum_alg= (uint8) BINLOG_CHECKSUM_ALG_UNDEF;
+ }
/*
In some previous versions, the events were given other event type
@@ -4018,21 +4341,59 @@ Format_description_log_event(const char* buf,
#ifndef MYSQL_CLIENT
bool Format_description_log_event::write(IO_CACHE* file)
{
+ bool ret;
+ bool no_checksum;
/*
We don't call Start_log_event_v3::write() because this would make 2
my_b_safe_write().
*/
- uchar buff[FORMAT_DESCRIPTION_HEADER_LEN];
+ uchar buff[FORMAT_DESCRIPTION_HEADER_LEN + BINLOG_CHECKSUM_ALG_DESC_LEN];
+ size_t rec_size= sizeof(buff);
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
if (!dont_set_created)
- created= when= get_time();
+ created= get_time();
int4store(buff + ST_CREATED_OFFSET,created);
buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN;
- memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len,
+ memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET + 1, (uchar*) post_header_len,
LOG_EVENT_TYPES);
- return (write_header(file, sizeof(buff)) ||
- my_b_safe_write(file, buff, sizeof(buff)));
+ /*
+ if checksum is requested
+ record the checksum-algorithm descriptor next to
+ post_header_len vector which will be followed by the checksum value.
+ Master is supposed to trigger checksum computing by binlog_checksum_options,
+ slave does it via marking the event according to
+ FD_queue checksum_alg value.
+ */
+ compile_time_assert(sizeof(BINLOG_CHECKSUM_ALG_DESC_LEN == 1));
+#ifndef DBUG_OFF
+ data_written= 0; // to prepare for need_checksum assert
+#endif
+ buff[FORMAT_DESCRIPTION_HEADER_LEN]= need_checksum() ?
+ checksum_alg : (uint8) BINLOG_CHECKSUM_ALG_OFF;
+ /*
+ FD of checksum-aware server is always checksum-equipped, (V) is in,
+ regardless of @@global.binlog_checksum policy.
+ Thereby a combination of (A) == 0, (V) != 0 means
+ it's the checksum-aware server's FD event that heads checksum-free binlog
+ file.
+ Here 0 stands for checksumming OFF to evaluate (V) as 0 is that case.
+ A combination of (A) != 0, (V) != 0 denotes FD of the checksum-aware server
+ heading the checksummed binlog.
+ (A), (V) presence in FD of the checksum-aware server makes the event
+ 1 + 4 bytes bigger comparing to the former FD.
+ */
+
+ if ((no_checksum= (checksum_alg == BINLOG_CHECKSUM_ALG_OFF)))
+ {
+ checksum_alg= BINLOG_CHECKSUM_ALG_CRC32; // Forcing (V) room to fill anyway
+ }
+ ret= (write_header(file, rec_size) ||
+ wrapper_my_b_safe_write(file, buff, rec_size) ||
+ write_footer(file));
+ if (no_checksum)
+ checksum_alg= BINLOG_CHECKSUM_ALG_OFF;
+ return ret;
}
#endif
@@ -4128,6 +4489,30 @@ Format_description_log_event::do_shall_skip(Relay_log_info *rli)
#endif
+static inline void
+do_server_version_split(char* version,
+ Format_description_log_event::master_version_split *split_versions)
+{
+ char *p= version, *r;
+ ulong number;
+ for (uint i= 0; i<=2; i++)
+ {
+ number= strtoul(p, &r, 10);
+ split_versions->ver[i]= (uchar) number;
+ DBUG_ASSERT(number < 256); // fit in uchar
+ p= r;
+ DBUG_ASSERT(!((i == 0) && (*r != '.'))); // should be true in practice
+ if (*r == '.')
+ p++; // skip the dot
+ }
+ if (strinstr(p, "MariaDB") != 0 || strinstr(p, "-maria-") != 0)
+ split_versions->kind=
+ Format_description_log_event::master_version_split::KIND_MARIADB;
+ else
+ split_versions->kind=
+ Format_description_log_event::master_version_split::KIND_MYSQL;
+}
+
/**
Splits the event's 'server_version' string into three numeric pieces stored
@@ -4140,24 +4525,67 @@ Format_description_log_event::do_shall_skip(Relay_log_info *rli)
*/
void Format_description_log_event::calc_server_version_split()
{
- char *p= server_version, *r;
- ulong number;
- for (uint i= 0; i<=2; i++)
- {
- number= strtoul(p, &r, 10);
- server_version_split[i]= (uchar)number;
- DBUG_ASSERT(number < 256); // fit in uchar
- p= r;
- DBUG_ASSERT(!((i == 0) && (*r != '.'))); // should be true in practice
- if (*r == '.')
- p++; // skip the dot
- }
+ do_server_version_split(server_version, &server_version_split);
+
DBUG_PRINT("info",("Format_description_log_event::server_version_split:"
" '%s' %d %d %d", server_version,
- server_version_split[0],
- server_version_split[1], server_version_split[2]));
+ server_version_split.ver[0],
+ server_version_split.ver[1], server_version_split.ver[2]));
}
+static inline ulong
+version_product(const Format_description_log_event::master_version_split* version_split)
+{
+ return ((version_split->ver[0] * 256 + version_split->ver[1]) * 256
+ + version_split->ver[2]);
+}
+
+/**
+ @return TRUE is the event's version is earlier than one that introduced
+ the replication event checksum. FALSE otherwise.
+*/
+bool
+Format_description_log_event::is_version_before_checksum(master_version_split
+ *version_split)
+{
+ return version_product(version_split) <
+ (version_split->kind == master_version_split::KIND_MARIADB ?
+ checksum_version_product_mariadb : checksum_version_product_mysql);
+}
+
+/**
+ @param buf buffer holding serialized FD event
+ @param len netto (possible checksum is stripped off) length of the event buf
+
+ @return the version-safe checksum alg descriptor where zero
+ designates no checksum, 255 - the orginator is
+ checksum-unaware (effectively no checksum) and the actuall
+ [1-254] range alg descriptor.
+*/
+uint8 get_checksum_alg(const char* buf, ulong len)
+{
+ uint8 ret;
+ char version[ST_SERVER_VER_LEN];
+ Format_description_log_event::master_version_split version_split;
+
+ DBUG_ENTER("get_checksum_alg");
+ DBUG_ASSERT(buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT);
+
+ memcpy(version, buf +
+ buf[LOG_EVENT_MINIMAL_HEADER_LEN + ST_COMMON_HEADER_LEN_OFFSET]
+ + ST_SERVER_VER_OFFSET, ST_SERVER_VER_LEN);
+ version[ST_SERVER_VER_LEN - 1]= 0;
+
+ do_server_version_split(version, &version_split);
+ ret= Format_description_log_event::is_version_before_checksum(&version_split) ?
+ (uint8) BINLOG_CHECKSUM_ALG_UNDEF :
+ * (uint8*) (buf + len - BINLOG_CHECKSUM_LEN - BINLOG_CHECKSUM_ALG_DESC_LEN);
+ DBUG_ASSERT(ret == BINLOG_CHECKSUM_ALG_OFF ||
+ ret == BINLOG_CHECKSUM_ALG_UNDEF ||
+ ret == BINLOG_CHECKSUM_ALG_CRC32);
+ DBUG_RETURN(ret);
+}
+
/**************************************************************************
Load_log_event methods
@@ -4732,7 +5160,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
*/
if (rpl_filter->db_ok(thd->db))
{
- thd->set_time((time_t)when);
+ thd->set_time(when, when_sec_part);
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id = next_query_id();
VOID(pthread_mutex_unlock(&LOCK_thread_count));
@@ -5001,6 +5429,7 @@ Rotate_log_event::Rotate_log_event(const char* new_log_ident_arg,
DBUG_PRINT("enter",("new_log_ident: %s pos: %s flags: %lu", new_log_ident_arg,
llstr(pos_arg, buff), (ulong) flags));
#endif
+ cache_type= EVENT_NO_CACHE;
if (flags & DUP_NAME)
new_log_ident= my_strndup(new_log_ident_arg, ident_len, MYF(MY_WME));
if (flags & RELAY_LOG)
@@ -5042,9 +5471,11 @@ bool Rotate_log_event::write(IO_CACHE* file)
{
char buf[ROTATE_HEADER_LEN];
int8store(buf + R_POS_OFFSET, pos);
- return (write_header(file, ROTATE_HEADER_LEN + ident_len) ||
- my_b_safe_write(file, (uchar*)buf, ROTATE_HEADER_LEN) ||
- my_b_safe_write(file, (uchar*)new_log_ident, (uint) ident_len));
+ return (write_header(file, ROTATE_HEADER_LEN + ident_len) ||
+ wrapper_my_b_safe_write(file, (uchar*) buf, ROTATE_HEADER_LEN) ||
+ wrapper_my_b_safe_write(file, (uchar*) new_log_ident,
+ (uint) ident_len) ||
+ write_footer(file));
}
#endif
@@ -5213,7 +5644,8 @@ bool Intvar_log_event::write(IO_CACHE* file)
buf[I_TYPE_OFFSET]= (uchar) type;
int8store(buf + I_VAL_OFFSET, val);
return (write_header(file, sizeof(buf)) ||
- my_b_safe_write(file, buf, sizeof(buf)));
+ wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+ write_footer(file));
}
#endif
@@ -5341,7 +5773,8 @@ bool Rand_log_event::write(IO_CACHE* file)
int8store(buf + RAND_SEED1_OFFSET, seed1);
int8store(buf + RAND_SEED2_OFFSET, seed2);
return (write_header(file, sizeof(buf)) ||
- my_b_safe_write(file, buf, sizeof(buf)));
+ wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+ write_footer(file));
}
#endif
@@ -5443,8 +5876,9 @@ Xid_log_event(const char* buf,
bool Xid_log_event::write(IO_CACHE* file)
{
DBUG_EXECUTE_IF("do_not_write_xid", return 0;);
- return write_header(file, sizeof(xid)) ||
- my_b_safe_write(file, (uchar*) &xid, sizeof(xid));
+ return (write_header(file, sizeof(xid)) ||
+ wrapper_my_b_safe_write(file, (uchar*) &xid, sizeof(xid)) ||
+ write_footer(file));
}
#endif
@@ -5663,10 +6097,11 @@ bool User_var_log_event::write(IO_CACHE* file)
event_length= sizeof(buf)+ name_len + buf1_length + val_len;
return (write_header(file, event_length) ||
- my_b_safe_write(file, (uchar*) buf, sizeof(buf)) ||
- my_b_safe_write(file, (uchar*) name, name_len) ||
- my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
- my_b_safe_write(file, pos, val_len));
+ wrapper_my_b_safe_write(file, (uchar*) buf, sizeof(buf)) ||
+ wrapper_my_b_safe_write(file, (uchar*) name, name_len) ||
+ wrapper_my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
+ wrapper_my_b_safe_write(file, pos, val_len) ||
+ write_footer(file));
}
#endif
@@ -6424,8 +6859,9 @@ bool Append_block_log_event::write(IO_CACHE* file)
uchar buf[APPEND_BLOCK_HEADER_LEN];
int4store(buf + AB_FILE_ID_OFFSET, file_id);
return (write_header(file, APPEND_BLOCK_HEADER_LEN + block_len) ||
- my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
- my_b_safe_write(file, (uchar*) block, block_len));
+ wrapper_my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
+ wrapper_my_b_safe_write(file, (uchar*) block, block_len) ||
+ write_footer(file));
}
#endif
@@ -6579,7 +7015,8 @@ bool Delete_file_log_event::write(IO_CACHE* file)
uchar buf[DELETE_FILE_HEADER_LEN];
int4store(buf + DF_FILE_ID_OFFSET, file_id);
return (write_header(file, sizeof(buf)) ||
- my_b_safe_write(file, buf, sizeof(buf)));
+ wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+ write_footer(file));
}
#endif
@@ -6676,7 +7113,8 @@ bool Execute_load_log_event::write(IO_CACHE* file)
uchar buf[EXEC_LOAD_HEADER_LEN];
int4store(buf + EL_FILE_ID_OFFSET, file_id);
return (write_header(file, sizeof(buf)) ||
- my_b_safe_write(file, buf, sizeof(buf)));
+ wrapper_my_b_safe_write(file, buf, sizeof(buf)) ||
+ write_footer(file));
}
#endif
@@ -6737,16 +7175,17 @@ int Execute_load_log_event::do_apply_event(Relay_log_info const *rli)
fname);
goto err;
}
- if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
- (pthread_mutex_t*)0,
- rli->relay_log.description_event_for_exec)) ||
+ if (!(lev= (Load_log_event*)
+ Log_event::read_log_event(&file,
+ (pthread_mutex_t*)0,
+ rli->relay_log.description_event_for_exec,
+ opt_slave_sql_verify_checksum)) ||
lev->get_type_code() != NEW_LOAD_EVENT)
{
rli->report(ERROR_LEVEL, 0, "Error in Exec_load event: "
"file '%s' appears corrupted", fname);
goto err;
}
-
lev->thd = thd;
/*
lev->do_apply_event should use rli only for errors i.e. should
@@ -6909,7 +7348,7 @@ Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file)
int4store(buf + 4, fn_pos_start);
int4store(buf + 4 + 4, fn_pos_end);
*(buf + 4 + 4 + 4)= (uchar) dup_handling;
- return my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
+ return wrapper_my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
}
#endif
@@ -7540,7 +7979,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
- query_cache.invalidate_locked_for_write(rli->tables_to_lock);
+ query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
}
@@ -7567,7 +8006,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
TIMESTAMP column to a table with one.
So we call set_time(), like in SBR. Presently it changes nothing.
*/
- thd->set_time((time_t)when);
+ thd->set_time(when, when_sec_part);
/*
Now we are in a statement and will stay in a statement until we
@@ -7876,11 +8315,11 @@ bool Rows_log_event::write_data_header(IO_CACHE *file)
{
int4store(buf + 0, m_table_id);
int2store(buf + 4, m_flags);
- return (my_b_safe_write(file, buf, 6));
+ return (wrapper_my_b_safe_write(file, buf, 6));
});
int6store(buf + RW_MAPID_OFFSET, (ulonglong)m_table_id);
int2store(buf + RW_FLAGS_OFFSET, m_flags);
- return (my_b_safe_write(file, buf, ROWS_HEADER_LEN));
+ return (wrapper_my_b_safe_write(file, buf, ROWS_HEADER_LEN));
}
bool Rows_log_event::write_data_body(IO_CACHE*file)
@@ -7896,10 +8335,10 @@ bool Rows_log_event::write_data_body(IO_CACHE*file)
DBUG_ASSERT(static_cast<size_t>(sbuf_end - sbuf) <= sizeof(sbuf));
DBUG_DUMP("m_width", sbuf, (size_t) (sbuf_end - sbuf));
- res= res || my_b_safe_write(file, sbuf, (size_t) (sbuf_end - sbuf));
+ res= res || wrapper_my_b_safe_write(file, sbuf, (size_t) (sbuf_end - sbuf));
DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
- res= res || my_b_safe_write(file, (uchar*) m_cols.bitmap,
+ res= res || wrapper_my_b_safe_write(file, (uchar*) m_cols.bitmap,
no_bytes_in_map(&m_cols));
/*
TODO[refactor write]: Remove the "down cast" here (and elsewhere).
@@ -7908,11 +8347,11 @@ bool Rows_log_event::write_data_body(IO_CACHE*file)
{
DBUG_DUMP("m_cols_ai", (uchar*) m_cols_ai.bitmap,
no_bytes_in_map(&m_cols_ai));
- res= res || my_b_safe_write(file, (uchar*) m_cols_ai.bitmap,
+ res= res || wrapper_my_b_safe_write(file, (uchar*) m_cols_ai.bitmap,
no_bytes_in_map(&m_cols_ai));
}
DBUG_DUMP("rows", m_rows_buf, data_size);
- res= res || my_b_safe_write(file, m_rows_buf, (size_t) data_size);
+ res= res || wrapper_my_b_safe_write(file, m_rows_buf, (size_t) data_size);
return res;
@@ -7961,13 +8400,15 @@ void Rows_log_event::print_helper(FILE *file,
**************************************************************************/
#ifndef MYSQL_CLIENT
-Annotate_rows_log_event::Annotate_rows_log_event(THD *thd)
+Annotate_rows_log_event::Annotate_rows_log_event(THD *thd,
+ uint16 cache_type_arg)
: Log_event(thd, 0, true),
m_save_thd_query_txt(0),
m_save_thd_query_len(0)
{
m_query_txt= thd->query();
m_query_len= thd->query_length();
+ cache_type= cache_type_arg;
}
#endif
@@ -8015,7 +8456,7 @@ bool Annotate_rows_log_event::write_data_header(IO_CACHE *file)
#ifndef MYSQL_CLIENT
bool Annotate_rows_log_event::write_data_body(IO_CACHE *file)
{
- return my_b_safe_write(file, (uchar*) m_query_txt, m_query_len);
+ return wrapper_my_b_safe_write(file, (uchar*) m_query_txt, m_query_len);
}
#endif
@@ -8590,11 +9031,11 @@ bool Table_map_log_event::write_data_header(IO_CACHE *file)
{
int4store(buf + 0, m_table_id);
int2store(buf + 4, m_flags);
- return (my_b_safe_write(file, buf, 6));
+ return (wrapper_my_b_safe_write(file, buf, 6));
});
int6store(buf + TM_MAPID_OFFSET, (ulonglong)m_table_id);
int2store(buf + TM_FLAGS_OFFSET, m_flags);
- return (my_b_safe_write(file, buf, TABLE_MAP_HEADER_LEN));
+ return (wrapper_my_b_safe_write(file, buf, TABLE_MAP_HEADER_LEN));
}
bool Table_map_log_event::write_data_body(IO_CACHE *file)
@@ -8618,15 +9059,15 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file)
uchar mbuf[sizeof(m_field_metadata_size)];
uchar *const mbuf_end= net_store_length(mbuf, m_field_metadata_size);
- return (my_b_safe_write(file, dbuf, sizeof(dbuf)) ||
- my_b_safe_write(file, (const uchar*)m_dbnam, m_dblen+1) ||
- my_b_safe_write(file, tbuf, sizeof(tbuf)) ||
- my_b_safe_write(file, (const uchar*)m_tblnam, m_tbllen+1) ||
- my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) ||
- my_b_safe_write(file, m_coltype, m_colcnt) ||
- my_b_safe_write(file, mbuf, (size_t) (mbuf_end - mbuf)) ||
- my_b_safe_write(file, m_field_metadata, m_field_metadata_size),
- my_b_safe_write(file, m_null_bits, (m_colcnt + 7) / 8));
+ return (wrapper_my_b_safe_write(file, dbuf, sizeof(dbuf)) ||
+ wrapper_my_b_safe_write(file, (const uchar*)m_dbnam, m_dblen+1) ||
+ wrapper_my_b_safe_write(file, tbuf, sizeof(tbuf)) ||
+ wrapper_my_b_safe_write(file, (const uchar*)m_tblnam, m_tbllen+1) ||
+ wrapper_my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) ||
+ wrapper_my_b_safe_write(file, m_coltype, m_colcnt) ||
+ wrapper_my_b_safe_write(file, mbuf, (size_t) (mbuf_end - mbuf)) ||
+ wrapper_my_b_safe_write(file, m_field_metadata, m_field_metadata_size),
+ wrapper_my_b_safe_write(file, m_null_bits, (m_colcnt + 7) / 8));
}
#endif
@@ -9159,7 +9600,19 @@ static bool record_compare(TABLE *table)
}
}
- if (table->s->blob_fields + table->s->varchar_fields == 0)
+ /**
+ Compare full record only if:
+ - there are no blob fields (otherwise we would also need
+ to compare blobs contents as well);
+ - there are no varchar fields (otherwise we would also need
+ to compare varchar contents as well);
+ - there are no null fields, otherwise NULLed fields
+ contents (i.e., the don't care bytes) may show arbitrary
+ values, depending on how each engine handles internally.
+ */
+ if ((table->s->blob_fields +
+ table->s->varchar_fields +
+ table->s->null_fields) == 0)
{
result= cmp_record(table,record[1]);
goto record_compare_exit;
@@ -9174,13 +9627,22 @@ static bool record_compare(TABLE *table)
goto record_compare_exit;
}
- /* Compare updated fields */
+ /* Compare fields */
for (Field **ptr=table->field ; *ptr ; ptr++)
{
- if ((*ptr)->cmp_binary_offset(table->s->rec_buff_length))
+
+ /**
+ We only compare field contents that are not null.
+ NULL fields (i.e., their null bits) were compared
+ earlier.
+ */
+ if (!(*(ptr))->is_null())
{
- result= TRUE;
- goto record_compare_exit;
+ if ((*ptr)->cmp_binary_offset(table->s->rec_buff_length))
+ {
+ result= TRUE;
+ goto record_compare_exit;
+ }
}
}
@@ -9966,13 +10428,25 @@ Incident_log_event::write_data_header(IO_CACHE *file)
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
uchar buf[sizeof(int16)];
int2store(buf, (int16) m_incident);
- DBUG_RETURN(my_b_safe_write(file, buf, sizeof(buf)));
+#ifndef MYSQL_CLIENT
+ DBUG_RETURN(wrapper_my_b_safe_write(file, buf, sizeof(buf)));
+#else
+ DBUG_RETURN(my_b_safe_write(file, buf, sizeof(buf)));
+#endif
}
bool
Incident_log_event::write_data_body(IO_CACHE *file)
{
+ uchar tmp[1];
DBUG_ENTER("Incident_log_event::write_data_body");
+ tmp[0]= (uchar) m_message.length;
+ crc= my_checksum(crc, (uchar*) tmp, 1);
+ if (m_message.length > 0)
+ {
+ crc= my_checksum(crc, (uchar*) m_message.str, m_message.length);
+ // todo: report a bug on write_str accepts uint but treats it as uchar
+ }
DBUG_RETURN(write_str(file, m_message.str, (uint) m_message.length));
}
diff --git a/sql/log_event.h b/sql/log_event.h
index 91a2ad9693c..4053db4e3e7 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -72,6 +72,7 @@
#define LOG_READ_MEM -5
#define LOG_READ_TRUNC -6
#define LOG_READ_TOO_LARGE -7
+#define LOG_READ_CHECKSUM_FAILURE -8
#define LOG_EVENT_OFFSET 4
@@ -266,6 +267,7 @@ struct sql_ex_info
1 + 2 /* type, charset_database_number */ + \
1 + 8 /* type, table_map_for_update */ + \
1 + 4 /* type, master_data_written */ + \
+ 1 + 3 /* type, sec_part of NOW() */ + \
1 + 16 + 1 + 60/* type, user_len, user, host_len, host */)
#define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \
LOG_EVENT_HEADER_LEN + /* write_header */ \
@@ -337,6 +339,8 @@ struct sql_ex_info
#define Q_INVOKER 11
+#define Q_HRNOW 128
+
/* Intvar event post-header */
/* Intvar event data */
@@ -525,6 +529,22 @@ struct sql_ex_info
#endif
#undef EXPECTED_OPTIONS /* You shouldn't use this one */
+enum enum_binlog_checksum_alg {
+ BINLOG_CHECKSUM_ALG_OFF= 0, // Events are without checksum though its generator
+ // is checksum-capable New Master (NM).
+ BINLOG_CHECKSUM_ALG_CRC32= 1, // CRC32 of zlib algorithm.
+ BINLOG_CHECKSUM_ALG_ENUM_END, // the cut line: valid alg range is [1, 0x7f].
+ BINLOG_CHECKSUM_ALG_UNDEF= 255 // special value to tag undetermined yet checksum
+ // or events from checksum-unaware servers
+};
+
+#define CHECKSUM_CRC32_SIGNATURE_LEN 4
+/**
+ defined statically while there is just one alg implemented
+*/
+#define BINLOG_CHECKSUM_LEN CHECKSUM_CRC32_SIGNATURE_LEN
+#define BINLOG_CHECKSUM_ALG_DESC_LEN 1 /* 1 byte checksum alg descriptor */
+
/**
@enum Log_event_type
@@ -903,7 +923,8 @@ public:
execution time, which guarantees good replication (otherwise, we
could have a query and its event with different timestamps).
*/
- time_t when;
+ my_time_t when;
+ ulong when_sec_part;
/* The number of seconds the query took to run on the master. */
ulong exec_time;
/* Number of bytes written by write() function */
@@ -923,6 +944,27 @@ public:
uint16 flags;
bool cache_stmt;
+ /*
+ The revid:alfranio.correia@sun.com-20091103190256-637o8qxlveikrt3i commit
+ ("WL#2687 WL#5072 BUG#40278 BUG#47175") in MySQL 5.5 changes the bool
+ cache_stmt into an enum cache_type. For the backport of WL#2540 binlog
+ event checksum, we need this event_type member to know if we are writing
+ directly to the log, or into a transaction cache.
+
+ Until the cache_type stuff is merged, we temporarily partially backport
+ the cache_type member, only enough to be able to check if we are writing
+ directly to log or not. Once MySQL 5.5 is merged, this can be removed, and
+ replaced with the MySQL 5.5 code.
+
+ Similarly, in MySQL 5.5 the decision on whether to write directly to log
+ or indirectly through cache is decided differently, and the
+ pre_55_writing_direct() (and all calls to it) are not needed and can be
+ removed once 5.5 is merged.
+ */
+ enum enum_event_cache_type { EVENT_INVALID_CACHE, EVENT_STMT_CACHE,
+ EVENT_TRANSACTIONAL_CACHE, EVENT_NO_CACHE };
+ uint16 cache_type;
+ void pre_55_writing_direct() { cache_type= EVENT_NO_CACHE; }
/**
A storage to cache the global system variable's value.
@@ -930,6 +972,10 @@ public:
*/
ulong slave_exec_mode;
+ /**
+ Placeholder for event checksum while writing to binlog.
+ */
+ ha_checksum crc;
#ifndef MYSQL_CLIENT
THD* thd;
@@ -949,9 +995,10 @@ public:
static Log_event* read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock,
const Format_description_log_event
- *description_event);
+ *description_event,
+ my_bool crc_check);
static int read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock);
+ pthread_mutex_t* log_lock, uint8 checksum_alg_arg);
/*
init_show_field_list() prepares the column names and types for the
output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
@@ -978,7 +1025,7 @@ public:
/* avoid having to link mysqlbinlog against libpthread */
static Log_event* read_log_event(IO_CACHE* file,
const Format_description_log_event
- *description_event);
+ *description_event, my_bool crc_check);
/* print*() functions are used by mysqlbinlog */
virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
void print_timestamp(IO_CACHE* file, time_t *ts = 0);
@@ -987,6 +1034,15 @@ public:
void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
bool is_more);
#endif
+ /*
+ The value is set by caller of FD constructor and
+ Log_event::write_header() for the rest.
+ In the FD case it's propagated into the last byte
+ of post_header_len[] at FD::write().
+ On the slave side the value is assigned from post_header_len[last]
+ of the last seen FD event.
+ */
+ uint8 checksum_alg;
static void *operator new(size_t size)
{
@@ -1001,29 +1057,46 @@ public:
/* Placement version of the above operators */
static void *operator new(size_t, void* ptr) { return ptr; }
static void operator delete(void*, void*) { }
+ bool wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong data_length);
#ifndef MYSQL_CLIENT
bool write_header(IO_CACHE* file, ulong data_length);
+ bool write_footer(IO_CACHE* file);
+ my_bool need_checksum();
+
virtual bool write(IO_CACHE* file)
{
- return (write_header(file, get_data_size()) ||
- write_data_header(file) ||
- write_data_body(file));
+ return(write_header(file, get_data_size()) ||
+ write_data_header(file) ||
+ write_data_body(file) ||
+ write_footer(file));
}
virtual bool write_data_header(IO_CACHE* file)
{ return 0; }
virtual bool write_data_body(IO_CACHE* file __attribute__((unused)))
{ return 0; }
- inline time_t get_time()
+ inline my_time_t get_time()
{
THD *tmp_thd;
if (when)
return when;
if (thd)
- return thd->start_time;
+ {
+ when= thd->start_time;
+ when_sec_part= thd->start_time_sec_part;
+ return when;
+ }
+ /* thd will only be 0 here at time of log creation */
if ((tmp_thd= current_thd))
- return tmp_thd->start_time;
- return my_time(0);
+ {
+ when= tmp_thd->start_time;
+ when_sec_part= tmp_thd->start_time_sec_part;
+ return when;
+ }
+ my_hrtime_t hrtime= my_hrtime();
+ when= hrtime_to_my_time(hrtime);
+ when_sec_part= hrtime_sec_part(hrtime);
+ return when;
}
#endif
virtual Log_event_type get_type_code() = 0;
@@ -1058,7 +1131,7 @@ public:
static Log_event* read_log_event(const char* buf, uint event_len,
const char **error,
const Format_description_log_event
- *description_event);
+ *description_event, my_bool crc_check);
/**
Returns the human readable name of the given event type.
*/
@@ -2237,9 +2310,17 @@ public:
*/
uint8 common_header_len;
uint8 number_of_event_types;
- /* The list of post-headers' lengthes */
+ /*
+ The list of post-headers' lengths followed
+ by the checksum alg decription byte
+ */
uint8 *post_header_len;
- uchar server_version_split[3];
+ struct master_version_split {
+ enum {KIND_MYSQL, KIND_MARIADB};
+ int kind;
+ uchar ver[3];
+ };
+ master_version_split server_version_split;
const uint8 *event_type_permutation;
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
@@ -2271,7 +2352,7 @@ public:
}
void calc_server_version_split();
-
+ static bool is_version_before_checksum(master_version_split *version_split);
protected:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int do_apply_event(Relay_log_info const *rli);
@@ -2326,9 +2407,10 @@ public:
uchar type;
#ifndef MYSQL_CLIENT
- Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
- :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
- {}
+ Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg,
+ uint16 cache_type_arg)
+ :Log_event(thd_arg,0,0), val(val_arg), type(type_arg)
+ { cache_type= cache_type_arg; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
@@ -2402,9 +2484,10 @@ class Rand_log_event: public Log_event
ulonglong seed2;
#ifndef MYSQL_CLIENT
- Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
- :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
- {}
+ Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
+ uint16 cache_type_arg)
+ :Log_event(thd_arg, 0, 0), seed1(seed1_arg), seed2(seed2_arg)
+ { cache_type= cache_type_arg; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
@@ -2448,7 +2531,8 @@ class Xid_log_event: public Log_event
my_xid xid;
#ifndef MYSQL_CLIENT
- Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
+ Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, 0), xid(x)
+ { cache_type= EVENT_NO_CACHE; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
@@ -2495,10 +2579,11 @@ public:
#ifndef MYSQL_CLIENT
User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
char *val_arg, ulong val_len_arg, Item_result type_arg,
- uint charset_number_arg)
- :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
- val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
- { is_null= !val; }
+ uint charset_number_arg,
+ uint16 cache_type_arg)
+ :Log_event(thd_arg, 0, 0), name(name_arg), name_len(name_len_arg), val(val_arg),
+ val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
+ { is_null= !val; cache_type= cache_type_arg; }
void pack_info(Protocol* protocol);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@@ -3010,7 +3095,7 @@ class Annotate_rows_log_event: public Log_event
{
public:
#ifndef MYSQL_CLIENT
- Annotate_rows_log_event(THD*);
+ Annotate_rows_log_event(THD*, uint16 cache_type_arg);
#endif
Annotate_rows_log_event(const char *buf, uint event_len,
const Format_description_log_event*);
@@ -4040,6 +4125,10 @@ bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
const char **group_relay_log_name,
ulonglong *relay_log_pos);
+bool event_checksum_test(uchar *buf, ulong event_len, uint8 alg);
+uint8 get_checksum_alg(const char* buf, ulong len);
+extern TYPELIB binlog_checksum_typelib;
+
/**
@} (end of group Replication)
*/
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 5d3ab1f17d5..06ad5cc3f93 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -137,7 +137,7 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
- query_cache.invalidate_locked_for_write(rli->tables_to_lock);
+ query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
}
@@ -159,7 +159,7 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
TIMESTAMP column to a table with one.
So we call set_time(), like in SBR. Presently it changes nothing.
*/
- ev_thd->set_time((time_t)ev->when);
+ ev_thd->set_time(ev->when, ev->when_sec_part);
/*
There are a few flags that are replicated with each row event.
Make sure to set/clear them before executing the main body of
@@ -1636,7 +1636,7 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
- query_cache.invalidate_locked_for_write(rli->tables_to_lock);
+ query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
}
@@ -1660,7 +1660,7 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
TIMESTAMP column to a table with one.
So we call set_time(), like in SBR. Presently it changes nothing.
*/
- thd->set_time((time_t)when);
+ thd->set_time(when, when_sec_part);
/*
There are a few flags that are replicated with each row event.
Make sure to set/clear them before executing the main body of
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 37ce7c3f840..c666c571787 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -998,7 +998,9 @@ int DsMrr_impl::setup_two_handlers()
DBUG_RETURN(1);
/* Create a separate handler object to do rnd_pos() calls. */
- if (!(new_h2= primary_file->clone(thd->mem_root)) ||
+ if (!(new_h2= primary_file->clone(primary_file->get_table()->s->
+ normalized_path.str,
+ thd->mem_root)) ||
new_h2->ha_external_lock(thd, F_RDLCK))
{
delete new_h2;
@@ -1414,7 +1416,7 @@ ha_rows DsMrr_impl::dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq,
/*
If HA_MRR_USE_DEFAULT_IMPL has been passed to us, that is an order to
use the default MRR implementation (we need it for UPDATE/DELETE).
- Otherwise, make a choice based on cost and @@optimizer_use_mrr.
+ Otherwise, make a choice based on cost and @@optimizer_switch settings
*/
if ((*flags & HA_MRR_USE_DEFAULT_IMPL) ||
choose_mrr_impl(keyno, rows, flags, bufsz, cost))
@@ -1518,7 +1520,8 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
bool using_cpk= test(keyno == table->s->primary_key &&
primary_file->primary_key_is_clustered());
*flags &= ~HA_MRR_IMPLEMENTATION_FLAGS;
- if (thd->variables.optimizer_use_mrr == 2 || *flags & HA_MRR_INDEX_ONLY ||
+ if (!optimizer_flag(thd, OPTIMIZER_SWITCH_MRR) ||
+ *flags & HA_MRR_INDEX_ONLY ||
(using_cpk && !doing_cpk_scan) || key_uses_partial_cols(table, keyno))
{
/* Use the default implementation */
@@ -1535,12 +1538,12 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
bool force_dsmrr;
/*
- If @@optimizer_use_mrr==force, then set cost of DS-MRR to be minimum of
+ If mrr_cost_based flag is not set, then set cost of DS-MRR to be minimum of
DS-MRR and Default implementations cost. This allows one to force use of
DS-MRR whenever it is applicable without affecting other cost-based
choices.
*/
- if ((force_dsmrr= (thd->variables.optimizer_use_mrr == 1)) &&
+ if ((force_dsmrr= !optimizer_flag(thd, OPTIMIZER_SWITCH_MRR_COST_BASED)) &&
dsmrr_cost.total_cost() > cost->total_cost())
dsmrr_cost= *cost;
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 2bbdeed2d87..93e1d2431af 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -16,6 +16,10 @@
#include "mysql_priv.h"
#include <time.h>
+#define DIG_BASE 1000000000
+#define DIG_PER_DEC1 9
+#define ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
+
#ifndef MYSQL_CLIENT
/**
@@ -30,21 +34,20 @@
result
*/
-int decimal_operation_results(int result)
+int decimal_operation_results(int result, const char *value, const char *type)
{
switch (result) {
case E_DEC_OK:
break;
case E_DEC_TRUNCATED:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
- "", (ulong) 0);
+ ER_DATA_TRUNCATED, ER(ER_DATA_TRUNCATED),
+ value, type);
break;
case E_DEC_OVERFLOW:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE),
- "DECIMAL", "");
+ ER_DATA_OVERFLOW, ER(ER_DATA_OVERFLOW),
+ value, type);
break;
case E_DEC_DIV_ZERO:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
@@ -52,9 +55,8 @@ int decimal_operation_results(int result)
break;
case E_DEC_BAD_NUM:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
- ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
- "decimal", "", "", (ulong) 0);
+ ER_BAD_DATA, ER(ER_BAD_DATA),
+ value, type);
break;
case E_DEC_OOM:
my_error(ER_OUT_OF_RESOURCES, MYF(0));
@@ -209,20 +211,69 @@ int str2my_decimal(uint mask, const char *from, uint length,
}
+/**
+ converts a decimal into a pair of integers - for integer and fractional parts
+
+ special version, for decimals representing number of seconds.
+ integer part cannot be larger that 1e18 (otherwise it's an overflow).
+ fractional part is microseconds.
+*/
+bool my_decimal2seconds(const my_decimal *d, ulonglong *sec, ulong *microsec)
+{
+ int pos;
+
+ if (d->intg)
+ {
+ pos= (d->intg-1)/DIG_PER_DEC1;
+ *sec= d->buf[pos];
+ if (pos > 0)
+ *sec+= static_cast<longlong>(d->buf[pos-1]) * DIG_BASE;
+ }
+ else
+ {
+ *sec=0;
+ pos= -1;
+ }
+
+ *microsec= d->frac ? static_cast<longlong>(d->buf[pos+1]) / (DIG_BASE/1000000) : 0;
+
+ if (pos > 1)
+ {
+ for (int i=0; i < pos-1; i++)
+ if (d->buf[i])
+ {
+ *sec= LONGLONG_MAX;
+ break;
+ }
+ }
+ return d->sign();
+}
+
+
+/**
+ converts a pair of integers (seconds, microseconds) into a decimal
+*/
+my_decimal *seconds2my_decimal(bool sign,
+ ulonglong sec, ulong microsec, my_decimal *d)
+{
+ d->init();
+ longlong2decimal(sec, d); // cannot fail
+ if (microsec)
+ {
+ d->buf[(d->intg-1) / DIG_PER_DEC1 + 1]= microsec * (DIG_BASE/1000000);
+ d->frac= 6;
+ }
+ ((decimal_t *)d)->sign= sign;
+ return d;
+}
+
+
my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec)
{
- longlong date;
- date = (ltime->year*100L + ltime->month)*100L + ltime->day;
+ longlong date= (ltime->year*100L + ltime->month)*100L + ltime->day;
if (ltime->time_type > MYSQL_TIMESTAMP_DATE)
date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
- if (int2my_decimal(E_DEC_FATAL_ERROR, ltime->neg ? -date : date, FALSE, dec))
- return dec;
- if (ltime->second_part)
- {
- dec->buf[(dec->intg-1) / 9 + 1]= ltime->second_part * 1000;
- dec->frac= 6;
- }
- return dec;
+ return seconds2my_decimal(ltime->neg, date, ltime->second_part, dec);
}
@@ -237,12 +288,37 @@ void my_decimal_trim(ulong *precision, uint *scale)
}
+/*
+ Convert a decimal to an ulong with a descriptive error message
+*/
+
+int my_decimal2int(uint mask, const decimal_t *d, bool unsigned_flag,
+ longlong *l)
+{
+ int res;
+ my_decimal rounded;
+ /* decimal_round can return only E_DEC_TRUNCATED */
+ decimal_round(d, &rounded, 0, HALF_UP);
+ res= (unsigned_flag ?
+ decimal2ulonglong(&rounded, (ulonglong *) l) :
+ decimal2longlong(&rounded, l));
+ if (res & mask)
+ {
+ char buff[DECIMAL_MAX_STR_LENGTH];
+ int length= sizeof(buff);
+ decimal2string(d, buff, &length, 0, 0, 0);
+
+ decimal_operation_results(res, buff,
+ unsigned_flag ? "UNSIGNED INT" :
+ "INT");
+ }
+ return res;
+}
+
+
#ifndef DBUG_OFF
/* routines for debugging print */
-#define DIG_PER_DEC1 9
-#define ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
-
/* print decimal */
void
print_decimal(const my_decimal *dec)
@@ -283,7 +359,6 @@ const char *dbug_decimal_as_string(char *buff, const my_decimal *val)
return buff;
}
-#endif /*DBUG_OFF*/
-
+#endif /*DBUG_OFF*/
#endif /*MYSQL_CLIENT*/
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index 86f5db29ed7..d05ec87461a 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -32,32 +32,7 @@ C_MODE_START
#include <decimal.h>
C_MODE_END
-#define DECIMAL_LONGLONG_DIGITS 22
-#define DECIMAL_LONG_DIGITS 10
-#define DECIMAL_LONG3_DIGITS 8
-
-/** maximum length of buffer in our big digits (uint32). */
-#define DECIMAL_BUFF_LENGTH 9
-
-/* the number of digits that my_decimal can possibly contain */
-#define DECIMAL_MAX_POSSIBLE_PRECISION (DECIMAL_BUFF_LENGTH * 9)
-
-
-/**
- maximum guaranteed precision of number in decimal digits (number of our
- digits * number of decimal digits in one our big digit - number of decimal
- digits in one our big digit decreased by 1 (because we always put decimal
- point on the border of our big digits))
-*/
-#define DECIMAL_MAX_PRECISION (DECIMAL_MAX_POSSIBLE_PRECISION - 8*2)
-#define DECIMAL_MAX_SCALE 30
-#define DECIMAL_NOT_SPECIFIED 31
-
-/**
- maximum length of string representation (number of maximum decimal
- digits + 1 position for sign + 1 position for decimal point)
-*/
-#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
+#include <my_decimal_limits.h>
/**
maximum size of packet length.
@@ -134,9 +109,10 @@ const char *dbug_decimal_as_string(char *buff, const my_decimal *val);
#endif
#ifndef MYSQL_CLIENT
-int decimal_operation_results(int result);
+int decimal_operation_results(int result, const char *value, const char *type);
#else
-inline int decimal_operation_results(int result)
+inline int decimal_operation_results(int result, const char *value,
+ const char *type)
{
return result;
}
@@ -158,7 +134,7 @@ inline void max_internal_decimal(my_decimal *to)
inline int check_result(uint mask, int result)
{
if (result & mask)
- decimal_operation_results(result);
+ decimal_operation_results(result, "", "DECIMAL");
return result;
}
@@ -294,24 +270,19 @@ int my_decimal2string(uint mask, const my_decimal *d, uint fixed_prec,
uint fixed_dec, char filler, String *str);
#endif
-inline
-int my_decimal2int(uint mask, const my_decimal *d, my_bool unsigned_flag,
- longlong *l)
-{
- my_decimal rounded;
- /* decimal_round can return only E_DEC_TRUNCATED */
- decimal_round((decimal_t*)d, &rounded, 0, HALF_UP);
- return check_result(mask, (unsigned_flag ?
- decimal2ulonglong(&rounded, (ulonglong *)l) :
- decimal2longlong(&rounded, l)));
-}
+bool my_decimal2seconds(const my_decimal *d, ulonglong *sec, ulong *microsec);
+my_decimal *seconds2my_decimal(bool sign, ulonglong sec, ulong microsec,
+ my_decimal *d);
+
+int my_decimal2int(uint mask, const decimal_t *d, bool unsigned_flag,
+ longlong *l);
inline
-int my_decimal2double(uint, const my_decimal *d, double *result)
+int my_decimal2double(uint, const decimal_t *d, double *result)
{
/* No need to call check_result as this will always succeed */
- return decimal2double((decimal_t*) d, result);
+ return decimal2double(d, result);
}
@@ -354,6 +325,16 @@ int int2my_decimal(uint mask, longlong i, my_bool unsigned_flag, my_decimal *d)
longlong2decimal(i, d)));
}
+inline
+void decimal2my_decimal(decimal_t *from, my_decimal *to)
+{
+ DBUG_ASSERT(to->len >= from->len);
+ to->intg= from->intg;
+ to->frac= from->frac;
+ to->sign(from->sign);
+ memcpy(to->buf, from->buf, to->len*sizeof(decimal_digit_t));
+}
+
inline
void my_decimal_neg(decimal_t *arg)
@@ -417,7 +398,6 @@ int my_decimal_mod(uint mask, my_decimal *res, const my_decimal *a,
res);
}
-
/**
@return
-1 if a<b, 1 if a>b and 0 if a==b
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 912f33ac983..f12874be1ea 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -61,12 +61,15 @@ class Parser_state;
QT_ORDINARY -- ordinary SQL query.
QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
- character set introducers).
+ character set introducers).
+ QT_VIEW_INTERNAL -- view internal representation (like QT_ORDINARY except
+ ORDER BY clause)
*/
enum enum_query_type
{
QT_ORDINARY,
- QT_IS
+ QT_IS,
+ QT_VIEW_INTERNAL
};
/* TODO convert all these three maps to Bitmap classes */
@@ -515,7 +518,6 @@ protected:
#define OPTION_PROFILING (ULL(1) << 33)
-
/**
Maximum length of time zone name that we support
(Time zone name is char(64) in db). mysqlbinlog needs it.
@@ -566,42 +568,61 @@ protected:
#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8
#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_INTERSECT 16
#define OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN 32
-
-#define OPTIMIZER_SWITCH_FIRSTMATCH 64
-#define OPTIMIZER_SWITCH_LOOSE_SCAN 128
-#define OPTIMIZER_SWITCH_MATERIALIZATION 256
-#define OPTIMIZER_SWITCH_SEMIJOIN 512
-#define OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE 1024
-#define OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN (1<<11)
-#define OPTIMIZER_SWITCH_SUBQUERY_CACHE (1<<12)
-#define OPTIMIZER_SWITCH_MRR_SORT_KEYS (1<<13)
-#define OPTIMIZER_SWITCH_OUTER_JOIN_WITH_CACHE (1<<14)
-#define OPTIMIZER_SWITCH_SEMIJOIN_WITH_CACHE (1<<15)
-#define OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL (1<<16)
-#define OPTIMIZER_SWITCH_JOIN_CACHE_HASHED (1<<17)
-#define OPTIMIZER_SWITCH_JOIN_CACHE_BKA (1<<18)
-#define OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE (1<<19)
+#define OPTIMIZER_SWITCH_DERIVED_MERGE 64
+#define OPTIMIZER_SWITCH_DERIVED_WITH_KEYS 128
+#define OPTIMIZER_SWITCH_FIRSTMATCH 256
+#define OPTIMIZER_SWITCH_LOOSE_SCAN 512
+#define OPTIMIZER_SWITCH_MATERIALIZATION 1024
+#define OPTIMIZER_SWITCH_IN_TO_EXISTS (1<<11)
+#define OPTIMIZER_SWITCH_SEMIJOIN (1<<12)
+#define OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE (1<<13)
+#define OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN (1<<14)
+#define OPTIMIZER_SWITCH_SUBQUERY_CACHE (1<<15)
+/** If this is off, MRR is never used. */
+#define OPTIMIZER_SWITCH_MRR (1ULL << 16)
+/**
+ If OPTIMIZER_SWITCH_MRR is on and this is on, MRR is used depending on a
+ cost-based choice ("automatic"). If OPTIMIZER_SWITCH_MRR is on and this is
+ off, MRR is "forced" (i.e. used as long as the storage engine is capable of
+ doing it).
+*/
+#define OPTIMIZER_SWITCH_MRR_COST_BASED (1ULL << 17)
+#define OPTIMIZER_SWITCH_MRR_SORT_KEYS (1ULL << 18)
+#define OPTIMIZER_SWITCH_OUTER_JOIN_WITH_CACHE (1ULL << 19)
+#define OPTIMIZER_SWITCH_SEMIJOIN_WITH_CACHE (1ULL << 20)
+#define OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL (1ULL << 21)
+#define OPTIMIZER_SWITCH_JOIN_CACHE_HASHED (1ULL << 22)
+#define OPTIMIZER_SWITCH_JOIN_CACHE_BKA (1ULL << 23)
+#define OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE (1ULL << 24)
#ifdef DBUG_OFF
-# define OPTIMIZER_SWITCH_LAST (1<<20)
+# define OPTIMIZER_SWITCH_LAST (1ULL << 25)
#else
-# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<20)
-# define OPTIMIZER_SWITCH_LAST (1<<21)
+# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1ULL << 25)
+# define OPTIMIZER_SWITCH_LAST (1ULL << 26)
#endif
#ifdef DBUG_OFF
/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
+/*
+TODO: Materialization is off by default to mimic 5.1/5.2 behavior.
+Once cost based choice between materialization and in-to-exists should be
+enabled by default, add OPTIMIZER_SWITCH_MATERIALIZATION
+*/
# define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN | \
+ OPTIMIZER_SWITCH_DERIVED_MERGE | \
+ OPTIMIZER_SWITCH_DERIVED_WITH_KEYS | \
OPTIMIZER_SWITCH_FIRSTMATCH | \
OPTIMIZER_SWITCH_LOOSE_SCAN | \
- OPTIMIZER_SWITCH_MATERIALIZATION | \
+ OPTIMIZER_SWITCH_IN_TO_EXISTS | \
OPTIMIZER_SWITCH_SEMIJOIN | \
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\
OPTIMIZER_SWITCH_SUBQUERY_CACHE|\
+ OPTIMIZER_SWITCH_MRR|\
OPTIMIZER_SWITCH_MRR_SORT_KEYS|\
OPTIMIZER_SWITCH_SUBQUERY_CACHE | \
OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL | \
@@ -614,14 +635,17 @@ protected:
OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN | \
+ OPTIMIZER_SWITCH_DERIVED_MERGE | \
+ OPTIMIZER_SWITCH_DERIVED_WITH_KEYS | \
OPTIMIZER_SWITCH_TABLE_ELIMINATION | \
OPTIMIZER_SWITCH_FIRSTMATCH | \
OPTIMIZER_SWITCH_LOOSE_SCAN | \
- OPTIMIZER_SWITCH_MATERIALIZATION | \
+ OPTIMIZER_SWITCH_IN_TO_EXISTS | \
OPTIMIZER_SWITCH_SEMIJOIN | \
OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE|\
OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\
OPTIMIZER_SWITCH_SUBQUERY_CACHE|\
+ OPTIMIZER_SWITCH_MRR|\
OPTIMIZER_SWITCH_MRR_SORT_KEYS|\
OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL | \
OPTIMIZER_SWITCH_JOIN_CACHE_HASHED | \
@@ -672,15 +696,36 @@ protected:
*/
#define CONTEXT_ANALYSIS_ONLY_DERIVED 4
-// uncachable cause
-#define UNCACHEABLE_DEPENDENT 1
-#define UNCACHEABLE_RAND 2
-#define UNCACHEABLE_SIDEEFFECT 4
-/// forcing to save JOIN for explain
-#define UNCACHEABLE_EXPLAIN 8
+/*
+ Don't evaluate constant sub-expressions of virtual column
+ expressions when opening tables
+*/
+#define CONTEXT_ANALYSIS_ONLY_VCOL_EXPR 8
+
+/*
+ Uncachable causes:
+
+This subquery has fields from outer query (put by user)
+*/
+#define UNCACHEABLE_DEPENDENT_GENERATED 1
+/* This subquery contains functions with random result */
+#define UNCACHEABLE_RAND 2
+/* This subquery contains functions with side effect */
+#define UNCACHEABLE_SIDEEFFECT 4
+/* Forcing to save JOIN tables for explain */
+#define UNCACHEABLE_EXPLAIN 8
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
-#define UNCACHEABLE_UNITED 16
-#define UNCACHEABLE_CHECKOPTION 32
+#define UNCACHEABLE_UNITED 16
+#define UNCACHEABLE_CHECKOPTION 32
+/*
+ This subquery has fields from outer query injected during
+ transformation process
+*/
+#define UNCACHEABLE_DEPENDENT_INJECTED 64
+
+/* This subquery has fields from outer query (any nature) */
+#define UNCACHEABLE_DEPENDENT (UNCACHEABLE_DEPENDENT_GENERATED | \
+ UNCACHEABLE_DEPENDENT_INJECTED)
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
#define UNDEF_POS (-1)
@@ -809,9 +854,92 @@ typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
uint key_length,
ulonglong *engine_data);
#include "sql_string.h"
+#include "my_decimal.h"
+
+/*
+ to unify the code that differs only in the argument passed to the
+ error message (string vs. number)
+
+ We pass this container around, and only convert the number
+ to a string when necessary.
+*/
+class Lazy_string
+{
+public:
+ Lazy_string() {}
+ virtual ~Lazy_string() {}
+ virtual void copy_to(String *str) const = 0;
+};
+
+class Lazy_string_str : public Lazy_string
+{
+ const char *str;
+ size_t len;
+public:
+ Lazy_string_str(const char *str_arg, size_t len_arg)
+ : Lazy_string(), str(str_arg), len(len_arg) {}
+ void copy_to(String *dst) const
+ { dst->copy(str, (uint32)len, system_charset_info); }
+};
+
+class Lazy_string_num : public Lazy_string
+{
+ longlong num;
+public:
+ Lazy_string_num(longlong num_arg) : Lazy_string(), num(num_arg) {}
+ void copy_to(String *dst) const { dst->set(num, &my_charset_bin); }
+};
+
+class Lazy_string_decimal: public Lazy_string
+{
+ const my_decimal *d;
+public:
+ Lazy_string_decimal(const my_decimal *d_arg)
+ : Lazy_string(), d(d_arg) {}
+ void copy_to(String *dst) const {
+ my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, ' ', dst);
+ }
+};
+
+class Lazy_string_double: public Lazy_string
+{
+ double num;
+public:
+ Lazy_string_double(double num_arg) : Lazy_string(), num(num_arg) {}
+ void copy_to(String *dst) const
+ { dst->set_real(num, NOT_FIXED_DEC, &my_charset_bin); }
+};
+
+class Lazy_string_time : public Lazy_string
+{
+ const MYSQL_TIME *ltime;
+public:
+ Lazy_string_time(const MYSQL_TIME *ltime_arg)
+ : Lazy_string(), ltime(ltime_arg) {}
+ void copy_to(String *dst) const
+ {
+ dst->alloc(MAX_DATETIME_FULL_WIDTH);
+ dst->length((uint) my_TIME_to_str(ltime, (char*) dst->ptr(),
+ AUTO_SEC_PART_DIGITS));
+ dst->set_charset(&my_charset_bin);
+ }
+};
+
+static inline enum enum_mysql_timestamp_type
+mysql_type_to_time_type(enum enum_field_types mysql_type)
+{
+ switch (mysql_type) {
+ case MYSQL_TYPE_TIME: return MYSQL_TIMESTAMP_TIME;
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATETIME: return MYSQL_TIMESTAMP_DATETIME;
+ case MYSQL_TYPE_NEWDATE:
+ case MYSQL_TYPE_DATE: return MYSQL_TIMESTAMP_DATE;
+ default: return MYSQL_TIMESTAMP_ERROR;
+ }
+}
+
#include "sql_list.h"
#include "sql_map.h"
-#include "my_decimal.h"
#include "handler.h"
#include "parse_file.h"
#include "table.h"
@@ -835,6 +963,7 @@ typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
#endif
#include "item.h"
extern my_decimal decimal_zero;
+extern my_decimal max_seconds_for_time_type, time_second_part_factor;
/* sql_parse.cc */
void free_items(Item *item);
@@ -968,7 +1097,7 @@ struct Query_cache_query_flags
#define query_cache_resize(A) query_cache.resize(A)
#define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A)
#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
-#define query_cache_invalidate1(A) query_cache.invalidate(A)
+#define query_cache_invalidate1(A,B) query_cache.invalidate(A,B)
#define query_cache_send_result_to_client(A, B, C) \
query_cache.send_result_to_client(A, B, C)
#define query_cache_invalidate_by_MyISAM_filename_ref \
@@ -980,19 +1109,18 @@ struct Query_cache_query_flags
(((L)->sql_command == SQLCOM_SELECT) && (L)->safe_to_cache_query)
#else
#define QUERY_CACHE_FLAGS_SIZE 0
-#define query_cache_store_query(A, B)
-#define query_cache_destroy()
-#define query_cache_result_size_limit(A)
-#define query_cache_init()
-#define query_cache_resize(A)
-#define query_cache_set_min_res_unit(A)
-#define query_cache_invalidate3(A, B, C)
-#define query_cache_invalidate1(A)
+#define query_cache_store_query(A, B) do { } while(0)
+#define query_cache_destroy() do { } while(0)
+#define query_cache_result_size_limit(A) do { } while(0)
+#define query_cache_init() do { } while(0)
+#define query_cache_resize(A) do { } while(0)
+#define query_cache_set_min_res_unit(A) do { } while(0)
+#define query_cache_invalidate3(A, B, C) do { } while(0)
+#define query_cache_invalidate1(A,B) do { } while(0)
#define query_cache_send_result_to_client(A, B, C) 0
#define query_cache_invalidate_by_MyISAM_filename_ref NULL
-
-#define query_cache_abort(A)
-#define query_cache_end_of_result(A)
+#define query_cache_abort(A) do { } while(0)
+#define query_cache_end_of_result(A) do { } while(0)
#define query_cache_maybe_disabled(T) 1
#define query_cache_is_cacheable_query(L) 0
#endif /*HAVE_QUERY_CACHE*/
@@ -1101,7 +1229,11 @@ void reset_mqh(LEX_USER *lu, bool get_them);
bool check_mqh(THD *thd, uint check_command);
void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
void decrease_user_connections(USER_CONN *uc);
-void thd_init_client_charset(THD *thd, uint cs_number);
+bool thd_init_client_charset(THD *thd, uint cs_number);
+inline bool is_supported_parser_charset(CHARSET_INFO *cs)
+{
+ return test(cs->mbminlen == 1);
+}
bool setup_connection_thread_globals(THD *thd);
bool login_connection(THD *thd);
void end_connection(THD *thd);
@@ -1280,11 +1412,14 @@ int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type,
select_result *result);
bool mysql_union(THD *thd, LEX *lex, select_result *result,
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
-bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
- LEX *lex,
- TABLE_LIST *table));
-bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
-bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
+bool mysql_handle_derived(LEX *lex, uint phases);
+bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases);
+bool mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *dt_list, uint phases);
+bool check_table_file_presence(char *old_path, char *path,
+ const char *db,
+ const char *table_name,
+ const char *alias,
+ bool issue_error);
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item ***copy_func, Field **from_field,
Field **def_field,
@@ -1293,6 +1428,11 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
bool make_copy_field,
uint convert_blob_length);
bool open_tmp_table(TABLE *table);
+bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
+ ENGINE_COLUMNDEF *start_recinfo,
+ ENGINE_COLUMNDEF **recinfo,
+ ulonglong options);
+
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
int prepare_create_field(Create_field *sql_field,
uint *blob_columns,
@@ -1412,6 +1552,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
Field *
find_field_in_table_sef(TABLE *table, const char *name);
int update_virtual_fields(THD *thd, TABLE *table, bool ignore_stored= FALSE);
+int dynamic_column_error_message(enum_dyncol_func_result rc);
#endif /* MYSQL_SERVER */
@@ -1599,17 +1740,21 @@ 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);
+void make_leaves_list(List<TABLE_LIST> &list, TABLE_LIST *tables,
+ bool full_table_list, TABLE_LIST *boundary);
bool setup_tables(THD *thd, Name_resolution_context *context,
List<TABLE_LIST> *from_clause, TABLE_LIST *tables,
- TABLE_LIST **leaves, bool select_insert);
+ List<TABLE_LIST> &leaves, bool select_insert,
+ bool full_table_list);
bool setup_tables_and_check_access(THD *thd,
Name_resolution_context *context,
List<TABLE_LIST> *from_clause,
TABLE_LIST *tables,
- TABLE_LIST **leaves,
+ List<TABLE_LIST> &leaves,
bool select_insert,
ulong want_access_first,
- ulong want_access);
+ ulong want_access,
+ bool full_table_list);
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
List<Item> *sum_func_list, uint wild_num);
bool setup_fields(THD *thd, Item** ref_pointer_array,
@@ -1628,8 +1773,9 @@ inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array,
thd->lex->select_lex.no_wrap_view_item= FALSE;
return res;
}
-int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
+int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
COND **conds);
+void wrap_ident(THD *thd, Item **conds);
int setup_ftfuncs(SELECT_LEX* select);
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
@@ -1650,7 +1796,8 @@ inline int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
/* simple open_and_lock_tables without derived handling for single table */
TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
thr_lock_type lock_type);
-bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
+bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags,
+ uint dt_phases);
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter, bool *need_reopen);
int decide_logging_format(THD *thd, TABLE_LIST *tables);
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
@@ -1680,6 +1827,7 @@ void flush_tables();
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
char *make_default_log_name(char *buff,const char* log_ext);
char *make_once_alloced_filename(const char *basename, const char *ext);
+void unfix_fields(List<Item> &items);
#ifdef WITH_PARTITION_STORAGE_ENGINE
uint fast_alter_partition_table(THD *thd, TABLE *table,
@@ -1947,6 +2095,7 @@ void flush_thread_cache();
/* item_func.cc */
extern bool check_reserved_words(LEX_STRING *name);
extern enum_field_types agg_field_type(Item **items, uint nitems);
+Item *find_date_time_item(Item **args, uint nargs, uint col);
/* strfunc.cc */
ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs,
@@ -2056,6 +2205,8 @@ extern ulong binlog_cache_size, open_files_limit;
extern ulonglong max_binlog_cache_size;
extern ulong max_binlog_size, max_relay_log_size;
extern ulong opt_binlog_rows_event_max_size;
+extern my_bool opt_master_verify_checksum;
+extern my_bool opt_slave_sql_verify_checksum;
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
extern ulong back_log;
#endif /* MYSQL_SERVER */
@@ -2065,12 +2216,14 @@ extern ulong MYSQL_PLUGIN_IMPORT specialflag;
#ifdef MYSQL_SERVER
extern ulong current_pid;
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
+extern ulong binlog_checksum_options;
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
extern ulong tc_log_page_waits;
extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
extern uint test_flags,select_errors,ha_open_options;
extern uint protocol_version, mysqld_port, mysqld_extra_port, dropping_tables;
extern uint delay_key_write_options;
+extern ulong max_long_data_size;
#endif /* MYSQL_SERVER */
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names;
@@ -2101,7 +2254,7 @@ extern uint thread_handling;
extern uint connection_count, extra_connection_count;
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
-extern my_bool opt_slave_compressed_protocol, use_temp_pool;
+extern my_bool opt_slave_compressed_protocol, use_temp_pool, opt_help;
extern ulong slave_exec_mode_options;
extern my_bool opt_readonly, lower_case_file_system;
extern my_bool opt_userstat_running;
@@ -2109,6 +2262,7 @@ extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
extern my_bool opt_secure_auth, debug_assert_if_crashed_table;
extern char* opt_secure_file_priv;
extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
+extern my_bool opt_query_cache_strip_comments;
extern my_bool sp_automatic_privileges, opt_noacl;
extern my_bool opt_old_style_user_limits, trust_function_creators;
extern uint opt_crash_binlog_innodb;
@@ -2321,17 +2475,34 @@ ulong convert_period_to_month(ulong period);
ulong convert_month_to_period(ulong month);
void get_date_from_daynr(long daynr,uint *year, uint *month,
uint *day);
-my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist);
-bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time);
+my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, uint *error);
+bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time,
+ ulong fuzzydate);
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
- MYSQL_TIME *l_time, uint flags);
+ MYSQL_TIME *l_time, ulong flags);
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
-void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
- const char *str_val,
- uint str_length, timestamp_type time_type,
+void make_truncated_value_warning(THD *thd,
+ MYSQL_ERROR::enum_warning_level level,
+ const Lazy_string *str_val,
+ timestamp_type time_type,
const char *field_name);
+bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
+ ulong fuzzydate, const char *field_name);
+bool decimal_to_datetime_with_warn(const my_decimal *value, MYSQL_TIME *ltime,
+ ulong fuzzydate, const char *field_name);
+bool int_to_datetime_with_warn(longlong value, MYSQL_TIME *ltime,
+ ulong fuzzydate, const char *field_name);
+
+static inline void make_truncated_value_warning(THD *thd,
+ MYSQL_ERROR::enum_warning_level level, const char *str_val,
+ uint str_length, timestamp_type time_type,
+ const char *field_name)
+{
+ const Lazy_string_str str(str_val, str_length);
+ make_truncated_value_warning(thd, level, &str, time_type, field_name);
+}
bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
@@ -2348,12 +2519,6 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
timestamp_type type);
extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
timestamp_type type, String *str);
-void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
- String *str);
-void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
- String *str);
-void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
- String *str);
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null);
@@ -2554,7 +2719,7 @@ Item * all_any_subquery_creator(Item *left_expr,
inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
{
table->used_fields= 0;
- table->const_table= 0;
+ table_list->reset_const_table();
table->null_row= 0;
table->status= STATUS_NO_RECORD;
table->maybe_null= table_list->outer_join;
@@ -2570,6 +2735,14 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
table->force_index_order= table->force_index_group= 0;
table->covering_keys= table->s->keys_for_keyread;
table->merge_keys.clear_all();
+ TABLE_LIST *orig= table_list->select_lex ?
+ table_list->select_lex->master_unit()->derived : 0;
+ if (!orig || !orig->is_merged_derived())
+ {
+ /* Tables merged from derived were set up already.*/
+ table->covering_keys= table->s->keys_for_keyread;
+ table->merge_keys.clear_all();
+ }
}
diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc
index 68d97936e7d..db916101eb1 100644
--- a/sql/mysql_upgrade_service.cc
+++ b/sql/mysql_upgrade_service.cc
@@ -67,6 +67,7 @@ static struct my_option my_long_options[]=
NO_ARG, 0, 0, 0, 0, 0, 0},
{"service", 'S', "Name of the existing Windows service",
&opt_service, &opt_service, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -96,7 +97,7 @@ static void log(const char *fmt, ...)
va_start(args, fmt);
vfprintf(stdout,fmt, args);
va_end(args);
- fputc('\n', stdout);
+ fputc('\n', stdout);
fflush(stdout);
}
@@ -117,13 +118,13 @@ static void die(const char *fmt, ...)
logfile_path);
}
va_end(args);
- fputc('\n', stderr);
+ fputc('\n', stderr);
fflush(stdout);
/* Cleanup */
- /*
- Stop service that we started, if it was not initally running at
- program start.
+ /*
+ Stop service that we started, if it was not initally running at
+ program start.
*/
if (initial_service_state != -1 && initial_service_state != SERVICE_RUNNING)
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 68140ae1b5a..08794b6ab68 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -151,6 +151,7 @@ static event_handle_t eh;
static Report_t ref;
static void *refneb= NULL;
my_bool event_flag= FALSE;
+
static int volumeid= -1;
/* NEB event callback */
@@ -335,10 +336,13 @@ static const char *optimizer_switch_names[]=
"index_merge","index_merge_union","index_merge_sort_union",
"index_merge_intersection","index_merge_sort_intersection",
"index_condition_pushdown",
- "firstmatch","loosescan","materialization", "semijoin",
+ "derived_merge", "derived_with_keys",
+ "firstmatch","loosescan","materialization","in_to_exists","semijoin",
"partial_match_rowid_merge",
"partial_match_table_scan",
"subquery_cache",
+ "mrr",
+ "mrr_cost_based",
"mrr_sort_keys",
"outer_join_with_cache",
"semijoin_with_cache",
@@ -361,13 +365,18 @@ static const unsigned int optimizer_switch_names_len[]=
sizeof("index_merge_intersection") - 1,
sizeof("index_merge_sort_intersection") - 1,
sizeof("index_condition_pushdown") - 1,
+ sizeof("derived_merge") - 1,
+ sizeof("derived_with_keys") - 1,
sizeof("firstmatch") - 1,
sizeof("loosescan") - 1,
sizeof("materialization") - 1,
+ sizeof("in_to_exists") - 1,
sizeof("semijoin") - 1,
sizeof("partial_match_rowid_merge") - 1,
sizeof("partial_match_table_scan") - 1,
sizeof("subquery_cache") - 1,
+ sizeof("mrr") - 1,
+ sizeof("mrr_cost_based") - 1,
sizeof("mrr_sort_keys") - 1,
sizeof("outer_join_with_cache") - 1,
sizeof("semijoin_with_cache") - 1,
@@ -430,14 +439,15 @@ bool opt_large_files= sizeof(my_off_t) > 4;
/*
Used with --help for detailed option
*/
-static my_bool opt_help= 0, opt_verbose= 0;
+static my_bool opt_verbose= 0;
-arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
+arg_cmp_func Arg_comparator::comparator_matrix[6][2] =
{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
{&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
{&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int},
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
- {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}};
+ {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal},
+ {&Arg_comparator::compare_datetime, &Arg_comparator::compare_e_datetime}};
const char *log_output_names[] = { "NONE", "FILE", "TABLE", NullS};
static const unsigned int log_output_names_len[]= { 4, 4, 5, 0 };
@@ -449,12 +459,20 @@ TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"",
/* the default log output is log tables */
static bool lower_case_table_names_used= 0;
+static bool max_long_data_size_used= false;
static bool volatile select_thread_in_use, signal_thread_in_use;
static bool volatile ready_to_exit;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_short_log_format= 0;
static my_bool opt_ignore_wrong_options= 0, opt_expect_abort= 0;
static my_bool opt_sync= 0, opt_thread_alarm;
+/*
+ Set this to 1 if you want to that 'strict mode' should affect all date
+ operations. If this is 0, then date checking is only done when storing
+ dates into a table.
+*/
+my_bool strict_date_checking= 0;
+
static uint kill_cached_threads, wake_thread;
ulong thread_created;
uint thread_handling;
@@ -468,13 +486,18 @@ static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
"index_merge_intersection=on,"
"index_merge_sort_intersection=off,"
"index_condition_pushdown=on,"
+ "derived_merge=on,"
+ "derived_with_keys=on,"
"firstmatch=on,"
"loosescan=on,"
- "materialization=on,"
+ "materialization=off,"
+ "in_to_exists=on,"
"semijoin=on,"
"partial_match_rowid_merge=on,"
"partial_match_table_scan=on,"
"subquery_cache=on,"
+ "mrr=on,"
+ "mrr_cost_based=off,"
"mrr_sort_keys=on,"
"join_cache_incremental=on,"
"join_cache_hashed=on,"
@@ -503,7 +526,7 @@ static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
/* Global variables */
bool opt_update_log, opt_bin_log, opt_ignore_builtin_innodb= 0;
-my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table;
+my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table, opt_help= 0;
my_bool opt_userstat_running;
ulong log_output_options;
my_bool opt_log_queries_not_using_indexes= 0;
@@ -584,6 +607,7 @@ my_bool opt_secure_auth= 0;
char* opt_secure_file_priv= 0;
my_bool opt_log_slow_admin_statements= 0;
my_bool opt_log_slow_slave_statements= 0;
+my_bool opt_query_cache_strip_comments = 0;
my_bool lower_case_file_system= 0;
my_bool opt_large_pages= 0;
my_bool opt_myisam_use_mmap= 0;
@@ -602,6 +626,8 @@ my_bool opt_noacl;
my_bool sp_automatic_privileges= 1;
ulong opt_binlog_rows_event_max_size;
+my_bool opt_master_verify_checksum= 0;
+my_bool opt_slave_sql_verify_checksum= 1;
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
TYPELIB binlog_format_typelib=
{ array_elements(binlog_format_names) - 1, "",
@@ -641,6 +667,12 @@ ulong specialflag=0;
ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong max_connections, max_connect_errors;
ulong extra_max_connections;
+/*
+ Maximum length of parameter value which can be set through
+ mysql_send_long_data() call.
+*/
+ulong max_long_data_size;
+
uint max_user_connections= 0;
ulonglong denied_connections;
/**
@@ -698,6 +730,8 @@ const char *in_additional_cond= "<IN COND>";
const char *in_having_cond= "<IN HAVING>";
my_decimal decimal_zero;
+my_decimal max_seconds_for_time_type, time_second_part_factor;
+
/* classes for comparation parsing/processing */
Eq_creator eq_creator;
Ne_creator ne_creator;
@@ -1528,6 +1562,7 @@ static void wait_for_signal_thread_to_end()
#endif
}
+#endif /*EMBEDDED_LIBRARY*/
static void clean_up_mutexes()
{
@@ -1555,19 +1590,21 @@ static void clean_up_mutexes()
(void) pthread_mutex_destroy(&LOCK_global_table_stats);
(void) pthread_mutex_destroy(&LOCK_global_index_stats);
+#ifndef EMBEDDED_LIBRARY
Events::destroy_mutexes();
+#endif /* !EMBEDDED_LIBRARY */
#ifdef HAVE_OPENSSL
(void) pthread_mutex_destroy(&LOCK_des_key_file);
#ifndef HAVE_YASSL
for (int i= 0; i < CRYPTO_num_locks(); ++i)
(void) rwlock_destroy(&openssl_stdlocks[i].lock);
OPENSSL_free(openssl_stdlocks);
-#endif
-#endif
+#endif /* HAVE_YASSL */
+#endif /* HAVE_OPENSSL */
#ifdef HAVE_REPLICATION
(void) pthread_mutex_destroy(&LOCK_rpl_status);
(void) pthread_cond_destroy(&COND_rpl_status);
-#endif
+#endif /* HAVE_REPLICATION */
(void) pthread_mutex_destroy(&LOCK_server_started);
(void) pthread_cond_destroy(&COND_server_started);
(void) pthread_mutex_destroy(&LOCK_active_mi);
@@ -1587,8 +1624,6 @@ static void clean_up_mutexes()
DBUG_VOID_RETURN;
}
-#endif /*EMBEDDED_LIBRARY*/
-
/**
Register order of mutex for wrong mutex deadlock detector
@@ -2099,7 +2134,7 @@ static bool cache_thread()
this thread for handling of new THD object/connection.
*/
thd->mysys_var->abort= 0;
- thd->thr_create_utime= my_micro_time();
+ thd->thr_create_utime= microsecond_interval_timer();
threads.append(thd);
return(1);
}
@@ -3243,6 +3278,19 @@ sizeof(load_default_groups)/sizeof(load_default_groups[0]);
#endif
+#ifndef EMBEDDED_LIBRARY
+static
+int
+check_enough_stack_size()
+{
+ uchar stack_top;
+
+ return check_stack_overrun(current_thd, STACK_MIN_SIZE,
+ &stack_top);
+}
+#endif
+
+
/**
Initialize one of the global date/time format variables.
@@ -3441,18 +3489,12 @@ static int init_common_variables(const char *conf_file_name, int argc,
char **argv, const char **groups)
{
char buff[FN_REFLEN], *s;
+ const char *basename;
umask(((~my_umask) & 0666));
- my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
tzset(); // Set tzname
max_system_variables.pseudo_thread_id= (ulong)~0;
server_start_time= flush_status_time= my_time(0);
- /* TODO: remove this when my_time_t is 64 bit compatible */
- if (server_start_time >= (time_t) MY_TIME_T_MAX)
- {
- sql_print_error("This MySQL server doesn't support dates later then 2038");
- return 1;
- }
rpl_filter= new Rpl_filter;
binlog_filter= new Rpl_filter;
@@ -3491,21 +3533,29 @@ static int init_common_variables(const char *conf_file_name, int argc,
*/
mysql_bin_log.init_pthread_objects();
+ /* TODO: remove this when my_time_t is 64 bit compatible */
+ if (!IS_TIME_T_VALID_FOR_TIMESTAMP(server_start_time))
+ {
+ sql_print_error("This MySQL server doesn't support dates later then 2038");
+ return 1;
+ }
+
+ if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
{
/*
Get hostname of computer (used by 'show variables') and as default
basename for the pid file if --log-basename is not given.
*/
- const char *basename= glob_hostname;
- if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
- {
- strmake(glob_hostname, STRING_WITH_LEN("localhost"));
- sql_print_warning("gethostname failed, using '%s' as hostname",
+ strmake(glob_hostname, STRING_WITH_LEN("localhost"));
+ sql_print_warning("gethostname failed, using '%s' as hostname",
glob_hostname);
- basename= "mysql";
- }
- strmake(pidfile_name, basename, sizeof(pidfile_name)-5);
+ basename= "mysql";
}
+ else
+ {
+ basename= glob_hostname;
+ }
+ strmake(pidfile_name, basename, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
/*
@@ -3634,7 +3684,11 @@ static int init_common_variables(const char *conf_file_name, int argc,
#endif
mysys_uses_curses=0;
#ifdef USE_REGEX
- my_regex_init(&my_charset_latin1);
+#ifndef EMBEDDED_LIBRARY
+ my_regex_init(&my_charset_latin1, check_enough_stack_size);
+#else
+ my_regex_init(&my_charset_latin1, NULL);
+#endif
#endif
/*
Process a comma-separated character set list and choose
@@ -3688,8 +3742,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
global_system_variables.character_set_results= default_charset_info;
global_system_variables.character_set_client= default_charset_info;
- global_system_variables.optimizer_use_mrr= 1;
-
if (!(character_set_filesystem=
get_charset_by_csname(character_set_filesystem_name,
MY_CS_PRIMARY, MYF(MY_WME))))
@@ -3782,8 +3834,7 @@ You should consider changing lower_case_table_names to 1 or 2",
}
}
else if (lower_case_table_names == 2 &&
- !(lower_case_file_system=
- (test_if_case_insensitive(mysql_real_data_home) == 1)))
+ !(lower_case_file_system= (lower_case_file_system == 1)))
{
if (global_system_variables.log_warnings)
sql_print_warning("lower_case_table_names was set to 2, even though your "
@@ -3794,8 +3845,7 @@ You should consider changing lower_case_table_names to 1 or 2",
}
else
{
- lower_case_file_system=
- (test_if_case_insensitive(mysql_real_data_home) == 1);
+ lower_case_file_system= (lower_case_file_system == 1);
}
/* Reset table_alias_charset, now that lower_case_table_names is set. */
@@ -4004,6 +4054,32 @@ static void end_ssl()
#endif /* EMBEDDED_LIBRARY */
+#ifdef _WIN32
+/**
+ Registers a file to be collected when Windows Error Reporting creates a crash
+ report.
+
+ @note only works on Vista and later, since WerRegisterFile() is not available
+ on earlier Windows.
+*/
+#include <werapi.h>
+static void add_file_to_crash_report(char *file)
+{
+ /* Load WerRegisterFile function dynamically.*/
+ HRESULT (WINAPI *pWerRegisterFile)(PCWSTR, WER_REGISTER_FILE_TYPE, DWORD)
+ =(HRESULT (WINAPI *) (PCWSTR, WER_REGISTER_FILE_TYPE, DWORD))
+ GetProcAddress(GetModuleHandle("kernel32"),"WerRegisterFile");
+
+ if (pWerRegisterFile)
+ {
+ wchar_t wfile[MAX_PATH+1]= {0};
+ if (mbstowcs(wfile, file, MAX_PATH) != (size_t)-1)
+ {
+ pWerRegisterFile(wfile, WerRegFileTypeOther, WER_FILE_ANONYMOUS_DATA);
+ }
+ }
+}
+#endif
static int init_server_components()
{
@@ -4056,6 +4132,11 @@ static int init_server_components()
if (!res)
setbuf(stderr, NULL);
+
+#ifdef _WIN32
+ /* Add error log to windows crash reporting. */
+ add_file_to_crash_report(log_error_file);
+#endif
}
}
@@ -4659,13 +4740,14 @@ int main(int argc, char **argv)
#ifndef DBUG_OFF
test_lc_time_sz();
+ srand((uint) time(NULL));
#endif
/*
We have enough space for fiddling with the argv, continue
*/
check_data_home(mysql_real_data_home);
- if (my_setwd(mysql_real_data_home,MYF(MY_WME)) && !opt_help)
+ if (my_setwd(mysql_real_data_home, opt_help ? 0 : MYF(MY_WME)) && !opt_help)
unireg_abort(1); /* purecov: inspected */
mysql_data_home= mysql_data_home_buff;
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
@@ -5149,9 +5231,9 @@ void handle_connection_in_main_thread(THD *thd)
safe_mutex_assert_owner(&LOCK_thread_count);
thread_cache_size=0; // Safety
threads.append(thd);
- thd->start_utime= my_micro_time();
+ thd->set_time(my_hrtime());
pthread_mutex_unlock(&LOCK_thread_count);
- thd->start_utime= my_micro_time();
+ thd->start_utime= microsecond_interval_timer();
handle_one_connection(thd);
}
@@ -5177,7 +5259,7 @@ void create_thread_to_handle_connection(THD *thd)
thread_created++;
threads.append(thd);
DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
- thd->prior_thr_create_utime= thd->start_utime= my_micro_time();
+ thd->prior_thr_create_utime= thd->start_utime= microsecond_interval_timer();
if ((error=pthread_create(&thd->real_id,&connection_attrib,
handle_one_connection,
(void*) thd)))
@@ -6077,7 +6159,11 @@ enum options_mysqld
OPT_SLOW_QUERY_LOG_FILE,
OPT_IGNORE_BUILTIN_INNODB,
OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
- OPT_DEFAULT_CHARACTER_SET_OLD
+ OPT_DEFAULT_CHARACTER_SET_OLD,
+ OPT_MAX_LONG_DATA_SIZE,
+ OPT_MASTER_VERIFY_CHECKSUM,
+ OPT_SLAVE_SQL_VERIFY_CHECKSUM,
+ OPT_QUERY_CACHE_STRIP_COMMENTS
};
@@ -6940,6 +7026,19 @@ each time the SQL thread starts.",
"not stop for operations that are idempotent. In STRICT mode, replication "
"will stop on any unexpected difference between the master and the slave.",
&slave_exec_mode_str, &slave_exec_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"master-verify-checksum", OPT_MASTER_VERIFY_CHECKSUM,
+ "Force checksum verification of logged events in binary log before "
+ "sending them to slaves or printing them in output of SHOW BINLOG EVENTS. "
+ "Disabled by default.",
+ &opt_master_verify_checksum, &opt_master_verify_checksum,
+ 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
+ {"slave-sql-verify-checksum", OPT_SLAVE_SQL_VERIFY_CHECKSUM,
+ "Force checksum verification of replication events after reading them "
+ "from relay log. Note: Events are always checksum-verified by slave on "
+ "receiving them from the network before writing them to the relay "
+ "log. Enabled by default.",
+ &opt_slave_sql_verify_checksum, &opt_slave_sql_verify_checksum,
+ 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
#endif
{"slow-query-log", OPT_SLOW_LOG,
"Enable/disable slow query log. See also '--log-slow-queries'",
@@ -7287,6 +7386,12 @@ each time the SQL thread starts.",
&global_system_variables.max_length_for_sort_data,
&max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
+ {"max_long_data_size", OPT_MAX_LONG_DATA_SIZE,
+ "The maximum size of prepared statement parameter which can be provided "
+ "through mysql_send_long_data() API call. To be used when limit of "
+ "max_allowed_packet is too small",
+ &max_long_data_size, &max_long_data_size, 0, GET_ULONG,
+ REQUIRED_ARG, 1024*1024L, 1024, UINT_MAX32, MALLOC_OVERHEAD, 1, 0},
{"max_prepared_stmt_count", OPT_MAX_PREPARED_STMT_COUNT,
"Maximum number of prepared statements in the server.",
&max_prepared_stmt_count, &max_prepared_stmt_count,
@@ -7443,8 +7548,9 @@ each time the SQL thread starts.",
{"optimizer_switch", OPT_OPTIMIZER_SWITCH,
"optimizer_switch=option=val[,option=val...], where option={index_merge, "
"index_merge_union, index_merge_sort_union, index_merge_intersection, "
- "index_merge_sort_intersection, "
- "index_condition_pushdown, firstmatch, loosescan, materialization, "
+ "index_merge_sort_intersection, index_condition_pushdown, "
+ "derived_merge, derived_with_keys, "
+ "firstmatch, loosescan, materialization, in_to_exists, "
"semijoin, partial_match_rowid_merge, partial_match_table_scan, "
"subquery_cache, outer_join_with_cache, semijoin_with_cache, "
"join_cache_incremental, join_cache_hashed, join_cache_bka, "
@@ -7497,6 +7603,13 @@ each time the SQL thread starts.",
&query_cache_size, &query_cache_size, 0, GET_ULONG,
REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1024, 0},
#ifdef HAVE_QUERY_CACHE
+ {"query_cache_strip_comments", OPT_QUERY_CACHE_STRIP_COMMENTS,
+ "Enable and disable optimisation \"strip comment for query cache\" - "
+ "optimisation strip all comments from query while search query result "
+ "in query cache",
+ (uchar**) &opt_query_cache_strip_comments,
+ (uchar**) &opt_query_cache_strip_comments,
+ 0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
{"query_cache_type", OPT_QUERY_CACHE_TYPE,
"0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results "
"except SELECT SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT "
@@ -8268,6 +8381,7 @@ static void usage(void)
puts("\
Copyright (C) 2000-2008 MySQL AB, by Monty and others.\n\
Copyright (C) 2008 Sun Microsystems, Inc.\n\
+Copyright (C) 2009-2011 Monty Program Ab.\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n\n\
Starts the MySQL database server.\n");
@@ -8438,6 +8552,13 @@ static int mysql_init_variables(void)
/* set key_cache_hash.default_value = dflt_key_cache */
multi_keycache_init();
+ /* Useful MariaDB variables */
+ double2decimal((double) TIME_MAX_VALUE_SECONDS +
+ TIME_MAX_SECOND_PART/(double)TIME_SECOND_PART_FACTOR,
+ &max_seconds_for_time_type);
+ longlong2decimal(TIME_SECOND_PART_FACTOR, &time_second_part_factor);
+ my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
+
/* Set directory paths */
strmake(language, LANGUAGE, sizeof(language)-1);
strmake(mysql_real_data_home, get_relative_path(MYSQL_DATADIR),
@@ -8929,7 +9050,7 @@ mysqld_get_one_option(int optid,
}
case OPT_EVENT_SCHEDULER:
#ifndef HAVE_EVENT_SCHEDULER
- sql_perror("Event scheduler is not supported in embedded build.");
+ sql_print_error("Event scheduler is not supported in embedded build.");
#else
if (Events::set_opt_event_scheduler(argument))
return 1;
@@ -9302,6 +9423,9 @@ mysqld_get_one_option(int optid,
}
break;
#endif /* defined(ENABLED_DEBUG_SYNC) */
+ case OPT_MAX_LONG_DATA_SIZE:
+ max_long_data_size_used= true;
+ break;
}
return 0;
}
@@ -9394,6 +9518,14 @@ static int get_options(int *argc,char **argv)
opt_log_slow_slave_statements) &&
!opt_slow_log)
sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set");
+ if (global_system_variables.net_buffer_length >
+ global_system_variables.max_allowed_packet)
+ {
+ sql_print_warning("net_buffer_length (%lu) is set to be larger "
+ "than max_allowed_packet (%lu). Please rectify.",
+ global_system_variables.net_buffer_length,
+ global_system_variables.max_allowed_packet);
+ }
#if defined(HAVE_BROKEN_REALPATH)
my_use_symdir=0;
@@ -9476,6 +9608,14 @@ static int get_options(int *argc,char **argv)
&extra_max_connections,
&extra_connection_count);
#endif
+
+ /*
+ If max_long_data_size is not specified explicitly use
+ value of max_allowed_packet.
+ */
+ if (!max_long_data_size_used)
+ max_long_data_size= global_system_variables.max_allowed_packet;
+
return 0;
}
@@ -9784,7 +9924,8 @@ static int test_if_case_insensitive(const char *dir_name)
(void) my_delete(buff2, MYF(0));
if ((file= my_create(buff, 0666, O_RDWR, MYF(0))) < 0)
{
- sql_print_warning("Can't create test file %s", buff);
+ if (!opt_help)
+ sql_print_warning("Can't create test file %s", buff);
DBUG_RETURN(-1);
}
my_close(file, MYF(0));
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index a605b3f8fe1..dc987e196f4 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -341,8 +341,9 @@ public:
SEL_ARG(Field *field, uint8 part, uchar *min_value, uchar *max_value,
uint8 min_flag, uint8 max_flag, uint8 maybe_flag);
SEL_ARG(enum Type type_arg)
- :min_flag(0),elements(1),use_count(1),left(0),right(0),next_key_part(0),
- color(BLACK), type(type_arg)
+ :min_flag(0), max_part_no(0) /* first key part means 1. 0 mean 'no parts'*/,
+ elements(1),use_count(1),left(0),right(0),
+ next_key_part(0), color(BLACK), type(type_arg)
{}
inline bool is_same(SEL_ARG *arg)
{
@@ -1665,7 +1666,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
select->read_tables=read_tables;
select->const_tables=const_tables;
select->head=head;
- select->cond=conds;
+ select->cond= conds;
if (head->sort.io_cache)
{
@@ -1816,6 +1817,12 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
DBUG_VOID_RETURN;
}
+/*
+ QUICK_INDEX_SORT_SELECT works as follows:
+ - Do index scans, accumulate rowids in the Unique object
+ (Unique will also sort and de-duplicate rowids)
+ - Use rowids from unique to run a disk-ordered sweep
+*/
QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT(THD *thd_param,
TABLE *table)
@@ -1848,7 +1855,18 @@ QUICK_INDEX_SORT_SELECT::push_quick_back(QUICK_RANGE_SELECT *quick_sel_range)
if (head->file->primary_key_is_clustered() &&
quick_sel_range->index == head->s->primary_key)
{
- /* A quick_select over a clustered primary key is handled specifically */
+ /*
+ A quick_select over a clustered primary key is handled specifically
+ Here we assume:
+ - PK columns are included in any other merged index
+ - Scan on the PK is disk-ordered.
+ (not meeting #2 will only cause performance degradation)
+
+ We could treat clustered PK as any other index, but that would
+ be inefficient. There is no point in doing scan on
+ CPK, remembering the rowid, then making rnd_pos() call with
+ that rowid.
+ */
pk_quick_select= quick_sel_range;
DBUG_RETURN(0);
}
@@ -1959,7 +1977,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
}
thd= head->in_use;
- if (!(file= head->file->clone(thd->mem_root)))
+ if (!(file= head->file->clone(head->s->normalized_path.str, thd->mem_root)))
{
/*
Manually set the error flag. Note: there seems to be quite a few
@@ -2909,7 +2927,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
quick=0;
needed_reg.clear_all();
quick_keys.clear_all();
- if (keys_to_use.is_clear_all())
+ DBUG_ASSERT(!head->is_filled_at_execution());
+ if (keys_to_use.is_clear_all() || head->is_filled_at_execution())
DBUG_RETURN(0);
records= head->file->stats.records;
if (!records)
@@ -4298,11 +4317,19 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records)
DBUG_ENTER("get_sweep_read_cost");
if (param->table->file->primary_key_is_clustered())
{
+ /*
+ We are using the primary key to find the rows.
+ Calculate the cost for this.
+ */
result= param->table->file->read_time(param->table->s->primary_key,
(uint)records, records);
}
else
{
+ /*
+ Rows will be retreived with rnd_pos(). Caluclate the expected
+ cost for this.
+ */
double n_blocks=
ceil(ulonglong2double(param->table->file->stats.data_file_length) /
IO_SIZE);
@@ -4319,7 +4346,7 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records)
return 1;
*/
JOIN *join= param->thd->lex->select_lex.join;
- if (!join || join->tables == 1)
+ if (!join || join->table_count == 1)
{
/* No join, assume reading is done in one 'sweep' */
result= busy_blocks*(DISK_SEEK_BASE_COST +
@@ -5013,7 +5040,7 @@ bool prepare_search_best_index_intersect(PARAM *param,
if ((*index_scan)->keynr == table->s->primary_key)
{
common->cpk_scan= cpk_scan= *index_scan;
- break;
+ break;
}
}
}
@@ -6187,7 +6214,6 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree,
ROR_SCAN_INFO **cur_ror_scan;
ROR_SCAN_INFO *cpk_scan= NULL;
uint cpk_no;
- bool cpk_scan_used= FALSE;
if (!(tree->ror_scans= (ROR_SCAN_INFO**)alloc_root(param->mem_root,
sizeof(ROR_SCAN_INFO*)*
@@ -6199,11 +6225,20 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree,
for (idx= 0, cur_ror_scan= tree->ror_scans; idx < param->keys; idx++)
{
ROR_SCAN_INFO *scan;
+ uint key_no;
if (!tree->ror_scans_map.is_set(idx))
continue;
+ key_no= param->real_keynr[idx];
+ if (key_no != cpk_no &&
+ param->table->file->index_flags(key_no,0,0) & HA_CLUSTERED_INDEX)
+ {
+ /* Ignore clustering keys */
+ tree->n_ror_scans--;
+ continue;
+ }
if (!(scan= make_ror_scan(param, idx, tree->keys[idx])))
return NULL;
- if (param->real_keynr[idx] == cpk_no)
+ if (key_no == cpk_no)
{
cpk_scan= scan;
tree->n_ror_scans--;
@@ -6289,15 +6324,14 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree,
{
if (ror_intersect_add(intersect, cpk_scan, TRUE) &&
(intersect->total_cost < min_cost))
- {
- cpk_scan_used= TRUE;
intersect_best= intersect; //just set pointer here
- }
}
+ else
+ cpk_scan= 0; // Don't use cpk_scan
/* Ok, return ROR-intersect plan if we have found one */
TRP_ROR_INTERSECT *trp= NULL;
- if (min_cost < read_time && (cpk_scan_used || best_num > 1))
+ if (min_cost < read_time && (cpk_scan || best_num > 1))
{
if (!(trp= new (param->mem_root) TRP_ROR_INTERSECT))
DBUG_RETURN(trp);
@@ -6316,7 +6350,7 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree,
set_if_smaller(param->table->quick_condition_rows, best_rows);
trp->records= best_rows;
trp->index_scan_costs= intersect_best->index_scan_costs;
- trp->cpk_scan= cpk_scan_used? cpk_scan: NULL;
+ trp->cpk_scan= cpk_scan;
DBUG_PRINT("info", ("Returning non-covering ROR-intersect plan:"
"cost %g, records %lu",
trp->read_cost, (ulong) trp->records));
@@ -7360,7 +7394,6 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
SEL_ARG *tree= 0;
MEM_ROOT *alloc= param->mem_root;
uchar *str;
- ulong orig_sql_mode;
int err;
DBUG_ENTER("get_mm_leaf");
@@ -7528,16 +7561,8 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
We can't always use indexes when comparing a string index to a number
cmp_type() is checked to allow compare of dates to numbers
*/
- if (field->result_type() == STRING_RESULT &&
- value->result_type() != STRING_RESULT &&
- field->cmp_type() != value->result_type())
+ if (field->cmp_type() == STRING_RESULT && value->cmp_type() != STRING_RESULT)
goto end;
- /* For comparison purposes allow invalid dates like 2000-01-32 */
- orig_sql_mode= field->table->in_use->variables.sql_mode;
- if (value->real_item()->type() == Item::STRING_ITEM &&
- (field->type() == MYSQL_TYPE_DATE ||
- field->type() == MYSQL_TYPE_DATETIME))
- field->table->in_use->variables.sql_mode|= MODE_INVALID_DATES;
err= value->save_in_field_no_warnings(field, 1);
if (err > 0)
{
@@ -7549,7 +7574,6 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
{
tree= new (alloc) SEL_ARG(field, 0, 0);
tree->type= SEL_ARG::IMPOSSIBLE;
- field->table->in_use->variables.sql_mode= orig_sql_mode;
goto end;
}
else
@@ -7583,10 +7607,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
*/
}
else
- {
- field->table->in_use->variables.sql_mode= orig_sql_mode;
goto end;
- }
}
}
@@ -7609,12 +7630,10 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
}
else if (err < 0)
{
- field->table->in_use->variables.sql_mode= orig_sql_mode;
/* This happens when we try to insert a NULL field in a not null column */
tree= &null_element; // cmp with NULL is never TRUE
goto end;
}
- field->table->in_use->variables.sql_mode= orig_sql_mode;
/*
Any sargable predicate except "<=>" involving NULL as a constant is always
@@ -9478,7 +9497,7 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
SEL_ARG_RANGE_SEQ seq;
RANGE_SEQ_IF seq_if = {NULL, sel_arg_range_seq_init, sel_arg_range_seq_next, 0, 0};
handler *file= param->table->file;
- ha_rows rows;
+ ha_rows rows= HA_POS_ERROR;
uint keynr= param->real_keynr[idx];
DBUG_ENTER("check_quick_select");
@@ -9511,15 +9530,20 @@ ha_rows check_quick_select(PARAM *param, uint idx, bool index_only,
bool pk_is_clustered= file->primary_key_is_clustered();
if (index_only &&
(file->index_flags(keynr, param->max_key_part, 1) & HA_KEYREAD_ONLY) &&
- !(pk_is_clustered && keynr == param->table->s->primary_key))
+ !(file->index_flags(keynr, param->max_key_part, 1) & HA_CLUSTERED_INDEX))
*mrr_flags |= HA_MRR_INDEX_ONLY;
- if (current_thd->lex->sql_command != SQLCOM_SELECT)
+ if (param->thd->lex->sql_command != SQLCOM_SELECT)
*mrr_flags |= HA_MRR_USE_DEFAULT_IMPL;
*bufsize= param->thd->variables.mrr_buff_size;
- rows= file->multi_range_read_info_const(keynr, &seq_if, (void*)&seq, 0,
- bufsize, mrr_flags, cost);
+ /*
+ Skip materialized derived table/view result table from MRR check as
+ they aren't contain any data yet.
+ */
+ if (param->table->pos_in_table_list->is_non_derived())
+ rows= file->multi_range_read_info_const(keynr, &seq_if, (void*)&seq, 0,
+ bufsize, mrr_flags, cost);
if (rows != HA_POS_ERROR)
{
param->quick_rows[keynr]= rows;
@@ -11104,7 +11128,7 @@ static bool get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree,
uchar *key_infix, uint *key_infix_len,
KEY_PART_INFO **first_non_infix_part);
static bool
-check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
+check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item,
Field::imagetype image_type);
static void
@@ -11270,7 +11294,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
/* Perform few 'cheap' tests whether this access method is applicable. */
if (!join)
DBUG_RETURN(NULL); /* This is not a select statement. */
- if ((join->tables != 1) || /* The query must reference one table. */
+ if ((join->table_count != 1) || /* The query must reference one table. */
((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */
(!join->select_distinct)) ||
(join->select_lex->olap == ROLLUP_TYPE)) /* Check (B3) for ROLLUP */
@@ -11678,14 +11702,14 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
static bool
-check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
+check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item,
Field::imagetype image_type)
{
DBUG_ENTER("check_group_min_max_predicates");
DBUG_ASSERT(cond && min_max_arg_item);
cond= cond->real_item();
- Item::Type cond_type= cond->type();
+ Item::Type cond_type= cond->real_type();
if (cond_type == Item::COND_ITEM) /* 'AND' or 'OR' */
{
DBUG_PRINT("info", ("Analyzing: %s", ((Item_func*) cond)->func_name()));
@@ -11701,16 +11725,25 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
}
/*
- TODO:
- This is a very crude fix to handle sub-selects in the WHERE clause
- (Item_subselect objects). With the test below we rule out from the
- optimization all queries with subselects in the WHERE clause. What has to
- be done, is that here we should analyze whether the subselect references
- the MIN/MAX argument field, and disallow the optimization only if this is
- so.
+ Disallow loose index scan if the MIN/MAX argument field is referenced by
+ a subquery in the WHERE clause.
*/
- if (cond->real_type() == Item::SUBSELECT_ITEM)
- DBUG_RETURN(FALSE);
+ if (cond_type == Item::SUBSELECT_ITEM)
+ {
+ Item_subselect *subs_cond= (Item_subselect*) cond;
+ if (subs_cond->is_correlated)
+ {
+ DBUG_ASSERT(subs_cond->depends_on.elements > 0);
+ List_iterator_fast<Item*> li(subs_cond->depends_on);
+ Item **dep;
+ while ((dep= li++))
+ {
+ if ((*dep)->eq(min_max_arg_item, FALSE))
+ DBUG_RETURN(FALSE);
+ }
+ }
+ DBUG_RETURN(TRUE);
+ }
/*
Condition of the form 'field' is equivalent to 'field <> 0' and thus
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index e12412299c5..8ff45e0306e 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -2,7 +2,7 @@
@file
@brief
- Subquery optimization code here.
+ Semi-join subquery optimizations code
*/
@@ -16,7 +16,162 @@
#include <my_bit.h>
-// Our own:
+/*
+ This file contains optimizations for semi-join subqueries.
+
+ Contents
+ --------
+ 1. What is a semi-join subquery
+ 2. General idea about semi-join execution
+ 2.1 Correlated vs uncorrelated semi-joins
+ 2.2 Mergeable vs non-mergeable semi-joins
+ 3. Code-level view of semi-join processing
+ 3.1 Conversion
+ 3.1.1 Merged semi-join TABLE_LIST object
+ 3.1.2 Non-merged semi-join data structure
+ 3.2 Semi-joins and query optimization
+ 3.2.1 Non-merged semi-joins and join optimization
+ 3.2.2 Merged semi-joins and join optimization
+ 3.3 Semi-joins and query execution
+
+ 1. What is a semi-join subquery
+ -------------------------------
+ We use this definition of semi-join:
+
+ outer_tbl SEMI JOIN inner_tbl ON cond = {set of outer_tbl.row such that
+ exist inner_tbl.row, for which
+ cond(outer_tbl.row,inner_tbl.row)
+ is satisfied}
+
+ That is, semi-join operation is similar to inner join operation, with
+ exception that we don't care how many matches a row from outer_tbl has in
+ inner_tbl.
+
+ In SQL terms: a semi-join subquery is an IN subquery that is an AND-part of
+ the WHERE/ON clause.
+
+ 2. General idea about semi-join execution
+ -----------------------------------------
+ We can execute semi-join in a way similar to inner join, with exception that
+ we need to somehow ensure that we do not generate record combinations that
+ differ only in rows of inner tables.
+ There is a number of different ways to achieve this property, implemented by
+ a number of semi-join execution strategies.
+ Some strategies can handle any semi-joins, other can be applied only to
+ semi-joins that have certain properties that are described below:
+
+ 2.1 Correlated vs uncorrelated semi-joins
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Uncorrelated semi-joins are special in the respect that they allow to
+ - execute the subquery (possible as it's uncorrelated)
+ - somehow make sure that generated set does not have duplicates
+ - perform an inner join with outer tables.
+
+ or, rephrasing in SQL form:
+
+ SELECT ... FROM ot WHERE ot.col IN (SELECT it.col FROM it WHERE uncorr_cond)
+ ->
+ SELECT ... FROM ot JOIN (SELECT DISTINCT it.col FROM it WHERE uncorr_cond)
+
+ 2.2 Mergeable vs non-mergeable semi-joins
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Semi-join operation has some degree of commutability with inner join
+ operation: we can join subquery's tables with ouside table(s) and eliminate
+ duplicate record combination after that:
+
+ ot1 JOIN ot2 SEMI_JOIN{it1,it2} (it1 JOIN it2) ON sjcond(ot2,it*) ->
+ |
+ +-------------------------------+
+ v
+ ot1 SEMI_JOIN{it1,it2} (it1 JOIN it2 JOIN ot2) ON sjcond(ot2,it*)
+
+ In order for this to work, subquery's top-level operation must be join, and
+ grouping or ordering with limit (grouping or ordering with limit are not
+ commutative with duplicate removal). In other words, the conversion is
+ possible when the subquery doesn't have GROUP BY clause, any aggregate
+ functions*, or ORDER BY ... LIMIT clause.
+
+ Definitions:
+ - Subquery whose top-level operation is a join is called *mergeable semi-join*
+ - All other kinds of semi-join subqueries are considered non-mergeable.
+
+ *- this requirement is actually too strong, but its exceptions are too
+ complicated to be considered here.
+
+ 3. Code-level view of semi-join processing
+ ------------------------------------------
+
+ 3.1 Conversion and pre-optimization data structures
+ ---------------------------------------------------
+ * When doing JOIN::prepare for the subquery, we detect that it can be
+ converted into a semi-join and register it in parent_join->sj_subselects
+
+ * At the start of parent_join->optimize(), the predicate is converted into
+ a semi-join node. A semi-join node is a TABLE_LIST object that is linked
+ somewhere in parent_join->join_list (either it is just present there, or
+ it is a descendant of some of its members).
+
+ There are two kinds of semi-joins:
+ - Merged semi-joins
+ - Non-merged semi-joins
+
+ 3.1.1 Merged semi-join TABLE_LIST object
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Merged semi-join object is a TABLE_LIST that contains a sub-join of
+ subquery tables and the semi-join ON expression (in this respect it is
+ very similar to nested outer join representation)
+ Merged semi-join represents this SQL:
+
+ ... SEMI JOIN (inner_tbl1 JOIN ... JOIN inner_tbl_n) ON sj_on_expr
+
+ Semi-join objects of this kind have TABLE_LIST::sj_subq_pred set.
+
+ 3.1.2 Non-merged semi-join data structure
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Non-merged semi-join object is a leaf TABLE_LIST object that has a subquery
+ that produces rows. It is similar to a base table and represents this SQL:
+
+ ... SEMI_JOIN (SELECT non_mergeable_select) ON sj_on_expr
+
+ Subquery items that were converted into semi-joins are removed from the WHERE
+ clause. (They do remain in PS-saved WHERE clause, and they replace themselves
+ with Item_int(1) on subsequent re-executions).
+
+ 3.2 Semi-joins and join optimization
+ ------------------------------------
+
+ 3.2.1 Non-merged semi-joins and join optimization
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ For join optimization purposes, non-merged semi-join nests are similar to
+ base tables - they've got one JOIN_TAB, which can be accessed with one of
+ two methods:
+ - full table scan (representing SJ-Materialization-Scan strategy)
+ - eq_ref-like table lookup (representing SJ-Materialization-Lookup)
+
+ Unlike regular base tables, non-merged semi-joins have:
+ - non-zero JOIN_TAB::startup_cost, and
+ - join_tab->table->is_filled_at_execution()==TRUE, which means one
+ cannot do const table detection or range analysis or other table data-
+ dependent inferences
+ // instead, get_delayed_table_estimates() runs optimization on the nest so that
+ // we get an idea about temptable size
+
+ 3.2.2 Merged semi-joins and join optimization
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ - optimize_semijoin_nests() does pre-optimization
+ - during join optimization, the join has one JOIN_TAB (or is it POSITION?)
+ array, and suffix-based detection is used, see advance_sj_state()
+ - after join optimization is done, get_best_combination() switches
+ the data-structure to prefix-based, multiple JOIN_TAB ranges format.
+
+ 3.3 Semi-joins and query execution
+ ----------------------------------
+ * Join executor has hooks for all semi-join strategies.
+ TODO elaborate.
+
+*/
+
+
static
bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
static bool replace_where_subcondition(JOIN *join, Item **expr,
@@ -25,10 +180,14 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
static int subq_sj_candidate_cmp(Item_in_subselect* const *el1,
Item_in_subselect* const *el2);
static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
+static bool convert_subq_to_jtbm(JOIN *parent_join,
+ Item_in_subselect *subq_pred, bool *remove);
static TABLE_LIST *alloc_join_nest(THD *thd);
-static
-void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist);
static uint get_tmp_table_rec_length(List<Item> &items);
+static double get_tmp_table_lookup_cost(THD *thd, double row_count,
+ uint row_size);
+static double get_tmp_table_write_cost(THD *thd, double row_count,
+ uint row_size);
bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables);
static SJ_MATERIALIZATION_INFO *
at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab,
@@ -46,27 +205,36 @@ static bool sj_table_is_included(JOIN *join, JOIN_TAB *join_tab);
static Item *remove_additional_cond(Item* conds);
static void remove_subq_pushed_predicates(JOIN *join, Item **where);
+enum_nested_loop_state
+end_sj_materialize(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
+
/*
Check if we need JOIN::prepare()-phase subquery rewrites and if yes, do them
+ SYNOPSIS
+ check_and_do_in_subquery_rewrites()
+ join Subquery's join
+
DESCRIPTION
Check if we need to do
- - subquery->semi-join rewrite
+ - subquery -> mergeable semi-join rewrite
- if the subquery can be handled with materialization
- 'substitution' rewrite for table-less subqueries like "(select 1)"
-
- and mark appropriately
+ - IN->EXISTS rewrite
+ and, depending on the rewrite, either do it, or record it to be done at a
+ later phase.
RETURN
- 0 - OK
- -1 - Some sort of query error
+ 0 - OK
+ Other - Some sort of query error
*/
int check_and_do_in_subquery_rewrites(JOIN *join)
{
THD *thd=join->thd;
st_select_lex *select_lex= join->select_lex;
+ st_select_lex_unit* parent_unit= select_lex->master_unit();
DBUG_ENTER("check_and_do_in_subquery_rewrites");
/*
If
@@ -85,11 +253,22 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
*/
Item_subselect *subselect;
if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) && // (1)
- (subselect= select_lex->master_unit()->item)) // (2)
+ (subselect= parent_unit->item)) // (2)
{
Item_in_subselect *in_subs= NULL;
- if (subselect->substype() == Item_subselect::IN_SUBS)
- in_subs= (Item_in_subselect*)subselect;
+ Item_allany_subselect *allany_subs= NULL;
+ switch (subselect->substype()) {
+ case Item_subselect::IN_SUBS:
+ in_subs= (Item_in_subselect *)subselect;
+ break;
+ case Item_subselect::ALL_SUBS:
+ case Item_subselect::ANY_SUBS:
+ allany_subs= (Item_allany_subselect *)subselect;
+ break;
+ default:
+ break;
+ }
+
/* Resolve expressions and perform semantic analysis for IN query */
if (in_subs != NULL)
@@ -129,6 +308,15 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
if (failure)
DBUG_RETURN(-1); /* purecov: deadcode */
}
+ if (select_lex == parent_unit->fake_select_lex)
+ {
+ /*
+ The join and its select_lex object represent the 'fake' select used
+ to compute the result of a UNION.
+ */
+ DBUG_RETURN(0);
+ }
+
DBUG_PRINT("info", ("Checking if subq can be converted to semi-join"));
/*
Check if we're in subquery that is a candidate for flattening into a
@@ -154,9 +342,9 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
!join->having && !select_lex->with_sum_func && // 4
thd->thd_marker.emb_on_expr_nest && // 5
select_lex->outer_select()->join && // 6
- select_lex->master_unit()->first_select()->leaf_tables && // 7
- in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED && // 8
- select_lex->outer_select()->leaf_tables && // 9
+ parent_unit->first_select()->leaf_tables.elements && // 7
+ !in_subs->in_strategy && // 8
+ select_lex->outer_select()->leaf_tables.elements && // 9
!((join->select_options | // 10
select_lex->outer_select()->join->select_options) // 10
& SELECT_STRAIGHT_JOIN)) // 10
@@ -166,72 +354,113 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
(void)subquery_types_allow_materialization(in_subs);
in_subs->emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest;
+ in_subs->is_flattenable_semijoin= TRUE;
/* Register the subquery for further processing in flatten_subqueries() */
select_lex->
outer_select()->join->sj_subselects.append(thd->mem_root, in_subs);
- in_subs->expr_join_nest= thd->thd_marker.emb_on_expr_nest;
}
else
{
- DBUG_PRINT("info", ("Subquery can't be converted to semi-join"));
+ DBUG_PRINT("info", ("Subquery can't be converted to merged semi-join"));
+ /* Test if the user has set a legal combination of optimizer switches. */
+ if (!optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) &&
+ !optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION))
+ my_error(ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES, MYF(0));
+
/*
- Check if the subquery predicate can be executed via materialization.
- The required conditions are:
- 1. Subquery predicate is an IN/=ANY subq predicate
- 2. Subquery is a single SELECT (not a UNION)
- 3. Subquery is not a table-less query. In this case there is no
- point in materializing.
- 3A The upper query is not a table-less SELECT ... FROM DUAL. We
+ If the subquery predicate is IN/=ANY, analyse and set all possible
+ subquery execution strategies based on optimizer switches and syntactic
+ properties.
+ */
+ if (in_subs)
+ {
+ /*
+ Check if the subquery predicate can be executed via materialization.
+ The required conditions are:
+ 0. The materialization optimizer switch was set.
+ 1. Subquery is a single SELECT (not a UNION).
+ TODO: this is a limitation that can be fixed
+ 2. Subquery is not a table-less query. In this case there is no
+ point in materializing.
+ 2A The upper query is not a table-less SELECT ... FROM DUAL. We
can't do materialization for SELECT .. FROM DUAL because it
does not call setup_subquery_materialization(). We could make
SELECT ... FROM DUAL call that function but that doesn't seem
to be the case that is worth handling.
- 4. Either the subquery predicate is a top-level predicate, or at
- least one partial match strategy is enabled. If no partial match
- strategy is enabled, then materialization cannot be used for
- non-top-level queries because it cannot handle NULLs correctly.
- 5. Subquery is non-correlated
- TODO:
- This is an overly restrictive condition. It can be extended to:
- (Subquery is non-correlated ||
- Subquery is correlated to any query outer to IN predicate ||
- (Subquery is correlated to the immediate outer query &&
- Subquery !contains {GROUP BY, ORDER BY [LIMIT],
- aggregate functions}) && subquery predicate is not under "NOT IN"))
- 6. No execution method was already chosen (by a prepared statement).
-
- (*) The subquery must be part of a SELECT statement. The current
- condition also excludes multi-table update statements.
-
- Determine whether we will perform subquery materialization before
- calling the IN=>EXISTS transformation, so that we know whether to
- perform the whole transformation or only that part of it which wraps
- Item_in_subselect in an Item_in_optimizer.
- */
- if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) &&
- in_subs && // 1
- !select_lex->is_part_of_union() && // 2
- select_lex->master_unit()->first_select()->leaf_tables && // 3
- thd->lex->sql_command == SQLCOM_SELECT && // *
- select_lex->outer_select()->leaf_tables && // 3A
- subquery_types_allow_materialization(in_subs) &&
- // psergey-todo: duplicated_subselect_card_check: where it's done?
- (in_subs->is_top_level_item() ||
- optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) ||
- optimizer_flag(thd, OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN)) &&//4
- !in_subs->is_correlated && // 5
- in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED) // 6
- {
- in_subs->exec_method= Item_in_subselect::MATERIALIZATION;
- }
+ 3. Either the subquery predicate is a top-level predicate, or at
+ least one partial match strategy is enabled. If no partial match
+ strategy is enabled, then materialization cannot be used for
+ non-top-level queries because it cannot handle NULLs correctly.
+ 4. Subquery is non-correlated
+ TODO:
+ This condition is too restrictive (limitation). It can be extended to:
+ (Subquery is non-correlated ||
+ Subquery is correlated to any query outer to IN predicate ||
+ (Subquery is correlated to the immediate outer query &&
+ Subquery !contains {GROUP BY, ORDER BY [LIMIT],
+ aggregate functions}) && subquery predicate is not under "NOT IN"))
+
+ (*) The subquery must be part of a SELECT statement. The current
+ condition also excludes multi-table update statements.
+ A note about prepared statements: we want the if-branch to be taken on
+ PREPARE and each EXECUTE. The rewrites are only done once, but we need
+ join->sj_subselects list to be populated for every EXECUTE.
- Item_subselect::trans_res trans_res;
- if ((trans_res= subselect->select_transformer(join)) !=
- Item_subselect::RES_OK)
- {
- DBUG_RETURN((trans_res == Item_subselect::RES_ERROR));
+ */
+ if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) && // 0
+ !select_lex->is_part_of_union() && // 1
+ parent_unit->first_select()->leaf_tables.elements && // 2
+ thd->lex->sql_command == SQLCOM_SELECT && // *
+ select_lex->outer_select()->leaf_tables.elements && // 2A
+ subquery_types_allow_materialization(in_subs) &&
+ (in_subs->is_top_level_item() || //3
+ optimizer_flag(thd,
+ OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) || //3
+ optimizer_flag(thd,
+ OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN)) && //3
+ !in_subs->is_correlated) //4
+ {
+ in_subs->in_strategy|= SUBS_MATERIALIZATION;
+
+ /*
+ If the subquery is an AND-part of WHERE register for being processed
+ with jtbm strategy
+ */
+ if (thd->thd_marker.emb_on_expr_nest == NO_JOIN_NEST &&
+ optimizer_flag(thd, OPTIMIZER_SWITCH_SEMIJOIN))
+ {
+ in_subs->emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest;
+ in_subs->is_flattenable_semijoin= FALSE;
+ select_lex->outer_select()->
+ join->sj_subselects.append(thd->mem_root, in_subs);
+ }
+ }
+
+ /*
+ IN-TO-EXISTS is the only universal strategy. Choose it if the user
+ allowed it via an optimizer switch, or if materialization is not
+ possible.
+ */
+ if (optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) ||
+ !in_subs->in_strategy)
+ {
+ in_subs->in_strategy|= SUBS_IN_TO_EXISTS;
+ }
}
+
+ /* Check if max/min optimization applicable */
+ if (allany_subs)
+ allany_subs->in_strategy|= (allany_subs->is_maxmin_applicable(join) ?
+ SUBS_MAXMIN :
+ SUBS_IN_TO_EXISTS);
+
+ /*
+ Transform each subquery predicate according to its overloaded
+ transformer.
+ */
+ if (subselect->select_transformer(join))
+ DBUG_RETURN(-1);
}
}
DBUG_RETURN(0);
@@ -308,29 +537,27 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs)
Item *inner= it++;
all_are_fields &= (outer->real_item()->type() == Item::FIELD_ITEM &&
inner->real_item()->type() == Item::FIELD_ITEM);
- if (outer->result_type() != inner->result_type())
+ if (outer->cmp_type() != inner->cmp_type())
DBUG_RETURN(FALSE);
- switch (outer->result_type()) {
+ switch (outer->cmp_type()) {
case STRING_RESULT:
- if (outer->is_datetime() != inner->is_datetime())
+ if (!(outer->collation.collation == inner->collation.collation))
DBUG_RETURN(FALSE);
-
- if (!(outer->collation.collation == inner->collation.collation
- /*&& outer->max_length <= inner->max_length */))
+ // Materialization does not work with BLOB columns
+ if (inner->field_type() == MYSQL_TYPE_BLOB ||
+ inner->field_type() == MYSQL_TYPE_GEOMETRY)
+ DBUG_RETURN(FALSE);
+ break;
+ case TIME_RESULT:
+ if (mysql_type_to_time_type(outer->field_type()) !=
+ mysql_type_to_time_type(outer->field_type()))
DBUG_RETURN(FALSE);
- /*case INT_RESULT:
- if (!(outer->unsigned_flag ^ inner->unsigned_flag))
- DBUG_RETURN(FALSE); */
default:
- ;/* suitable for materialization */
+ /* suitable for materialization */
+ break;
}
-
- // Materialization does not work with BLOB columns
- if (inner->field_type() == MYSQL_TYPE_BLOB ||
- inner->field_type() == MYSQL_TYPE_GEOMETRY)
- DBUG_RETURN(FALSE);
}
-
+
in_subs->types_allow_materialization= TRUE;
in_subs->sjm_scan_allowed= all_are_fields;
DBUG_PRINT("info",("subquery_types_allow_materialization: ok, allowed"));
@@ -338,6 +565,122 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs)
}
+/**
+ Apply max min optimization of all/any subselect
+*/
+
+bool JOIN::transform_max_min_subquery()
+{
+ DBUG_ENTER("JOIN::transform_max_min_subquery");
+ Item_subselect *subselect= unit->item;
+ if (!subselect || (subselect->substype() != Item_subselect::ALL_SUBS &&
+ subselect->substype() != Item_subselect::ANY_SUBS))
+ DBUG_RETURN(0);
+ DBUG_RETURN(((Item_allany_subselect *) subselect)->
+ transform_into_max_min(this));
+}
+
+
+/*
+ Finalize IN->EXISTS conversion in case we couldn't use materialization.
+
+ DESCRIPTION Invoke the IN->EXISTS converter
+ Replace the Item_in_subselect with its wrapper Item_in_optimizer in WHERE.
+
+ RETURN
+ FALSE - Ok
+ TRUE - Fatal error
+*/
+
+bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
+{
+ DBUG_ENTER("make_in_exists_conversion");
+ JOIN *child_join= item->unit->first_select()->join;
+ bool res;
+
+ /*
+ We're going to finalize IN->EXISTS conversion.
+ Normally, IN->EXISTS conversion takes place inside the
+ Item_subselect::fix_fields() call, where item_subselect->fixed==FALSE (as
+ fix_fields() haven't finished yet) and item_subselect->changed==FALSE (as
+ the conversion haven't been finalized)
+
+ At the end of Item_subselect::fix_fields() we had to set fixed=TRUE,
+ changed=TRUE (the only other option would have been to return error).
+
+ So, now we have to set these back for the duration of select_transformer()
+ call.
+ */
+ item->changed= 0;
+ item->fixed= 0;
+
+ SELECT_LEX *save_select_lex= thd->lex->current_select;
+ thd->lex->current_select= item->unit->first_select();
+
+ res= item->select_transformer(child_join);
+
+ thd->lex->current_select= save_select_lex;
+
+ if (res)
+ DBUG_RETURN(TRUE);
+
+ item->changed= 1;
+ item->fixed= 1;
+
+ Item *substitute= item->substitution;
+ bool do_fix_fields= !item->substitution->fixed;
+ /*
+ The Item_subselect has already been wrapped with Item_in_optimizer, so we
+ should search for item->optimizer, not 'item'.
+ */
+ Item *replace_me= item->optimizer;
+ DBUG_ASSERT(replace_me==substitute);
+
+ Item **tree= (item->emb_on_expr_nest == NO_JOIN_NEST)?
+ &join->conds : &(item->emb_on_expr_nest->on_expr);
+ if (replace_where_subcondition(join, tree, replace_me, substitute,
+ do_fix_fields))
+ DBUG_RETURN(TRUE);
+ item->substitution= NULL;
+
+ /*
+ If this is a prepared statement, repeat the above operation for
+ prep_where (or prep_on_expr).
+ */
+ if (!thd->stmt_arena->is_conventional())
+ {
+ tree= (item->emb_on_expr_nest == (TABLE_LIST*)NO_JOIN_NEST)?
+ &join->select_lex->prep_where :
+ &(item->emb_on_expr_nest->prep_on_expr);
+
+ if (replace_where_subcondition(join, tree, replace_me, substitute,
+ FALSE))
+ DBUG_RETURN(TRUE);
+ }
+ DBUG_RETURN(FALSE);
+}
+
+
+bool check_for_outer_joins(List<TABLE_LIST> *join_list)
+{
+ TABLE_LIST *table;
+ NESTED_JOIN *nested_join;
+ List_iterator<TABLE_LIST> li(*join_list);
+ while ((table= li++))
+ {
+ if ((nested_join= table->nested_join))
+ {
+ if (check_for_outer_joins(&nested_join->join_list))
+ return TRUE;
+ }
+
+ if (table->outer_join)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
/*
Convert semi-join subquery predicates into semi-join join nests
@@ -391,11 +734,25 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
Item_in_subselect **in_subq;
Item_in_subselect **in_subq_end;
THD *thd= join->thd;
+ List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
DBUG_ENTER("convert_join_subqueries_to_semijoins");
if (join->sj_subselects.elements() == 0)
DBUG_RETURN(FALSE);
+ for (in_subq= join->sj_subselects.front(),
+ in_subq_end= join->sj_subselects.back();
+ in_subq != in_subq_end;
+ in_subq++)
+ {
+ SELECT_LEX *subq_sel= (*in_subq)->get_select_lex();
+ if (subq_sel->handle_derived(thd->lex, DT_OPTIMIZE))
+ DBUG_RETURN(1);
+ if (subq_sel->handle_derived(thd->lex, DT_MERGE))
+ DBUG_RETURN(TRUE);
+ subq_sel->update_used_tables();
+ }
+
/* First, convert child join's subqueries. We proceed bottom-up here */
for (in_subq= join->sj_subselects.front(),
in_subq_end= join->sj_subselects.back();
@@ -404,7 +761,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
{
st_select_lex *child_select= (*in_subq)->get_select_lex();
JOIN *child_join= child_select->join;
- child_join->outer_tables = child_join->tables;
+ child_join->outer_tables = child_join->table_count;
/*
child_select->where contains only the WHERE predicate of the
@@ -422,16 +779,11 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
// Temporary measure: disable semi-joins when they are together with outer
// joins.
- for (TABLE_LIST *tbl= join->select_lex->leaf_tables; tbl; tbl=tbl->next_leaf)
+ if (check_for_outer_joins(join->join_list))
{
- TABLE_LIST *embedding= tbl->embedding;
- if (tbl->on_expr || (tbl->embedding && !(embedding->sj_on_expr &&
- !embedding->embedding)))
- {
- in_subq= join->sj_subselects.front();
- arena= thd->activate_stmt_arena_if_needed(&backup);
- goto skip_conversion;
- }
+ in_subq= join->sj_subselects.front();
+ arena= thd->activate_stmt_arena_if_needed(&backup);
+ goto skip_conversion;
}
//dump_TABLE_LIST_struct(select_lex, select_lex->leaf_tables);
@@ -445,25 +797,36 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
// #tables-in-parent-query + #tables-in-subquery < MAX_TABLES
/* Replace all subqueries to be flattened with Item_int(1) */
arena= thd->activate_stmt_arena_if_needed(&backup);
- for (in_subq= join->sj_subselects.front();
- in_subq != in_subq_end &&
- join->tables + (*in_subq)->unit->first_select()->join->tables < MAX_TABLES;
- in_subq++)
- {
- Item **tree= ((*in_subq)->emb_on_expr_nest == (TABLE_LIST*)1)?
- &join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
- if (replace_where_subcondition(join, tree, *in_subq, new Item_int(1),
- FALSE))
- DBUG_RETURN(TRUE); /* purecov: inspected */
- }
for (in_subq= join->sj_subselects.front();
- in_subq != in_subq_end &&
- join->tables + (*in_subq)->unit->first_select()->join->tables < MAX_TABLES;
+ in_subq != in_subq_end;
in_subq++)
{
- if (convert_subq_to_sj(join, *in_subq))
- DBUG_RETURN(TRUE);
+ bool remove_item= TRUE;
+ if ((*in_subq)->is_flattenable_semijoin)
+ {
+ if (join->table_count +
+ (*in_subq)->unit->first_select()->join->table_count >= MAX_TABLES)
+ break;
+ if (convert_subq_to_sj(join, *in_subq))
+ DBUG_RETURN(TRUE);
+ }
+ else
+ {
+ if (join->table_count + 1 >= MAX_TABLES)
+ break;
+ if (convert_subq_to_jtbm(join, *in_subq, &remove_item))
+ DBUG_RETURN(TRUE);
+ }
+ if (remove_item)
+ {
+ Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
+ &join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
+ Item *replace_me= (*in_subq)->original_item();
+ if (replace_where_subcondition(join, tree, replace_me, new Item_int(1),
+ FALSE))
+ DBUG_RETURN(TRUE); /* purecov: inspected */
+ }
}
skip_conversion:
/*
@@ -473,18 +836,17 @@ skip_conversion:
for (; in_subq!= in_subq_end; in_subq++)
{
JOIN *child_join= (*in_subq)->unit->first_select()->join;
- Item_subselect::trans_res res;
(*in_subq)->changed= 0;
(*in_subq)->fixed= 0;
SELECT_LEX *save_select_lex= thd->lex->current_select;
thd->lex->current_select= (*in_subq)->unit->first_select();
- res= (*in_subq)->select_transformer(child_join);
+ bool res= (*in_subq)->select_transformer(child_join);
thd->lex->current_select= save_select_lex;
- if (res == Item_subselect::RES_ERROR)
+ if (res)
DBUG_RETURN(TRUE);
(*in_subq)->changed= 1;
@@ -492,23 +854,38 @@ skip_conversion:
Item *substitute= (*in_subq)->substitution;
bool do_fix_fields= !(*in_subq)->substitution->fixed;
- Item **tree= ((*in_subq)->emb_on_expr_nest == (TABLE_LIST*)1)?
+ Item **tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
&join->conds : &((*in_subq)->emb_on_expr_nest->on_expr);
- if (replace_where_subcondition(join, tree, *in_subq, substitute,
+ Item *replace_me= (*in_subq)->original_item();
+ if (replace_where_subcondition(join, tree, replace_me, substitute,
do_fix_fields))
DBUG_RETURN(TRUE);
(*in_subq)->substitution= NULL;
-
+
+ /*
+ If this is a prepared statement, repeat the above operation for
+ prep_where (or prep_on_expr). Subquery-to-semijoin conversion is
+ done once for prepared statement.
+ */
if (!thd->stmt_arena->is_conventional())
{
- tree= ((*in_subq)->emb_on_expr_nest == (TABLE_LIST*)1)?
+ tree= ((*in_subq)->emb_on_expr_nest == NO_JOIN_NEST)?
&join->select_lex->prep_where :
&((*in_subq)->emb_on_expr_nest->prep_on_expr);
- if (replace_where_subcondition(join, tree, *in_subq, substitute,
+ if (replace_where_subcondition(join, tree, replace_me, substitute,
FALSE))
DBUG_RETURN(TRUE);
}
+ /*
+ Revert to the IN->EXISTS strategy in the rare case when the subquery could
+ not be flattened.
+ TODO: This is a limitation done for simplicity. Such subqueries could also
+ be executed via materialization. In order to determine this, we should
+ re-run the test for materialization that was done in
+ check_and_do_in_subquery_rewrites.
+ */
+ (*in_subq)->in_strategy= SUBS_IN_TO_EXISTS;
}
if (arena)
@@ -517,6 +894,52 @@ skip_conversion:
DBUG_RETURN(FALSE);
}
+
+/*
+ Get #output_rows and scan_time estimates for a "delayed" table.
+
+ SYNOPSIS
+ get_delayed_table_estimates()
+ table IN Table to get estimates for
+ out_rows OUT E(#rows in the table)
+ scan_time OUT E(scan_time).
+ startup_cost OUT cost to populate the table.
+
+ DESCRIPTION
+ Get #output_rows and scan_time estimates for a "delayed" table. By
+ "delayed" here we mean that the table is filled at the start of query
+ execution. This means that the optimizer can't use table statistics to
+ get #rows estimate for it, it has to call this function instead.
+
+ This function is expected to make different actions depending on the nature
+ of the table. At the moment there is only one kind of delayed tables,
+ non-flattenable semi-joins.
+*/
+
+void get_delayed_table_estimates(TABLE *table,
+ ha_rows *out_rows,
+ double *scan_time,
+ double *startup_cost)
+{
+ Item_in_subselect *item= table->pos_in_table_list->jtbm_subselect;
+
+ DBUG_ASSERT(item->engine->engine_type() ==
+ subselect_engine::HASH_SJ_ENGINE);
+
+ subselect_hash_sj_engine *hash_sj_engine=
+ ((subselect_hash_sj_engine*)item->engine);
+
+ *out_rows= (ha_rows)item->jtbm_record_count;
+ *startup_cost= item->jtbm_read_time;
+
+ /* Calculate cost of scanning the temptable */
+ double data_size= item->jtbm_record_count *
+ hash_sj_engine->tmp_table->s->reclength;
+ /* Do like in handler::read_time */
+ *scan_time= data_size/IO_SIZE + 2;
+}
+
+
/**
@brief Replaces an expression destructively inside the expression tree of
the WHERE clase.
@@ -534,6 +957,7 @@ skip_conversion:
@return <code>true</code> if there was an error, <code>false</code> if
successful.
*/
+
static bool replace_where_subcondition(JOIN *join, Item **expr,
Item *old_cond, Item *new_cond,
bool do_fix_fields)
@@ -615,9 +1039,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
1. Find out where to put the predicate into.
Note: for "t1 LEFT JOIN t2" this will be t2, a leaf.
*/
- if ((void*)subq_pred->expr_join_nest != (void*)1)
+ if ((void*)subq_pred->emb_on_expr_nest != (void*)NO_JOIN_NEST)
{
- if (subq_pred->expr_join_nest->nested_join)
+ if (subq_pred->emb_on_expr_nest->nested_join)
{
/*
We're dealing with
@@ -626,10 +1050,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
The sj-nest will be inserted into the brackets nest.
*/
- emb_tbl_nest= subq_pred->expr_join_nest;
+ emb_tbl_nest= subq_pred->emb_on_expr_nest;
emb_join_list= &emb_tbl_nest->nested_join->join_list;
}
- else if (!subq_pred->expr_join_nest->outer_join)
+ else if (!subq_pred->emb_on_expr_nest->outer_join)
{
/*
We're dealing with
@@ -639,13 +1063,13 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
The sj-nest will be tblX's "sibling", i.e. another child of its
parent. This is ok because tblX is joined as an inner join.
*/
- emb_tbl_nest= subq_pred->expr_join_nest->embedding;
+ emb_tbl_nest= subq_pred->emb_on_expr_nest->embedding;
if (emb_tbl_nest)
emb_join_list= &emb_tbl_nest->nested_join->join_list;
}
- else if (!subq_pred->expr_join_nest->nested_join)
+ else if (!subq_pred->emb_on_expr_nest->nested_join)
{
- TABLE_LIST *outer_tbl= subq_pred->expr_join_nest;
+ TABLE_LIST *outer_tbl= subq_pred->emb_on_expr_nest;
TABLE_LIST *wrap_nest;
/*
We're dealing with
@@ -737,7 +1161,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
st_select_lex *subq_lex= subq_pred->unit->first_select();
nested_join->join_list.empty();
List_iterator_fast<TABLE_LIST> li(subq_lex->top_join_list);
- TABLE_LIST *tl, *last_leaf;
+ TABLE_LIST *tl;
while ((tl= li++))
{
tl->embedding= sj_nest;
@@ -752,31 +1176,29 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
NOTE: We actually insert them at the front! That's because the order is
reversed in this list.
*/
- for (tl= parent_lex->leaf_tables; tl->next_leaf; tl= tl->next_leaf) ;
- tl->next_leaf= subq_lex->leaf_tables;
- last_leaf= tl;
+ parent_lex->leaf_tables.concat(&subq_lex->leaf_tables);
/*
Same as above for next_local chain
(a theory: a next_local chain always starts with ::leaf_tables
because view's tables are inserted after the view)
*/
- for (tl= parent_lex->leaf_tables; tl->next_local; tl= tl->next_local) ;
- tl->next_local= subq_lex->leaf_tables;
+ for (tl= parent_lex->leaf_tables.head(); tl->next_local; tl= tl->next_local) ;
+ tl->next_local= subq_lex->leaf_tables.head();
/* A theory: no need to re-connect the next_global chain */
/* 3. Remove the original subquery predicate from the WHERE/ON */
// The subqueries were replaced for Item_int(1) earlier
- subq_pred->exec_method=
- Item_in_subselect::SEMI_JOIN; // for subsequent executions
+ subq_pred->in_strategy= SUBS_SEMI_JOIN; // for subsequent executions
/*TODO: also reset the 'with_subselect' there. */
- /* n. Adjust the parent_join->tables counter */
- uint table_no= parent_join->tables;
+ /* n. Adjust the parent_join->table_count counter */
+ uint table_no= parent_join->table_count;
/* n. Walk through child's tables and adjust table->map */
- for (tl= subq_lex->leaf_tables; tl; tl= tl->next_leaf, table_no++)
+ List_iterator_fast<TABLE_LIST> si(subq_lex->leaf_tables);
+ while ((tl= si++))
{
tl->table->tablenr= table_no;
tl->table->map= ((table_map)1) << table_no;
@@ -786,8 +1208,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
emb && emb->select_lex == old_sl;
emb= emb->embedding)
emb->select_lex= parent_join->select_lex;
+ table_no++;
}
- parent_join->tables += subq_lex->join->tables;
+ parent_join->table_count += subq_lex->join->table_count;
/*
Put the subquery's WHERE into semi-join's sj_on_expr
@@ -845,7 +1268,8 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
}
}
/* Fix the created equality and AND */
- sj_nest->sj_on_expr->fix_fields(parent_join->thd, &sj_nest->sj_on_expr);
+ if (!sj_nest->sj_on_expr->fixed)
+ sj_nest->sj_on_expr->fix_fields(parent_join->thd, &sj_nest->sj_on_expr);
/*
Walk through sj nest's WHERE and ON expressions and call
@@ -866,13 +1290,23 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
{
emb_tbl_nest->on_expr= and_items(emb_tbl_nest->on_expr,
sj_nest->sj_on_expr);
- emb_tbl_nest->on_expr->fix_fields(parent_join->thd, &emb_tbl_nest->on_expr);
+ if (!emb_tbl_nest->on_expr->fixed)
+ emb_tbl_nest->on_expr->fix_fields(parent_join->thd,
+ &emb_tbl_nest->on_expr);
}
else
{
/* Inject into the WHERE */
parent_join->conds= and_items(parent_join->conds, sj_nest->sj_on_expr);
- parent_join->conds->fix_fields(parent_join->thd, &parent_join->conds);
+ /*
+ fix_fields must update the properties (e.g. st_select_lex::cond_count of
+ the correct select_lex.
+ */
+ save_lex= thd->lex->current_select;
+ thd->lex->current_select=parent_join->select_lex;
+ if (!parent_join->conds->fixed)
+ parent_join->conds->fix_fields(parent_join->thd, &parent_join->conds);
+ thd->lex->current_select=save_lex;
parent_join->select_lex->where= parent_join->conds;
}
@@ -887,6 +1321,138 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
DBUG_RETURN(FALSE);
}
+
+const int SUBQERY_TEMPTABLE_NAME_MAX_LEN= 20;
+
+static void create_subquery_temptable_name(char *to, uint number)
+{
+ DBUG_ASSERT(number < 10000);
+ to= strmov(to, "<subquery");
+ to= int10_to_str((int) number, to, 10);
+ to[0]= '>';
+ to[1]= 0;
+}
+
+
+/*
+ Convert subquery predicate into non-mergeable semi-join nest.
+
+ TODO:
+ why does this do IN-EXISTS conversion? Can't we unify it with mergeable
+ semi-joins? currently, convert_subq_to_sj() cannot fail to convert (unless
+ fatal errors)
+
+
+ RETURN
+ FALSE - Ok
+ TRUE - Fatal error
+*/
+
+static bool convert_subq_to_jtbm(JOIN *parent_join,
+ Item_in_subselect *subq_pred,
+ bool *remove_item)
+{
+ SELECT_LEX *parent_lex= parent_join->select_lex;
+ List<TABLE_LIST> *emb_join_list= &parent_lex->top_join_list;
+ TABLE_LIST *emb_tbl_nest= NULL; // will change when we learn to handle outer joins
+ TABLE_LIST *tl;
+ double rows;
+ double read_time;
+ DBUG_ENTER("convert_subq_to_jtbm");
+
+ subq_pred->in_strategy &= ~SUBS_IN_TO_EXISTS;
+ subq_pred->optimize(&rows, &read_time);
+
+ subq_pred->jtbm_read_time= read_time;
+ subq_pred->jtbm_record_count=rows;
+ subq_pred->is_jtbm_merged= TRUE;
+
+ if (subq_pred->engine->engine_type() != subselect_engine::HASH_SJ_ENGINE)
+ {
+ *remove_item= FALSE;
+ DBUG_RETURN(FALSE);
+ }
+
+
+ *remove_item= TRUE;
+
+ TABLE_LIST *jtbm;
+ char *tbl_alias;
+ if (!(tbl_alias= (char*)parent_join->thd->calloc(SUBQERY_TEMPTABLE_NAME_MAX_LEN)) ||
+ !(jtbm= alloc_join_nest(parent_join->thd))) //todo: this is not a join nest!
+ {
+ DBUG_RETURN(TRUE);
+ }
+
+ jtbm->join_list= emb_join_list;
+ jtbm->embedding= emb_tbl_nest;
+ jtbm->jtbm_subselect= subq_pred;
+ jtbm->nested_join= NULL;
+
+ /* Nests do not participate in those 'chains', so: */
+ /* jtbm->next_leaf= jtbm->next_local= jtbm->next_global == NULL*/
+ emb_join_list->push_back(jtbm);
+
+ /*
+ Inject the jtbm table into TABLE_LIST::next_leaf list, so that
+ make_join_statistics() and co. can find it.
+ */
+ parent_lex->leaf_tables.push_back(jtbm);
+
+ /*
+ Same as above for TABLE_LIST::next_local chain
+ (a theory: a next_local chain always starts with ::leaf_tables
+ because view's tables are inserted after the view)
+ */
+ for (tl= parent_lex->leaf_tables.head(); tl->next_local; tl= tl->next_local)
+ {}
+ tl->next_local= jtbm;
+
+ /* A theory: no need to re-connect the next_global chain */
+
+ subselect_hash_sj_engine *hash_sj_engine=
+ ((subselect_hash_sj_engine*)subq_pred->engine);
+ jtbm->table= hash_sj_engine->tmp_table;
+
+ jtbm->table->tablenr= parent_join->table_count;
+ jtbm->table->map= table_map(1) << (parent_join->table_count);
+ jtbm->jtbm_table_no= jtbm->table->tablenr;
+
+ parent_join->table_count++;
+ DBUG_ASSERT(parent_join->table_count < MAX_TABLES);
+
+ Item *conds= hash_sj_engine->semi_join_conds;
+ conds->fix_after_pullout(parent_lex, &conds);
+
+ DBUG_EXECUTE("where", print_where(conds,"SJ-EXPR", QT_ORDINARY););
+
+ create_subquery_temptable_name(tbl_alias, hash_sj_engine->materialize_join->
+ select_lex->select_number);
+ jtbm->alias= tbl_alias;
+#if 0
+ /* Inject sj_on_expr into the parent's WHERE or ON */
+ if (emb_tbl_nest)
+ {
+ DBUG_ASSERT(0);
+ /*emb_tbl_nest->on_expr= and_items(emb_tbl_nest->on_expr,
+ sj_nest->sj_on_expr);
+ emb_tbl_nest->on_expr->fix_fields(parent_join->thd, &emb_tbl_nest->on_expr);
+ */
+ }
+ else
+ {
+ /* Inject into the WHERE */
+ parent_join->conds= and_items(parent_join->conds, conds);
+ parent_join->conds->fix_fields(parent_join->thd, &parent_join->conds);
+ parent_join->select_lex->where= parent_join->conds;
+ }
+#endif
+ /* Don't unlink the child subselect, as the subquery will be used. */
+
+ DBUG_RETURN(FALSE);
+}
+
+
static TABLE_LIST *alloc_join_nest(THD *thd)
{
TABLE_LIST *tbl;
@@ -899,7 +1465,6 @@ static TABLE_LIST *alloc_join_nest(THD *thd)
}
-static
void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist)
{
List_iterator<TABLE_LIST> it(*tlist);
@@ -1167,8 +1732,16 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
sjm->tables= n_tables;
sjm->is_used= FALSE;
double subjoin_out_rows, subjoin_read_time;
- get_partial_join_cost(join, n_tables,
- &subjoin_read_time, &subjoin_out_rows);
+
+ /*
+ join->get_partial_cost_and_fanout(n_tables + join->const_tables,
+ table_map(-1),
+ &subjoin_read_time,
+ &subjoin_out_rows);
+ */
+ join->get_prefix_cost_and_fanout(n_tables,
+ &subjoin_read_time,
+ &subjoin_out_rows);
sjm->materialization_cost.convert_from_cost(subjoin_read_time);
sjm->rows= subjoin_out_rows;
@@ -1189,6 +1762,8 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
"oe IN (SELECT t.key ...)" it is trivial.
- Functional dependencies between the tables in the semi-join
nest (the payoff is probably less here?)
+
+ See also get_post_group_estimate().
*/
{
for (uint i=0 ; i < join->const_tables + sjm->tables ; i++)
@@ -1216,17 +1791,16 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
Calculate temporary table parameters and usage costs
*/
uint rowlen= get_tmp_table_rec_length(right_expr_list);
- double lookup_cost;
- if (rowlen * subjoin_out_rows< join->thd->variables.max_heap_table_size)
- lookup_cost= HEAP_TEMPTABLE_LOOKUP_COST;
- else
- lookup_cost= DISK_TEMPTABLE_LOOKUP_COST;
+ double lookup_cost= get_tmp_table_lookup_cost(join->thd,
+ subjoin_out_rows, rowlen);
+ double write_cost= get_tmp_table_write_cost(join->thd,
+ subjoin_out_rows, rowlen);
/*
Let materialization cost include the cost to write the data into the
temporary table:
*/
- sjm->materialization_cost.add_io(subjoin_out_rows, lookup_cost);
+ sjm->materialization_cost.add_io(subjoin_out_rows, write_cost);
/*
Set the cost to do a full scan of the temptable (will need this to
@@ -1245,6 +1819,7 @@ bool optimize_semijoin_nests(JOIN *join, table_map all_table_map)
DBUG_RETURN(FALSE);
}
+
/*
Get estimated record length for semi-join materialization temptable
@@ -1301,7 +1876,51 @@ static uint get_tmp_table_rec_length(List<Item> &items)
return len;
}
-//psergey-todo: is the below a kind of table elimination??
+
+/**
+ The cost of a lookup into a unique hash/btree index on a temporary table
+ with 'row_count' rows each of size 'row_size'.
+
+ @param thd current query context
+ @param row_count number of rows in the temp table
+ @param row_size average size in bytes of the rows
+
+ @return the cost of one lookup
+*/
+
+static double
+get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size)
+{
+ if (row_count * row_size > thd->variables.max_heap_table_size)
+ return (double) DISK_TEMPTABLE_LOOKUP_COST;
+ else
+ return (double) HEAP_TEMPTABLE_LOOKUP_COST;
+}
+
+/**
+ The cost of writing a row into a temporary table with 'row_count' unique
+ rows each of size 'row_size'.
+
+ @param thd current query context
+ @param row_count number of rows in the temp table
+ @param row_size average size in bytes of the rows
+
+ @return the cost of writing one row
+*/
+
+static double
+get_tmp_table_write_cost(THD *thd, double row_count, uint row_size)
+{
+ double lookup_cost= get_tmp_table_lookup_cost(thd, row_count, row_size);
+ /*
+ TODO:
+ This is an optimistic estimate. Add additional costs resulting from
+ actually writing the row to memory/disk and possible index reorganization.
+ */
+ return lookup_cost;
+}
+
+
/*
Check if table's KEYUSE elements have an eq_ref(outer_tables) candidate
@@ -1318,6 +1937,8 @@ static uint get_tmp_table_rec_length(List<Item> &items)
Check again if it is feasible to factor common parts with constant table
search
+ Also check if it's feasible to factor common parts with table elimination
+
RETURN
TRUE - There exists an eq_ref(outer-tables) candidate
FALSE - Otherwise
@@ -1368,6 +1989,7 @@ bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables)
return FALSE;
}
+
/*
Do semi-join optimization step after we've added a new tab to join prefix
@@ -1424,15 +2046,17 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
TABLE_LIST *emb_sj_nest;
POSITION *pos= join->positions + idx;
remaining_tables &= ~new_join_tab->table->map;
+ bool disable_jbuf= join->thd->variables.join_cache_level == 0;
pos->prefix_cost.convert_from_cost(*current_read_time);
pos->prefix_record_count= *current_record_count;
pos->sj_strategy= SJ_OPT_NONE;
+ pos->prefix_dups_producing_tables= join->cur_dups_producing_tables;
/* Initialize the state or copy it from prev. tables */
if (idx == join->const_tables)
{
- pos->first_firstmatch_table= MAX_TABLES;
+ pos->invalidate_firstmatch_prefix();
pos->first_loosescan_table= MAX_TABLES;
pos->dupsweedout_tables= 0;
pos->sjm_scan_need_tables= 0;
@@ -1497,7 +2121,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
pos->first_firstmatch_rtbl= remaining_tables;
}
- if (pos->first_firstmatch_table != MAX_TABLES)
+ if (pos->in_firstmatch_prefix())
{
if (outer_corr_tables & pos->first_firstmatch_rtbl)
{
@@ -1505,7 +2129,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
Trying to add an sj-inner table whose sj-nest has an outer correlated
table that was not in the prefix. This means FirstMatch can't be used.
*/
- pos->first_firstmatch_table= MAX_TABLES;
+ pos->invalidate_firstmatch_prefix();
}
else
{
@@ -1513,7 +2137,8 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
pos->firstmatch_need_tables|= sj_inner_tables;
}
- if (!(pos->firstmatch_need_tables & remaining_tables))
+ if (pos->in_firstmatch_prefix() &&
+ !(pos->firstmatch_need_tables & remaining_tables))
{
/*
Got a complete FirstMatch range.
@@ -1589,7 +2214,8 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
optimize_wo_join_buffering(join, pos->first_loosescan_table, idx,
remaining_tables,
TRUE, //first_alt
- pos->first_loosescan_table + n_tables,
+ disable_jbuf ? join->table_count :
+ pos->first_loosescan_table + n_tables,
current_record_count,
current_read_time);
/*
@@ -1728,8 +2354,8 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
/* Need to re-run best-access-path as we prefix_rec_count has changed */
for (i= first_tab + mat_info->tables; i <= idx; i++)
{
- best_access_path(join, join->positions[i].table, rem_tables, i, FALSE,
- prefix_rec_count, &curpos, &dummy);
+ best_access_path(join, join->positions[i].table, rem_tables, i,
+ disable_jbuf, prefix_rec_count, &curpos, &dummy);
prefix_rec_count *= curpos.records_read;
prefix_cost += curpos.read_time;
}
@@ -1830,15 +2456,15 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
- sj_inner_fanout*sj_outer_fanout lookups.
*/
- double one_lookup_cost;
- if (sj_outer_fanout*temptable_rec_size >
- join->thd->variables.max_heap_table_size)
- one_lookup_cost= DISK_TEMPTABLE_LOOKUP_COST;
- else
- one_lookup_cost= HEAP_TEMPTABLE_LOOKUP_COST;
+ double one_lookup_cost= get_tmp_table_lookup_cost(join->thd,
+ sj_outer_fanout,
+ temptable_rec_size);
+ double one_write_cost= get_tmp_table_write_cost(join->thd,
+ sj_outer_fanout,
+ temptable_rec_size);
double write_cost= join->positions[first_tab].prefix_record_count*
- sj_outer_fanout * one_lookup_cost;
+ sj_outer_fanout * one_write_cost;
double full_lookup_cost= join->positions[first_tab].prefix_record_count*
sj_outer_fanout* sj_inner_fanout *
one_lookup_cost;
@@ -1861,7 +2487,6 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
}
}
}
- pos->prefix_dups_producing_tables= join->cur_dups_producing_tables;
}
@@ -2027,7 +2652,7 @@ at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab,
void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
{
- uint table_count=join->tables;
+ uint table_count=join->table_count;
uint tablenr;
table_map remaining_tables= 0;
table_map handled_tabs= 0;
@@ -2089,8 +2714,9 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
join->cur_sj_inner_tables= 0;
for (i= first + sjm->tables; i <= tablenr; i++)
{
- best_access_path(join, join->best_positions[i].table, rem_tables, i, FALSE,
- prefix_rec_count, join->best_positions + i, &dummy);
+ best_access_path(join, join->best_positions[i].table, rem_tables, i,
+ FALSE, prefix_rec_count,
+ join->best_positions + i, &dummy);
prefix_rec_count *= join->best_positions[i].records_read;
rem_tables &= ~join->best_positions[i].table->table->map;
}
@@ -2188,9 +2814,11 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
remaining_tables |= s->table->map;
//s->sj_strategy= pos->sj_strategy;
join->join_tab[first].sj_strategy= join->best_positions[first].sj_strategy;
+ join->join_tab[first].n_sj_tables= join->best_positions[first].n_sj_tables;
}
}
+
/*
Setup semi-join materialization strategy for one semi-join nest
@@ -2212,10 +2840,11 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
TRUE Error
*/
-bool setup_sj_materialization(JOIN_TAB *tab)
+bool setup_sj_materialization(JOIN_TAB *sjm_tab)
{
uint i;
DBUG_ENTER("setup_sj_materialization");
+ JOIN_TAB *tab= sjm_tab->bush_children->start;
TABLE_LIST *emb_sj_nest= tab->table->pos_in_table_list->embedding;
SJ_MATERIALIZATION_INFO *sjm= emb_sj_nest->sj_mat_info;
THD *thd= tab->join->thd;
@@ -2243,10 +2872,13 @@ bool setup_sj_materialization(JOIN_TAB *tab)
DBUG_RETURN(TRUE); /* purecov: inspected */
sjm->table->file->extra(HA_EXTRA_WRITE_CACHE);
sjm->table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
+
tab->join->sj_tmp_tables.push_back(sjm->table);
tab->join->sjm_info_list.push_back(sjm);
sjm->materialized= FALSE;
+ sjm_tab->table= sjm->table;
+
if (!sjm->is_sj_scan)
{
KEY *tmp_key; /* The only index on the temporary table. */
@@ -2259,8 +2891,7 @@ bool setup_sj_materialization(JOIN_TAB *tab)
temptable.
*/
TABLE_REF *tab_ref;
- if (!(tab_ref= (TABLE_REF*) thd->alloc(sizeof(TABLE_REF))))
- DBUG_RETURN(TRUE); /* purecov: inspected */
+ tab_ref= &sjm_tab->ref;
tab_ref->key= 0; /* The only temp table index. */
tab_ref->key_length= tmp_key->key_length;
if (!(tab_ref->key_buff=
@@ -2293,12 +2924,22 @@ bool setup_sj_materialization(JOIN_TAB *tab)
use that information instead.
*/
cur_ref_buff + null_count,
- null_count ? tab_ref->key_buff : 0,
+ null_count ? cur_ref_buff : 0,
cur_key_part->length, tab_ref->items[i],
FALSE);
cur_ref_buff+= cur_key_part->store_length;
}
*ref_key= NULL; /* End marker. */
+
+ /*
+ We don't ever have guarded conditions for SJM tables, but code at SQL
+ layer depends on cond_guards array being alloced.
+ */
+ if (!(tab_ref->cond_guards= (bool**) thd->calloc(sizeof(uint*)*tmp_key_parts)))
+ {
+ DBUG_RETURN(TRUE);
+ }
+
tab_ref->key_err= 1;
tab_ref->key_parts= tmp_key_parts;
sjm->tab_ref= tab_ref;
@@ -2318,6 +2959,8 @@ bool setup_sj_materialization(JOIN_TAB *tab)
if (!(sjm->in_equality= create_subq_in_equalities(thd, sjm,
emb_sj_nest->sj_subq_pred)))
DBUG_RETURN(TRUE); /* purecov: inspected */
+ sjm_tab->type= JT_EQ_REF;
+ sjm_tab->select_cond= sjm->in_equality;
}
else
{
@@ -2370,9 +3013,11 @@ bool setup_sj_materialization(JOIN_TAB *tab)
then substitute_for_best_equal_field() will change the conditions
according to the join order:
- it1
- it2 it1.col=it2.col
- ot cond(it1.col)
+ table | attached condition
+ ------+--------------------
+ it1 |
+ it2 | it1.col=it2.col
+ ot | cond(it1.col)
although we've originally had "SELECT it2.col", conditions attached
to subsequent outer tables will refer to it1.col, so SJM-Scan will
@@ -2401,8 +3046,18 @@ bool setup_sj_materialization(JOIN_TAB *tab)
/* The write_set for source tables must be set up to allow the copying */
bitmap_set_bit(copy_to->table->write_set, copy_to->field_index);
}
+ sjm_tab->type= JT_ALL;
+
+ /* Initialize full scan */
+ sjm_tab->read_first_record= join_read_record_no_init;
+ sjm_tab->read_record.copy_field= sjm->copy_field;
+ sjm_tab->read_record.copy_field_end= sjm->copy_field +
+ sjm->sjm_table_cols.elements;
+ sjm_tab->read_record.read_record= rr_sequential_and_unpack;
}
+ sjm_tab->bush_children->end[-1].next_select= end_sj_materialize;
+
DBUG_RETURN(FALSE);
}
@@ -2624,7 +3279,6 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
init_tmp_table_share(thd, share, "", 0, tmpname, tmpname);
share->blob_field= blob_field;
share->blob_ptr_size= portable_sizeof_char_ptr;
- share->db_low_byte_first=1; // True for HEAP and MyISAM
share->table_charset= NULL;
share->primary_key= MAX_KEY; // Indicate no primary key
share->keys_for_keyread.init();
@@ -2873,7 +3527,6 @@ int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
}
ptr= sjtbl->tmp_table->record[0] + 1;
- nulls_ptr= ptr;
/* Put the the rowids tuple into table->record[0]: */
@@ -2889,6 +3542,7 @@ int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl)
ptr += 2;
}
+ nulls_ptr= ptr;
// 2. Zero the null bytes
if (sjtbl->null_bytes)
{
@@ -3030,17 +3684,19 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
uint i;
THD *thd= join->thd;
DBUG_ENTER("setup_semijoin_dups_elimination");
-
- for (i= join->const_tables ; i < join->tables; )
+
+ POSITION *pos= join->best_positions + join->const_tables;
+ for (i= join->const_tables ; i < join->top_join_tab_count; )
{
JOIN_TAB *tab=join->join_tab + i;
- POSITION *pos= join->best_positions + i;
+ //POSITION *pos= join->best_positions + i;
uint keylen, keyno;
switch (pos->sj_strategy) {
case SJ_OPT_MATERIALIZE:
case SJ_OPT_MATERIALIZE_SCAN:
/* Do nothing */
- i+= pos->n_sj_tables;
+ i+= 1;// It used to be pos->n_sj_tables, but now they are embedded in a nest
+ pos += pos->n_sj_tables;
break;
case SJ_OPT_LOOSE_SCAN:
{
@@ -3057,6 +3713,7 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
if (pos->n_sj_tables > 1)
tab[pos->n_sj_tables - 1].do_firstmatch= tab;
i+= pos->n_sj_tables;
+ pos+= pos->n_sj_tables;
break;
}
case SJ_OPT_DUPS_WEEDOUT:
@@ -3120,7 +3777,7 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
SJ_TMP_TABLE *sjtbl;
if (jt_rowid_offset) /* Temptable has at least one rowid */
{
- uint tabs_size= (last_tab - sjtabs) * sizeof(SJ_TMP_TABLE::TAB);
+ size_t tabs_size= (last_tab - sjtabs) * sizeof(SJ_TMP_TABLE::TAB);
if (!(sjtbl= (SJ_TMP_TABLE*)thd->alloc(sizeof(SJ_TMP_TABLE))) ||
!(sjtbl->tabs= (SJ_TMP_TABLE::TAB*) thd->alloc(tabs_size)))
DBUG_RETURN(TRUE); /* purecov: inspected */
@@ -3154,6 +3811,7 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
join->join_tab[i + pos->n_sj_tables - 1].check_weed_out_table= sjtbl;
i+= pos->n_sj_tables;
+ pos+= pos->n_sj_tables;
break;
}
case SJ_OPT_FIRST_MATCH:
@@ -3176,10 +3834,12 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
}
j[-1].do_firstmatch= jump_to;
i+= pos->n_sj_tables;
+ pos+= pos->n_sj_tables;
break;
}
case SJ_OPT_NONE:
i++;
+ pos++;
break;
}
}
@@ -3360,13 +4020,27 @@ int rewrite_to_index_subquery_engine(JOIN *join)
JOIN_TAB* join_tab=join->join_tab;
SELECT_LEX_UNIT *unit= join->unit;
DBUG_ENTER("rewrite_to_index_subquery_engine");
+
/*
is this simple IN subquery?
*/
+ /* TODO: In order to use these more efficient subquery engines in more cases,
+ the following problems need to be solved:
+ - the code that removes GROUP BY (group_list), also adds an ORDER BY
+ (order), thus GROUP BY queries (almost?) never pass through this branch.
+ Solution: remove the test below '!join->order', because we remove the
+ ORDER clase for subqueries anyway.
+ - in order to set a more efficient engine, the optimizer needs to both
+ decide to remove GROUP BY, *and* select one of the JT_[EQ_]REF[_OR_NULL]
+ access methods, *and* loose scan should be more expensive or
+ inapliccable. When is that possible?
+ - Consider expanding the applicability of this rewrite for loose scan
+ for group by queries.
+ */
if (!join->group_list && !join->order &&
join->unit->item &&
join->unit->item->substype() == Item_subselect::IN_SUBS &&
- join->tables == 1 && join->conds &&
+ join->table_count == 1 && join->conds &&
!join->unit->is_union())
{
if (!join->having)
@@ -3503,3 +4177,439 @@ static void remove_subq_pushed_predicates(JOIN *join, Item **where)
}
+
+
+/**
+ Optimize all subqueries of a query that were not flattened into a semijoin.
+
+ @details
+ Optimize all immediate children subqueries of a query.
+
+ This phase must be called after substitute_for_best_equal_field() because
+ that function may replace items with other items from a multiple equality,
+ and we need to reference the correct items in the index access method of the
+ IN predicate.
+
+ @return Operation status
+ @retval FALSE success.
+ @retval TRUE error occurred.
+*/
+
+bool JOIN::optimize_unflattened_subqueries()
+{
+ return select_lex->optimize_unflattened_subqueries();
+}
+
+
+/*
+ Join tab execution startup function.
+
+ SYNOPSIS
+ join_tab_execution_startup()
+ tab Join tab to perform startup actions for
+
+ DESCRIPTION
+ Join tab execution startup function. This is different from
+ tab->read_first_record in the regard that this has actions that are to be
+ done once per join execution.
+
+ Currently there are only two possible startup functions, so we have them
+ both here inside if (...) branches. In future we could switch to function
+ pointers.
+
+ RETURN
+ NESTED_LOOP_OK - OK
+ NESTED_LOOP_ERROR| NESTED_LOOP_KILLED - Error, abort the join execution
+*/
+
+enum_nested_loop_state join_tab_execution_startup(JOIN_TAB *tab)
+{
+ Item_in_subselect *in_subs;
+ DBUG_ENTER("join_tab_execution_startup");
+
+ if (tab->table->pos_in_table_list &&
+ (in_subs= tab->table->pos_in_table_list->jtbm_subselect))
+ {
+ /* It's a non-merged SJM nest */
+ DBUG_ASSERT(in_subs->engine->engine_type() ==
+ subselect_engine::HASH_SJ_ENGINE);
+ subselect_hash_sj_engine *hash_sj_engine=
+ ((subselect_hash_sj_engine*)in_subs->engine);
+ if (!hash_sj_engine->is_materialized)
+ {
+ hash_sj_engine->materialize_join->exec();
+ hash_sj_engine->is_materialized= TRUE;
+
+ if (hash_sj_engine->materialize_join->error || tab->join->thd->is_fatal_error)
+ DBUG_RETURN(NESTED_LOOP_ERROR);
+ }
+ }
+ else if (tab->bush_children)
+ {
+ /* It's a merged SJM nest */
+ enum_nested_loop_state rc;
+ SJ_MATERIALIZATION_INFO *sjm= tab->bush_children->start->emb_sj_nest->sj_mat_info;
+
+ if (!sjm->materialized)
+ {
+ JOIN *join= tab->join;
+ JOIN_TAB *join_tab= tab->bush_children->start;
+ JOIN_TAB *save_return_tab= join->return_tab;
+ /*
+ Now run the join for the inner tables. The first call is to run the
+ join, the second one is to signal EOF (this is essential for some
+ join strategies, e.g. it will make join buffering flush the records)
+ */
+ if ((rc= sub_select(join, join_tab, FALSE/* no EOF */)) < 0 ||
+ (rc= sub_select(join, join_tab, TRUE/* now EOF */)) < 0)
+ {
+ join->return_tab= save_return_tab;
+ DBUG_RETURN(rc); /* it's NESTED_LOOP_(ERROR|KILLED)*/
+ }
+ join->return_tab= save_return_tab;
+ sjm->materialized= TRUE;
+ }
+ }
+
+ DBUG_RETURN(NESTED_LOOP_OK);
+}
+
+
+/**
+ Choose an optimal strategy to execute an IN/ALL/ANY subquery predicate
+ based on cost.
+
+ @param join_tables the set of tables joined in the subquery
+
+ @notes
+ The method chooses between the materialization and IN=>EXISTS rewrite
+ strategies for the execution of a non-flattened subquery IN predicate.
+ The cost-based decision is made as follows:
+
+ 1. compute materialize_strategy_cost based on the unmodified subquery
+ 2. reoptimize the subquery taking into account the IN-EXISTS predicates
+ 3. compute in_exists_strategy_cost based on the reoptimized plan
+ 4. compare and set the cheaper strategy
+ if (materialize_strategy_cost >= in_exists_strategy_cost)
+ in_strategy = MATERIALIZATION
+ else
+ in_strategy = IN_TO_EXISTS
+ 5. if in_strategy = MATERIALIZATION and it is not possible to initialize it
+ revert to IN_TO_EXISTS
+ 6. if (in_strategy == MATERIALIZATION)
+ revert the subquery plan to the original one before reoptimizing
+ else
+ inject the IN=>EXISTS predicates into the new EXISTS subquery plan
+
+ The implementation itself is a bit more complicated because it takes into
+ account two more factors:
+ - whether the user allowed both strategies through an optimizer_switch, and
+ - if materialization was the cheaper strategy, whether it can be executed
+ or not.
+
+ @retval FALSE success.
+ @retval TRUE error occurred.
+*/
+
+bool JOIN::choose_subquery_plan(table_map join_tables)
+{
+ Join_plan_state save_qep; /* The original QEP of the subquery. */
+ enum_reopt_result reopt_result= REOPT_NONE;
+ Item_in_subselect *in_subs;
+
+ if (is_in_subquery())
+ {
+ in_subs= (Item_in_subselect*) unit->item;
+ if (in_subs->create_in_to_exists_cond(this))
+ return true;
+ }
+ else
+ return false;
+
+ DBUG_ASSERT(in_subs->in_strategy); /* A strategy must be chosen earlier. */
+ DBUG_ASSERT(in_to_exists_where || in_to_exists_having);
+ DBUG_ASSERT(!in_to_exists_where || in_to_exists_where->fixed);
+ DBUG_ASSERT(!in_to_exists_having || in_to_exists_having->fixed);
+
+ /*
+ Compute and compare the costs of materialization and in-exists if both
+ strategies are possible and allowed by the user (checked during the prepare
+ phase.
+ */
+ if (in_subs->in_strategy & SUBS_MATERIALIZATION &&
+ in_subs->in_strategy & SUBS_IN_TO_EXISTS)
+ {
+ JOIN *outer_join;
+ JOIN *inner_join= this;
+ /* Number of (partial) rows of the outer JOIN filtered by the IN predicate. */
+ double outer_record_count;
+ /* Number of unique value combinations filtered by the IN predicate. */
+ double outer_lookup_keys;
+ /* Cost and row count of the unmodified subquery. */
+ double inner_read_time_1, inner_record_count_1;
+ /* Cost of the subquery with injected IN-EXISTS predicates. */
+ double inner_read_time_2;
+ /* The cost to compute IN via materialization. */
+ double materialize_strategy_cost;
+ /* The cost of the IN->EXISTS strategy. */
+ double in_exists_strategy_cost;
+ double dummy;
+
+ /*
+ A. Estimate the number of rows of the outer table that will be filtered
+ by the IN predicate.
+ */
+ outer_join= unit->outer_select() ? unit->outer_select()->join : NULL;
+ if (outer_join)
+ {
+ uint outer_partial_plan_len;
+ /*
+ Make_cond_for_table is called for predicates only in the WHERE/ON
+ clauses. In all other cases, predicates are not pushed to any
+ JOIN_TAB, and their joi_tab_idx remains MAX_TABLES. Such predicates
+ are evaluated for each complete row of the outer join.
+ */
+ outer_partial_plan_len= (in_subs->get_join_tab_idx() == MAX_TABLES) ?
+ outer_join->table_count :
+ in_subs->get_join_tab_idx() + 1;
+ outer_join->get_partial_cost_and_fanout(outer_partial_plan_len,
+ table_map(-1),
+ &dummy,
+ &outer_record_count);
+
+ if (outer_join->table_count > outer_join->const_tables)
+ {
+ outer_join->get_partial_cost_and_fanout(outer_partial_plan_len,
+ in_subs->used_tables(),
+ &dummy,
+ &outer_lookup_keys);
+ /*
+ outer_lookup_keys= prev_record_reads(outer_join->best_positions,
+ outer_partial_plan_len,
+ in_subs->used_tables());
+ */
+ }
+ else
+ {
+ /* If all tables are constant, positions is undefined. */
+ outer_lookup_keys= 1;
+ }
+ }
+ else
+ {
+ /*
+ TODO: outer_join can be NULL for DELETE statements.
+ How to compute its cost?
+ */
+ outer_record_count= 1;
+ outer_lookup_keys=1;
+ }
+ /*
+ There cannot be more lookup keys than the total number of records.
+ TODO: this a temporary solution until we find a better way to compute
+ get_partial_join_cost() and prev_record_reads() in a consitent manner,
+ where it is guaranteed that (outer_lookup_keys <= outer_record_count).
+ */
+ if (outer_lookup_keys > outer_record_count)
+ outer_lookup_keys= outer_record_count;
+
+ /*
+ B. Estimate the cost and number of records of the subquery both
+ unmodified, and with injected IN->EXISTS predicates.
+ */
+ inner_read_time_1= inner_join->best_read;
+ inner_record_count_1= inner_join->record_count;
+
+ if (in_to_exists_where && const_tables != table_count)
+ {
+ /*
+ Re-optimize and cost the subquery taking into account the IN-EXISTS
+ conditions.
+ */
+ reopt_result= reoptimize(in_to_exists_where, join_tables, &save_qep);
+ if (reopt_result == REOPT_ERROR)
+ return TRUE;
+
+ /* Get the cost of the modified IN-EXISTS plan. */
+ inner_read_time_2= inner_join->best_read;
+
+ }
+ else
+ {
+ /* Reoptimization would not produce any better plan. */
+ inner_read_time_2= inner_read_time_1;
+ }
+
+ /*
+ C. Compute execution costs.
+ */
+ /* C.1 Compute the cost of the materialization strategy. */
+ uint rowlen= get_tmp_table_rec_length(unit->first_select()->item_list);
+ /* The cost of writing one row into the temporary table. */
+ double write_cost= get_tmp_table_write_cost(thd, inner_record_count_1,
+ rowlen);
+ /* The cost of a lookup into the unique index of the materialized table. */
+ double lookup_cost= get_tmp_table_lookup_cost(thd, inner_record_count_1,
+ rowlen);
+ /*
+ The cost of executing the subquery and storing its result in an indexed
+ temporary table.
+ */
+ double materialization_cost= inner_read_time_1 +
+ write_cost * inner_record_count_1;
+
+ materialize_strategy_cost= materialization_cost +
+ outer_record_count * lookup_cost;
+
+ /* C.2 Compute the cost of the IN=>EXISTS strategy. */
+ in_exists_strategy_cost= outer_lookup_keys * inner_read_time_2;
+
+ /* C.3 Compare the costs and choose the cheaper strategy. */
+ if (materialize_strategy_cost >= in_exists_strategy_cost)
+ in_subs->in_strategy&= ~SUBS_MATERIALIZATION;
+ else
+ in_subs->in_strategy&= ~SUBS_IN_TO_EXISTS;
+ }
+
+ /*
+ If (1) materialization is a possible strategy based on semantic analysis
+ during the prepare phase, then if
+ (2) it is more expensive than the IN->EXISTS transformation, and
+ (3) it is not possible to create usable indexes for the materialization
+ strategy,
+ fall back to IN->EXISTS.
+ otherwise
+ use materialization.
+ */
+ if (in_subs->in_strategy & SUBS_MATERIALIZATION &&
+ in_subs->setup_mat_engine())
+ {
+ /*
+ If materialization was the cheaper or the only user-selected strategy,
+ but it is not possible to execute it due to limitations in the
+ implementation, fall back to IN-TO-EXISTS.
+ */
+ in_subs->in_strategy&= ~SUBS_MATERIALIZATION;
+ in_subs->in_strategy|= SUBS_IN_TO_EXISTS;
+ }
+
+ if (in_subs->in_strategy & SUBS_MATERIALIZATION)
+ {
+ /* Restore the original query plan used for materialization. */
+ if (reopt_result == REOPT_NEW_PLAN)
+ restore_query_plan(&save_qep);
+
+ in_subs->unit->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
+ select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED;
+
+ /*
+ Reset the "LIMIT 1" set in Item_exists_subselect::fix_length_and_dec.
+ TODO:
+ Currently we set the subquery LIMIT to infinity, and this is correct
+ because we forbid at parse time LIMIT inside IN subqueries (see
+ Item_in_subselect::test_limit). However, once we allow this, here
+ we should set the correct limit if given in the query.
+ */
+ in_subs->unit->global_parameters->select_limit= NULL;
+ in_subs->unit->set_limit(unit->global_parameters);
+ /*
+ Set the limit of this JOIN object as well, because normally its being
+ set in the beginning of JOIN::optimize, which was already done.
+ */
+ select_limit= in_subs->unit->select_limit_cnt;
+ }
+ else if (in_subs->in_strategy & SUBS_IN_TO_EXISTS)
+ {
+ if (reopt_result == REOPT_NONE && in_to_exists_where &&
+ const_tables != table_count)
+ {
+ /*
+ The subquery was not reoptimized either because the user allowed only the
+ IN-EXISTS strategy, or because materialization was not possible based on
+ semantic analysis. Clenup the original plan and reoptimize.
+ */
+ for (uint i= 0; i < table_count; i++)
+ {
+ join_tab[i].keyuse= NULL;
+ join_tab[i].checked_keys.clear_all();
+ }
+ if ((reopt_result= reoptimize(in_to_exists_where, join_tables, NULL)) ==
+ REOPT_ERROR)
+ return TRUE;
+ }
+
+ if (in_subs->inject_in_to_exists_cond(this))
+ return TRUE;
+ /*
+ It is IN->EXISTS transformation so we should mark subquery as
+ dependent
+ */
+ in_subs->unit->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
+ select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
+ select_limit= 1;
+ }
+ else
+ DBUG_ASSERT(FALSE);
+
+ return FALSE;
+}
+
+
+/**
+ Choose a query plan for a table-less subquery.
+
+ @notes
+
+ @retval FALSE success.
+ @retval TRUE error occurred.
+*/
+
+bool JOIN::choose_tableless_subquery_plan()
+{
+ DBUG_ASSERT(!tables_list || !table_count);
+ if (unit->item)
+ {
+ DBUG_ASSERT(unit->item->type() == Item::SUBSELECT_ITEM);
+ Item_subselect *subs_predicate= unit->item;
+
+ /*
+ If the optimizer determined that his query has an empty result,
+ in most cases the subquery predicate is a known constant value -
+ either FALSE or NULL. The implementation of Item_subselect::reset()
+ determines which one.
+ */
+ if (zero_result_cause)
+ {
+ if (!implicit_grouping)
+ {
+ /*
+ Both group by queries and non-group by queries without aggregate
+ functions produce empty subquery result.
+ */
+ subs_predicate->reset();
+ subs_predicate->make_const();
+ return FALSE;
+ }
+
+ /* TODO:
+ A further optimization is possible when a non-group query with
+ MIN/MAX/COUNT is optimized by opt_sum_query. Then, if there are
+ only MIN/MAX functions over an empty result set, the subquery
+ result is a NULL value/row, thus the value of subs_predicate is
+ NULL.
+ */
+ }
+
+ if (subs_predicate->is_in_predicate())
+ {
+ Item_in_subselect *in_subs;
+ in_subs= (Item_in_subselect*) subs_predicate;
+ in_subs->in_strategy= SUBS_IN_TO_EXISTS;
+ if (in_subs->create_in_to_exists_cond(this) ||
+ in_subs->inject_in_to_exists_cond(this))
+ return TRUE;
+ tmp_having= having;
+ }
+ }
+ return FALSE;
+}
diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h
index 47d85d5c38d..4d89609e1a8 100644
--- a/sql/opt_subselect.h
+++ b/sql/opt_subselect.h
@@ -1,4 +1,6 @@
-/* */
+/*
+ Semi-join subquery optimization code definitions
+*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
@@ -366,4 +368,10 @@ int clear_sj_tmp_tables(JOIN *join);
int rewrite_to_index_subquery_engine(JOIN *join);
+void get_delayed_table_estimates(TABLE *table,
+ ha_rows *out_rows,
+ double *scan_time,
+ double *startup_cost);
+
+enum_nested_loop_state join_tab_execution_startup(JOIN_TAB *tab);
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 310b48756d0..965eb853471 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -74,10 +74,12 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond);
# Multiplication of number of rows in all tables
*/
-static ulonglong get_exact_record_count(TABLE_LIST *tables)
+static ulonglong get_exact_record_count(List<TABLE_LIST> &tables)
{
ulonglong count= 1;
- for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
+ TABLE_LIST *tl;
+ List_iterator<TABLE_LIST> ti(tables);
+ while ((tl= ti++))
{
ha_rows tmp= tl->table->file->records();
if ((tmp == HA_POS_ERROR))
@@ -211,6 +213,7 @@ static int get_index_max_value(TABLE *table, TABLE_REF *ref, uint range_fl)
/**
Substitutes constants for some COUNT(), MIN() and MAX() functions.
+ @param thd thread handler
@param tables list of leaves of join table tree
@param all_fields All fields to be returned
@param conds WHERE clause
@@ -228,11 +231,16 @@ static int get_index_max_value(TABLE *table, TABLE_REF *ref, uint range_fl)
HA_ERR_KEY_NOT_FOUND on impossible conditions
@retval
HA_ERR_... if a deadlock or a lock wait timeout happens, for example
+ @retval
+ ER_... e.g. ER_SUBQUERY_NO_1_ROW
*/
-int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
+int opt_sum_query(THD *thd,
+ List<TABLE_LIST> &tables, List<Item> &all_fields, COND *conds)
{
List_iterator_fast<Item> it(all_fields);
+ List_iterator<TABLE_LIST> ti(tables);
+ TABLE_LIST *tl;
int const_result= 1;
bool recalc_const_item= 0;
ulonglong count= 1;
@@ -240,7 +248,8 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
table_map removed_tables= 0, outer_tables= 0, used_tables= 0;
table_map where_tables= 0;
Item *item;
- int error;
+ int error= 0;
+ DBUG_ENTER("opt_sum_query");
if (conds)
where_tables= conds->used_tables();
@@ -249,7 +258,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
Analyze outer join dependencies, and, if possible, compute the number
of returned rows.
*/
- for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
+ while ((tl= ti++))
{
TABLE_LIST *embedded;
for (embedded= tl ; embedded; embedded= embedded->embedding)
@@ -269,7 +278,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
WHERE t2.field IS NULL;
*/
if (tl->table->map & where_tables)
- return 0;
+ DBUG_RETURN(0);
}
else
used_tables|= tl->table->map;
@@ -290,6 +299,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
is_exact_count= FALSE;
count= 1; // ensure count != 0
}
+ else if (tl->is_materialized_derived())
+ {
+ /*
+ Can't remove a derived table as it's number of rows is just an
+ estimate.
+ */
+ DBUG_RETURN(0);
+ }
else
{
error= tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
@@ -297,7 +314,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
{
tl->table->file->print_error(error, MYF(0));
tl->table->in_use->fatal_error();
- return error;
+ DBUG_RETURN(error);
}
count*= tl->table->file->stats.records;
}
@@ -389,10 +406,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if (error)
{
if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE)
- return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE
+ DBUG_RETURN(HA_ERR_KEY_NOT_FOUND); // No rows matching WHERE
/* HA_ERR_LOCK_DEADLOCK or some other error */
table->file->print_error(error, MYF(0));
- return(error);
+ DBUG_RETURN(error);
}
removed_tables|= table->map;
}
@@ -436,6 +453,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
const_result= 0;
}
}
+
+ if (thd->is_error())
+ DBUG_RETURN(thd->main_da.sql_errno());
+
/*
If we have a where clause, we can only ignore searching in the
tables if MIN/MAX optimisation replaced all used tables
@@ -445,7 +466,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
*/
if (removed_tables && used_tables != removed_tables)
const_result= 0; // We didn't remove all tables
- return const_result;
+ DBUG_RETURN(const_result);
}
@@ -731,6 +752,12 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
if (is_null || (is_null_safe_eq && args[1]->is_null()))
{
+ /*
+ If we have a non-nullable index, we cannot use it,
+ since set_null will be ignored, and we will compare uninitialized data.
+ */
+ if (!part->field->real_maybe_null())
+ DBUG_RETURN(FALSE);
part->field->set_null();
*key_ptr= (uchar) 1;
}
@@ -801,8 +828,9 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
@param[out] prefix_len Length of prefix for the search range
@note
- This function may set table->key_read to 1, which must be reset after
- index is used! (This can only happen when function returns 1)
+ This function may set field->table->key_read to true,
+ which must be reset after index is used!
+ (This can only happen when function returns 1)
@retval
0 Index can not be used to optimize MIN(field)/MAX(field)
@@ -817,7 +845,9 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
uint *range_fl, uint *prefix_len)
{
if (!(field->flags & PART_KEY_FLAG))
- return 0; // Not key field
+ return FALSE; // Not key field
+
+ DBUG_ENTER("find_key_for_maxmin");
TABLE *table= field->table;
uint idx= 0;
@@ -842,7 +872,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1)
{
if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER))
- return 0;
+ DBUG_RETURN(FALSE);
/* Check whether the index component is partial */
Field *part_field= table->field[part->fieldnr-1];
@@ -891,12 +921,12 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
*/
if (field->part_of_key.is_set(idx))
table->enable_keyread();
- return 1;
+ DBUG_RETURN(TRUE);
}
}
}
}
- return 0;
+ DBUG_RETURN(FALSE);
}
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 2db81e925a2..a0e14423b73 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -617,7 +617,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
Protocol_text prot(thd);
String *local_packet= prot.storage_packet();
CHARSET_INFO *thd_charset= thd->variables.character_set_results;
- DBUG_ENTER("send_fields");
+ DBUG_ENTER("Protocol::send_fields");
if (flags & SEND_NUM_ROWS)
{ // Packet with number of elements
@@ -1041,13 +1041,7 @@ bool Protocol_text::store(Field *field)
}
-/**
- @todo
- Second_part format ("%06") needs to change when
- we support 0-6 decimals for time.
-*/
-
-bool Protocol_text::store(MYSQL_TIME *tm)
+bool Protocol_text::store(MYSQL_TIME *tm, int decimals)
{
#ifndef DBUG_OFF
DBUG_ASSERT(field_types == 0 ||
@@ -1055,18 +1049,8 @@ bool Protocol_text::store(MYSQL_TIME *tm)
field_types[field_pos] == MYSQL_TYPE_TIMESTAMP);
field_pos++;
#endif
- char buff[40];
- uint length;
- length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
- (int) tm->year,
- (int) tm->month,
- (int) tm->day,
- (int) tm->hour,
- (int) tm->minute,
- (int) tm->second));
- if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d",
- (int)tm->second_part));
+ char buff[MAX_DATE_STRING_REP_LENGTH];
+ uint length= my_datetime_to_str(tm, buff, decimals);
return net_store_data((uchar*) buff, length);
}
@@ -1084,29 +1068,15 @@ bool Protocol_text::store_date(MYSQL_TIME *tm)
}
-/**
- @todo
- Second_part format ("%06") needs to change when
- we support 0-6 decimals for time.
-*/
-
-bool Protocol_text::store_time(MYSQL_TIME *tm)
+bool Protocol_text::store_time(MYSQL_TIME *tm, int decimals)
{
#ifndef DBUG_OFF
DBUG_ASSERT(field_types == 0 ||
field_types[field_pos] == MYSQL_TYPE_TIME);
field_pos++;
#endif
- char buff[40];
- uint length;
- uint day= (tm->year || tm->month) ? 0 : tm->day;
- length= my_sprintf(buff,(buff, "%s%02ld:%02d:%02d",
- tm->neg ? "-" : "",
- (long) day*24L+(long) tm->hour,
- (int) tm->minute,
- (int) tm->second));
- if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part));
+ char buff[MAX_DATE_STRING_REP_LENGTH];
+ uint length= my_time_to_str(tm, buff, decimals);
return net_store_data((uchar*) buff, length);
}
@@ -1263,7 +1233,7 @@ bool Protocol_binary::store(Field *field)
}
-bool Protocol_binary::store(MYSQL_TIME *tm)
+bool Protocol_binary::store(MYSQL_TIME *tm, int decimals)
{
char buff[12],*pos;
uint length;
@@ -1276,6 +1246,10 @@ bool Protocol_binary::store(MYSQL_TIME *tm)
pos[4]= (uchar) tm->hour;
pos[5]= (uchar) tm->minute;
pos[6]= (uchar) tm->second;
+ DBUG_ASSERT(decimals == AUTO_SEC_PART_DIGITS ||
+ (decimals >= 0 && decimals <= TIME_SECOND_PART_DIGITS));
+ if (decimals != AUTO_SEC_PART_DIGITS)
+ tm->second_part= sec_part_truncate(tm->second_part, decimals);
int4store(pos+7, tm->second_part);
if (tm->second_part)
length=11;
@@ -1293,11 +1267,11 @@ bool Protocol_binary::store_date(MYSQL_TIME *tm)
{
tm->hour= tm->minute= tm->second=0;
tm->second_part= 0;
- return Protocol_binary::store(tm);
+ return Protocol_binary::store(tm, 0);
}
-bool Protocol_binary::store_time(MYSQL_TIME *tm)
+bool Protocol_binary::store_time(MYSQL_TIME *tm, int decimals)
{
char buff[13], *pos;
uint length;
@@ -1306,7 +1280,6 @@ bool Protocol_binary::store_time(MYSQL_TIME *tm)
pos[0]= tm->neg ? 1 : 0;
if (tm->hour >= 24)
{
- /* Fix if we come from Item::send */
uint days= tm->hour/24;
tm->hour-= days*24;
tm->day+= days;
@@ -1315,6 +1288,10 @@ bool Protocol_binary::store_time(MYSQL_TIME *tm)
pos[5]= (uchar) tm->hour;
pos[6]= (uchar) tm->minute;
pos[7]= (uchar) tm->second;
+ DBUG_ASSERT(decimals == AUTO_SEC_PART_DIGITS ||
+ (decimals >= 0 && decimals <= TIME_SECOND_PART_DIGITS));
+ if (decimals != AUTO_SEC_PART_DIGITS)
+ tm->second_part= sec_part_truncate(tm->second_part, decimals);
int4store(pos+8, tm->second_part);
if (tm->second_part)
length=12;
diff --git a/sql/protocol.h b/sql/protocol.h
index 3eb5091a7c7..4ab5c169928 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -91,9 +91,9 @@ public:
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0;
virtual bool store(float from, uint32 decimals, String *buffer)=0;
virtual bool store(double from, uint32 decimals, String *buffer)=0;
- virtual bool store(MYSQL_TIME *time)=0;
+ virtual bool store(MYSQL_TIME *time, int decimals)=0;
virtual bool store_date(MYSQL_TIME *time)=0;
- virtual bool store_time(MYSQL_TIME *time)=0;
+ virtual bool store_time(MYSQL_TIME *time, int decimals)=0;
virtual bool store(Field *field)=0;
#ifdef EMBEDDED_LIBRARY
int begin_dataset();
@@ -130,9 +130,9 @@ public:
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs);
virtual bool store(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
- virtual bool store(MYSQL_TIME *time);
+ virtual bool store(MYSQL_TIME *time, int decimals);
virtual bool store_date(MYSQL_TIME *time);
- virtual bool store_time(MYSQL_TIME *time);
+ virtual bool store_time(MYSQL_TIME *time, int decimals);
virtual bool store(float nr, uint32 decimals, String *buffer);
virtual bool store(double from, uint32 decimals, String *buffer);
virtual bool store(Field *field);
@@ -165,9 +165,9 @@ public:
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs);
virtual bool store(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
- virtual bool store(MYSQL_TIME *time);
+ virtual bool store(MYSQL_TIME *time, int decimals);
virtual bool store_date(MYSQL_TIME *time);
- virtual bool store_time(MYSQL_TIME *time);
+ virtual bool store_time(MYSQL_TIME *time, int decimals);
virtual bool store(float nr, uint32 decimals, String *buffer);
virtual bool store(double from, uint32 decimals, String *buffer);
virtual bool store(Field *field);
diff --git a/sql/records.cc b/sql/records.cc
index 6bb7c7cffa1..5ce7d8660e9 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -299,7 +299,8 @@ void end_read_record(READ_RECORD *info)
if (info->table)
{
filesort_free_buffers(info->table,0);
- (void) info->file->extra(HA_EXTRA_NO_CACHE);
+ if (info->table->created)
+ (void) info->file->extra(HA_EXTRA_NO_CACHE);
if (info->read_record != rr_quick) // otherwise quick_range does it
(void) info->file->ha_index_or_rnd_end();
info->table=0;
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 9b1b1f70784..99536b68cf6 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -244,7 +244,8 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg)
for (;;)
{
Log_event* ev;
- if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*) 0, 0)))
+ if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*) 0, 0,
+ opt_slave_sql_verify_checksum)))
{
if (log->error > 0)
strmov(errmsg, "Binary log truncated in the middle of event");
@@ -418,7 +419,8 @@ static Slave_log_event* find_slave_event(IO_CACHE* log,
for (i = 0; i < 2; i++)
{
- if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*)0, 0)))
+ if (!(ev = Log_event::read_log_event(log, (pthread_mutex_t*)0, 0,
+ opt_slave_sql_verify_checksum)))
{
my_snprintf(errmsg, SLAVE_ERRMSG_SIZE,
"Error reading event in log '%s'",
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 47fc88c9a8a..eb5ee58e538 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -24,7 +24,8 @@
Master_info::Master_info()
:Slave_reporting_capability("I/O"),
- ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), inited(0),
+ ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0),
+ checksum_alg_before_fd(BINLOG_CHECKSUM_ALG_UNDEF), inited(0),
abort_slave(0),slave_running(0),
slave_run_id(0)
{
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index d63432545e5..5cac5284d9d 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -83,6 +83,12 @@ class Master_info : public Slave_reporting_capability
Relay_log_info rli;
uint port;
uint connect_retry;
+ /*
+ to hold checksum alg in use until IO thread has received FD.
+ Initialized to novalue, then set to the queried from master
+ @@global.binlog_checksum and deactivated once FD has been received.
+ */
+ uint8 checksum_alg_before_fd;
#ifndef DBUG_OFF
int events_till_disconnect;
#endif
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 35e283a886e..d07aeddc5b9 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -103,7 +103,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
const uchar *old_pack_ptr= pack_ptr;
#endif
pack_ptr= field->pack(pack_ptr, field->ptr + offset,
- field->max_data_length(), TRUE);
+ field->max_data_length());
DBUG_PRINT("debug", ("field: %s; pack_ptr: 0x%lx;"
" pack_ptr':0x%lx; bytes: %d",
field->field_name, (ulong) old_pack_ptr,
@@ -269,7 +269,7 @@ unpack_row(Relay_log_info const *rli,
#ifndef DBUG_OFF
uchar const *const old_pack_ptr= pack_ptr;
#endif
- pack_ptr= f->unpack(f->ptr, pack_ptr, metadata, TRUE);
+ pack_ptr= f->unpack(f->ptr, pack_ptr, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
" pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d",
f->field_name, metadata,
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 42701bc9e24..c88a0908356 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -176,6 +176,9 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
"this problem.", ln);
name_warning_sent= 1;
}
+
+ rli->relay_log.is_relay_log= TRUE;
+
/*
note, that if open() fails, we'll still have index file open
but a destructor will take care of that
@@ -189,7 +192,6 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
sql_print_error("Failed in open_log() called from init_relay_log_info()");
DBUG_RETURN(1);
}
- rli->relay_log.is_relay_log= TRUE;
}
/* if file does not exist */
@@ -535,8 +537,9 @@ int init_relay_log_pos(Relay_log_info* rli,const char* log,
Because of we have rli->data_lock and log_lock, we can safely read an
event
*/
- if (!(ev=Log_event::read_log_event(rli->cur_log,0,
- rli->relay_log.description_event_for_exec)))
+ if (!(ev= Log_event::read_log_event(rli->cur_log, 0,
+ rli->relay_log.description_event_for_exec,
+ opt_slave_sql_verify_checksum)))
{
DBUG_PRINT("info",("could not read event, rli->cur_log->error=%d",
rli->cur_log->error));
@@ -1172,11 +1175,7 @@ void Relay_log_info::stmt_done(my_off_t event_master_log_pos,
is that value may take some time to display in
Seconds_Behind_Master - not critical).
*/
-#ifndef DBUG_OFF
- if (!(event_creation_time == 0 && debug_not_change_ts_if_art_event > 0))
-#else
- if (event_creation_time != 0)
-#endif
+ if (!(event_creation_time == 0 IF_DBUG(&& debug_not_change_ts_if_art_event > 0)))
last_master_timestamp= event_creation_time;
}
}
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 6058c473e9f..68dd0e13c25 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -14,6 +14,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "rpl_utility.h"
+
+#ifndef MYSQL_CLIENT
#include "rpl_rli.h"
/*********************************************************************
@@ -133,7 +135,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
always read the length in little-endian order.
*/
Field_blob fb(m_field_metadata[col]);
- length= fb.get_packed_size(master_data, TRUE);
+ length= fb.get_packed_size(master_data);
#else
/*
Compute the length of the data. We cannot use get_length() here
@@ -224,3 +226,62 @@ table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table)
return error;
}
+
+#endif /* MYSQL_CLIENT */
+
+
+/**
+ @param even_buf point to the buffer containing serialized event
+ @param event_len length of the event accounting possible checksum alg
+
+ @return TRUE if test fails
+ FALSE as success
+*/
+bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg)
+{
+ bool res= FALSE;
+ uint16 flags= 0; // to store in FD's buffer flags orig value
+
+ if (alg != BINLOG_CHECKSUM_ALG_OFF && alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ {
+ ha_checksum incoming;
+ ha_checksum computed;
+
+ if (event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT)
+ {
+#ifndef DBUG_OFF
+ int8 fd_alg= event_buf[event_len - BINLOG_CHECKSUM_LEN -
+ BINLOG_CHECKSUM_ALG_DESC_LEN];
+#endif
+ /*
+ FD event is checksummed and therefore verified w/o the binlog-in-use flag
+ */
+ flags= uint2korr(event_buf + FLAGS_OFFSET);
+ if (flags & LOG_EVENT_BINLOG_IN_USE_F)
+ event_buf[FLAGS_OFFSET] &= ~LOG_EVENT_BINLOG_IN_USE_F;
+ /*
+ The only algorithm currently is CRC32. Zero indicates
+ the binlog file is checksum-free *except* the FD-event.
+ */
+ DBUG_ASSERT(fd_alg == BINLOG_CHECKSUM_ALG_CRC32 || fd_alg == 0);
+ DBUG_ASSERT(alg == BINLOG_CHECKSUM_ALG_CRC32);
+ /*
+ Complile time guard to watch over the max number of alg
+ */
+ compile_time_assert(BINLOG_CHECKSUM_ALG_ENUM_END <= 0x80);
+ }
+ incoming= uint4korr(event_buf + event_len - BINLOG_CHECKSUM_LEN);
+ computed= my_checksum(0L, NULL, 0);
+ /* checksum the event content but the checksum part itself */
+ computed= my_checksum(computed, (const uchar*) event_buf,
+ event_len - BINLOG_CHECKSUM_LEN);
+ if (flags != 0)
+ {
+ /* restoring the orig value of flags of FD */
+ DBUG_ASSERT(event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT);
+ event_buf[FLAGS_OFFSET]= (uchar) flags;
+ }
+ res= !(computed == incoming);
+ }
+ return DBUG_EVALUATE_IF("simulate_checksum_test_failure", TRUE, res);
+}
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 33575de1ccf..85722f3d64a 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -128,9 +128,11 @@ static void fix_net_read_timeout(THD *thd, enum_var_type type);
static void fix_net_write_timeout(THD *thd, enum_var_type type);
static void fix_net_retry_count(THD *thd, enum_var_type type);
static void fix_max_join_size(THD *thd, enum_var_type type);
-static void fix_query_cache_size(THD *thd, enum_var_type type);
#ifdef HAVE_QUERY_CACHE
+static void fix_query_cache_size(THD *thd, enum_var_type type);
static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type);
+static int check_query_cache_type(THD *thd, set_var *var);
+static void fix_query_cache_type(THD *thd, enum_var_type type);
#endif
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
static void fix_max_binlog_size(THD *thd, enum_var_type type);
@@ -154,6 +156,8 @@ static bool sys_update_slow_log_path(THD *thd, set_var * var);
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
static void fix_sys_log_slow_filter(THD *thd, enum_var_type);
static uchar *get_myisam_mmap_size(THD *thd);
+static int check_max_allowed_packet(THD *thd, set_var *var);
+static int check_net_buffer_length(THD *thd, set_var *var);
/*
Variable definition list
@@ -401,7 +405,8 @@ static sys_var_const sys_lower_case_table_names(&vars,
(uchar*)
&lower_case_table_names);
static sys_var_thd_ulong_session_readonly sys_max_allowed_packet(&vars, "max_allowed_packet",
- &SV::max_allowed_packet);
+ &SV::max_allowed_packet,
+ check_max_allowed_packet);
static sys_var_ulonglong_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
&max_binlog_cache_size);
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size",
@@ -435,6 +440,12 @@ static sys_var_thd_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
&SV::max_seeks_for_key);
static sys_var_thd_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
&SV::max_length_for_sort_data);
+static sys_var_const sys_max_long_data_size(&vars,
+ "max_long_data_size",
+ OPT_GLOBAL, SHOW_LONG,
+ (uchar*)
+ &max_long_data_size);
+
#ifndef TO_BE_DELETED /* Alias for max_join_size */
static sys_var_thd_ha_rows sys_sql_max_join_size(&vars, "sql_max_join_size",
&SV::max_join_size,
@@ -487,7 +498,8 @@ static sys_var_const sys_named_pipe(&vars, "named_pipe",
/* purecov: end */
#endif
static sys_var_thd_ulong_session_readonly sys_net_buffer_length(&vars, "net_buffer_length",
- &SV::net_buffer_length);
+ &SV::net_buffer_length,
+ check_net_buffer_length);
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
&SV::net_read_timeout,
0, fix_net_read_timeout);
@@ -515,17 +527,6 @@ static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_sea
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
&SV::optimizer_switch);
-const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
-TYPELIB optimizer_use_mrr_typelib= {
- array_elements(optimizer_use_mrr_names) - 1, "",
- optimizer_use_mrr_names, NULL
-};
-
-static sys_var_thd_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
- &SV::optimizer_use_mrr,
- &optimizer_use_mrr_typelib,
- NULL);
-
static sys_var_const sys_pid_file(&vars, "pid_file",
OPT_GLOBAL, SHOW_CHAR,
(uchar*) pidfile_name);
@@ -555,9 +556,6 @@ static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
&SV::div_precincrement);
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
&rpl_recovery_rank);
-static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
&SV::range_alloc_block_size);
@@ -625,14 +623,20 @@ sys_var_enum_const sys_thread_handling(&vars, "thread_handling",
&thread_handling_typelib);
#ifdef HAVE_QUERY_CACHE
+static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size",
+ &query_cache_size,
+ fix_query_cache_size);
static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit",
- &query_cache.query_cache_limit);
-static sys_var_long_ptr sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
- &query_cache_min_res_unit,
- fix_query_cache_min_res_unit);
+ &query_cache.query_cache_limit);
+static sys_var_long_ptr
+ sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
+ &query_cache_min_res_unit,
+ fix_query_cache_min_res_unit);
static sys_var_thd_enum sys_query_cache_type(&vars, "query_cache_type",
&SV::query_cache_type,
- &query_cache_type_typelib);
+ &query_cache_type_typelib,
+ fix_query_cache_type,
+ check_query_cache_type);
static sys_var_thd_bool
sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate",
&SV::query_cache_wlock_invalidate);
@@ -928,6 +932,8 @@ static sys_var_const_str_ptr sys_log_basename(&vars, "log_basename",
#ifndef EMBEDDED_LIBRARY
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
+static sys_var_bool_ptr sys_query_cache_strip_comments(&vars, "query_cache_strip_comments",
+ &opt_query_cache_strip_comments);
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
static uchar *slave_get_report_port(THD *thd)
@@ -1217,10 +1223,9 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)),
{}
#endif /* HAVE_REPLICATION */
-
+#ifdef HAVE_QUERY_CACHE
static void fix_query_cache_size(THD *thd, enum_var_type type)
{
-#ifdef HAVE_QUERY_CACHE
ulong new_cache_size= query_cache.resize(query_cache_size);
/*
@@ -1234,11 +1239,60 @@ static void fix_query_cache_size(THD *thd, enum_var_type type)
query_cache_size, new_cache_size);
query_cache_size= new_cache_size;
-#endif
}
-#ifdef HAVE_QUERY_CACHE
+/**
+ Trigger before query_cache_type variable is updated.
+ @param thd Thread handler
+ @param var Pointer to the new variable status
+
+ @return Status code
+ @retval TRUE Failure
+ @retval FALSE Success
+*/
+
+static int check_query_cache_type(THD *thd, set_var *var)
+{
+ /*
+ Don't allow changes of the query_cache_type if the query cache
+ is disabled.
+ */
+ if (query_cache.is_disable_in_progress())
+ {
+ my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
+ return TRUE;
+ }
+ if (var->type != OPT_GLOBAL &&
+ global_system_variables.query_cache_type == 0 &&
+ var->value->val_int() != 0)
+ {
+ my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static void fix_query_cache_type(THD *thd, enum_var_type type)
+{
+ if (type == OPT_GLOBAL)
+ {
+ if (global_system_variables.query_cache_type != 0 &&
+ query_cache.is_disabled())
+ {
+ /* if disabling in progress variable will not be set */
+ DBUG_ASSERT(!query_cache.is_disable_in_progress());
+ /* Enable query cache because it was disabled */
+ fix_query_cache_size(thd, type);
+ }
+ else if (global_system_variables.query_cache_type == 0)
+ query_cache.disable_query_cache(thd);
+ }
+}
+
+
static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
{
query_cache_min_res_unit=
@@ -1919,7 +1973,7 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
}
var->save_result.ulong_value= ((ulong)
- find_set(enum_names, res->ptr(),
+ find_set(enum_names, res->c_ptr_safe(),
res->length(),
NULL,
&error, &error_len,
@@ -2334,7 +2388,7 @@ bool sys_var_character_set_client::check(THD *thd, set_var *var)
if (sys_var_character_set_sv::check(thd, var))
return 1;
/* Currently, UCS-2 cannot be used as a client character set */
- if (var->save_result.charset->mbminlen > 1)
+ if (!is_supported_parser_charset(var->save_result.charset))
{
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
var->save_result.charset->csname);
@@ -2846,38 +2900,43 @@ int set_var_collation_client::update(THD *thd)
bool sys_var_timestamp::check(THD *thd, set_var *var)
{
- time_t val;
- var->save_result.ulonglong_value= var->value->val_int();
- val= (time_t) var->save_result.ulonglong_value;
- if (val < (time_t) MY_TIME_T_MIN || val > (time_t) MY_TIME_T_MAX)
+ ulonglong sec;
+ ulong sec_part;
+ char buf[64], *errval= 0;
+ if (var->value->get_seconds(&sec, &sec_part))
+ errval= llstr(sec, buf);
+ else if (sec > TIMESTAMP_MAX_VALUE)
+ errval= ullstr(sec, buf);
+
+ if (errval)
{
- my_message(ER_UNKNOWN_ERROR,
- "This version of MySQL doesn't support dates later than 2038",
- MYF(0));
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", errval);
return TRUE;
}
+ var->save_result.ulonglong_value= hrtime_from_time(sec)+sec_part;
return FALSE;
}
bool sys_var_timestamp::update(THD *thd, set_var *var)
{
- thd->set_time((time_t) var->save_result.ulonglong_value);
+ my_hrtime_t hrtime = { var->save_result.ulonglong_value };
+ thd->set_time(hrtime);
return FALSE;
}
void sys_var_timestamp::set_default(THD *thd, enum_var_type type)
{
- thd->user_time=0;
+ thd->user_time.val= 0;
}
uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
- thd->sys_var_tmp.long_value= (long) thd->start_time;
- return (uchar*) &thd->sys_var_tmp.long_value;
+ thd->sys_var_tmp.double_value= thd->start_time + thd->start_time_sec_part/1e6;
+ return (uchar*) &thd->sys_var_tmp.double_value;
}
@@ -3130,7 +3189,7 @@ void sys_var_thd_lc_time_names::set_default(THD *thd, enum_var_type type)
}
/*
- Handling of microseoncds given as seconds.part_seconds
+ Handling of microseconds given as seconds.part_seconds
NOTES
The argument to long query time is in seconds in decimal
@@ -3176,10 +3235,10 @@ void sys_var_microseconds::set_default(THD *thd, enum_var_type type)
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
- thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
+ thd->sys_var_tmp.double_value= (double) ((type == OPT_GLOBAL) ?
global_system_variables.*offset :
thd->variables.*offset) / 1000000.0;
- return (uchar*) &thd->tmp_double_value;
+ return (uchar*) &thd->sys_var_tmp.double_value;
}
@@ -3662,6 +3721,16 @@ bool not_all_support_one_shot(List<set_var_base> *var_list)
Functions to handle SET mysql_internal_variable=const_expr
*****************************************************************************/
+/**
+ Verify that the supplied value is correct.
+
+ @param thd Thread handler
+
+ @return status code
+ @retval -1 Failure
+ @retval 0 Success
+*/
+
int set_var::check(THD *thd)
{
if (var->is_readonly())
@@ -4432,6 +4501,36 @@ uchar *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
}
#endif
+
+int
+check_max_allowed_packet(THD *thd, set_var *var)
+{
+ longlong val= var->value->val_int();
+ if (val < (longlong) global_system_variables.net_buffer_length)
+ {
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR,
+ "The value of 'max_allowed_packet' should be no less than "
+ "the value of 'net_buffer_length'");
+ }
+ return 0;
+}
+
+
+int
+check_net_buffer_length(THD *thd, set_var *var)
+{
+ longlong val= var->value->val_int();
+ if (val > (longlong) global_system_variables.max_allowed_packet)
+ {
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR,
+ "The value of 'max_allowed_packet' should be no less than "
+ "the value of 'net_buffer_length'");
+ }
+ return 0;
+}
+
/****************************************************************************
Used templates
****************************************************************************/
diff --git a/sql/set_var.h b/sql/set_var.h
index 95885357b83..c591ab5b866 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -516,10 +516,15 @@ public:
{ chain_sys_var(chain); }
bool check(THD *thd, set_var *var)
{
- int ret= 0;
- if (check_func)
- ret= (*check_func)(thd, var);
- return ret ? ret : check_enum(thd, var, enum_names);
+ /*
+ check_enum fails if the character representation supplied was wrong
+ or that the integer value was wrong or missing.
+ */
+ if (check_enum(thd, var, enum_names))
+ return TRUE;
+ if ((check_func && (*check_func)(thd, var)))
+ return TRUE;
+ return FALSE;
}
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
@@ -675,8 +680,12 @@ public:
void set_default(THD *thd, enum_var_type type);
bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
bool check_default(enum_var_type type) { return 0; }
- SHOW_TYPE show_type() { return SHOW_LONG; }
+ SHOW_TYPE show_type() { return SHOW_DOUBLE; }
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+ virtual bool check_update_type(Item_result type)
+ {
+ return type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT;
+ }
};
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 853c9fac56e..eb5d7ed935d 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5321,7 +5321,7 @@ ER_NO_DEFAULT_FOR_FIELD
ER_DIVISION_BY_ZERO 22012
eng "Division by 0"
ger "Division durch 0"
-ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
+ER_TRUNCATED_WRONG_VALUE_FOR_FIELD 22007
eng "Incorrect %-.32s value: '%-.128s' for column '%.192s' at row %lu"
ger "Falscher %-.32s-Wert: '%-.128s' für Feld '%.192s' in Zeile %lu"
ER_ILLEGAL_VALUE_FOR_TYPE 22007
@@ -5513,11 +5513,11 @@ ER_SP_NO_RECURSION
eng "Recursive stored functions and triggers are not allowed."
ger "Rekursive gespeicherte Routinen und Triggers sind nicht erlaubt"
ER_TOO_BIG_SCALE 42000 S1009
- eng "Too big scale %d specified for column '%-.192s'. Maximum is %lu."
- ger "Zu großer Skalierungsfaktor %d für Feld '%-.192s' angegeben. Maximum ist %lu"
+ eng "Too big scale %u specified for '%-.192s'. Maximum is %lu."
+ ger "Zu großer Skalierungsfaktor %u für '%-.192s' angegeben. Maximum ist %lu"
ER_TOO_BIG_PRECISION 42000 S1009
- eng "Too big precision %d specified for column '%-.192s'. Maximum is %lu."
- ger "Zu große Genauigkeit %d für Feld '%-.192s' angegeben. Maximum ist %lu"
+ eng "Too big precision %u specified for '%-.192s'. Maximum is %lu."
+ ger "Zu große Genauigkeit %u für '%-.192s' angegeben. Maximum ist %lu"
ER_M_BIGGER_THAN_D 42000 S1009
eng "For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '%-.192s')."
ger "Für FLOAT(M,D), DOUBLE(M,D) oder DECIMAL(M,D) muss M >= D sein (Feld '%-.192s')"
@@ -5555,8 +5555,8 @@ ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
eng "Cannot drop default keycache"
ger "Der vorgabemäßige Schlüssel-Cache kann nicht gelöscht werden"
ER_TOO_BIG_DISPLAYWIDTH 42000 S1009
- eng "Display width out of range for column '%-.192s' (max = %lu)"
- ger "Anzeigebreite außerhalb des zulässigen Bereichs für Spalte '%-.192s' (Maximum: %lu)"
+ eng "Display width out of range for '%-.192s' (max = %lu)"
+ ger "Anzeigebreite außerhalb des zulässigen Bereichs für '%-.192s' (Maximum: %lu)"
ER_XAER_DUPID XAE08
eng "XAER_DUPID: The XID already exists"
ger "XAER_DUPID: Die XID existiert bereits"
@@ -6214,6 +6214,19 @@ ER_DEBUG_SYNC_HIT_LIMIT
eng "debug sync point hit limit reached"
ger "Debug Sync Point Hit Limit erreicht"
+#
+# MariaDB error messages section starts here
+#
+
+# The following is here to allow us to detect if there was missing
+# error messages in the errmsg.sys file
+
+ER_LAST_MYSQL_ERROR_MESSAGE
+ eng ""
+
+# MariaDB error numbers starts from 1900
+start-error-number 1900
+
ER_VCOL_BASED_ON_VCOL
eng "A computed column cannot be based on a computed column"
@@ -6249,6 +6262,31 @@ ER_UNKNOWN_OPTION
eng "Unknown option '%-.64s'"
ER_BAD_OPTION_VALUE
eng "Incorrect value '%-.64s' for option '%-.64s'"
+ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
+ eng "Replication event checksum verification failed while reading from network."
+ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE
+ eng "Replication event checksum verification failed while reading from a log file."
ER_CANT_DO_ONLINE
eng "Can't execute the given '%s' command as online"
-
+ER_DATA_OVERFLOW 22003
+ eng "Got overflow when converting '%-.128s' to %-.32s. Value truncated."
+ER_DATA_TRUNCATED 22003
+ eng "Truncated value '%-.128s' when converting to %-.32s"
+ER_BAD_DATA 22007
+ eng "Encountered illegal value '%-.128s' when converting to %-.32s"
+ER_DYN_COL_WRONG_FORMAT
+ eng "Encountered illegal format of dynamic column string"
+ER_DYN_COL_IMPLEMENTATION_LIMIT
+ eng "Dynamic column implementation limit reached"
+ER_DYN_COL_DATA 22007
+ eng "Illegal value used as argument of dynamic column function"
+ER_DYN_COL_WRONG_CHARSET
+ eng "Dynamic column contains unknown character set"
+ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES
+ eng "At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'."
+ER_QUERY_CACHE_IS_DISABLED
+ eng "Query cache is disabled (resize or similar command in progress); repeat this command later"
+ER_QUERY_CACHE_IS_GLOBALY_DISABLED
+ eng "Query cache is globally disabled and you can't enable it only for this session"
+ER_SPATIAL_MUST_HAVE_GEOM_COL 42000
+ eng "A SPATIAL index may only contain a geometrical type column"
diff --git a/sql/slave.cc b/sql/slave.cc
index 63b7ce715c9..cfa6c9fdc56 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (C) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -408,17 +409,6 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
- if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
- {
- DBUG_PRINT("info",("Terminating IO thread"));
- mi->abort_slave=1;
- if ((error=terminate_slave_thread(mi->io_thd, io_lock,
- &mi->stop_cond,
- &mi->slave_running,
- skip_lock)) &&
- !force_all)
- DBUG_RETURN(error);
- }
if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))
{
DBUG_PRINT("info",("Terminating SQL thread"));
@@ -430,6 +420,17 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
!force_all)
DBUG_RETURN(error);
}
+ if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
+ {
+ DBUG_PRINT("info",("Terminating IO thread"));
+ mi->abort_slave=1;
+ if ((error=terminate_slave_thread(mi->io_thd, io_lock,
+ &mi->stop_cond,
+ &mi->slave_running,
+ skip_lock)) &&
+ !force_all)
+ DBUG_RETURN(error);
+ }
DBUG_RETURN(0);
}
@@ -937,6 +938,48 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi)
}
/*
+ FD_q's (A) is set initially from RL's (A): FD_q.(A) := RL.(A).
+ It's necessary to adjust FD_q.(A) at this point because in the following
+ course FD_q is going to be dumped to RL.
+ Generally FD_q is derived from a received FD_m (roughly FD_q := FD_m)
+ in queue_event and the master's (A) is installed.
+ At one step with the assignment the Relay-Log's checksum alg is set to
+ a new value: RL.(A) := FD_q.(A). If the slave service is stopped
+ the last time assigned RL.(A) will be passed over to the restarting
+ service (to the current execution point).
+ RL.A is a "codec" to verify checksum in queue_event() almost all the time
+ the first fake Rotate event.
+ Starting from this point IO thread will executes the following checksum
+ warmup sequence of actions:
+
+ FD_q.A := RL.A,
+ A_m^0 := master.@@global.binlog_checksum,
+ {queue_event(R_f): verifies(R_f, A_m^0)},
+ {queue_event(FD_m): verifies(FD_m, FD_m.A), dump(FD_q), rotate(RL),
+ FD_q := FD_m, RL.A := FD_q.A)}
+
+ See legends definition on MYSQL_BIN_LOG::relay_log_checksum_alg
+ docs lines (binlog.h).
+ In above A_m^0 - the value of master's
+ @@binlog_checksum determined in the upcoming handshake (stored in
+ mi->checksum_alg_before_fd).
+
+
+ After the warm-up sequence IO gets to "normal" checksum verification mode
+ to use RL.A in
+
+ {queue_event(E_m): verifies(E_m, RL.A)}
+
+ until it has received a new FD_m.
+ */
+ mi->rli.relay_log.description_event_for_queue->checksum_alg=
+ mi->rli.relay_log.relay_log_checksum_alg;
+
+ DBUG_ASSERT(mi->rli.relay_log.description_event_for_queue->checksum_alg !=
+ BINLOG_CHECKSUM_ALG_UNDEF);
+ DBUG_ASSERT(mi->rli.relay_log.relay_log_checksum_alg !=
+ BINLOG_CHECKSUM_ALG_UNDEF);
+ /*
Compare the master and slave's clock. Do not die if master's clock is
unavailable (very old master not supporting UNIX_TIMESTAMP()?).
*/
@@ -1175,6 +1218,103 @@ when it try to get the value of TIME_ZONE global variable from master.";
}
}
+ /*
+ Querying if master is capable to checksum and notifying it about own
+ CRC-awareness. The master's side instant value of @@global.binlog_checksum
+ is stored in the dump thread's uservar area as well as cached locally
+ to become known in consensus by master and slave.
+ */
+ DBUG_EXECUTE_IF("simulate_slave_unaware_checksum",
+ mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_OFF;
+ goto past_checksum;);
+ {
+ int rc;
+ const char query[]= "SET @master_binlog_checksum= @@global.binlog_checksum";
+ master_res= NULL;
+ mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_UNDEF; //initially undefined
+ /*
+ @c checksum_alg_before_fd is queried from master in this block.
+ If master is old checksum-unaware the value stays undefined.
+ Once the first FD will be received its alg descriptor will replace
+ the being queried one.
+ */
+ rc= mysql_real_query(mysql, query, strlen(query));
+ if (rc != 0)
+ {
+ if (check_io_slave_killed(mi->io_thd, mi, NULL))
+ goto slave_killed_err;
+
+ if (mysql_errno(mysql) == ER_UNKNOWN_SYSTEM_VARIABLE)
+ {
+ // this is tolerable as OM -> NS is supported
+ mi->report(WARNING_LEVEL, mysql_errno(mysql),
+ "Notifying master by %s failed with "
+ "error: %s", query, mysql_error(mysql));
+ }
+ else
+ {
+ if (is_network_error(mysql_errno(mysql)))
+ {
+ mi->report(WARNING_LEVEL, mysql_errno(mysql),
+ "Notifying master by %s failed with "
+ "error: %s", query, mysql_error(mysql));
+ mysql_free_result(mysql_store_result(mysql));
+ goto network_err;
+ }
+ else
+ {
+ errmsg= "The slave I/O thread stops because a fatal error is encountered "
+ "when it tried to SET @master_binlog_checksum on master.";
+ err_code= ER_SLAVE_FATAL_ERROR;
+ sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
+ mysql_free_result(mysql_store_result(mysql));
+ goto err;
+ }
+ }
+ }
+ else
+ {
+ mysql_free_result(mysql_store_result(mysql));
+ if (!mysql_real_query(mysql,
+ STRING_WITH_LEN("SELECT @master_binlog_checksum")) &&
+ (master_res= mysql_store_result(mysql)) &&
+ (master_row= mysql_fetch_row(master_res)) &&
+ (master_row[0] != NULL))
+ {
+ mi->checksum_alg_before_fd= (uint8)
+ find_type(master_row[0], &binlog_checksum_typelib, 1) - 1;
+ // valid outcome is either of
+ DBUG_ASSERT(mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_OFF ||
+ mi->checksum_alg_before_fd == BINLOG_CHECKSUM_ALG_CRC32);
+ }
+ else if (check_io_slave_killed(mi->io_thd, mi, NULL))
+ goto slave_killed_err;
+ else if (is_network_error(mysql_errno(mysql)))
+ {
+ mi->report(WARNING_LEVEL, mysql_errno(mysql),
+ "Get master BINLOG_CHECKSUM failed with error: %s", mysql_error(mysql));
+ goto network_err;
+ }
+ else
+ {
+ errmsg= "The slave I/O thread stops because a fatal error is encountered "
+ "when it tried to SELECT @master_binlog_checksum.";
+ err_code= ER_SLAVE_FATAL_ERROR;
+ sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
+ mysql_free_result(mysql_store_result(mysql));
+ goto err;
+ }
+ }
+ if (master_res)
+ {
+ mysql_free_result(master_res);
+ master_res= NULL;
+ }
+ }
+
+#ifndef DBUG_OFF
+past_checksum:
+#endif
err:
if (errmsg)
{
@@ -1191,6 +1331,11 @@ network_err:
if (master_res)
mysql_free_result(master_res);
DBUG_RETURN(2);
+
+slave_killed_err:
+ if (master_res)
+ mysql_free_result(master_res);
+ DBUG_RETURN(2);
}
/*
@@ -2115,7 +2260,11 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli)
thd->set_time(); // time the query
thd->lex->current_select= 0;
if (!ev->when)
- ev->when= my_time(0);
+ {
+ my_hrtime_t hrtime= my_hrtime();
+ ev->when= hrtime_to_my_time(hrtime);
+ ev->when_sec_part= hrtime_sec_part(hrtime);
+ }
ev->thd = thd; // because up to this point, ev->thd == 0
int reason= ev->shall_skip(rli);
@@ -3384,10 +3533,15 @@ static int process_io_rotate(Master_info *mi, Rotate_log_event *rev)
*/
if (mi->rli.relay_log.description_event_for_queue->binlog_version >= 4)
{
+ DBUG_ASSERT(mi->rli.relay_log.description_event_for_queue->checksum_alg ==
+ mi->rli.relay_log.relay_log_checksum_alg);
+
delete mi->rli.relay_log.description_event_for_queue;
/* start from format 3 (MySQL 4.0) again */
mi->rli.relay_log.description_event_for_queue= new
Format_description_log_event(3);
+ mi->rli.relay_log.description_event_for_queue->checksum_alg=
+ mi->rli.relay_log.relay_log_checksum_alg;
}
/*
Rotate the relay log makes binlog format detection easier (at next slave
@@ -3440,8 +3594,9 @@ static int queue_binlog_ver_1_event(Master_info *mi, const char *buf,
Append_block/Exec_load (the SQL thread needs the data, as that thread is not
connected to the master).
*/
- Log_event *ev = Log_event::read_log_event(buf,event_len, &errmsg,
- mi->rli.relay_log.description_event_for_queue);
+ Log_event *ev=
+ Log_event::read_log_event(buf, event_len, &errmsg,
+ mi->rli.relay_log.description_event_for_queue, 0);
if (unlikely(!ev))
{
sql_print_error("Read invalid event from master: '%s',\
@@ -3528,8 +3683,9 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
DBUG_ENTER("queue_binlog_ver_3_event");
/* read_log_event() will adjust log_pos to be end_log_pos */
- Log_event *ev = Log_event::read_log_event(buf,event_len, &errmsg,
- mi->rli.relay_log.description_event_for_queue);
+ Log_event *ev=
+ Log_event::read_log_event(buf,event_len, &errmsg,
+ mi->rli.relay_log.description_event_for_queue, 0);
if (unlikely(!ev))
{
sql_print_error("Read invalid event from master: '%s',\
@@ -3555,6 +3711,7 @@ static int queue_binlog_ver_3_event(Master_info *mi, const char *buf,
inc_pos= event_len;
break;
}
+
if (unlikely(rli->relay_log.append(ev)))
{
delete ev;
@@ -3616,7 +3773,68 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
ulong inc_pos;
Relay_log_info *rli= &mi->rli;
pthread_mutex_t *log_lock= rli->relay_log.get_log_lock();
+ bool unlock_data_lock= TRUE;
+ /*
+ FD_q must have been prepared for the first R_a event
+ inside get_master_version_and_clock()
+ Show-up of FD:s affects checksum_alg at once because
+ that changes FD_queue.
+ */
+ uint8 checksum_alg= mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF ?
+ mi->checksum_alg_before_fd :
+ mi->rli.relay_log.relay_log_checksum_alg;
+
+ char *save_buf= NULL; // needed for checksumming the fake Rotate event
+ char rot_buf[LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN + FN_REFLEN];
+
+ DBUG_ASSERT(checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
+ checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
+ checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
+
DBUG_ENTER("queue_event");
+ /*
+ FD_queue checksum alg description does not apply in a case of
+ FD itself. The one carries both parts of the checksum data.
+ */
+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT)
+ {
+ checksum_alg= get_checksum_alg(buf, event_len);
+ }
+ else if (buf[EVENT_TYPE_OFFSET] == START_EVENT_V3)
+ {
+ // checksum behaviour is similar to the pre-checksum FD handling
+ mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_UNDEF;
+ mi->rli.relay_log.description_event_for_queue->checksum_alg=
+ mi->rli.relay_log.relay_log_checksum_alg= checksum_alg=
+ BINLOG_CHECKSUM_ALG_OFF;
+ }
+
+ // does not hold always because of old binlog can work with NM
+ // DBUG_ASSERT(checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF);
+
+ // should hold unless manipulations with RL. Tests that do that
+ // will have to refine the clause.
+ DBUG_ASSERT(mi->rli.relay_log.relay_log_checksum_alg !=
+ BINLOG_CHECKSUM_ALG_UNDEF);
+
+ // Emulate the network corruption
+ DBUG_EXECUTE_IF("corrupt_queue_event",
+ if (buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT)
+ {
+ char *debug_event_buf_c = (char*) buf;
+ int debug_cor_pos = rand() % (event_len - BINLOG_CHECKSUM_LEN);
+ debug_event_buf_c[debug_cor_pos] =~ debug_event_buf_c[debug_cor_pos];
+ DBUG_PRINT("info", ("Corrupt the event at queue_event: byte on position %d", debug_cor_pos));
+ DBUG_SET("-d,corrupt_queue_event");
+ }
+ );
+
+ if (event_checksum_test((uchar *) buf, event_len, checksum_alg))
+ {
+ error= ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE;
+ unlock_data_lock= FALSE;
+ goto err;
+ }
LINT_INIT(inc_pos);
@@ -3644,12 +3862,67 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
goto err;
case ROTATE_EVENT:
{
- Rotate_log_event rev(buf,event_len,mi->rli.relay_log.description_event_for_queue);
- if (unlikely(process_io_rotate(mi,&rev)))
+ Rotate_log_event rev(buf, checksum_alg != BINLOG_CHECKSUM_ALG_OFF ?
+ event_len - BINLOG_CHECKSUM_LEN : event_len,
+ mi->rli.relay_log.description_event_for_queue);
+
+ if (unlikely(process_io_rotate(mi, &rev)))
{
error= 1;
goto err;
}
+ /*
+ Checksum special cases for the fake Rotate (R_f) event caused by the protocol
+ of events generation and serialization in RL where Rotate of master is
+ queued right next to FD of slave.
+ Since it's only FD that carries the alg desc of FD_s has to apply to R_m.
+ Two special rules apply only to the first R_f which comes in before any FD_m.
+ The 2nd R_f should be compatible with the FD_s that must have taken over
+ the last seen FD_m's (A).
+
+ RSC_1: If OM \and fake Rotate \and slave is configured to
+ to compute checksum for its first FD event for RL
+ the fake Rotate gets checksummed here.
+ */
+ if (uint4korr(&buf[0]) == 0 && checksum_alg == BINLOG_CHECKSUM_ALG_OFF &&
+ mi->rli.relay_log.relay_log_checksum_alg != BINLOG_CHECKSUM_ALG_OFF)
+ {
+ ha_checksum rot_crc= my_checksum(0L, NULL, 0);
+ event_len += BINLOG_CHECKSUM_LEN;
+ memcpy(rot_buf, buf, event_len - BINLOG_CHECKSUM_LEN);
+ int4store(&rot_buf[EVENT_LEN_OFFSET],
+ uint4korr(&rot_buf[EVENT_LEN_OFFSET]) + BINLOG_CHECKSUM_LEN);
+ rot_crc= my_checksum(rot_crc, (const uchar *) rot_buf,
+ event_len - BINLOG_CHECKSUM_LEN);
+ int4store(&rot_buf[event_len - BINLOG_CHECKSUM_LEN], rot_crc);
+ DBUG_ASSERT(event_len == uint4korr(&rot_buf[EVENT_LEN_OFFSET]));
+ DBUG_ASSERT(mi->rli.relay_log.description_event_for_queue->checksum_alg ==
+ mi->rli.relay_log.relay_log_checksum_alg);
+ /* the first one */
+ DBUG_ASSERT(mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF);
+ save_buf= (char *) buf;
+ buf= rot_buf;
+ }
+ else
+ /*
+ RSC_2: If NM \and fake Rotate \and slave does not compute checksum
+ the fake Rotate's checksum is stripped off before relay-logging.
+ */
+ if (uint4korr(&buf[0]) == 0 && checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ mi->rli.relay_log.relay_log_checksum_alg == BINLOG_CHECKSUM_ALG_OFF)
+ {
+ event_len -= BINLOG_CHECKSUM_LEN;
+ memcpy(rot_buf, buf, event_len);
+ int4store(&rot_buf[EVENT_LEN_OFFSET],
+ uint4korr(&rot_buf[EVENT_LEN_OFFSET]) - BINLOG_CHECKSUM_LEN);
+ DBUG_ASSERT(event_len == uint4korr(&rot_buf[EVENT_LEN_OFFSET]));
+ DBUG_ASSERT(mi->rli.relay_log.description_event_for_queue->checksum_alg ==
+ mi->rli.relay_log.relay_log_checksum_alg);
+ /* the first one */
+ DBUG_ASSERT(mi->checksum_alg_before_fd != BINLOG_CHECKSUM_ALG_UNDEF);
+ save_buf= (char *) buf;
+ buf= rot_buf;
+ }
/*
Now the I/O thread has just changed its mi->master_log_name, so
incrementing mi->master_log_pos is nonsense.
@@ -3670,15 +3943,24 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
*/
Format_description_log_event* tmp;
const char* errmsg;
+ // mark it as undefined that is irrelevant anymore
+ mi->checksum_alg_before_fd= BINLOG_CHECKSUM_ALG_UNDEF;
if (!(tmp= (Format_description_log_event*)
Log_event::read_log_event(buf, event_len, &errmsg,
- mi->rli.relay_log.description_event_for_queue)))
+ mi->rli.relay_log.description_event_for_queue,
+ 1)))
{
error= 2;
goto err;
}
delete mi->rli.relay_log.description_event_for_queue;
mi->rli.relay_log.description_event_for_queue= tmp;
+ if (tmp->checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF)
+ tmp->checksum_alg= BINLOG_CHECKSUM_ALG_OFF;
+
+ /* installing new value of checksum Alg for relay log */
+ mi->rli.relay_log.relay_log_checksum_alg= tmp->checksum_alg;
+
/*
Though this does some conversion to the slave's format, this will
preserve the master's binlog format version, and number of event types.
@@ -3755,12 +4037,15 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
else
error= 3;
rli->ign_master_log_name_end[0]= 0; // last event is not ignored
+ if (save_buf != NULL)
+ buf= save_buf;
}
pthread_mutex_unlock(log_lock);
err:
- pthread_mutex_unlock(&mi->data_lock);
+ if (unlock_data_lock)
+ pthread_mutex_unlock(&mi->data_lock);
DBUG_PRINT("info", ("error: %d", error));
DBUG_RETURN(error);
}
@@ -4150,8 +4435,9 @@ static Log_event* next_event(Relay_log_info* rli)
But if the relay log is created by new_file(): then the solution is:
MYSQL_BIN_LOG::open() will write the buffered description event.
*/
- if ((ev=Log_event::read_log_event(cur_log,0,
- rli->relay_log.description_event_for_exec)))
+ if ((ev= Log_event::read_log_event(cur_log,0,
+ rli->relay_log.description_event_for_exec,
+ opt_slave_sql_verify_checksum)))
{
DBUG_ASSERT(thd==rli->sql_thd);
@@ -4552,9 +4838,9 @@ bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
{37426, { 5, 1, 0 }, { 5, 1, 26 } },
};
const uchar *master_ver=
- rli->relay_log.description_event_for_exec->server_version_split;
+ rli->relay_log.description_event_for_exec->server_version_split.ver;
- DBUG_ASSERT(sizeof(rli->relay_log.description_event_for_exec->server_version_split) == 3);
+ DBUG_ASSERT(sizeof(rli->relay_log.description_event_for_exec->server_version_split.ver) == 3);
for (uint i= 0;
i < sizeof(versions_for_all_bugs)/sizeof(*versions_for_all_bugs);i++)
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index dbaeb9467ae..bd2dcfd8653 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -49,19 +49,7 @@ static void reset_start_time_for_sp(THD *thd)
constant during the execution of those.
*/
if (!thd->in_sub_stmt)
- {
- /*
- First investigate if there is a cached time stamp
- */
- if (thd->user_time)
- {
- thd->start_time= thd->user_time;
- }
- else
- {
- my_micro_time_and_time(&thd->start_time);
- }
- }
+ thd->set_time();
}
Item_result
@@ -2847,6 +2835,9 @@ int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables)
result= -1;
else
result= 0;
+ /* Prepare all derived tables/views to catch possible errors. */
+ if (!result)
+ result= mysql_handle_derived(thd->lex, DT_PREPARE) ? -1 : 0;
return result;
}
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 686e1a1346f..18c80b2b054 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -651,7 +651,7 @@ int Select_fetch_into_spvars::prepare(List<Item> &fields, SELECT_LEX_UNIT *u)
}
-bool Select_fetch_into_spvars::send_data(List<Item> &items)
+int Select_fetch_into_spvars::send_data(List<Item> &items)
{
List_iterator_fast<struct sp_variable> spvar_iter(*spvar_list);
List_iterator_fast<Item> item_iter(items);
@@ -668,7 +668,7 @@ bool Select_fetch_into_spvars::send_data(List<Item> &items)
for (; spvar= spvar_iter++, item= item_iter++; )
{
if (thd->spcont->set_variable(thd, spvar->offset, &item))
- return TRUE;
+ return 1;
}
- return FALSE;
+ return 0;
}
diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h
index ecd11453e49..15815e496dd 100644
--- a/sql/sp_rcontext.h
+++ b/sql/sp_rcontext.h
@@ -254,7 +254,7 @@ public:
void set_spvar_list(List<struct sp_variable> *vars) { spvar_list= vars; }
virtual bool send_eof() { return FALSE; }
- virtual bool send_data(List<Item> &items);
+ virtual int send_data(List<Item> &items);
virtual int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
};
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 47d85238cff..b133e1e4d68 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -3057,7 +3058,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
class LEX_COLUMN *column;
List_iterator <LEX_COLUMN> column_iter(columns);
- if (open_and_lock_tables(thd, table_list))
+ if (open_and_lock_tables(thd, table_list) ||
+ mysql_handle_derived(thd->lex, DT_PREPARE))
DBUG_RETURN(TRUE);
while ((column = column_iter++))
@@ -5422,18 +5424,15 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop,
}
-/*
+/**
Handle an in-memory privilege structure.
- SYNOPSIS
- handle_grant_struct()
- struct_no The number of the structure to handle (0..3).
- drop If user_from is to be dropped.
- user_from The the user to be searched/dropped/renamed.
- user_to The new name for the user if to be renamed,
- NULL otherwise.
+ @param struct_no The number of the structure to handle (0..4).
+ @param drop If user_from is to be dropped.
+ @param user_from The the user to be searched/dropped/renamed.
+ @param user_to The new name for the user if to be renamed, NULL otherwise.
- DESCRIPTION
+ @note
Scan through all elements in an in-memory grant structure and apply
the requested operation.
Delete from grant structure if drop is true.
@@ -5443,12 +5442,12 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop,
0 acl_users
1 acl_dbs
2 column_priv_hash
- 3 procs_priv_hash
+ 3 proc_priv_hash
+ 4 func_priv_hash
- RETURN
- > 0 At least one element matched.
- 0 OK, but no element matched.
- -1 Wrong arguments to function
+ @retval > 0 At least one element matched.
+ @retval 0 OK, but no element matched.
+ @retval -1 Wrong arguments to function.
*/
static int handle_grant_struct(uint struct_no, bool drop,
@@ -5462,6 +5461,7 @@ static int handle_grant_struct(uint struct_no, bool drop,
ACL_USER *acl_user= NULL;
ACL_DB *acl_db= NULL;
GRANT_NAME *grant_name= NULL;
+ HASH *grant_name_hash= NULL;
DBUG_ENTER("handle_grant_struct");
DBUG_PRINT("info",("scan struct: %u search: '%s'@'%s'",
struct_no, user_from->user.str, user_from->host.str));
@@ -5480,10 +5480,16 @@ static int handle_grant_struct(uint struct_no, bool drop,
elements= acl_dbs.elements;
break;
case 2:
- elements= column_priv_hash.records;
+ grant_name_hash= &column_priv_hash;
+ elements= grant_name_hash->records;
break;
case 3:
- elements= proc_priv_hash.records;
+ grant_name_hash= &proc_priv_hash;
+ elements= grant_name_hash->records;
+ break;
+ case 4:
+ grant_name_hash= &func_priv_hash;
+ elements= grant_name_hash->records;
break;
default:
return -1;
@@ -5513,16 +5519,13 @@ static int handle_grant_struct(uint struct_no, bool drop,
break;
case 2:
- grant_name= (GRANT_NAME*) hash_element(&column_priv_hash, idx);
- user= grant_name->user;
- host= grant_name->host.hostname;
- break;
-
case 3:
- grant_name= (GRANT_NAME*) hash_element(&proc_priv_hash, idx);
+ case 4:
+ grant_name= (GRANT_NAME*) hash_element(grant_name_hash, idx);
user= grant_name->user;
host= grant_name->host.hostname;
break;
+
default:
MY_ASSERT_UNREACHABLE();
}
@@ -5552,14 +5555,25 @@ static int handle_grant_struct(uint struct_no, bool drop,
break;
case 2:
- hash_delete(&column_priv_hash, (uchar*) grant_name);
- break;
-
case 3:
- hash_delete(&proc_priv_hash, (uchar*) grant_name);
+ case 4:
+ hash_delete(grant_name_hash, (uchar*) grant_name);
break;
}
elements--;
+ /*
+ - If we are iterating through an array then we just have moved all
+ elements after the current element one position closer to its head.
+ This means that we have to take another look at the element at
+ current position as it is a new element from the array's tail.
+ - If we are iterating through a hash the current element was replaced
+ with one of elements from the tail. So we also have to take a look
+ at the new element in current position.
+ Note that in our HASH implementation hash_delete() won't move any
+ elements with position after current one to position before the
+ current (i.e. from the tail to the head), so it is safe to continue
+ iteration without re-starting.
+ */
idx--;
}
else if ( user_to )
@@ -5577,22 +5591,41 @@ static int handle_grant_struct(uint struct_no, bool drop,
case 2:
case 3:
- /*
- Update the grant structure with the new user name and
- host name
- */
- grant_name->set_user_details(user_to->host.str, grant_name->db,
- user_to->user.str, grant_name->tname,
- TRUE);
-
- /*
- Since username is part of the hash key, when the user name
- is renamed, the hash key is changed. Update the hash to
- ensure that the position matches the new hash key value
- */
- hash_update(&column_priv_hash, (uchar*) grant_name,
- (uchar*) grant_name->hash_key, grant_name->key_length);
- break;
+ case 4:
+ {
+ /*
+ Save old hash key and its length to be able properly update
+ element position in hash.
+ */
+ char *old_key= grant_name->hash_key;
+ size_t old_key_length= grant_name->key_length;
+
+ /*
+ Update the grant structure with the new user name and host name.
+ */
+ grant_name->set_user_details(user_to->host.str, grant_name->db,
+ user_to->user.str, grant_name->tname,
+ TRUE);
+
+ /*
+ Since username is part of the hash key, when the user name
+ is renamed, the hash key is changed. Update the hash to
+ ensure that the position matches the new hash key value
+ */
+ hash_update(grant_name_hash, (uchar*) grant_name, (uchar*) old_key,
+ old_key_length);
+ /*
+ hash_update() operation could have moved element from the tail
+ of the hash to the current position. So we need to take a look
+ at the element in current position once again.
+ Thanks to the fact that hash_update() for our HASH implementation
+ won't move any elements from the tail of the hash to the positions
+ before the current one (a.k.a. head) it is safe to continue
+ iteration without restarting.
+ */
+ idx--;
+ break;
+ }
}
}
else
@@ -5649,8 +5682,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
else
{
/* Handle user array. */
- if ((handle_grant_struct(0, drop, user_from, user_to) && ! result) ||
- found)
+ if ((handle_grant_struct(0, drop, user_from, user_to)) || found)
{
result= 1; /* At least one record/element found. */
/* If search is requested, we do not need to search further. */
@@ -5678,7 +5710,7 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
}
}
- /* Handle procedures table. */
+ /* Handle stored routines table. */
if ((found= handle_grant_table(tables, 4, drop, user_from, user_to)) < 0)
{
/* Handle of table failed, don't touch in-memory array. */
@@ -5695,6 +5727,15 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop,
if (! drop && ! user_to)
goto end;
}
+ /* Handle funcs array. */
+ if (((handle_grant_struct(4, drop, user_from, user_to) && ! result) ||
+ found) && ! result)
+ {
+ result= 1; /* At least one record/element found. */
+ /* If search is requested, we do not need to search further. */
+ if (! drop && ! user_to)
+ goto end;
+ }
}
/* Handle tables table. */
@@ -7348,7 +7389,8 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
if (ptr+1 < end)
{
uint cs_number= uint2korr(ptr);
- thd_init_client_charset(thd, cs_number);
+ if (thd_init_client_charset(thd, cs_number))
+ return 1;
thd->update_charset();
}
@@ -7451,7 +7493,8 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
thd->max_client_packet_length= uint4korr(net->read_pos+4);
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
- thd_init_client_charset(thd, (uint) net->read_pos[8]);
+ if (thd_init_client_charset(thd, (uint) net->read_pos[8]))
+ return packet_error;
thd->update_charset();
end= (char*) net->read_pos+32;
}
@@ -7999,7 +8042,8 @@ static int do_auth_once(THD *thd, LEX_STRING *auth_plugin_name,
@retval 1 error
*/
-bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_len)
+bool acl_authenticate(THD *thd, uint connect_errors,
+ uint com_change_user_pkt_len)
{
int res= CR_OK;
MPVIO_EXT mpvio;
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 2c6937d29b7..218f1a6bab1 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -242,7 +242,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
if (str == end)
{
info->is_float = 1; // we can't use variable decimals here
- return 1;
+ DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
@@ -753,7 +753,7 @@ int analyse::end_of_records()
tmp_str.append(STRING_WITH_LEN(" NOT NULL"));
output_str_length = tmp_str.length();
func_items[9]->set(tmp_str.ptr(), tmp_str.length(), tmp_str.charset());
- if (result->send_data(result_fields))
+ if (result->send_data(result_fields) > 0)
return -1;
continue;
}
@@ -798,7 +798,7 @@ int analyse::end_of_records()
if (!(*f)->nulls)
ans.append(STRING_WITH_LEN(" NOT NULL"));
func_items[9]->set(ans.ptr(), ans.length(), ans.charset());
- if (result->send_data(result_fields))
+ if (result->send_data(result_fields) > 0)
return -1;
}
return 0;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fa495a776e1..c42551100ae 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2827,10 +2827,9 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
("Found table '%s.%s' with different refresh version",
table_list->db, table_list->table_name));
- /* Ignore FLUSH, but not name locks! */
+ /* Ignore FLUSH and pending name locks, but not acquired name locks! */
if (flags & MYSQL_LOCK_IGNORE_FLUSH && !table->open_placeholder)
{
- DBUG_ASSERT(table->db_stat);
/* Force close at once after usage */
thd->version= table->s->version;
continue;
@@ -3026,6 +3025,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
*/
DBUG_ASSERT(table->file->pushed_cond == NULL);
table->reginfo.impossible_range= 0;
+ table->created= TRUE;
/* Catch wrong handling of the auto_increment_field_not_null. */
DBUG_ASSERT(!table->auto_increment_field_not_null);
table->auto_increment_field_not_null= FALSE;
@@ -5123,9 +5123,10 @@ int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived)
close_tables_for_reopen(thd, &tables);
}
if (derived &&
- (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
- (thd->fill_derived_tables() &&
- mysql_handle_derived(thd->lex, &mysql_derived_filling))))
+ (mysql_handle_derived(thd->lex, DT_INIT)))
+ DBUG_RETURN(TRUE); /* purecov: inspected */
+ if (thd->prepare_derived_at_open && derived &&
+ (mysql_handle_derived(thd->lex, DT_PREPARE)))
DBUG_RETURN(TRUE); /* purecov: inspected */
DBUG_RETURN(0);
}
@@ -5141,6 +5142,7 @@ int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived)
flags - bitmap of flags to modify how the tables will be open:
MYSQL_LOCK_IGNORE_FLUSH - open table even if someone has
done a flush on it.
+ dt_phases - set of flags to pass to the mysql_handle_derived
RETURN
FALSE - ok
@@ -5151,13 +5153,14 @@ int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived)
data from the tables.
*/
-bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags)
+bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags,
+ uint dt_phases)
{
uint counter;
DBUG_ENTER("open_normal_and_derived_tables");
DBUG_ASSERT(!thd->fill_derived_tables());
if (open_tables(thd, &tables, &counter, flags) ||
- mysql_handle_derived(thd->lex, &mysql_derived_prepare))
+ mysql_handle_derived(thd->lex, dt_phases))
DBUG_RETURN(TRUE); /* purecov: inspected */
DBUG_RETURN(0);
}
@@ -5829,9 +5832,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
Field_iterator_view field_it;
field_it.set(table_list);
Query_arena *arena= 0, backup;
-
- DBUG_ASSERT(table_list->schema_table_reformed ||
- (ref != 0 && table_list->view != 0));
+
for (; !field_it.end_of_fields(); field_it.next())
{
if (!my_strcasecmp(system_charset_info, field_it.name(), name))
@@ -5850,6 +5851,8 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
if (!item)
DBUG_RETURN(0);
+ if (!ref)
+ DBUG_RETURN((Field*) view_ref_found);
/*
*ref != NULL means that *ref contains the item that we need to
replace. If the item was aliased by the user, set the alias to
@@ -6254,6 +6257,8 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
Field *field_to_set= NULL;
if (fld == view_ref_found)
{
+ if (!ref)
+ DBUG_RETURN(fld);
Item *it= (*ref)->real_item();
if (it->type() == Item::FIELD_ITEM)
field_to_set= ((Item_field*)it)->field;
@@ -6261,6 +6266,8 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
{
if (thd->mark_used_columns == MARK_COLUMNS_READ)
it->walk(&Item::register_field_in_read_map, 1, (uchar *) 0);
+ else
+ it->walk(&Item::register_field_in_write_map, 1, (uchar *) 0);
}
}
else
@@ -6400,8 +6407,11 @@ find_field_in_tables(THD *thd, Item_ident *item,
find_field_in_table even in the case of information schema tables
when table_ref->field_translation != NULL.
*/
- if (table_ref->table && !table_ref->view)
+ if (table_ref->table && !table_ref->view &&
+ (!table_ref->is_merged_derived() ||
+ (!table_ref->is_multitable() && table_ref->merged_for_insert)))
{
+
found= find_field_in_table(thd, table_ref->table, name, length,
TRUE, &(item->cached_field_index));
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -6426,7 +6436,8 @@ find_field_in_tables(THD *thd, Item_ident *item,
Only views fields should be marked as dependent, not an underlying
fields.
*/
- if (!table_ref->belong_to_view)
+ if (!table_ref->belong_to_view &&
+ !table_ref->belong_to_derived)
{
SELECT_LEX *current_sel= thd->lex->current_select;
SELECT_LEX *last_select= table_ref->select_lex;
@@ -7021,6 +7032,10 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
*/
if (nj_col_2 && (!using_fields ||is_using_column_1))
{
+ /*
+ Create non-fixed fully qualified field and let fix_fields to
+ resolve it.
+ */
Item *item_1= nj_col_1->create_item(thd);
Item *item_2= nj_col_2->create_item(thd);
Field *field_1= nj_col_1->field();
@@ -7469,7 +7484,11 @@ static bool setup_natural_join_row_types(THD *thd,
for (left_neighbor= table_ref_it++; left_neighbor ; )
{
table_ref= left_neighbor;
- left_neighbor= table_ref_it++;
+ do
+ {
+ left_neighbor= table_ref_it++;
+ }
+ while (left_neighbor && left_neighbor->sj_subq_pred);
/*
Do not redo work if already done:
1) for stored procedures,
@@ -7684,27 +7703,36 @@ bool setup_fields(THD *thd, Item **ref_pointer_array,
make_leaves_list()
list pointer to pointer on list first element
tables table list
+ full_table_list whether to include tables from mergeable derived table/view.
+ we need them for checks for INSERT/UPDATE statements only.
RETURN pointer on pointer to next_leaf of last element
*/
-TABLE_LIST **make_leaves_list(TABLE_LIST **list, TABLE_LIST *tables)
+void make_leaves_list(List<TABLE_LIST> &list, TABLE_LIST *tables,
+ bool full_table_list, TABLE_LIST *boundary)
+
{
for (TABLE_LIST *table= tables; table; table= table->next_local)
{
- if (table->merge_underlying_list)
+ if (table == boundary)
+ full_table_list= !full_table_list;
+ if (full_table_list && table->is_merged_derived())
{
- DBUG_ASSERT(table->view &&
- table->effective_algorithm == VIEW_ALGORITHM_MERGE);
- list= make_leaves_list(list, table->merge_underlying_list);
+ SELECT_LEX *select_lex= table->get_single_select();
+ /*
+ It's safe to use select_lex->leaf_tables because all derived
+ tables/views were already prepared and has their leaf_tables
+ set properly.
+ */
+ make_leaves_list(list, select_lex->get_table_list(),
+ full_table_list, boundary);
}
else
{
- *list= table;
- list= &table->next_leaf;
+ list.push_back(table);
}
}
- return list;
}
/*
@@ -7719,6 +7747,7 @@ TABLE_LIST **make_leaves_list(TABLE_LIST **list, TABLE_LIST *tables)
leaves List of join table leaves list (select_lex->leaf_tables)
refresh It is onle refresh for subquery
select_insert It is SELECT ... INSERT command
+ full_table_list a parameter to pass to the make_leaves_list function
NOTE
Check also that the 'used keys' and 'ignored keys' exists and set up the
@@ -7737,9 +7766,13 @@ TABLE_LIST **make_leaves_list(TABLE_LIST **list, TABLE_LIST *tables)
bool setup_tables(THD *thd, Name_resolution_context *context,
List<TABLE_LIST> *from_clause, TABLE_LIST *tables,
- TABLE_LIST **leaves, bool select_insert)
+ List<TABLE_LIST> &leaves, bool select_insert,
+ bool full_table_list)
{
uint tablenr= 0;
+ List_iterator<TABLE_LIST> ti(leaves);
+ TABLE_LIST *table_list;
+
DBUG_ENTER("setup_tables");
DBUG_ASSERT ((select_insert && !tables->next_name_resolution_table) || !tables ||
@@ -7751,40 +7784,66 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
TABLE_LIST *first_select_table= (select_insert ?
tables->next_local:
0);
- if (!(*leaves))
- make_leaves_list(leaves, tables);
-
- TABLE_LIST *table_list;
- for (table_list= *leaves;
- table_list;
- table_list= table_list->next_leaf, tablenr++)
+ SELECT_LEX *select_lex= select_insert ? &thd->lex->select_lex :
+ thd->lex->current_select;
+ if (select_lex->first_cond_optimization)
{
- TABLE *table= table_list->table;
- table->pos_in_table_list= table_list;
- if (first_select_table &&
- table_list->top_table() == first_select_table)
+ leaves.empty();
+ select_lex->leaf_tables_exec.empty();
+ make_leaves_list(leaves, tables, full_table_list, first_select_table);
+
+ while ((table_list= ti++))
{
- /* new counting for SELECT of INSERT ... SELECT command */
- first_select_table= 0;
- tablenr= 0;
+ TABLE *table= table_list->table;
+ table->pos_in_table_list= table_list;
+ if (first_select_table &&
+ table_list->top_table() == first_select_table)
+ {
+ /* new counting for SELECT of INSERT ... SELECT command */
+ first_select_table= 0;
+ thd->lex->select_lex.insert_tables= tablenr;
+ tablenr= 0;
+ }
+ if(table_list->jtbm_subselect)
+ {
+ table_list->jtbm_table_no= tablenr;
+ }
+ else
+ {
+ table->pos_in_table_list= table_list;
+ setup_table_map(table, table_list, tablenr);
+
+ if (table_list->process_index_hints(table))
+ DBUG_RETURN(1);
+ }
+ tablenr++;
}
- setup_table_map(table, table_list, tablenr);
- if (table_list->process_index_hints(table))
+ if (tablenr > MAX_TABLES)
+ {
+ my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
DBUG_RETURN(1);
+ }
}
- if (tablenr > MAX_TABLES)
- {
- my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
- DBUG_RETURN(1);
- }
+ else
+ {
+ List_iterator_fast <TABLE_LIST> ti(select_lex->leaf_tables_exec);
+ select_lex->leaf_tables.empty();
+ while ((table_list= ti++))
+ {
+ table_list->table->tablenr= table_list->tablenr_exec;
+ table_list->table->map= table_list->map_exec;
+ table_list->table->pos_in_table_list= table_list;
+ select_lex->leaf_tables.push_back(table_list);
+ }
+ }
+
for (table_list= tables;
table_list;
table_list= table_list->next_local)
{
if (table_list->merge_underlying_list)
{
- DBUG_ASSERT(table_list->view &&
- table_list->effective_algorithm == VIEW_ALGORITHM_MERGE);
+ DBUG_ASSERT(table_list->is_merged_derived());
Query_arena *arena= thd->stmt_arena, backup;
bool res;
if (arena->is_conventional())
@@ -7797,6 +7856,17 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
if (res)
DBUG_RETURN(1);
}
+
+ if (table_list->jtbm_subselect)
+ {
+ Item *item= table_list->jtbm_subselect->optimizer;
+ if (table_list->jtbm_subselect->optimizer->fix_fields(thd, &item))
+ {
+ my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES); /* psergey-todo: WHY ER_TOO_MANY_TABLES ???*/
+ DBUG_RETURN(1);
+ }
+ DBUG_ASSERT(item == table_list->jtbm_subselect->optimizer);
+ }
}
/* Precompute and store the row types of NATURAL/USING joins. */
@@ -7811,7 +7881,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
prepare tables and check access for the view tables
SYNOPSIS
- setup_tables_and_check_view_access()
+ setup_tables_and_check_access()
thd Thread handler
context name resolution contest to setup table list there
from_clause Top-level list of table references in the FROM clause
@@ -7821,6 +7891,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
refresh It is onle refresh for subquery
select_insert It is SELECT ... INSERT command
want_access what access is needed
+ full_table_list a parameter to pass to the make_leaves_list function
NOTE
a wrapper for check_tables that will also check the resulting
@@ -7834,27 +7905,26 @@ bool setup_tables_and_check_access(THD *thd,
Name_resolution_context *context,
List<TABLE_LIST> *from_clause,
TABLE_LIST *tables,
- TABLE_LIST **leaves,
+ List<TABLE_LIST> &leaves,
bool select_insert,
ulong want_access_first,
- ulong want_access)
+ ulong want_access,
+ bool full_table_list)
{
- TABLE_LIST *leaves_tmp= NULL;
bool first_table= true;
DBUG_ENTER("setup_tables_and_check_access");
if (setup_tables(thd, context, from_clause, tables,
- &leaves_tmp, select_insert))
+ leaves, select_insert, full_table_list))
DBUG_RETURN(TRUE);
- if (leaves)
- *leaves= leaves_tmp;
-
- for (; leaves_tmp; leaves_tmp= leaves_tmp->next_leaf)
+ List_iterator<TABLE_LIST> ti(leaves);
+ TABLE_LIST *table_list;
+ while((table_list= ti++))
{
- if (leaves_tmp->belong_to_view &&
+ if (table_list->belong_to_view && !table_list->view &&
check_single_table_access(thd, first_table ? want_access_first :
- want_access, leaves_tmp, FALSE))
+ want_access, table_list, FALSE))
{
tables->hide_view_error(thd);
DBUG_RETURN(TRUE);
@@ -7997,8 +8067,10 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
information_schema table, or a nested table reference. See the comment
for TABLE_LIST.
*/
- if (!((table && !tables->view && (table->grant.privilege & SELECT_ACL)) ||
- (tables->view && (tables->grant.privilege & SELECT_ACL))) &&
+ if (!((table && tables->is_non_derived() &&
+ (table->grant.privilege & SELECT_ACL)) ||
+ ((!tables->is_non_derived() &&
+ (tables->grant.privilege & SELECT_ACL)))) &&
!any_privileges)
{
field_iterator.set(tables);
@@ -8028,7 +8100,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
if (!(item= field_iterator.create_item(thd)))
DBUG_RETURN(TRUE);
- DBUG_ASSERT(item->fixed);
+// DBUG_ASSERT(item->fixed);
/* cache the table for the Item_fields inserted by expanding stars */
if (item->type() == Item::FIELD_ITEM && tables->cacheable_table)
((Item_field *)item)->cached_table= tables;
@@ -8140,6 +8212,29 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
}
+/**
+ Wrap Item_ident
+
+ @param thd thread handle
+ @param conds pointer to the condition which should be wrapped
+*/
+
+void wrap_ident(THD *thd, Item **conds)
+{
+ Item_direct_ref_to_ident *wrapper;
+ DBUG_ASSERT((*conds)->type() == Item::FIELD_ITEM || (*conds)->type() == Item::REF_ITEM);
+ Query_arena *arena= thd->stmt_arena, backup;
+ if (arena->is_conventional())
+ arena= 0;
+ else
+ thd->set_n_backup_active_arena(arena, &backup);
+ if ((wrapper= new Item_direct_ref_to_ident((Item_ident *)(*conds))))
+ (*conds)= (Item*) wrapper;
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+}
+
+
/*
Fix all conditions and outer join expressions.
@@ -8158,13 +8253,14 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
FALSE if all is OK
*/
-int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
+int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
COND **conds)
{
SELECT_LEX *select_lex= thd->lex->current_select;
Query_arena *arena= thd->stmt_arena, backup;
TABLE_LIST *table= NULL; // For HP compilers
TABLE_LIST *save_emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest;
+ List_iterator<TABLE_LIST> ti(leaves);
/*
it_is_update set to TRUE when tables of primary SELECT_LEX (SELECT_LEX
which belong to LEX, i.e. most up SELECT) will be updated by
@@ -8176,9 +8272,15 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
bool it_is_update= (select_lex == &thd->lex->select_lex) &&
thd->lex->which_check_option_applicable();
bool save_is_item_list_lookup= select_lex->is_item_list_lookup;
- select_lex->is_item_list_lookup= 0;
+ TABLE_LIST *derived= select_lex->master_unit()->derived;
DBUG_ENTER("setup_conds");
+ /* Do not fix conditions for the derived tables that have been merged */
+ if (derived && derived->merged)
+ DBUG_RETURN(0);
+
+ select_lex->is_item_list_lookup= 0;
+
if (select_lex->conds_processed_with_permanent_arena ||
arena->is_conventional())
arena= 0; // For easier test
@@ -8191,11 +8293,14 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
for (table= tables; table; table= table->next_local)
{
- if (table->prepare_where(thd, conds, FALSE))
+ if (select_lex == &thd->lex->select_lex &&
+ select_lex->first_cond_optimization &&
+ table->merged_for_insert &&
+ table->prepare_where(thd, conds, FALSE))
goto err_no_arena;
}
- thd->thd_marker.emb_on_expr_nest= (TABLE_LIST*)1;
+ thd->thd_marker.emb_on_expr_nest= NO_JOIN_NEST;
if (*conds)
{
thd->where="where clause";
@@ -8203,6 +8308,12 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
print_where(*conds,
"WHERE in setup_conds",
QT_ORDINARY););
+ /*
+ Wrap alone field in WHERE clause in case it will be outer field of subquery
+ which need persistent pointer on it, but conds could be changed by optimizer
+ */
+ if ((*conds)->type() == Item::FIELD_ITEM && !derived)
+ wrap_ident(thd, conds);
if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
(*conds)->check_cols(1))
goto err_no_arena;
@@ -8213,7 +8324,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
Apply fix_fields() to all ON clauses at all levels of nesting,
including the ones inside view definitions.
*/
- for (table= leaves; table; table= table->next_leaf)
+ while ((table= ti++))
{
TABLE_LIST *embedded; /* The table at the current level of nesting. */
TABLE_LIST *embedding= table; /* The parent nested table reference. */
@@ -8346,12 +8457,10 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
value->type() != Item::NULL_ITEM &&
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
{
- thd->abort_on_warning= FALSE;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
ER(ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
rfield->field_name, table->s->table_name.str);
- thd->abort_on_warning= abort_on_warning_saved;
}
if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
{
@@ -8501,12 +8610,10 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors,
value->type() != Item::NULL_ITEM &&
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
{
- thd->abort_on_warning= FALSE;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
ER(ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
field->field_name, table->s->table_name.str);
- thd->abort_on_warning= abort_on_warning_saved;
}
if (use_value)
@@ -9406,6 +9513,61 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
thd->restore_backup_open_tables_state(backup);
}
+
+/**
+ @brief
+ Remove 'fixed' flag from items in a list
+
+ @param items list of items to un-fix
+
+ @details
+ This function sets to 0 the 'fixed' flag for items in the 'items' list.
+ It's needed to force correct marking of views' fields for INSERT/UPDATE
+ statements.
+*/
+
+void unfix_fields(List<Item> &fields)
+{
+ List_iterator<Item> li(fields);
+ Item *item;
+ while ((item= li++))
+ item->fixed= 0;
+}
+
+
+/**
+ Check result of dynamic column function and issue error if it is needed
+
+ @param rc The result code of dynamic column function
+
+ @return the result code which was get as an argument\
+*/
+
+int dynamic_column_error_message(enum_dyncol_func_result rc)
+{
+ switch (rc) {
+ case ER_DYNCOL_YES:
+ case ER_DYNCOL_OK:
+ break; // it is not an error
+ case ER_DYNCOL_FORMAT:
+ my_error(ER_DYN_COL_WRONG_FORMAT, MYF(0));
+ break;
+ case ER_DYNCOL_LIMIT:
+ my_error(ER_DYN_COL_IMPLEMENTATION_LIMIT, MYF(0));
+ break;
+ case ER_DYNCOL_RESOURCE:
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
+ break;
+ case ER_DYNCOL_DATA:
+ my_error(ER_DYN_COL_DATA, MYF(0));
+ break;
+ case ER_DYNCOL_UNKNOWN_CHARSET:
+ my_error(ER_DYN_COL_WRONG_CHARSET, MYF(0));
+ break;
+ }
+ return rc;
+}
+
/**
@} (end of group Data_Dictionary)
*/
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index a59cd631fef..93ade4ffe4e 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -186,7 +186,8 @@ void mysql_client_binlog_statement(THD* thd)
}
ev= Log_event::read_log_event(bufptr, event_len, &error,
- rli->relay_log.description_event_for_exec);
+ rli->relay_log.description_event_for_exec,
+ 0);
DBUG_PRINT("info",("binlog base64 err=%s", error));
if (!ev)
diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h
index 5385acc934f..25725ff6c42 100644
--- a/sql/sql_bitmap.h
+++ b/sql/sql_bitmap.h
@@ -91,6 +91,10 @@ public:
DBUG_ASSERT(sizeof(buffer) >= 4);
return (ulonglong) uint4korr(buffer);
}
+ uint bits_set()
+ {
+ return bitmap_bits_set(&map);
+ }
};
/* An iterator to quickly walk over bits in unlonglong bitmap. */
@@ -169,5 +173,16 @@ public:
public:
Iterator(Bitmap<64> &bmp) : Table_map_iterator(bmp.map) {}
};
+ uint bits_set()
+ {
+ //TODO: use my_count_bits()
+ uint res= 0, i= 0;
+ for (; i < 64 ; i++)
+ {
+ if (map & ((ulonglong)1<<i))
+ res++;
+ }
+ return res;
+ }
};
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 81cc87723c5..d7040a825fb 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -286,6 +286,7 @@ functions:
if (and only if) this query has a registered result set writer
(thd->net.query_cache_query).
4. Query_cache::invalidate
+ Query_cache::invalidate_locked_for_write
- Called from various places to invalidate query cache based on data-
base, table and myisam file name. During an on going invalidation
the query cache is temporarily disabled.
@@ -334,6 +335,8 @@ TODO list:
#include "../storage/myisammrg/ha_myisammrg.h"
#include "../storage/myisammrg/myrg_def.h"
+const uchar *query_state_map;
+
#ifdef EMBEDDED_LIBRARY
#include "emb_qcache.h"
#endif
@@ -422,6 +425,136 @@ TYPELIB query_cache_type_typelib=
};
+/*
+ Check if character is a white space.
+*/
+
+inline bool is_white_space(char c)
+{
+ return (query_state_map[(uint) ((uchar) c)] == MY_LEX_SKIP);
+}
+
+
+/**
+ Generate a query_string without query comments or duplicated space
+
+ @param new_query New query without 'fluff' is stored here
+ @param query Original query
+ @param query_length Length of original query
+ @param additional_length Extra space for query cache we need to allocate
+ in new_query buffer.
+
+ Note:
+ If there is no space to allocate new_query, we will put original query
+ into new_query.
+*/
+
+static void make_base_query(String *new_query,
+ const char *query, size_t query_length,
+ size_t additional_length)
+{
+ char *buffer;
+ const char *query_end, *last_space;
+
+ /* The following is guaranteed by the query_cache interface */
+ DBUG_ASSERT(query[query_length] == 0);
+ DBUG_ASSERT(!is_white_space(query[0]));
+
+ if (new_query->realloc(query_length + additional_length))
+ {
+ /*
+ We could not allocate the query. Use original query for
+ the query cache; Better than nothing....
+ */
+ new_query->set(query, query_length, system_charset_info);
+ return;
+ }
+
+ buffer= (char*) new_query->ptr(); // Store base query here
+ query_end= query + query_length;
+ last_space= 0; // No space found yet
+
+ while (query < query_end)
+ {
+ char current = *(query++);
+ switch (current) {
+ case '\'':
+ case '`':
+ case '"':
+ *(buffer++)= current; // copy first quote
+ while (query < query_end)
+ {
+ *(buffer++)= *query;
+ if (*(query++) == current) // found pair quote
+ break;
+ }
+ continue; // Continue with next symbol
+ case '/': // Start of comment ?
+ /*
+ Comment of format /#!number #/, must be skipped.
+ These may include '"' and other comments, but it should
+ be safe to parse the content as a normal string.
+ */
+ if (query[0] != '*' || query[1] == '!')
+ break;
+
+ query++; // skip "/"
+ while (++query < query_end)
+ {
+ if (query[0] == '*' && query[1] == '/')
+ {
+ query+= 2;
+ goto insert_space;
+ }
+ }
+ continue; // Will end outer loop
+ case '-':
+ if (*query != '-' || !is_white_space(query[1])) // Not a comment
+ break;
+ query++; // skip second "-", and go to search of "\n"
+ /* fall through */
+ case '#':
+ while (query < query_end)
+ {
+ if (*(query++) == '\n')
+ goto insert_space;
+ }
+ continue; // Will end outer loop
+ default:
+ if (is_white_space(current))
+ goto insert_space;
+ break;
+ }
+ *(buffer++)= current;
+ continue;
+
+insert_space:
+ if (buffer != last_space)
+ {
+ *(buffer++)= ' ';
+ last_space= buffer;
+ }
+ }
+ if (buffer == last_space)
+ buffer--; // Remove the last space
+ *buffer= 0;
+ new_query->length((size_t) (buffer - new_query->ptr()));
+}
+
+
+/**
+ Check and change local variable if global one is switched
+
+ @param thd thread handle
+*/
+
+void inline fix_local_query_cache_mode(THD *thd)
+{
+ if (global_system_variables.query_cache_type == 0)
+ thd->variables.query_cache_type= 0;
+}
+
+
/**
Serialize access to the query cache.
If the lock cannot be granted the thread hangs in a conditional wait which
@@ -431,31 +564,47 @@ TYPELIB query_cache_type_typelib=
effect by another thread. This enables a quick path in execution to skip waits
when the outcome is known.
- @param use_timeout TRUE if the lock can abort because of a timeout.
+ @param mode TIMEOUT the lock can abort because of a timeout
+ TRY the lock can abort because it is locked now
+ WAIT wait for lock (default)
- @note use_timeout is optional and default value is FALSE.
+ @note mode is optional and default value is WAIT.
@return
@retval FALSE An exclusive lock was taken
@retval TRUE The locking attempt failed
*/
-bool Query_cache::try_lock(bool use_timeout)
+bool Query_cache::try_lock(THD *thd, Cache_try_lock_mode mode)
{
- bool interrupt= FALSE;
+ bool interrupt= TRUE;
+ const char* old_proc_info;
DBUG_ENTER("Query_cache::try_lock");
+ old_proc_info= thd->proc_info;
+ thd_proc_info(thd,"Waiting on query cache mutex");
+
pthread_mutex_lock(&structure_guard_mutex);
+ DBUG_EXECUTE_IF("status_wait_query_cache_mutex_sleep", {
+ sleep(5);
+ });
+ if (m_cache_status == DISABLED)
+ {
+ pthread_mutex_unlock(&structure_guard_mutex);
+ thd->proc_info= old_proc_info;
+ DBUG_RETURN(TRUE);
+ }
+ m_requests_in_progress++;
+ fix_local_query_cache_mode(thd);
while (1)
{
if (m_cache_lock_status == Query_cache::UNLOCKED)
{
m_cache_lock_status= Query_cache::LOCKED;
#ifndef DBUG_OFF
- THD *thd= current_thd;
- if (thd)
- m_cache_lock_thread_id= thd->thread_id;
+ m_cache_lock_thread_id= thd->thread_id;
#endif
+ interrupt= FALSE;
break;
}
else if (m_cache_lock_status == Query_cache::LOCKED_NO_WAIT)
@@ -464,7 +613,6 @@ bool Query_cache::try_lock(bool use_timeout)
If query cache is protected by a LOCKED_NO_WAIT lock this thread
should avoid using the query cache as it is being evicted.
*/
- interrupt= TRUE;
break;
}
else
@@ -474,25 +622,36 @@ bool Query_cache::try_lock(bool use_timeout)
To prevent send_result_to_client() and query_cache_insert() from
blocking execution for too long a timeout is put on the lock.
*/
- if (use_timeout)
+ if (mode == WAIT)
+ {
+ pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
+ }
+ else if (mode == TIMEOUT)
{
struct timespec waittime;
set_timespec_nsec(waittime,(ulong)(50000000L)); /* Wait for 50 msec */
int res= pthread_cond_timedwait(&COND_cache_status_changed,
&structure_guard_mutex,&waittime);
if (res == ETIMEDOUT)
- {
- interrupt= TRUE;
break;
- }
}
else
{
- pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
+ /**
+ If we are here, then mode is == TRY and there was someone else using
+ the query cache. (m_cache_lock_status != Query_cache::UNLOCKED).
+ Signal that we didn't get a lock.
+ */
+ DBUG_ASSERT(m_requests_in_progress > 1);
+ DBUG_ASSERT(mode == TRY);
+ break;
}
}
}
+ if (interrupt)
+ m_requests_in_progress--;
pthread_mutex_unlock(&structure_guard_mutex);
+ thd->proc_info = old_proc_info;
DBUG_RETURN(interrupt);
}
@@ -514,10 +673,12 @@ void Query_cache::lock_and_suspend(void)
DBUG_ENTER("Query_cache::lock_and_suspend");
pthread_mutex_lock(&structure_guard_mutex);
+ m_requests_in_progress++;
while (m_cache_lock_status != Query_cache::UNLOCKED)
pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
m_cache_lock_status= Query_cache::LOCKED_NO_WAIT;
#ifndef DBUG_OFF
+ /* Here thd may not be set during shutdown */
THD *thd= current_thd;
if (thd)
m_cache_lock_thread_id= thd->thread_id;
@@ -537,18 +698,18 @@ void Query_cache::lock_and_suspend(void)
It is used by all methods which invalidates one or more tables.
*/
-void Query_cache::lock(void)
+void Query_cache::lock(THD *thd)
{
DBUG_ENTER("Query_cache::lock");
pthread_mutex_lock(&structure_guard_mutex);
+ m_requests_in_progress++;
+ fix_local_query_cache_mode(thd);
while (m_cache_lock_status != Query_cache::UNLOCKED)
pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex);
m_cache_lock_status= Query_cache::LOCKED;
#ifndef DBUG_OFF
- THD *thd= current_thd;
- if (thd)
- m_cache_lock_thread_id= thd->thread_id;
+ m_cache_lock_thread_id= thd->thread_id;
#endif
pthread_mutex_unlock(&structure_guard_mutex);
@@ -565,6 +726,7 @@ void Query_cache::unlock(void)
DBUG_ENTER("Query_cache::unlock");
pthread_mutex_lock(&structure_guard_mutex);
#ifndef DBUG_OFF
+ /* Thd may not be set in resize() at mysqld start */
THD *thd= current_thd;
if (thd)
DBUG_ASSERT(m_cache_lock_thread_id == thd->thread_id);
@@ -574,6 +736,14 @@ void Query_cache::unlock(void)
m_cache_lock_status= Query_cache::UNLOCKED;
DBUG_PRINT("Query_cache",("Sending signal"));
pthread_cond_signal(&COND_cache_status_changed);
+ DBUG_ASSERT(m_requests_in_progress > 0);
+ m_requests_in_progress--;
+ if (m_requests_in_progress == 0 && m_cache_status == DISABLE_REQUEST)
+ {
+ /* No clients => just free query cache */
+ free_cache();
+ m_cache_status= DISABLED;
+ }
pthread_mutex_unlock(&structure_guard_mutex);
DBUG_VOID_RETURN;
}
@@ -590,25 +760,24 @@ void Query_cache::unlock(void)
@retval FALSE No directive found.
*/
-static bool has_no_cache_directive(char *sql)
+static bool has_no_cache_directive(const char *sql)
{
- int i=0;
- while (sql[i] == ' ')
- ++i;
+ while (is_white_space(*sql))
+ sql++;
- if (my_toupper(system_charset_info, sql[i]) == 'S' &&
- my_toupper(system_charset_info, sql[i+1]) == 'Q' &&
- my_toupper(system_charset_info, sql[i+2]) == 'L' &&
- my_toupper(system_charset_info, sql[i+3]) == '_' &&
- my_toupper(system_charset_info, sql[i+4]) == 'N' &&
- my_toupper(system_charset_info, sql[i+5]) == 'O' &&
- my_toupper(system_charset_info, sql[i+6]) == '_' &&
- my_toupper(system_charset_info, sql[i+7]) == 'C' &&
- my_toupper(system_charset_info, sql[i+8]) == 'A' &&
- my_toupper(system_charset_info, sql[i+9]) == 'C' &&
- my_toupper(system_charset_info, sql[i+10]) == 'H' &&
- my_toupper(system_charset_info, sql[i+11]) == 'E' &&
- my_toupper(system_charset_info, sql[i+12]) == ' ')
+ if (my_toupper(system_charset_info, sql[0]) == 'S' &&
+ my_toupper(system_charset_info, sql[1]) == 'Q' &&
+ my_toupper(system_charset_info, sql[2]) == 'L' &&
+ my_toupper(system_charset_info, sql[3]) == '_' &&
+ my_toupper(system_charset_info, sql[4]) == 'N' &&
+ my_toupper(system_charset_info, sql[5]) == 'O' &&
+ my_toupper(system_charset_info, sql[6]) == '_' &&
+ my_toupper(system_charset_info, sql[7]) == 'C' &&
+ my_toupper(system_charset_info, sql[8]) == 'A' &&
+ my_toupper(system_charset_info, sql[9]) == 'C' &&
+ my_toupper(system_charset_info, sql[10]) == 'H' &&
+ my_toupper(system_charset_info, sql[11]) == 'E' &&
+ my_isspace(system_charset_info, sql[12]))
return TRUE;
return FALSE;
@@ -866,14 +1035,23 @@ void query_cache_insert(NET *net, const char *packet, ulong length)
{
DBUG_ENTER("query_cache_insert");
- /* See the comment on double-check locking usage above. */
if (net->query_cache_query == 0)
DBUG_VOID_RETURN;
+ DBUG_ASSERT(current_thd);
+
DBUG_EXECUTE_IF("wait_in_query_cache_insert",
debug_wait_for_kill("wait_in_query_cache_insert"); );
- if (query_cache.try_lock())
+ /* First we check if query cache is disable without doing a mutex lock */
+ if(query_cache.is_disabled())
+ DBUG_VOID_RETURN;
+
+ /*
+ Lock the cache with try_lock(). try_lock() will fail if
+ cache was disabled between the above test and lock.
+ */
+ if (query_cache.try_lock(current_thd, Query_cache::WAIT))
DBUG_VOID_RETURN;
Query_cache_block *query_block= (Query_cache_block*)net->query_cache_query;
@@ -931,7 +1109,7 @@ void query_cache_abort(NET *net)
if (net->query_cache_query == 0)
DBUG_VOID_RETURN;
- if (query_cache.try_lock())
+ if (query_cache.try_lock(current_thd, Query_cache::WAIT))
{
net->query_cache_query = 0;
DBUG_VOID_RETURN;
@@ -984,7 +1162,7 @@ void query_cache_end_of_result(THD *thd)
emb_count_querycache_size(thd));
#endif
- if (query_cache.try_lock())
+ if (query_cache.try_lock(thd, Query_cache::WAIT))
{
thd->net.query_cache_query= 0;
DBUG_VOID_RETURN;
@@ -1073,6 +1251,7 @@ Query_cache::Query_cache(ulong query_cache_limit_arg,
query_cache_limit(query_cache_limit_arg),
queries_in_cache(0), hits(0), inserts(0), refused(0),
total_blocks(0), lowmem_prunes(0),
+ m_cache_status(OK),
min_allocation_unit(ALIGN_SIZE(min_allocation_unit_arg)),
min_result_data_size(ALIGN_SIZE(min_result_data_size_arg)),
def_query_hash_size(ALIGN_SIZE(def_query_hash_size_arg)),
@@ -1096,6 +1275,13 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
query_cache_size_arg));
DBUG_ASSERT(initialized);
+ if (global_system_variables.query_cache_type == 0)
+ {
+ if (query_cache_size_arg != 0)
+ my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
+ DBUG_RETURN(0);
+ }
+
lock_and_suspend();
/*
@@ -1128,8 +1314,17 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
query_cache_size= query_cache_size_arg;
new_query_cache_size= init_cache();
+ /*
+ m_cache_status is internal query cache switch so switching it on/off
+ will not be reflected on global_system_variables.query_cache_type
+ */
if (new_query_cache_size)
+ {
DBUG_EXECUTE("check_querycache",check_integrity(1););
+ m_cache_status= OK; // size > 0 => enable cache
+ }
+ else
+ m_cache_status= DISABLED; // size 0 means the cache disabled
unlock();
DBUG_RETURN(new_query_cache_size);
@@ -1148,6 +1343,9 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
{
TABLE_COUNTER_TYPE local_tables;
ulong tot_length;
+ const char *query;
+ size_t query_length;
+ uint8 tables_type;
DBUG_ENTER("Query_cache::store_query");
/*
Testing 'query_cache_size' without a lock here is safe: the thing
@@ -1157,12 +1355,23 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
See also a note on double-check locking usage above.
*/
- if (thd->locked_tables || query_cache_size == 0)
+ if (!thd->query_cache_is_applicable || query_cache_size == 0)
+ {
+ DBUG_PRINT("qcache", ("Query cache not ready"));
DBUG_VOID_RETURN;
- uint8 tables_type= 0;
+ }
+ if (thd->lex->sql_command != SQLCOM_SELECT)
+ {
+ DBUG_PRINT("qcache", ("Ignoring not SELECT command"));
+ DBUG_VOID_RETURN;
+ }
+
+ /* The following assert fails if we haven't called send_result_to_client */
+ DBUG_ASSERT(thd->base_query.is_alloced() ||
+ thd->base_query.ptr() == thd->query());
- if ((local_tables= is_cacheable(thd, thd->query_length(),
- thd->query(), thd->lex, tables_used,
+ tables_type= 0;
+ if ((local_tables= is_cacheable(thd, thd->lex, tables_used,
&tables_type)))
{
NET *net= &thd->net;
@@ -1239,7 +1448,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
The 'TRUE' parameter indicate that the lock is allowed to timeout
*/
- if (try_lock(TRUE))
+ if (try_lock(thd, Query_cache::WAIT))
DBUG_VOID_RETURN;
if (query_cache_size == 0)
{
@@ -1255,11 +1464,13 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
DBUG_VOID_RETURN;
}
+ query= thd->base_query.ptr();
+ query_length= thd->base_query.length();
+
/* Key is query + database + flag */
if (thd->db_length)
{
- memcpy(thd->query() + thd->query_length() + 1, thd->db,
- thd->db_length);
+ memcpy((char*) (query + query_length + 1), thd->db, thd->db_length);
DBUG_PRINT("qcache", ("database: %s length: %u",
thd->db, (unsigned) thd->db_length));
}
@@ -1267,24 +1478,24 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
{
DBUG_PRINT("qcache", ("No active database"));
}
- tot_length= thd->query_length() + thd->db_length + 1 +
+ tot_length= query_length + thd->db_length + 1 +
QUERY_CACHE_FLAGS_SIZE;
/*
We should only copy structure (don't use it location directly)
because of alignment issue
*/
- memcpy((void*) (thd->query() + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
+ memcpy((void*) (query + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
&flags, QUERY_CACHE_FLAGS_SIZE);
/* Check if another thread is processing the same query? */
Query_cache_block *competitor = (Query_cache_block *)
- hash_search(&queries, (uchar*) thd->query(), tot_length);
+ hash_search(&queries, (uchar*) query, tot_length);
DBUG_PRINT("qcache", ("competitor 0x%lx", (ulong) competitor));
if (competitor == 0)
{
/* Query is not in cache and no one is working with it; Store it */
Query_cache_block *query_block;
- query_block= write_block_data(tot_length, (uchar*) thd->query(),
+ query_block= write_block_data(tot_length, (uchar*) query,
ALIGN_SIZE(sizeof(Query_cache_query)),
Query_cache_block::QUERY, local_tables);
if (query_block != 0)
@@ -1341,7 +1552,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
DBUG_PRINT("qcache", ("Another thread process same query"));
}
}
- else if (thd->lex->sql_command == SQLCOM_SELECT)
+ else
statistic_increment(refused, &structure_guard_mutex);
end:
@@ -1416,7 +1627,7 @@ send_data_in_chunks(NET *net, const uchar *packet, ulong len)
*/
int
-Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
+Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
{
ulonglong engine_data;
Query_cache_query *query;
@@ -1427,6 +1638,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
Query_cache_block_table *block_table, *block_table_end;
ulong tot_length;
Query_cache_query_flags flags;
+ const char *sql, *sql_end;
DBUG_ENTER("Query_cache::send_result_to_client");
/*
@@ -1436,51 +1648,96 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
See also a note on double-check locking usage above.
*/
- if (thd->locked_tables || thd->variables.query_cache_type == 0 ||
- query_cache_size == 0)
+ if (is_disabled() || thd->locked_tables ||
+ thd->variables.query_cache_type == 0)
goto err;
+ DBUG_ASSERT(query_cache_size != 0); // otherwise cache would be disabled
- if (!thd->lex->safe_to_cache_query)
+ thd->query_cache_is_applicable= 1;
+ sql= org_sql; sql_end= sql + query_length;
+
+ /*
+ Skip all comments at start of query. The following tests is false for
+ all normal queries.
+ */
+ if (!my_isalpha(system_charset_info, *sql))
{
- DBUG_PRINT("qcache", ("SELECT is non-cacheable"));
+ while (sql < sql_end)
+ {
+ char current= *sql;
+ switch (current) {
+ case '/':
+ if (sql[1] != '*')
+ break;
+ sql+= 2; // Skip '/*'
+ if (*sql == '!')
+ {
+ /*
+ Found / *!number comment; Skip number to see if sql
+ starts with 'select'
+ */
+ sql++;
+ while (my_isdigit(system_charset_info, *sql))
+ sql++;
+ }
+ else
+ {
+ while (sql++ < sql_end)
+ {
+ if (sql[-1] == '*' && *sql == '/')
+ {
+ sql++;
+ break;
+ }
+ }
+ }
+ continue;
+ case '-':
+ if (sql[1] != '-' || !is_white_space(sql[2])) // Not a comment
+ break;
+ sql++; // Skip first '-'
+ /* Fall through */
+ case '#':
+ while (++sql < sql_end)
+ {
+ if (*sql == '\n')
+ {
+ sql++; // Skip '\n'
+ break;
+ }
+ }
+ /* Continue with analyzing current symbol */
+ continue;
+ case '\r':
+ case '\n':
+ case '\t':
+ case ' ':
+ case '(': // To handle (select a from t1) union (select a from t1);
+ sql++;
+ continue;
+ default:
+ break;
+ }
+ /* We only come here when we found the first word of the sql */
+ break;
+ }
+ }
+ if ((my_toupper(system_charset_info, sql[0]) != 'S' ||
+ my_toupper(system_charset_info, sql[1]) != 'E' ||
+ my_toupper(system_charset_info, sql[2]) != 'L'))
+ {
+ DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
goto err;
}
+ if ((sql_end - sql) > 20 && has_no_cache_directive(sql+6))
{
- uint i= 0;
- /*
- Skip '(' characters in queries like following:
- (select a from t1) union (select a from t1);
- */
- while (sql[i]=='(')
- i++;
-
/*
- Test if the query is a SELECT
- (pre-space is removed in dispatch_command).
-
- First '/' looks like comment before command it is not
- frequently appeared in real life, consequently we can
- check all such queries, too.
+ We do not increase 'refused' statistics here since it will be done
+ later when the query is parsed.
*/
- if ((my_toupper(system_charset_info, sql[i]) != 'S' ||
- my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
- my_toupper(system_charset_info, sql[i + 2]) != 'L') &&
- sql[i] != '/')
- {
- DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
- goto err;
- }
-
- if (query_length > 20 && has_no_cache_directive(&sql[i+6]))
- {
- /*
- We do not increase 'refused' statistics here since it will be done
- later when the query is parsed.
- */
- DBUG_PRINT("qcache", ("The statement has a SQL_NO_CACHE directive"));
- goto err;
- }
+ DBUG_PRINT("qcache", ("The statement has a SQL_NO_CACHE directive"));
+ goto err;
}
/*
@@ -1488,9 +1745,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
disabled or if a full cache flush is in progress, the attempt to
get the lock is aborted.
- The 'TRUE' parameter indicate that the lock is allowed to timeout
+ The WAIT parameter indicate that the lock is allowed to timeout.
*/
- if (try_lock(TRUE))
+ if (try_lock(thd, Query_cache::WAIT))
goto err;
if (query_cache_size == 0)
@@ -1503,11 +1760,23 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_ASSERT(thd->net.query_cache_query == 0);
Query_cache_block *query_block;
+ if (opt_query_cache_strip_comments)
+ {
+ make_base_query(&thd->base_query, sql, (size_t) (sql_end - sql),
+ thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE);
+ sql= thd->base_query.ptr();
+ query_length= thd->base_query.length();
+ }
+ else
+ {
+ sql= org_sql;
+ thd->base_query.set(sql, query_length, system_charset_info);
+ }
tot_length= query_length + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE;
if (thd->db_length)
{
- memcpy(sql+query_length+1, thd->db, thd->db_length);
+ memcpy((char*) (sql+query_length+1), thd->db, thd->db_length);
DBUG_PRINT("qcache", ("database: '%s' length: %u",
thd->db, (unsigned)thd->db_length));
}
@@ -1638,7 +1907,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
temporary tables => assign following variable to make check
faster.
*/
- thd->lex->safe_to_cache_query=0;
+ thd->query_cache_is_applicable= 0; // Query can't be cached
BLOCK_UNLOCK_RD(query_block);
DBUG_RETURN(-1);
}
@@ -1654,7 +1923,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
("probably no SELECT access to %s.%s => return to normal processing",
table_list.db, table_list.alias));
unlock();
- thd->lex->safe_to_cache_query=0; // Don't try to cache this
+ thd->query_cache_is_applicable= 0; // Query can't be cached
BLOCK_UNLOCK_RD(query_block);
DBUG_RETURN(-1); // Privilege error
}
@@ -1663,7 +1932,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
DBUG_PRINT("qcache", ("Need to check column privileges for %s.%s",
table_list.db, table_list.alias));
BLOCK_UNLOCK_RD(query_block);
- thd->lex->safe_to_cache_query= 0; // Don't try to cache this
+ thd->query_cache_is_applicable= 0; // Query can't be cached
goto err_unlock; // Parse query
}
#endif /*!NO_EMBEDDED_ACCESS_CHECKS*/
@@ -1687,7 +1956,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
table->key_length());
}
else
- thd->lex->safe_to_cache_query= 0; // Don't try to cache this
+ thd->query_cache_is_applicable= 0; // Query can't be cached
goto err_unlock; // Parse query
}
else
@@ -1738,12 +2007,15 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
err_unlock:
unlock();
-err:
/*
query_plan_flags doesn't have to be changed here as it contains
QPLAN_QC_NO by default
*/
DBUG_RETURN(0); // Query was not cached
+
+err:
+ thd->query_cache_is_applicable= 0; // Query can't be cached
+ DBUG_RETURN(0); // Query was not cached
}
@@ -1755,6 +2027,8 @@ void Query_cache::invalidate(THD *thd, TABLE_LIST *tables_used,
my_bool using_transactions)
{
DBUG_ENTER("Query_cache::invalidate (table list)");
+ if (is_disabled())
+ DBUG_VOID_RETURN;
using_transactions= using_transactions &&
(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
@@ -1782,10 +2056,12 @@ void Query_cache::invalidate(THD *thd, TABLE_LIST *tables_used,
DBUG_VOID_RETURN;
}
-void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
+void Query_cache::invalidate(THD *thd, CHANGED_TABLE_LIST *tables_used)
{
DBUG_ENTER("Query_cache::invalidate (changed table list)");
- THD *thd= current_thd;
+ if (is_disabled())
+ DBUG_VOID_RETURN;
+
for (; tables_used; tables_used= tables_used->next)
{
thd_proc_info(thd, "invalidating query cache entries (table list)");
@@ -1808,10 +2084,13 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
NOTE
can be used only for opened tables
*/
-void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used)
+void Query_cache::invalidate_locked_for_write(THD *thd,
+ TABLE_LIST *tables_used)
{
- THD *thd= current_thd;
DBUG_ENTER("Query_cache::invalidate_locked_for_write");
+ if (is_disabled())
+ DBUG_VOID_RETURN;
+
for (; tables_used; tables_used= tables_used->next_local)
{
thd_proc_info(thd, "invalidating query cache entries (table)");
@@ -1832,7 +2111,9 @@ void Query_cache::invalidate(THD *thd, TABLE *table,
my_bool using_transactions)
{
DBUG_ENTER("Query_cache::invalidate (table)");
-
+ if (is_disabled())
+ DBUG_VOID_RETURN;
+
using_transactions= using_transactions &&
(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
if (using_transactions &&
@@ -1849,6 +2130,8 @@ void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length,
my_bool using_transactions)
{
DBUG_ENTER("Query_cache::invalidate (key)");
+ if (is_disabled())
+ DBUG_VOID_RETURN;
using_transactions= using_transactions &&
(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
@@ -1865,18 +2148,19 @@ void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length,
Remove all cached queries that uses the given database.
*/
-void Query_cache::invalidate(char *db)
+void Query_cache::invalidate(THD *thd, char *db)
{
- bool restart= FALSE;
+ bool restart;
DBUG_ENTER("Query_cache::invalidate (db)");
+ if (is_disabled())
+ DBUG_VOID_RETURN;
+ restart= FALSE;
/*
Lock the query cache and queue all invalidation attempts to avoid
the risk of a race between invalidation, cache inserts and flushes.
*/
- lock();
-
- THD *thd= current_thd;
+ lock(thd);
if (query_cache_size > 0)
{
@@ -1954,6 +2238,9 @@ void Query_cache::invalidate_by_MyISAM_filename(const char *filename)
void Query_cache::flush()
{
DBUG_ENTER("Query_cache::flush");
+ if (is_disabled())
+ DBUG_VOID_RETURN;
+
DBUG_EXECUTE_IF("wait_in_query_cache_flush1",
debug_wait_for_kill("wait_in_query_cache_flush1"););
@@ -1981,7 +2268,7 @@ void Query_cache::flush()
*/
-void Query_cache::pack(ulong join_limit, uint iteration_limit)
+void Query_cache::pack(THD *thd, ulong join_limit, uint iteration_limit)
{
DBUG_ENTER("Query_cache::pack");
@@ -1989,7 +2276,7 @@ void Query_cache::pack(ulong join_limit, uint iteration_limit)
If the entire qc is being invalidated we can bail out early
instead of waiting for the lock.
*/
- if (try_lock())
+ if (try_lock(thd, Query_cache::WAIT))
DBUG_VOID_RETURN;
if (query_cache_size == 0)
@@ -2026,11 +2313,25 @@ void Query_cache::destroy()
pthread_cond_destroy(&COND_cache_status_changed);
pthread_mutex_destroy(&structure_guard_mutex);
initialized = 0;
+ DBUG_ASSERT(m_requests_in_progress == 0);
}
DBUG_VOID_RETURN;
}
+void Query_cache::disable_query_cache(THD *thd)
+{
+ m_cache_status= DISABLE_REQUEST;
+ /*
+ If there is no requests in progress try to free buffer.
+ try_lock(TRY) will exit immediately if there is lock.
+ unlock() should free block.
+ */
+ if (m_requests_in_progress == 0 && !try_lock(thd, TRY))
+ unlock();
+}
+
+
/*****************************************************************************
init/destroy
*****************************************************************************/
@@ -2041,7 +2342,21 @@ void Query_cache::init()
pthread_mutex_init(&structure_guard_mutex,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_cache_status_changed, NULL);
m_cache_lock_status= Query_cache::UNLOCKED;
+ m_cache_status= Query_cache::OK;
+ m_requests_in_progress= 0;
initialized = 1;
+ query_state_map= default_charset_info->state_map;
+ /*
+ If we explicitly turn off query cache from the command line query
+ cache will be disabled for the reminder of the server life
+ time. This is because we want to avoid locking the QC specific
+ mutex if query cache isn't going to be used.
+ */
+ if (global_system_variables.query_cache_type == 0)
+ {
+ free_cache();
+ m_cache_status= DISABLED;
+ }
DBUG_VOID_RETURN;
}
@@ -2253,6 +2568,18 @@ void Query_cache::free_cache()
{
DBUG_ENTER("Query_cache::free_cache");
+ /* Destroy locks */
+ Query_cache_block *block= queries_blocks;
+ if (block)
+ {
+ do
+ {
+ Query_cache_query *query= block->query();
+ rwlock_destroy(&query->lock);
+ block= block->next;
+ } while (block != queries_blocks);
+ }
+
my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR));
make_disabled();
hash_free(&queries);
@@ -2735,7 +3062,7 @@ void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length)
Lock the query cache and queue all invalidation attempts to avoid
the risk of a race between invalidation, cache inserts and flushes.
*/
- lock();
+ lock(thd);
DBUG_EXECUTE_IF("wait_in_query_cache_invalidate2",
debug_wait_for_kill("wait_in_query_cache_invalidate2"); );
@@ -3516,7 +3843,7 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used,
{
DBUG_PRINT("qcache", ("Don't cache statement as it refers to "
"tables with column privileges."));
- thd->lex->safe_to_cache_query= 0;
+ thd->query_cache_is_applicable= 0; // Query can't be cached
DBUG_RETURN(0);
}
#endif
@@ -3529,16 +3856,17 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used,
}
else
{
- DBUG_PRINT("qcache", ("table: %s db: %s type: %u",
- tables_used->table->s->table_name.str,
- tables_used->table->s->db.str,
- tables_used->table->s->db_type()->db_type));
if (tables_used->derived)
{
+ DBUG_PRINT("qcache", ("table: %s", tables_used->alias));
table_count--;
DBUG_PRINT("qcache", ("derived table skipped"));
continue;
}
+ DBUG_PRINT("qcache", ("table: %s db: %s type: %u",
+ tables_used->table->s->table_name.str,
+ tables_used->table->s->db.str,
+ tables_used->table->s->db_type()->db_type));
*tables_type|= tables_used->table->file->table_cache_type();
/*
@@ -3581,13 +3909,13 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used,
*/
TABLE_COUNTER_TYPE
-Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex,
+Query_cache::is_cacheable(THD *thd, LEX *lex,
TABLE_LIST *tables_used, uint8 *tables_type)
{
TABLE_COUNTER_TYPE table_count;
DBUG_ENTER("Query_cache::is_cacheable");
- if (query_cache_is_cacheable_query(lex) &&
+ if (thd->lex->safe_to_cache_query &&
(thd->variables.query_cache_type == 1 ||
(thd->variables.query_cache_type == 2 && (lex->select_lex.options &
OPTION_TO_QUERY_CACHE))))
@@ -3652,7 +3980,7 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
{
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
tables_used->db, tables_used->alias));
- thd->lex->safe_to_cache_query= 0; // Don't try to cache this
+ thd->query_cache_is_applicable= 0; // Query can't be cached
DBUG_RETURN(1);
}
}
@@ -4745,3 +5073,4 @@ err2:
#endif /* DBUG_OFF */
#endif /*HAVE_QUERY_CACHE*/
+
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index 91666625a12..c99aa861b68 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -276,8 +276,11 @@ private:
my_thread_id m_cache_lock_thread_id;
#endif
pthread_cond_t COND_cache_status_changed;
+ uint m_requests_in_progress;
enum Cache_lock_status { UNLOCKED, LOCKED_NO_WAIT, LOCKED };
Cache_lock_status m_cache_lock_status;
+ enum Cache_staus {OK, DISABLE_REQUEST, DISABLED};
+ Cache_staus m_cache_status;
void free_query_internal(Query_cache_block *point);
void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length);
@@ -292,7 +295,7 @@ protected:
2. query block (for operation inside query (query block/results))
Thread doing cache flush releases the mutex once it sets
- m_cache_status flag, so other threads may bypass the cache as
+ m_cache_lock_status flag, so other threads may bypass the cache as
if it is disabled, not waiting for reset to finish. The exception
is other threads that were going to do cache flush---they'll wait
till the end of a flush operation.
@@ -407,7 +410,7 @@ protected:
If query is cacheable return number tables in query
(query without tables not cached)
*/
- TABLE_COUNTER_TYPE is_cacheable(THD *thd, uint32 query_len, char *query,
+ TABLE_COUNTER_TYPE is_cacheable(THD *thd,
LEX *lex, TABLE_LIST *tables_used,
uint8 *tables_type);
TABLE_COUNTER_TYPE process_and_count_tables(THD *thd,
@@ -423,6 +426,10 @@ protected:
uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
+ bool is_disabled(void) { return m_cache_status != OK; }
+ bool is_disable_in_progress(void)
+ { return m_cache_status == DISABLE_REQUEST; }
+
/* initialize cache (mutex) */
void init();
/* resize query cache (return real query size, 0 if disabled) */
@@ -442,22 +449,23 @@ protected:
int send_result_to_client(THD *thd, char *query, uint query_length);
/* Remove all queries that uses any of the listed following tables */
- void invalidate(THD* thd, TABLE_LIST *tables_used,
+ void invalidate(THD *thd, TABLE_LIST *tables_used,
my_bool using_transactions);
- void invalidate(CHANGED_TABLE_LIST *tables_used);
- void invalidate_locked_for_write(TABLE_LIST *tables_used);
- void invalidate(THD* thd, TABLE *table, my_bool using_transactions);
+ void invalidate(THD *thd, CHANGED_TABLE_LIST *tables_used);
+ void invalidate_locked_for_write(THD *thd, TABLE_LIST *tables_used);
+ void invalidate(THD *thd, TABLE *table, my_bool using_transactions);
void invalidate(THD *thd, const char *key, uint32 key_length,
my_bool using_transactions);
/* Remove all queries that uses any of the tables in following database */
- void invalidate(char *db);
+ void invalidate(THD *thd, char *db);
/* Remove all queries that uses any of the listed following table */
void invalidate_by_MyISAM_filename(const char *filename);
void flush();
- void pack(ulong join_limit = QUERY_CACHE_PACK_LIMIT,
+ void pack(THD *thd,
+ ulong join_limit = QUERY_CACHE_PACK_LIMIT,
uint iteration_limit = QUERY_CACHE_PACK_ITERATION);
void destroy();
@@ -485,10 +493,13 @@ protected:
const char *name);
my_bool in_blocks(Query_cache_block * point);
- bool try_lock(bool use_timeout= FALSE);
- void lock(void);
+ enum Cache_try_lock_mode {WAIT, TIMEOUT, TRY};
+ bool try_lock(THD *thd, Cache_try_lock_mode mode= WAIT);
+ void lock(THD *thd);
void lock_and_suspend(void);
void unlock(void);
+
+ void disable_query_cache(THD *thd);
};
extern Query_cache query_cache;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index a5c06d2aa77..97a33b4fe1a 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -663,7 +663,7 @@ THD::THD()
/* statement id */ 0),
Open_tables_state(refresh_version), rli_fake(0),
lock_id(&main_lock_id),
- user_time(0), in_sub_stmt(0),
+ in_sub_stmt(0),
sql_log_bin_toplevel(false),
binlog_table_maps(0), binlog_flags(0UL),
table_map_for_update(0),
@@ -705,7 +705,7 @@ THD::THD()
main_security_ctx.init();
security_ctx= &main_security_ctx;
some_tables_deleted=no_errors=password= 0;
- query_start_used= 0;
+ query_start_used= query_start_sec_part_used= 0;
count_cuted_fields= CHECK_FIELD_IGNORE;
killed= NOT_KILLED;
col_access=0;
@@ -722,7 +722,7 @@ THD::THD()
#endif
// Must be reset to handle error with THD's created for init of mysqld
lex->current_select= 0;
- start_time=(time_t) 0;
+ user_time.val= start_time= start_time_sec_part= 0;
start_utime= prior_thr_create_utime= 0L;
utime_after_lock= 0L;
current_linfo = 0;
@@ -813,6 +813,7 @@ THD::THD()
m_binlog_invoker= FALSE;
memset(&invoker_user, 0, sizeof(invoker_user));
memset(&invoker_host, 0, sizeof(invoker_host));
+ prepare_derived_at_open= FALSE;
}
@@ -986,7 +987,6 @@ void THD::update_stats(void)
void THD::update_all_stats()
{
- time_t save_time;
ulonglong end_cpu_time, end_utime;
double busy_time, cpu_time;
@@ -995,8 +995,8 @@ void THD::update_all_stats()
return;
end_cpu_time= my_getcputime();
- end_utime= my_micro_time_and_time(&save_time);
- busy_time= (end_utime - start_utime) / 1000000.0;
+ end_utime= microsecond_interval_timer();
+ busy_time= (end_utime - start_utime) / 1000000.0;
cpu_time= (end_cpu_time - start_cpu_time) / 10000000.0;
/* In case there are bad values, 2629743 is the #seconds in a month. */
if (cpu_time > 2629743.0)
@@ -1004,7 +1004,8 @@ void THD::update_all_stats()
status_var_add(status_var.cpu_time, cpu_time);
status_var_add(status_var.busy_time, busy_time);
- update_global_user_stats(this, TRUE, save_time);
+ update_global_user_stats(this, TRUE, my_time(0));
+ // Has to be updated after update_global_user_stats()
userstat_running= 0;
}
@@ -1195,11 +1196,11 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
*(to++)+= *(from++);
/* Handle the not ulong variables. See end of system_status_var */
- to_var->bytes_received= from_var->bytes_received;
+ to_var->bytes_received+= from_var->bytes_received;
to_var->bytes_sent+= from_var->bytes_sent;
to_var->rows_read+= from_var->rows_read;
to_var->rows_sent+= from_var->rows_sent;
- to_var->binlog_bytes_written= from_var->binlog_bytes_written;
+ to_var->binlog_bytes_written+= from_var->binlog_bytes_written;
to_var->cpu_time+= from_var->cpu_time;
to_var->busy_time+= from_var->busy_time;
}
@@ -1890,7 +1891,7 @@ void select_send::cleanup()
/* Send data to client. Returns 0 if ok */
-bool select_send::send_data(List<Item> &items)
+int select_send::send_data(List<Item> &items)
{
if (unit->offset_limit_cnt)
{ // using limit offset,count
@@ -2199,7 +2200,7 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
(int) (uchar) (x) == line_sep_char || \
!(x))
-bool select_export::send_data(List<Item> &items)
+int select_export::send_data(List<Item> &items)
{
DBUG_ENTER("select_export::send_data");
@@ -2456,7 +2457,7 @@ select_dump::prepare(List<Item> &list __attribute__((unused)),
}
-bool select_dump::send_data(List<Item> &items)
+int select_dump::send_data(List<Item> &items)
{
List_iterator_fast<Item> li(items);
char buff[MAX_FIELD_WIDTH];
@@ -2501,7 +2502,7 @@ select_subselect::select_subselect(Item_subselect *item_arg)
}
-bool select_singlerow_subselect::send_data(List<Item> &items)
+int select_singlerow_subselect::send_data(List<Item> &items)
{
DBUG_ENTER("select_singlerow_subselect::send_data");
Item_singlerow_subselect *it= (Item_singlerow_subselect *)item;
@@ -2532,7 +2533,7 @@ void select_max_min_finder_subselect::cleanup()
}
-bool select_max_min_finder_subselect::send_data(List<Item> &items)
+int select_max_min_finder_subselect::send_data(List<Item> &items)
{
DBUG_ENTER("select_max_min_finder_subselect::send_data");
Item_maxmin_subselect *it= (Item_maxmin_subselect *)item;
@@ -2564,6 +2565,7 @@ bool select_max_min_finder_subselect::send_data(List<Item> &items)
op= &select_max_min_finder_subselect::cmp_decimal;
break;
case ROW_RESULT:
+ case TIME_RESULT:
case IMPOSSIBLE_RESULT:
// This case should never be choosen
DBUG_ASSERT(0);
@@ -2636,7 +2638,7 @@ bool select_max_min_finder_subselect::cmp_str()
sortcmp(val1, val2, cache->collation.collation) < 0);
}
-bool select_exists_subselect::send_data(List<Item> &items)
+int select_exists_subselect::send_data(List<Item> &items)
{
DBUG_ENTER("select_exists_subselect::send_data");
Item_exists_subselect *it= (Item_exists_subselect *)item;
@@ -2697,6 +2699,7 @@ void Query_arena::free_items()
for (; free_list; free_list= next)
{
next= free_list->next;
+ DBUG_ASSERT(free_list != next);
free_list->delete_self();
}
/* Postcondition: free_list is 0 */
@@ -2988,7 +2991,7 @@ Statement_map::~Statement_map()
hash_free(&st_hash);
}
-bool select_dumpvar::send_data(List<Item> &items)
+int select_dumpvar::send_data(List<Item> &items)
{
List_iterator_fast<my_var> var_li(var_list);
List_iterator<Item> it(items);
@@ -3045,7 +3048,8 @@ bool
select_materialize_with_stats::
create_result_table(THD *thd_arg, List<Item> *column_types,
bool is_union_distinct, ulonglong options,
- const char *table_alias, bool bit_fields_as_long)
+ const char *table_alias, bool bit_fields_as_long,
+ bool create_table)
{
DBUG_ASSERT(table == 0);
tmp_table_param.field_count= column_types->elements;
@@ -3091,15 +3095,16 @@ void select_materialize_with_stats::cleanup()
@return FALSE on success
*/
-bool select_materialize_with_stats::send_data(List<Item> &items)
+int select_materialize_with_stats::send_data(List<Item> &items)
{
List_iterator_fast<Item> item_it(items);
Item *cur_item;
Column_statistics *cur_col_stat= col_stat;
uint nulls_in_row= 0;
+ int res;
- if (select_union::send_data(items))
- return 1;
+ if ((res= select_union::send_data(items)))
+ return res;
/* Skip duplicate rows. */
if (write_err == HA_ERR_FOUND_DUPP_KEY ||
write_err == HA_ERR_FOUND_DUPP_UNIQUE)
@@ -3140,6 +3145,7 @@ void TMP_TABLE_PARAM::init()
table_charset= 0;
precomputed_group_by= 0;
bit_fields_as_long= 0;
+ materialized_subquery= 0;
skip_create_table= 0;
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 904ffda5c85..fe9288c0e52 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -188,7 +188,7 @@ typedef struct st_user_var_events
#define RP_LOCK_LOG_IS_ALREADY_LOCKED 1
#define RP_FORCE_ROTATE 2
-
+#define RP_BINLOG_CHECKSUM_ALG_CHANGE 4
/*
The COPY_INFO structure is used by INSERT/REPLACE code.
The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY
@@ -408,14 +408,6 @@ struct system_variables
ulong optimizer_search_depth;
/* A bitmap for switching optimizations on/off */
ulong optimizer_switch;
- /*
- Controls use of Engine-MRR:
- 0 - auto, based on cost
- 1 - force MRR when the storage engine is capable of doing it
- 2 - disable MRR.
- */
- ulong optimizer_use_mrr;
-
ulong preload_buff_size;
ulong profiling_history_size;
ulong query_cache_type;
@@ -767,8 +759,12 @@ public:
ENGINE INNODB STATUS.
*/
LEX_STRING query_string;
+ /*
+ If opt_query_cache_strip_comments is set, this contains query without
+ comments. If not set, it contains pointer to query_string.
+ */
+ String base_query;
Server_side_cursor *cursor;
-
inline char *query() { return query_string.str; }
inline uint32 query_length() { return (uint32)query_string.length; }
void set_query_inner(char *query_arg, uint32 query_length_arg);
@@ -789,7 +785,8 @@ public:
char *db;
size_t db_length;
-public:
+ /* This is set to 1 of last call to send_result_to_client() was ok */
+ my_bool query_cache_is_applicable;
/* This constructor is called for backup statements */
Statement() {}
@@ -1520,7 +1517,6 @@ public:
*/
const char *where;
- double tmp_double_value; /* Used in set_var.cc */
ulong client_capabilities; /* What the client supports */
ulong max_client_packet_length;
@@ -1544,7 +1540,9 @@ public:
uint32 file_id; // for LOAD DATA INFILE
/* remote (peer) port */
uint16 peer_port;
- time_t start_time, user_time;
+ my_time_t start_time; // start_time and its sec_part
+ ulong start_time_sec_part; // are almost always used separately
+ my_hrtime_t user_time;
// track down slow pthread_create
ulonglong prior_thr_create_utime, thr_create_utime;
ulonglong start_utime, utime_after_lock;
@@ -1570,6 +1568,9 @@ public:
*/
TABLE_LIST *emb_on_expr_nest;
} thd_marker;
+
+ bool prepare_derived_at_open;
+
#ifndef MYSQL_CLIENT
int binlog_setup_trx_data();
@@ -1979,6 +1980,7 @@ public:
*/
bool is_fatal_sub_stmt_error;
bool query_start_used, rand_used, time_zone_used;
+ bool query_start_sec_part_used;
/* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
bool substitute_null_with_insert_id;
bool in_lock_tables;
@@ -2039,6 +2041,7 @@ public:
long long_value;
ulong ulong_value;
ulonglong ulonglong_value;
+ double double_value;
} sys_var_tmp;
struct {
@@ -2177,30 +2180,41 @@ public:
proc_info = old_msg;
pthread_mutex_unlock(&mysys_var->mutex);
}
- inline time_t query_start() { query_start_used=1; return start_time; }
+ inline my_time_t query_start() { query_start_used=1; return start_time; }
+ inline ulong query_start_sec_part()
+ { query_start_sec_part_used=1; return start_time_sec_part; }
+ inline void set_current_time()
+ {
+ my_hrtime_t hrtime= my_hrtime();
+ start_time= hrtime_to_my_time(hrtime);
+ start_time_sec_part= hrtime_sec_part(hrtime);
+ }
inline void set_time()
{
- if (user_time)
+ if (user_time.val)
{
- start_time= user_time;
- start_utime= utime_after_lock= my_micro_time();
+ start_time= hrtime_to_my_time(user_time);
+ start_time_sec_part= hrtime_sec_part(user_time);
}
else
- start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
+ set_current_time();
+ start_utime= utime_after_lock= microsecond_interval_timer();
}
- inline void set_current_time() { start_time= my_time(MY_WME); }
- inline void set_time(time_t t)
+ inline void set_time(my_hrtime_t t)
{
- start_time= user_time= t;
- start_utime= utime_after_lock= my_micro_time();
+ user_time= t;
+ start_time= hrtime_to_my_time(user_time);
+ start_time_sec_part= hrtime_sec_part(user_time);
+ start_utime= utime_after_lock= microsecond_interval_timer();
}
- /*TODO: this will be obsolete when we have support for 64 bit my_time_t */
- inline bool is_valid_time()
- {
- return (start_time < (time_t) MY_TIME_T_MAX);
+ inline void set_time(my_time_t t, ulong sec_part)
+ {
+ my_hrtime_t hrtime= { hrtime_from_time(t) + sec_part };
+ set_time(hrtime);
}
- void set_time_after_lock() { utime_after_lock= my_micro_time(); }
- ulonglong current_utime() { return my_micro_time(); }
+ void set_time_after_lock() { utime_after_lock= microsecond_interval_timer(); }
+ ulonglong current_utime() { return microsecond_interval_timer(); }
+
inline ulonglong found_rows(void)
{
return limit_found_rows;
@@ -2323,7 +2337,11 @@ public:
{
if (!stmt_arena->is_conventional())
check_and_register_item_tree_change(place, new_value, mem_root);
- *place= *new_value;
+ /*
+ We have to use memcpy instead of *place= *new_value merge to
+ avoid problems with strict aliasing.
+ */
+ memcpy((char*) place, new_value, sizeof(*new_value));
}
void nocheck_register_item_tree_change(Item **place, Item *old_value,
MEM_ROOT *runtime_memroot);
@@ -2637,6 +2655,27 @@ my_eof(THD *thd)
/*
+ These functions are for making it later easy to add strict
+ checking for all date handling.
+*/
+
+extern my_bool strict_date_checking;
+
+inline ulong sql_mode_for_dates(THD *thd)
+{
+ if (unlikely(strict_date_checking))
+ return (thd->variables.sql_mode &
+ (MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE |
+ MODE_INVALID_DATES));
+ return (thd->variables.sql_mode & MODE_INVALID_DATES);
+}
+
+inline ulong sql_mode_for_dates()
+{
+ return sql_mode_for_dates(current_thd);
+}
+
+/*
Used to hold information about file and file structure in exchange
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
XXX: We never call destructor for objects of this class.
@@ -2685,7 +2724,11 @@ public:
virtual uint field_count(List<Item> &fields) const
{ return fields.elements; }
virtual bool send_fields(List<Item> &list, uint flags)=0;
- virtual bool send_data(List<Item> &items)=0;
+ /*
+ send_data returns 0 on ok, 1 on error and -1 if data was ignored, for
+ example for a duplicate row entry written to a temp table.
+ */
+ virtual int send_data(List<Item> &items)=0;
virtual bool initialize_tables (JOIN *join=0) { return 0; }
virtual void send_error(uint errcode,const char *err);
virtual bool send_eof()=0;
@@ -2727,7 +2770,12 @@ public:
class select_result_interceptor: public select_result
{
public:
- select_result_interceptor() {} /* Remove gcc warning */
+ select_result_interceptor()
+ {
+ DBUG_ENTER("select_result_interceptor::select_result_interceptor");
+ DBUG_PRINT("enter", ("this 0x%lx", (ulong) this));
+ DBUG_VOID_RETURN;
+ } /* Remove gcc warning */
uint field_count(List<Item> &fields) const { return 0; }
bool send_fields(List<Item> &fields, uint flag) { return FALSE; }
};
@@ -2743,7 +2791,7 @@ class select_send :public select_result {
public:
select_send() :is_result_set_started(FALSE) {}
bool send_fields(List<Item> &list, uint flags);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
bool send_eof();
virtual bool check_simple_select() const { return FALSE; }
void abort();
@@ -2814,7 +2862,7 @@ public:
}
~select_export();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
};
@@ -2831,7 +2879,7 @@ public:
nest_level= nest_level_arg;
}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
};
@@ -2852,7 +2900,7 @@ public:
~select_insert();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
virtual int prepare2(void);
- bool send_data(List<Item> &items);
+ virtual int send_data(List<Item> &items);
virtual void store_values(List<Item> &values);
virtual bool can_rollback_data() { return 0; }
void send_error(uint errcode,const char *err);
@@ -2970,6 +3018,8 @@ public:
uint convert_blob_length;
CHARSET_INFO *table_charset;
bool schema_table;
+ /* TRUE if the temp table is created for subquery materialization. */
+ bool materialized_subquery;
/*
True if GROUP BY and its aggregate functions are already computed
by a table access method (e.g. by loose index scan). In this case
@@ -2993,8 +3043,8 @@ public:
TMP_TABLE_PARAM()
:copy_field(0), group_parts(0),
group_length(0), group_null_parts(0), convert_blob_length(0),
- schema_table(0), precomputed_group_by(0), force_copy_fields(0),
- bit_fields_as_long(0), skip_create_table(0)
+ schema_table(0), materialized_subquery(0), precomputed_group_by(0),
+ force_copy_fields(0), bit_fields_as_long(0), skip_create_table(0)
{}
~TMP_TABLE_PARAM()
{
@@ -3013,21 +3063,25 @@ public:
class select_union :public select_result_interceptor
{
-protected:
+public:
TMP_TABLE_PARAM tmp_table_param;
int write_err; /* Error code from the last send_data->ha_write_row call. */
public:
TABLE *table;
+ ha_rows records;
- select_union() :write_err(0),table(0) { tmp_table_param.init(); }
+ select_union() :write_err(0), table(0), records(0) { tmp_table_param.init(); }
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
bool send_eof();
bool flush();
void cleanup();
virtual bool create_result_table(THD *thd, List<Item> *column_types,
bool is_distinct, ulonglong options,
- const char *alias, bool bit_fields_as_long);
+ const char *alias,
+ bool bit_fields_as_long,
+ bool create_table);
+ TMP_TABLE_PARAM *get_tmp_table_param() { return &tmp_table_param; }
};
/* Base subselect interface class */
@@ -3037,7 +3091,7 @@ protected:
Item_subselect *item;
public:
select_subselect(Item_subselect *item);
- bool send_data(List<Item> &items)=0;
+ int send_data(List<Item> &items)=0;
bool send_eof() { return 0; };
};
@@ -3048,7 +3102,7 @@ public:
select_singlerow_subselect(Item_subselect *item_arg)
:select_subselect(item_arg)
{}
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
};
@@ -3091,12 +3145,14 @@ protected:
void reset();
public:
- select_materialize_with_stats() {}
- virtual bool create_result_table(THD *thd, List<Item> *column_types,
- bool is_distinct, ulonglong options,
- const char *alias, bool bit_fields_as_long);
+ select_materialize_with_stats() { tmp_table_param.init(); }
+ bool create_result_table(THD *thd, List<Item> *column_types,
+ bool is_distinct, ulonglong options,
+ const char *alias,
+ bool bit_fields_as_long,
+ bool create_table);
bool init_result_table(ulonglong select_options);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
void cleanup();
ha_rows get_null_count_of_col(uint idx)
{
@@ -3128,7 +3184,7 @@ public:
:select_subselect(item_arg), cache(0), fmax(mx)
{}
void cleanup();
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
bool cmp_real();
bool cmp_int();
bool cmp_decimal();
@@ -3141,7 +3197,7 @@ class select_exists_subselect :public select_subselect
public:
select_exists_subselect(Item_subselect *item_arg)
:select_subselect(item_arg){}
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
};
@@ -3389,7 +3445,7 @@ public:
multi_delete(TABLE_LIST *dt, uint num_of_tables);
~multi_delete();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
bool initialize_tables (JOIN *join);
void send_error(uint errcode,const char *err);
int do_deletes();
@@ -3402,7 +3458,7 @@ public:
class multi_update :public select_result_interceptor
{
TABLE_LIST *all_tables; /* query/update command tables */
- TABLE_LIST *leaves; /* list of leves of join table tree */
+ List<TABLE_LIST> *leaves; /* list of leves of join table tree */
TABLE_LIST *update_tables, *table_being_updated;
TABLE **tmp_tables, *main_table, *table_to_update;
TMP_TABLE_PARAM *tmp_table_param;
@@ -3428,12 +3484,12 @@ class multi_update :public select_result_interceptor
bool error_handled;
public:
- multi_update(TABLE_LIST *ut, TABLE_LIST *leaves_list,
+ multi_update(TABLE_LIST *ut, List<TABLE_LIST> *leaves_list,
List<Item> *fields, List<Item> *values,
enum_duplicates handle_duplicates, bool ignore);
~multi_update();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
bool initialize_tables (JOIN *join);
void send_error(uint errcode,const char *err);
int do_updates();
@@ -3477,7 +3533,7 @@ public:
}
~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- bool send_data(List<Item> &items);
+ int send_data(List<Item> &items);
bool send_eof();
virtual bool check_simple_select() const;
void cleanup();
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 1c2ae915259..05e33826da9 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -780,8 +780,23 @@ void update_global_user_stats(THD *thd, bool create_user, time_t now)
}
-void thd_init_client_charset(THD *thd, uint cs_number)
+/**
+ Set thread character set variables from the given ID
+
+ @param thd thread handle
+ @param cs_number character set and collation ID
+
+ @retval 0 OK; character_set_client, collation_connection and
+ character_set_results are set to the new value,
+ or to the default global values.
+
+ @retval 1 error, e.g. the given ID is not supported by parser.
+ Corresponding SQL error is sent.
+*/
+
+bool thd_init_client_charset(THD *thd, uint cs_number)
{
+ CHARSET_INFO *cs;
/*
Use server character set and collation if
- opt_character_set_client_handshake is not set
@@ -790,10 +805,10 @@ void thd_init_client_charset(THD *thd, uint cs_number)
- client character set doesn't exists in server
*/
if (!opt_character_set_client_handshake ||
- !(thd->variables.character_set_client= get_charset(cs_number, MYF(0))) ||
+ !(cs= get_charset(cs_number, MYF(0))) ||
!my_strcasecmp(&my_charset_latin1,
global_system_variables.character_set_client->name,
- thd->variables.character_set_client->name))
+ cs->name))
{
thd->variables.character_set_client=
global_system_variables.character_set_client;
@@ -804,10 +819,18 @@ void thd_init_client_charset(THD *thd, uint cs_number)
}
else
{
+ if (!is_supported_parser_charset(cs))
+ {
+ /* Disallow non-supported parser character sets: UCS2, UTF16, UTF32 */
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
+ cs->csname);
+ return true;
+ }
thd->variables.character_set_results=
thd->variables.collation_connection=
- thd->variables.character_set_client;
+ thd->variables.character_set_client= cs;
}
+ return false;
}
@@ -1098,7 +1121,7 @@ pthread_handler_t handle_one_connection(void *arg)
{
THD *thd= (THD*) arg;
- thd->thr_create_utime= my_micro_time();
+ thd->thr_create_utime= microsecond_interval_timer();
if (thread_scheduler.init_new_connection_thread())
{
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 308c49fc15c..8cd181d9ba1 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -363,7 +363,6 @@ Sensitive_cursor::open(JOIN *join_arg)
join= join_arg;
THD *thd= join->thd;
/* First non-constant table */
- JOIN_TAB *join_tab= join->join_tab + join->const_tables;
DBUG_ENTER("Sensitive_cursor::open");
join->change_result(result);
@@ -381,26 +380,29 @@ Sensitive_cursor::open(JOIN *join_arg)
/* Prepare JOIN for reading rows. */
join->tmp_table= 0;
- join->join_tab[join->tables-1].next_select= setup_end_select_func(join);
+ join->join_tab[join->top_join_tab_count - 1].next_select= setup_end_select_func(join);
join->send_records= 0;
join->fetch_limit= join->unit->offset_limit_cnt;
/* Disable JOIN CACHE as it is not working with cursors yet */
- for (JOIN_TAB *tab= join_tab;
- tab != join->join_tab + join->tables - 1;
- tab++)
+ for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ tab != join->join_tab + join->top_join_tab_count - 1;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
if (tab->next_select == sub_select_cache)
tab->next_select= sub_select;
}
- DBUG_ASSERT(join_tab->table->reginfo.not_exists_optimize == 0);
- DBUG_ASSERT(join_tab->not_used_in_distinct == 0);
+#ifndef DBUG_OFF
+ JOIN_TAB *first_tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ DBUG_ASSERT(first_tab->table->reginfo.not_exists_optimize == 0);
+ DBUG_ASSERT(first_tab->not_used_in_distinct == 0);
/*
null_row is set only if row not found and it's outer join: should never
happen for the first table in join_tab list
*/
- DBUG_ASSERT(join_tab->table->null_row == 0);
+ DBUG_ASSERT(first_tab->table->null_row == 0);
+#endif
DBUG_RETURN(0);
}
@@ -662,7 +664,7 @@ void Materialized_cursor::fetch(ulong num_rows)
If network write failed (i.e. due to a closed socked),
the error has already been set. Just return.
*/
- if (result->send_data(item_list))
+ if (result->send_data(item_list) > 0)
return;
}
@@ -720,8 +722,8 @@ bool Select_materialize::send_fields(List<Item> &list, uint flags)
DBUG_ASSERT(table == 0);
if (create_result_table(unit->thd, unit->get_unit_column_types(),
FALSE, thd->options | TMP_TABLE_ALL_COLUMNS, "",
- FALSE))
- return TRUE;
+ FALSE, TRUE))
+ return TRUE;
materialized_cursor= new (&table->mem_root)
Materialized_cursor(result, table);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 35823408ef2..c788d324743 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -973,7 +973,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
ha_drop_database(path);
tmp_disable_binlog(thd);
- query_cache_invalidate1(db);
+ query_cache_invalidate1(thd, db);
(void) sp_drop_db_routines(thd, db); /* @todo Do not ignore errors */
#ifdef HAVE_EVENT_SCHEDULER
Events::drop_schema_events(thd, db);
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index e2cb17090a1..6ace7ba8086 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -60,10 +60,20 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
- if (!(table= table_list->table))
+
+ if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
+ mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
+ DBUG_RETURN(TRUE);
+
+ if (!table_list->updatable)
{
- my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
- table_list->view_db.str, table_list->view_name.str);
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
+ DBUG_RETURN(TRUE);
+ }
+ if (!(table= table_list->table) || !table->created)
+ {
+ my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
+ table_list->view_db.str, table_list->view_name.str);
DBUG_RETURN(TRUE);
}
thd_proc_info(thd, "init");
@@ -72,6 +82,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (mysql_prepare_delete(thd, table_list, &conds))
DBUG_RETURN(TRUE);
+ if (thd->lex->current_select->first_cond_optimization)
+ {
+ thd->lex->current_select->save_leaf_tables(thd);
+ thd->lex->current_select->first_cond_optimization= 0;
+ }
/* check ORDER BY even if it can be ignored */
if (order && order->elements)
{
@@ -93,6 +108,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
}
+ /* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
+ if (select_lex->optimize_unflattened_subqueries())
+ DBUG_RETURN(TRUE);
+
const_cond= (!conds || conds->const_item());
safe_update=test(thd->options & OPTION_SAFE_UPDATES);
if (safe_update && const_cond)
@@ -401,6 +420,12 @@ cleanup:
query_cache_invalidate3(thd, table_list, 1);
}
+ if (thd->lex->current_select->first_cond_optimization)
+ {
+ thd->lex->current_select->save_leaf_tables(thd);
+ thd->lex->current_select->first_cond_optimization= 0;
+ }
+
delete select;
transactional_table= table->file->has_transactions();
@@ -502,8 +527,8 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list,
- &select_lex->leaf_tables, FALSE,
- DELETE_ACL, SELECT_ACL) ||
+ select_lex->leaf_tables, FALSE,
+ DELETE_ACL, SELECT_ACL, TRUE) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
setup_ftfuncs(select_lex))
DBUG_RETURN(TRUE);
@@ -561,6 +586,11 @@ int mysql_multi_delete_prepare(THD *thd)
TABLE_LIST *target_tbl;
DBUG_ENTER("mysql_multi_delete_prepare");
+ TABLE_LIST *tables= lex->query_tables;
+ if (mysql_handle_derived(lex, DT_INIT) ||
+ mysql_handle_list_of_derived(lex, tables, DT_MERGE_FOR_INSERT) ||
+ mysql_handle_list_of_derived(lex, tables, DT_PREPARE))
+ DBUG_RETURN(TRUE);
/*
setup_tables() need for VIEWs. JOIN::prepare() will not do it second
time.
@@ -570,8 +600,8 @@ int mysql_multi_delete_prepare(THD *thd)
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
lex->query_tables,
- &lex->select_lex.leaf_tables, FALSE,
- DELETE_ACL, SELECT_ACL))
+ lex->select_lex.leaf_tables, FALSE,
+ DELETE_ACL, SELECT_ACL, TRUE))
DBUG_RETURN(TRUE);
@@ -585,16 +615,13 @@ int mysql_multi_delete_prepare(THD *thd)
target_tbl;
target_tbl= target_tbl->next_local)
{
+
if (!(target_tbl->table= target_tbl->correspondent_table->table))
{
- DBUG_ASSERT(target_tbl->correspondent_table->view &&
- target_tbl->correspondent_table->merge_underlying_list &&
- target_tbl->correspondent_table->merge_underlying_list->
- next_local);
- my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
- target_tbl->correspondent_table->view_db.str,
- target_tbl->correspondent_table->view_name.str);
- DBUG_RETURN(TRUE);
+ my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
+ target_tbl->correspondent_table->view_db.str,
+ target_tbl->correspondent_table->view_name.str);
+ DBUG_RETURN(TRUE);
}
if (!target_tbl->correspondent_table->updatable ||
@@ -644,6 +671,12 @@ multi_delete::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
unit= u;
do_delete= 1;
thd_proc_info(thd, "deleting from main table");
+ SELECT_LEX *select_lex= u->first_select();
+ if (select_lex->first_cond_optimization)
+ {
+ if (select_lex->handle_derived(thd->lex, DT_MERGE))
+ DBUG_RETURN(TRUE);
+ }
DBUG_RETURN(0);
}
@@ -677,9 +710,10 @@ multi_delete::initialize_tables(JOIN *join)
walk= delete_tables;
- for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables;
- tab < end;
- tab++)
+
+ for (JOIN_TAB *tab= first_linear_tab(join, WITH_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
if (tab->table->map & tables_to_delete_from)
{
@@ -758,7 +792,7 @@ multi_delete::~multi_delete()
}
-bool multi_delete::send_data(List<Item> &values)
+int multi_delete::send_data(List<Item> &values)
{
int secure_counter= delete_while_scanning ? -1 : 0;
TABLE_LIST *del_table;
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index e92b8f83c95..9bfa49c5f2d 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -23,38 +23,79 @@
#include "mysql_priv.h"
#include "sql_select.h"
+typedef bool (*dt_processor)(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived);
+bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived);
+
+
+dt_processor processors[]=
+{
+ &mysql_derived_init,
+ &mysql_derived_prepare,
+ &mysql_derived_optimize,
+ &mysql_derived_merge,
+ &mysql_derived_merge_for_insert,
+ &mysql_derived_create,
+ &mysql_derived_fill,
+ &mysql_derived_reinit,
+};
/*
- Call given derived table processor (preparing or filling tables)
+ @brief
+ Run specified phases on all derived tables/views in given LEX.
- SYNOPSIS
- mysql_handle_derived()
- lex LEX for this thread
- processor procedure of derived table processing
+ @param lex LEX for this thread
+ @param phases phases to run derived tables/views through
- RETURN
- FALSE OK
- TRUE Error
+ @return FALSE OK
+ @return TRUE Error
*/
-
bool
-mysql_handle_derived(LEX *lex, bool (*processor)(THD*, LEX*, TABLE_LIST*))
+mysql_handle_derived(LEX *lex, uint phases)
{
bool res= FALSE;
- if (lex->derived_tables)
+ THD *thd= lex->thd;
+ if (!lex->derived_tables)
+ return FALSE;
+
+ lex->thd->derived_tables_processing= TRUE;
+
+ for (uint phase= 0; phase < DT_PHASES && !res; phase++)
{
- lex->thd->derived_tables_processing= TRUE;
+ uint phase_flag= DT_INIT << phase;
+ if (phase_flag > phases)
+ break;
+ if (!(phases & phase_flag))
+ continue;
+ if (phase_flag >= DT_CREATE && !thd->fill_derived_tables())
+ break;
+
for (SELECT_LEX *sl= lex->all_selects_list;
- sl;
+ sl && !res;
sl= sl->next_select_in_list())
{
for (TABLE_LIST *cursor= sl->get_table_list();
- cursor;
+ cursor && !res;
cursor= cursor->next_local)
{
- if ((res= (*processor)(lex->thd, lex, cursor)))
- goto out;
+ uint8 allowed_phases= (cursor->is_merged_derived() ? DT_PHASES_MERGE :
+ DT_PHASES_MATERIALIZE);
+ /*
+ Skip derived tables to which the phase isn't applicable.
+ TODO: mark derived at the parse time, later set it's type
+ (merged or materialized)
+ */
+ if ((phase_flag != DT_PREPARE && !(allowed_phases & phase_flag)) ||
+ (cursor->merged_for_insert && phase_flag != DT_REINIT))
+ continue;
+ res= (*processors[phase])(lex->thd, lex, cursor);
}
if (lex->describe)
{
@@ -67,30 +108,463 @@ mysql_handle_derived(LEX *lex, bool (*processor)(THD*, LEX*, TABLE_LIST*))
}
}
}
-out:
+ lex->thd->derived_tables_processing= FALSE;
+ return res;
+}
+
+/*
+ @brief
+ Run through phases for the given derived table/view.
+
+ @param lex LEX for this thread
+ @param derived the derived table to handle
+ @param phase_map phases to process tables/views through
+
+ @details
+
+ This function process the derived table (view) 'derived' to performs all
+ actions that are to be done on the table at the phases specified by
+ phase_map. The processing is carried out starting from the actions
+ performed at the earlier phases (those having smaller ordinal numbers).
+
+ @note
+ This function runs specified phases of the derived tables handling on the
+ given derived table/view. This function is used in the chain of calls:
+ SELECT_LEX::handle_derived ->
+ TABLE_LIST::handle_derived ->
+ mysql_handle_single_derived
+ This chain of calls implements the bottom-up handling of the derived tables:
+ i.e. most inner derived tables/views are handled first. This order is
+ required for the all phases except the merge and the create steps.
+ For the sake of code simplicity this order is kept for all phases.
+
+ @return FALSE ok
+ @return TRUE error
+*/
+
+bool
+mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
+{
+ bool res= FALSE;
+ THD *thd= lex->thd;
+ uint8 allowed_phases= (derived->is_merged_derived() ? DT_PHASES_MERGE :
+ DT_PHASES_MATERIALIZE);
+ if (!lex->derived_tables)
+ return FALSE;
+
+ lex->thd->derived_tables_processing= TRUE;
+
+ for (uint phase= 0; phase < DT_PHASES; phase++)
+ {
+ uint phase_flag= DT_INIT << phase;
+ if (phase_flag > phases)
+ break;
+ if (!(phases & phase_flag))
+ continue;
+ /* Skip derived tables to which the phase isn't applicable. */
+ if (phase_flag != DT_PREPARE &&
+ !(allowed_phases & phase_flag))
+ continue;
+ if (phase_flag >= DT_CREATE && !thd->fill_derived_tables())
+ break;
+
+ if ((res= (*processors[phase])(lex->thd, lex, derived)))
+ break;
+ }
lex->thd->derived_tables_processing= FALSE;
return res;
}
/**
- @brief Create temporary table structure (but do not fill it).
+ @brief
+ Run specified phases for derived tables/views in the given list
- @param thd Thread handle
- @param lex LEX for this thread
- @param orig_table_list TABLE_LIST for the upper SELECT
+ @param lex LEX for this thread
+ @param table_list list of derived tables/view to handle
+ @param phase_map phases to process tables/views through
- @details
+ @details
+ This function runs phases specified by the 'phases_map' on derived
+ tables/views found in the 'dt_list' with help of the
+ TABLE_LIST::handle_derived function.
+ 'lex' is passed as an argument to the TABLE_LIST::handle_derived.
- This function is called before any command containing derived tables is
- executed. Currently the function is used for derived tables, i.e.
+ @return FALSE ok
+ @return TRUE error
+*/
+
+bool
+mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *table_list, uint phases)
+{
+ for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
+ {
+ if (tl->is_view_or_derived() &&
+ tl->handle_derived(lex, phases))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ @brief
+ Merge a derived table/view into the embedding select
+
+ @param thd thread handle
+ @param lex LEX of the embedding query.
+ @param derived reference to the derived table.
+
+ @details
+ This function merges the given derived table / view into the parent select
+ construction. Any derived table/reference to view occurred in the FROM
+ clause of the embedding select is represented by a TABLE_LIST structure a
+ pointer to which is passed to the function as in the parameter 'derived'.
+ This structure contains the number/map, alias, a link to SELECT_LEX of the
+ derived table and other info. If the 'derived' table is used in a nested join
+ then additionally the structure contains a reference to the ON expression
+ for this join.
+
+ The merge process results in elimination of the derived table (or the
+ reference to a view) such that:
+ - the FROM list of the derived table/view is wrapped into a nested join
+ after which the nest is added to the FROM list of the embedding select
+ - the WHERE condition of the derived table (view) is ANDed with the ON
+ condition attached to the table.
+
+ @note
+ Tables are merged into the leaf_tables list, original derived table is removed
+ from this list also. SELECT_LEX::table_list list is left untouched.
+ Where expression is merged with derived table's on_expr and can be found after
+ the merge through the SELECT_LEX::table_list.
+
+ Examples of the derived table/view merge:
+
+ Schema:
+ Tables: t1(f1), t2(f2), t3(f3)
+ View v1: SELECT f1 FROM t1 WHERE f1 < 1
+
+ Example with a view:
+ Before merge:
+
+ The query (Q1): SELECT f1,f2 FROM t2 LEFT JOIN v1 ON f1 = f2
+
+ (LEX of the main query)
+ |
+ (select_lex)
+ |
+ (FROM table list)
+ |
+ (join list)= t2, v1
+ / \
+ / (on_expr)= (f1 = f2)
+ |
+ (LEX of the v1 view)
+ |
+ (select_lex)= SELECT f1 FROM t1 WHERE f1 < 1
+
+
+ After merge:
+
+ The rewritten query Q1 (Q1'):
+ SELECT f1,f2 FROM t2 LEFT JOIN (t1) ON ((f1 = f2) and (f1 < 1))
+
+ (LEX of the main query)
+ |
+ (select_lex)
+ |
+ (FROM table list)
+ |
+ (join list)= t2, (t1)
+ \
+ (on_expr)= (f1 = f2) and (f1 < 1)
+
+ In this example table numbers are assigned as follows:
+ (outer select): t2 - 1, v1 - 2
+ (inner select): t1 - 1
+ After the merge table numbers will be:
+ (outer select): t2 - 1, t1 - 2
+
+ Example with a derived table:
+ The query Q2:
+ SELECT f1,f2
+ FROM (SELECT f1 FROM t1, t3 WHERE f1=f3 and f1 < 1) tt, t2
+ WHERE f1 = f2
+
+ Before merge:
+ (LEX of the main query)
+ |
+ (select_lex)
+ / \
+ (FROM table list) (WHERE clause)= (f1 = f2)
+ |
+ (join list)= tt, t2
+ / \
+ / (on_expr)= (empty)
+ /
+ (select_lex)= SELECT f1 FROM t1, t3 WHERE f1 = f3 and f1 < 1
+
+ After merge:
+
+ The rewritten query Q2 (Q2'):
+ SELECT f1,f2
+ FROM (t1, t3) JOIN t2 ON (f1 = f3 and f1 < 1)
+ WHERE f1 = f2
+
+ (LEX of the main query)
+ |
+ (select_lex)
+ / \
+ (FROM table list) (WHERE clause)= (f1 = f2)
+ |
+ (join list)= t2, (t1, t3)
+ \
+ (on_expr)= (f1 = f3 and f1 < 1)
+
+ In this example table numbers are assigned as follows:
+ (outer select): tt - 1, t2 - 2
+ (inner select): t1 - 1, t3 - 2
+ After the merge table numbers will be:
+ (outer select): t1 - 1, t2 - 2, t3 - 3
+
+ @return FALSE if derived table/view were successfully merged.
+ @return TRUE if an error occur.
+*/
+
+bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ bool res= FALSE;
+ SELECT_LEX *dt_select= derived->get_single_select();
+ table_map map;
+ uint tablenr;
+ SELECT_LEX *parent_lex= derived->select_lex;
+ Query_arena *arena, backup;
+
+ if (derived->merged)
+ return FALSE;
+
+ arena= thd->activate_stmt_arena_if_needed(&backup); // For easier test
+ derived->merged= TRUE;
+ /*
+ Check whether there is enough free bits in table map to merge subquery.
+ If not - materialize it. This check isn't cached so when there is a big
+ and small subqueries, and the bigger one can't be merged it wouldn't
+ block the smaller one.
+ */
+ if (parent_lex->get_free_table_map(&map, &tablenr))
+ {
+ /* There is no enough table bits, fall back to materialization. */
+ derived->change_refs_to_fields();
+ derived->set_materialized_derived();
+ goto exit_merge;
+ }
+
+ if (dt_select->leaf_tables.elements + tablenr > MAX_TABLES)
+ {
+ /* There is no enough table bits, fall back to materialization. */
+ derived->change_refs_to_fields();
+ derived->set_materialized_derived();
+ goto exit_merge;
+ }
+
+ if (dt_select->options & OPTION_SCHEMA_TABLE)
+ parent_lex->options |= OPTION_SCHEMA_TABLE;
+
+ parent_lex->cond_count+= dt_select->cond_count;
+
+ if (!derived->get_unit()->prepared)
+ {
+ dt_select->leaf_tables.empty();
+ make_leaves_list(dt_select->leaf_tables, derived, TRUE, 0);
+ }
+
+ if (!derived->merged_for_insert)
+ { derived->nested_join= (NESTED_JOIN*) thd->calloc(sizeof(NESTED_JOIN));
+ if (!derived->nested_join)
+ {
+ res= TRUE;
+ goto exit_merge;
+ }
+
+ /* Merge derived table's subquery in the parent select. */
+ if (parent_lex->merge_subquery(derived, dt_select, tablenr, map))
+ {
+ res= TRUE;
+ goto exit_merge;
+ }
+
+ /*
+ exclude select lex so it doesn't show up in explain.
+ do this only for derived table as for views this is already done.
+
+ From sql_view.cc
+ Add subqueries units to SELECT into which we merging current view.
+ unit(->next)* chain starts with subqueries that are used by this
+ view and continues with subqueries that are used by other views.
+ We must not add any subquery twice (otherwise we'll form a loop),
+ to do this we remember in end_unit the first subquery that has
+ been already added.
+ */
+ derived->get_unit()->exclude_level();
+ if (parent_lex->join)
+ parent_lex->join->table_count+= dt_select->join->table_count - 1;
+ }
+ if (derived->get_unit()->prepared)
+ {
+ Item *expr= derived->on_expr;
+ expr= and_conds(expr, dt_select->join ? dt_select->join->conds : 0);
+ if (expr && (derived->prep_on_expr || expr != derived->on_expr))
+ {
+ derived->on_expr= expr;
+ derived->prep_on_expr= expr->copy_andor_structure(thd);
+ }
+ if (derived->on_expr &&
+ ((!derived->on_expr->fixed &&
+ derived->on_expr->fix_fields(thd, &derived->on_expr)) ||
+ derived->on_expr->check_cols(1)))
+ {
+ res= TRUE; /* purecov: inspected */
+ goto exit_merge;
+ }
+ // Update used tables cache according to new table map
+ if (derived->on_expr)
+ {
+ derived->on_expr->fix_after_pullout(parent_lex, &derived->on_expr);
+ fix_list_after_tbl_changes(parent_lex, &derived->nested_join->join_list);
+ }
+ }
+
+exit_merge:
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+ return res;
+}
+
+
+/**
+ @brief
+ Merge a view for the embedding INSERT/UPDATE/DELETE
+
+ @param thd thread handle
+ @param lex LEX of the embedding query.
+ @param derived reference to the derived table.
+
+ @details
+ This function substitutes the derived table for the first table from
+ the query of the derived table thus making it a correct target table for the
+ INSERT/UPDATE/DELETE statements. As this operation is correct only for
+ single table views only, for multi table views this function does nothing.
+ The derived parameter isn't checked to be a view as derived tables aren't
+ allowed for INSERT/UPDATE/DELETE statements.
+
+ @return FALSE if derived table/view were successfully merged.
+ @return TRUE if an error occur.
+*/
+
+bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ SELECT_LEX *dt_select= derived->get_single_select();
+
+ if (derived->merged_for_insert)
+ return FALSE;
+ /* It's a target view for an INSERT, create field translation only. */
+ if (!derived->updatable || derived->is_materialized_derived())
+ {
+ bool res= derived->create_field_translation(thd);
+ return res;
+ }
+ if (!derived->is_multitable())
+ {
+ TABLE_LIST *tl=((TABLE_LIST*)dt_select->table_list.first);
+ TABLE *table= tl->table;
+ /* preserve old map & tablenr. */
+ if (!derived->merged_for_insert && derived->table)
+ table->set_table_map(derived->table->map, derived->table->tablenr);
+
+ derived->table= table;
+ derived->schema_table=
+ ((TABLE_LIST*)dt_select->table_list.first)->schema_table;
+ if (!derived->merged)
+ {
+ Query_arena *arena, backup;
+ arena= thd->activate_stmt_arena_if_needed(&backup); // For easier test
+ derived->select_lex->leaf_tables.push_back(tl);
+ derived->nested_join= (NESTED_JOIN*) thd->calloc(sizeof(NESTED_JOIN));
+ if (derived->nested_join)
+ {
+ derived->wrap_into_nested_join(tl->select_lex->top_join_list);
+ derived->get_unit()->exclude_level();
+ }
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+ derived->merged= TRUE;
+ if (!derived->nested_join)
+ return TRUE;
+ }
+ }
+ else
+ {
+ if (!derived->merged_for_insert && mysql_derived_merge(thd, lex, derived))
+ return TRUE;
+ }
+ derived->merged_for_insert= TRUE;
+
+ return FALSE;
+}
+
+
+/*
+ @brief
+ Initialize a derived table/view
+
+ @param thd Thread handle
+ @param lex LEX of the embedding query.
+ @param derived reference to the derived table.
+
+ @detail
+ Fill info about derived table/view without preparing an
+ underlying select. Such as: create a field translation for views, mark it as
+ a multitable if it is and so on.
+
+ @return
+ false OK
+ true Error
+*/
- - Anonymous derived tables, or
- - Named derived tables (aka views) with the @c TEMPTABLE algorithm.
-
- The table reference, contained in @c orig_table_list, is updated with the
- fields of a new temporary table.
+bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ SELECT_LEX_UNIT *unit= derived->get_unit();
+ DBUG_ENTER("mysql_derived_init");
+
+ // Skip already prepared views/DT
+ if (!unit || unit->prepared)
+ DBUG_RETURN(FALSE);
+
+ DBUG_RETURN(derived->init_derived(thd, TRUE));
+}
+
+
+/*
+ @brief
+ Create temporary table structure (but do not fill it)
+
+ @param thd Thread handle
+ @param lex LEX of the embedding query.
+ @param derived reference to the derived table.
+
+ @detail
+ Prepare underlying select for a derived table/view. To properly resolve
+ names in the embedding query the TABLE structure is created. Actual table
+ is created later by the mysql_derived_create function.
+
+ This function is called before any command containing derived table
+ is executed. All types of derived tables are handled by this function:
+ - Anonymous derived tables, or
+ - Named derived tables (aka views).
+
+ The table reference, contained in @c derived, is updated with the
+ fields of a new temporary table.
Derived tables are stored in @c thd->derived_tables and closed by
close_thread_tables().
@@ -114,203 +588,355 @@ out:
the state of privilege checking (GRANT_INFO struct) is copied as-is to the
temporary table.
- This function implements a signature called "derived table processor", and
- is passed as a function pointer to mysql_handle_derived().
+ Only the TABLE structure is created here, actual table is created by the
+ mysql_derived_create function.
@note This function sets @c SELECT_ACL for @c TEMPTABLE views as well as
anonymous derived tables, but this is ok since later access checking will
distinguish between them.
- @see mysql_handle_derived(), mysql_derived_filling(), GRANT_INFO
+ @see mysql_handle_derived(), mysql_derived_fill(), GRANT_INFO
@return
false OK
true Error
*/
-bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
+bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
{
- SELECT_LEX_UNIT *unit= orig_table_list->derived;
- ulonglong create_options;
+ SELECT_LEX_UNIT *unit= derived->get_unit();
DBUG_ENTER("mysql_derived_prepare");
bool res= FALSE;
- if (unit)
+
+ // Skip already prepared views/DT
+ if (!unit || unit->prepared || derived->merged_for_insert)
+ DBUG_RETURN(FALSE);
+
+ Query_arena *arena= thd->stmt_arena, backup;
+ if (arena->is_conventional())
+ arena= 0; // For easier test
+ else
+ thd->set_n_backup_active_arena(arena, &backup);
+
+ SELECT_LEX *first_select= unit->first_select();
+
+ /* prevent name resolving out of derived table */
+ for (SELECT_LEX *sl= first_select; sl; sl= sl->next_select())
{
- SELECT_LEX *first_select= unit->first_select();
- TABLE *table= 0;
- select_union *derived_result;
-
- /* prevent name resolving out of derived table */
- for (SELECT_LEX *sl= first_select; sl; sl= sl->next_select())
- sl->context.outer_context= 0;
-
- if (!(derived_result= new select_union))
- DBUG_RETURN(TRUE); // out of memory
-
- lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
- // st_select_lex_unit::prepare correctly work for single select
- if ((res= unit->prepare(thd, derived_result, 0)))
- goto exit;
- lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
- if ((res= check_duplicate_names(unit->types, 0)))
- goto exit;
-
- create_options= (first_select->options | thd->options |
- TMP_TABLE_ALL_COLUMNS);
- /*
- Temp table is created so that it hounours if UNION without ALL is to be
- processed
-
- As 'distinct' parameter we always pass FALSE (0), because underlying
- query will control distinct condition by itself. Correct test of
- distinct underlying query will be is_union &&
- !unit->union_distinct->next_select() (i.e. it is union and last distinct
- SELECT is last SELECT of UNION).
- */
- if ((res= derived_result->create_result_table(thd, &unit->types, FALSE,
- create_options,
- orig_table_list->alias,
- FALSE)))
- goto exit;
+ sl->context.outer_context= 0;
+ // Prepare underlying views/DT first.
+ sl->handle_derived(lex, DT_PREPARE);
+ }
- table= derived_result->table;
+ unit->derived= derived;
+
+ if (!(derived->derived_result= new select_union))
+ DBUG_RETURN(TRUE); // out of memory
+
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_DERIVED;
+ // st_select_lex_unit::prepare correctly work for single select
+ if ((res= unit->prepare(thd, derived->derived_result, 0)))
+ goto exit;
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED;
+ if ((res= check_duplicate_names(unit->types, 0)))
+ goto exit;
+
+ /*
+ Check whether we can merge this derived table into main select.
+ Depending on the result field translation will or will not
+ be created.
+ */
+ if (derived->init_derived(thd, FALSE))
+ goto exit;
+
+ /*
+ Temp table is created so that it hounours if UNION without ALL is to be
+ processed
+
+ As 'distinct' parameter we always pass FALSE (0), because underlying
+ query will control distinct condition by itself. Correct test of
+ distinct underlying query will be is_union &&
+ !unit->union_distinct->next_select() (i.e. it is union and last distinct
+ SELECT is last SELECT of UNION).
+ */
+ if (derived->derived_result->create_result_table(thd, &unit->types, FALSE,
+ (first_select->options |
+ thd->options |
+ TMP_TABLE_ALL_COLUMNS),
+ derived->alias,
+ FALSE, FALSE))
+ goto exit;
+
+ derived->table= derived->derived_result->table;
+ if (derived->is_derived() && derived->is_merged_derived())
+ first_select->mark_as_belong_to_derived(derived);
exit:
- /* Hide "Unknown column" or "Unknown function" error */
- if (orig_table_list->view)
- {
- if (thd->is_error() &&
+ /* Hide "Unknown column" or "Unknown function" error */
+ if (derived->view)
+ {
+ if (thd->is_error() &&
(thd->main_da.sql_errno() == ER_BAD_FIELD_ERROR ||
- thd->main_da.sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION ||
- thd->main_da.sql_errno() == ER_SP_DOES_NOT_EXIST))
- {
- thd->clear_error();
- my_error(ER_VIEW_INVALID, MYF(0), orig_table_list->db,
- orig_table_list->table_name);
- }
- }
-
- /*
- if it is preparation PS only or commands that need only VIEW structure
- then we do not need real data and we can skip execution (and parameters
- is not defined, too)
- */
- if (res)
+ thd->main_da.sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION ||
+ thd->main_da.sql_errno() == ER_SP_DOES_NOT_EXIST))
{
- if (table)
- free_tmp_table(thd, table);
- delete derived_result;
+ thd->clear_error();
+ my_error(ER_VIEW_INVALID, MYF(0), derived->db,
+ derived->table_name);
}
+ }
+
+ /*
+ if it is preparation PS only or commands that need only VIEW structure
+ then we do not need real data and we can skip execution (and parameters
+ is not defined, too)
+ */
+ if (res)
+ {
+ if (derived->table)
+ free_tmp_table(thd, derived->table);
+ delete derived->derived_result;
+ }
+ else
+ {
+ TABLE *table= derived->table;
+ table->derived_select_number= first_select->select_number;
+ table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ if (derived->referencing_view)
+ table->grant= derived->grant;
else
{
- if (!thd->fill_derived_tables())
- {
- delete derived_result;
- derived_result= NULL;
- }
- orig_table_list->derived_result= derived_result;
- orig_table_list->table= table;
- orig_table_list->table_name= table->s->table_name.str;
- orig_table_list->table_name_length= table->s->table_name.length;
- table->derived_select_number= first_select->select_number;
- table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- if (orig_table_list->referencing_view)
- table->grant= orig_table_list->grant;
- else
- table->grant.privilege= SELECT_ACL;
-#endif
- orig_table_list->db= (char *)"";
- orig_table_list->db_length= 0;
- // Force read of table stats in the optimizer
- table->file->info(HA_STATUS_VARIABLE);
- /* Add new temporary table to list of open derived tables */
- table->next= thd->derived_tables;
- thd->derived_tables= table;
+ table->grant.privilege= SELECT_ACL;
+ if (derived->is_derived())
+ derived->grant.privilege= SELECT_ACL;
}
+#endif
+ /* Add new temporary table to list of open derived tables */
+ table->next= thd->derived_tables;
+ thd->derived_tables= table;
}
- else if (orig_table_list->merge_underlying_list)
- orig_table_list->set_underlying_merge();
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
DBUG_RETURN(res);
}
-/*
- fill derived table
-
- SYNOPSIS
- mysql_derived_filling()
- thd Thread handle
- lex LEX for this thread
- unit node that contains all SELECT's for derived tables
- orig_table_list TABLE_LIST for the upper SELECT
-
- IMPLEMENTATION
- Derived table is resolved with temporary table. It is created based on the
- queries defined. After temporary table is filled, if this is not EXPLAIN,
- then the entire unit / node is deleted. unit is deleted if UNION is used
- for derived table and node is deleted is it is a simple SELECT.
- If you use this function, make sure it's not called at prepare.
- Due to evaluation of LIMIT clause it can not be used at prepared stage.
-
- RETURN
- FALSE OK
- TRUE Error
+/**
+ @brief
+ Runs optimize phase for a derived table/view.
+
+ @param thd thread handle
+ @param lex LEX of the embedding query.
+ @param derived reference to the derived table.
+
+ @details
+ Runs optimize phase for given 'derived' derived table/view.
+ If optimizer finds out that it's of the type "SELECT a_constant" then this
+ functions also materializes it.
+
+ @return FALSE ok.
+ @return TRUE if an error occur.
*/
-bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
+bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
{
- TABLE *table= orig_table_list->table;
- SELECT_LEX_UNIT *unit= orig_table_list->derived;
+ SELECT_LEX_UNIT *unit= derived->get_unit();
+ SELECT_LEX *first_select= unit->first_select();
+ SELECT_LEX *save_current_select= lex->current_select;
+
bool res= FALSE;
- /*check that table creation pass without problem and it is derived table */
- if (table && unit)
+ if (unit->optimized && !unit->uncacheable && !unit->describe)
+ return FALSE;
+ lex->current_select= first_select;
+
+ if (unit->is_union())
+ {
+ // optimize union without execution
+ res= unit->optimize();
+ }
+ else if (unit->derived)
{
- SELECT_LEX *first_select= unit->first_select();
- select_union *derived_result= orig_table_list->derived_result;
- SELECT_LEX *save_current_select= lex->current_select;
- if (unit->is_union())
+ if (!derived->is_merged_derived())
{
- // execute union without clean up
- res= unit->exec();
+ JOIN *join= first_select->join;
+ unit->optimized= TRUE;
+ if ((res= join->optimize()))
+ goto err;
+ if (join->table_count == join->const_tables)
+ derived->fill_me= TRUE;
}
- else
+ }
+ /*
+ Materialize derived tables/views of the "SELECT a_constant" type.
+ Such tables should be materialized at the optimization phase for
+ correct constant evaluation.
+ */
+ if (!res && derived->fill_me && !derived->merged_for_insert)
+ {
+ if (derived->is_merged_derived())
{
- unit->set_limit(first_select);
- if (unit->select_limit_cnt == HA_POS_ERROR)
- first_select->options&= ~OPTION_FOUND_ROWS;
-
- lex->current_select= first_select;
- res= mysql_select(thd, &first_select->ref_pointer_array,
- first_select->table_list.first,
- first_select->with_wild,
- first_select->item_list, first_select->where,
- (first_select->order_list.elements+
- first_select->group_list.elements),
- first_select->order_list.first,
- first_select->group_list.first,
- first_select->having, (ORDER*) NULL,
- (first_select->options | thd->options |
- SELECT_NO_UNLOCK),
- derived_result, unit, first_select);
+ derived->change_refs_to_fields();
+ derived->set_materialized_derived();
}
+ if ((res= mysql_derived_create(thd, lex, derived)))
+ goto err;
+ if ((res= mysql_derived_fill(thd, lex, derived)))
+ goto err;
+ }
+err:
+ lex->current_select= save_current_select;
+ return res;
+}
- if (!res)
- {
- /*
- Here we entirely fix both TABLE_LIST and list of SELECT's as
- there were no derived tables
- */
- if (derived_result->flush())
- res= TRUE;
-
- if (!lex->describe)
- unit->cleanup();
- }
- else
- unit->cleanup();
- lex->current_select= save_current_select;
+
+/**
+ @brief
+ Actually create result table for a materialized derived table/view.
+
+ @param thd thread handle
+ @param lex LEX of the embedding query.
+ @param derived reference to the derived table.
+
+ @details
+ This function actually creates the result table for given 'derived'
+ table/view, but it doesn't fill it.
+ 'thd' and 'lex' parameters are not used by this function.
+
+ @return FALSE ok.
+ @return TRUE if an error occur.
+*/
+
+bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ TABLE *table= derived->table;
+ SELECT_LEX_UNIT *unit= derived->get_unit();
+
+ if (table->created)
+ return FALSE;
+ select_union *result= (select_union*)unit->result;
+ if (table->s->db_type() == TMP_ENGINE_HTON)
+ {
+ if (create_internal_tmp_table(table, result->tmp_table_param.keyinfo,
+ result->tmp_table_param.start_recinfo,
+ &result->tmp_table_param.recinfo,
+ (unit->first_select()->options |
+ thd->options | TMP_TABLE_ALL_COLUMNS)))
+ return(TRUE);
+ }
+ if (open_tmp_table(table))
+ return TRUE;
+ table->file->extra(HA_EXTRA_WRITE_CACHE);
+ table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
+ return FALSE;
+}
+
+
+/*
+ @brief
+ Execute subquery of a materialized derived table/view and fill the result
+ table.
+
+ @param thd Thread handle
+ @param lex LEX for this thread
+ @param derived reference to the derived table.
+
+ @details
+ Execute subquery of given 'derived' table/view and fill the result
+ table. After result table is filled, if this is not the EXPLAIN statement,
+ the entire unit / node is deleted. unit is deleted if UNION is used
+ for derived table and node is deleted is it is a simple SELECT.
+ 'lex' is unused and 'thd' is passed as an argument to an underlying function.
+
+ @note
+ If you use this function, make sure it's not called at prepare.
+ Due to evaluation of LIMIT clause it can not be used at prepared stage.
+
+ @return FALSE OK
+ @return TRUE Error
+*/
+
+bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ SELECT_LEX_UNIT *unit= derived->get_unit();
+ bool res= FALSE;
+
+ if (unit->executed && !unit->uncacheable && !unit->describe)
+ return FALSE;
+ /*check that table creation passed without problems. */
+ DBUG_ASSERT(derived->table && derived->table->created);
+ SELECT_LEX *first_select= unit->first_select();
+ select_union *derived_result= derived->derived_result;
+ SELECT_LEX *save_current_select= lex->current_select;
+ if (unit->is_union())
+ {
+ // execute union without clean up
+ res= unit->exec();
+ }
+ else
+ {
+ unit->set_limit(first_select);
+ if (unit->select_limit_cnt == HA_POS_ERROR)
+ first_select->options&= ~OPTION_FOUND_ROWS;
+
+ lex->current_select= first_select;
+ res= mysql_select(thd, &first_select->ref_pointer_array,
+ (TABLE_LIST*) first_select->table_list.first,
+ first_select->with_wild,
+ first_select->item_list, first_select->where,
+ (first_select->order_list.elements+
+ first_select->group_list.elements),
+ (ORDER *) first_select->order_list.first,
+ (ORDER *) first_select->group_list.first,
+ first_select->having, (ORDER*) NULL,
+ (first_select->options | thd->options |
+ SELECT_NO_UNLOCK),
+ derived_result, unit, first_select);
+ }
+
+ if (!res)
+ {
+ if (derived_result->flush())
+ res= TRUE;
+ unit->executed= TRUE;
}
+ if (res || !lex->describe)
+ unit->cleanup();
+ lex->current_select= save_current_select;
+
return res;
}
+
+
+/**
+ @brief
+ Re-initialize given derived table/view for the next execution.
+
+ @param thd thread handle
+ @param lex LEX for this thread
+ @param derived reference to the derived table.
+
+ @details
+ Re-initialize given 'derived' table/view for the next execution.
+ All underlying views/derived tables are recursively reinitialized prior
+ to re-initialization of given derived table.
+ 'thd' and 'lex' are passed as arguments to called functions.
+
+ @return FALSE OK
+ @return TRUE Error
+*/
+
+bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived)
+{
+ st_select_lex_unit *unit= derived->get_unit();
+
+ if (derived->table)
+ derived->merged_for_insert= FALSE;
+ unit->unclean();
+ unit->types.empty();
+ /* for derived tables & PS (which can't be reset by Item_subquery) */
+ unit->reinit_exec_mechanism();
+ unit->set_thd(thd);
+ return FALSE;
+}
diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc
index db1f47c5603..c3450884610 100644
--- a/sql/sql_expression_cache.cc
+++ b/sql/sql_expression_cache.cc
@@ -109,7 +109,8 @@ void Expression_cache_tmptable::init()
~(OPTION_BIG_TABLES |
TMP_TABLE_FORCE_MYISAM)),
HA_POS_ERROR,
- (char *)"subquery-cache-table")))
+ (char *)"subquery-cache-table",
+ TRUE)))
{
DBUG_PRINT("error", ("create_tmp_table failed, caching switched off"));
DBUG_VOID_RETURN;
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 6ede7bb9574..af946737b87 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -637,7 +637,7 @@ bool mysqld_help(THD *thd, const char *mask)
Protocol *protocol= thd->protocol;
SQL_SELECT *select;
st_find_field used_fields[array_elements(init_used_fields)];
- TABLE_LIST *leaves= 0;
+ List<TABLE_LIST> leaves;
TABLE_LIST tables[4];
List<String> topics_list, categories_list, subcategories_list;
String name, description, example;
@@ -676,7 +676,7 @@ bool mysqld_help(THD *thd, const char *mask)
thd->lex->select_lex.context.first_name_resolution_table= &tables[0];
if (setup_tables(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
- tables, &leaves, FALSE))
+ tables, leaves, FALSE, FALSE))
goto error;
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 05804c2ee7e..72514d72dc1 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -115,7 +115,7 @@ bool check_view_single_update(List<Item> &fields, List<Item> *values,
{
it.init(*values);
while ((item= it++))
- tables|= item->used_tables();
+ tables|= item->view_used_tables(view);
}
/* Convert to real table bits */
@@ -131,6 +131,11 @@ bool check_view_single_update(List<Item> &fields, List<Item> *values,
if (view->check_single_table(&tbl, tables, view) || tbl == 0)
goto error;
+ /*
+ A buffer for the insert values was allocated for the merged view.
+ Use it.
+ */
+ //tbl->table->insert_values= view->table->insert_values;
view->table= tbl->table;
*map= tables;
@@ -234,6 +239,10 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
*/
table_list->next_local= 0;
context->resolve_in_table_list_only(table_list);
+ /* 'Unfix' fields to allow correct marking by the setup_fields function. */
+ if (table_list->is_view())
+ unfix_fields(fields);
+
res= setup_fields(thd, 0, fields, MARK_COLUMNS_WRITE, 0, 0);
/* Restore the current context. */
@@ -243,7 +252,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (res)
return -1;
- if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE)
+ if (table_list->is_view() && table_list->is_merged_derived())
{
if (check_view_single_update(fields,
fields_and_values_from_different_maps ?
@@ -332,7 +341,8 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
if (setup_fields(thd, 0, update_fields, MARK_COLUMNS_WRITE, 0, 0))
return -1;
- if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE &&
+ if (insert_table_list->is_view() &&
+ insert_table_list->is_merged_derived() &&
check_view_single_update(update_fields, &update_values,
insert_table_list, map))
return -1;
@@ -631,6 +641,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
table_list->table_name);
DBUG_RETURN(TRUE);
}
+ /*
+ mark the table_list as a target for insert, to skip the DT/view prepare phase
+ for correct access rights checks
+ TODO: remove this hack
+ */
+ table_list->skip_prepare_derived= TRUE;
if (table_list->lock_type == TL_WRITE_DELAYED)
{
@@ -642,6 +658,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
}
+
lock_type= table_list->lock_type;
thd_proc_info(thd, "init");
@@ -904,7 +921,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
*/
query_cache_invalidate3(thd, table_list, 1);
}
- if ((changed && error <= 0) ||
+ if (error <= 0 ||
thd->transaction.stmt.modified_non_trans_table ||
was_insert_delayed)
{
@@ -1005,6 +1022,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
::my_ok(thd, (ulong) thd->row_count_func, id, buff);
}
thd->abort_on_warning= 0;
+ if (thd->lex->current_select->first_cond_optimization)
+ {
+ thd->lex->current_select->save_leaf_tables(thd);
+ thd->lex->current_select->first_cond_optimization= 0;
+ }
+
DBUG_RETURN(FALSE);
abort:
@@ -1133,6 +1156,11 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
bool insert_into_view= (table_list->view != 0);
DBUG_ENTER("mysql_prepare_insert_check_table");
+ if (!table_list->updatable)
+ {
+ my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
+ DBUG_RETURN(TRUE);
+ }
/*
first table in list is the one we'll INSERT into, requires INSERT_ACL.
all others require SELECT_ACL only. the ACL requirement below is for
@@ -1143,14 +1171,16 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list,
- &thd->lex->select_lex.leaf_tables,
- select_insert, INSERT_ACL, SELECT_ACL))
+ thd->lex->select_lex.leaf_tables,
+ select_insert, INSERT_ACL, SELECT_ACL,
+ TRUE))
DBUG_RETURN(TRUE);
if (insert_into_view && !fields.elements)
{
thd->lex->empty_field_list_on_rset= 1;
- if (!table_list->table)
+ if (!thd->lex->select_lex.leaf_tables.head()->table ||
+ table_list->is_multitable())
{
my_error(ER_VIEW_NO_INSERT_FIELD_LIST, MYF(0),
table_list->view_db.str, table_list->view_name.str);
@@ -1241,6 +1271,12 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
/* INSERT should have a SELECT or VALUES clause */
DBUG_ASSERT (!select_insert || !values);
+ if (mysql_handle_derived(thd->lex, DT_INIT))
+ DBUG_RETURN(TRUE);
+ if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
+ DBUG_RETURN(TRUE);
+ if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
+ DBUG_RETURN(TRUE);
/*
For subqueries in VALUES() we should not see the table in which we are
inserting (for INSERT ... SELECT this is done by changing table_list,
@@ -1730,10 +1766,11 @@ class delayed_row :public ilink {
public:
char *record;
enum_duplicates dup;
- time_t start_time;
+ my_time_t start_time;
+ ulong start_time_sec_part;
ulong sql_mode;
bool auto_increment_field_not_null;
- bool query_start_used, ignore, log_query;
+ bool query_start_used, ignore, log_query, query_start_sec_part_used;
bool stmt_depends_on_first_successful_insert_id_in_prev_stmt;
ulonglong first_successful_insert_id_in_prev_stmt;
ulonglong forced_insert_id;
@@ -2234,8 +2271,10 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
if (!(row->record= (char*) my_malloc(table->s->reclength, MYF(MY_WME))))
goto err;
memcpy(row->record, table->record[0], table->s->reclength);
- row->start_time= thd->start_time;
- row->query_start_used= thd->query_start_used;
+ row->start_time= thd->start_time;
+ row->query_start_used= thd->query_start_used;
+ row->start_time_sec_part= thd->start_time_sec_part;
+ row->query_start_sec_part_used= thd->query_start_sec_part_used;
/*
those are for the binlog: LAST_INSERT_ID() has been evaluated at this
time, so record does not need it, but statement-based binlogging of the
@@ -2693,6 +2732,8 @@ bool Delayed_insert::handle_inserts(void)
thd.start_time=row->start_time;
thd.query_start_used=row->query_start_used;
+ thd.start_time_sec_part=row->start_time_sec_part;
+ thd.query_start_sec_part_used=row->query_start_sec_part_used;
/*
To get the exact auto_inc interval to store in the binlog we must not
use values from the previous interval (of the previous rows).
@@ -2929,9 +2970,9 @@ bool mysql_insert_select_prepare(THD *thd)
{
LEX *lex= thd->lex;
SELECT_LEX *select_lex= &lex->select_lex;
- TABLE_LIST *first_select_leaf_table;
DBUG_ENTER("mysql_insert_select_prepare");
+
/*
Statement-based replication of INSERT ... SELECT ... LIMIT is not safe
as order of rows is not defined, so in mixed mode we go to row-based.
@@ -2957,21 +2998,37 @@ bool mysql_insert_select_prepare(THD *thd)
&select_lex->where, TRUE, FALSE, FALSE))
DBUG_RETURN(TRUE);
+ DBUG_ASSERT(select_lex->leaf_tables.elements != 0);
+ List_iterator<TABLE_LIST> ti(select_lex->leaf_tables);
+ TABLE_LIST *table;
+ uint insert_tables;
+
+ if (select_lex->first_cond_optimization)
+ {
+ /* Back up leaf_tables list. */
+ Query_arena *arena= thd->stmt_arena, backup;
+ arena= thd->activate_stmt_arena_if_needed(&backup); // For easier test
+
+ insert_tables= select_lex->insert_tables;
+ while ((table= ti++) && insert_tables--)
+ {
+ select_lex->leaf_tables_exec.push_back(table);
+ table->tablenr_exec= table->table->tablenr;
+ table->map_exec= table->table->map;
+ }
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+ }
+ ti.rewind();
/*
exclude first table from leaf tables list, because it belong to
INSERT
*/
- DBUG_ASSERT(select_lex->leaf_tables != 0);
- lex->leaf_tables_insert= select_lex->leaf_tables;
/* skip all leaf tables belonged to view where we are insert */
- for (first_select_leaf_table= select_lex->leaf_tables->next_leaf;
- first_select_leaf_table &&
- first_select_leaf_table->belong_to_view &&
- first_select_leaf_table->belong_to_view ==
- lex->leaf_tables_insert->belong_to_view;
- first_select_leaf_table= first_select_leaf_table->next_leaf)
- {}
- select_lex->leaf_tables= first_select_leaf_table;
+ insert_tables= select_lex->insert_tables;
+ while ((table= ti++) && insert_tables--)
+ ti.remove();
+
DBUG_RETURN(FALSE);
}
@@ -3188,7 +3245,7 @@ void select_insert::cleanup()
select_insert::~select_insert()
{
DBUG_ENTER("~select_insert");
- if (table)
+ if (table && table->created)
{
table->next_number_field=0;
table->auto_increment_field_not_null= FALSE;
@@ -3200,7 +3257,7 @@ select_insert::~select_insert()
}
-bool select_insert::send_data(List<Item> &values)
+int select_insert::send_data(List<Item> &values)
{
DBUG_ENTER("select_insert::send_data");
bool error=0;
@@ -3590,9 +3647,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
tmp_table.s->db_create_options=0;
tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
- tmp_table.s->db_low_byte_first=
- test(create_info->db_type == myisam_hton ||
- create_info->db_type == heap_hton);
tmp_table.null_row= 0;
tmp_table.maybe_null= 0;
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 44b953a27fb..64b82efd8ff 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -33,6 +33,7 @@
#define NO_MORE_RECORDS_IN_BUFFER (uint)(-1)
+static void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save);
/*****************************************************************************
* Join cache module
@@ -139,52 +140,6 @@ uint add_table_data_fields_to_join_cache(JOIN_TAB *tab,
}
/*
- Get the next table whose records are stored in the join buffer of this cache
-
- SYNOPSIS
- get_next_table()
- tab the table for which the next table is to be returned
-
- DESCRIPTION
- For a given table whose records are stored in this cache the function
- returns the next such table if there is any.
- The function takes into account that the tables whose records are
- are stored in the same cache now can interleave with tables from
- materialized semijoin subqueries.
-
- TODO
- This function should be modified/simplified after the new code for
- materialized semijoins is merged.
-
- RETURN
- The next join table whose records are stored in the buffer of this cache
- if such table exists, 0 - otherwise
-*/
-
-JOIN_TAB *JOIN_CACHE::get_next_table(JOIN_TAB *tab)
-{
-
- if (++tab == join_tab)
- return NULL;
- if (join_tab->first_sjm_sibling)
- return tab;
- uint i= tab-join->join_tab;
- /*
- Temporary measure before MWL#90 refactorings are there: if 'tab' is at upper
- level (i.e. it's not inside an SJM nest), still include into the join buffer
- the tables from within SJM nest. We might need the subquery's select list
- columns, because SJ-Materialization-Scan upacks data to those.
-
- while (sj_is_materialize_strategy(join->best_positions[i].sj_strategy) &&
- i < join->tables)
- i+= join->best_positions[i].n_sj_tables;
-
- */
- return join->join_tab+i < join_tab ? join->join_tab+i : NULL;
-}
-
-
-/*
Determine different counters of fields associated with a record in the cache
SYNOPSIS
@@ -203,12 +158,55 @@ JOIN_TAB *JOIN_CACHE::get_next_table(JOIN_TAB *tab)
void JOIN_CACHE::calc_record_fields()
{
- JOIN_TAB *tab = prev_cache ? prev_cache->join_tab :
- (join_tab->first_sjm_sibling ?
- join_tab->first_sjm_sibling :
- join->join_tab+join->const_tables);
- tables= join_tab-tab;
+ JOIN_TAB *tab;
+
+ if (prev_cache)
+ tab= prev_cache->join_tab;
+ else
+ {
+ if (join_tab->bush_root_tab)
+ {
+ /*
+ --ot1--SJM1--------------ot2--...
+ |
+ |
+ +-it1--...--itN
+ ^____________ this->join_tab is somewhere here,
+ inside an sjm nest.
+
+ The join buffer should store the values of it1.*, it2.*, ..
+ It should not store values of ot1.*.
+ */
+ tab= join_tab->bush_root_tab->bush_children->start;
+ }
+ else
+ {
+ /*
+ -ot1--ot2--SJM1--SJM2--------------ot3--...--otN
+ | | ^
+ | +-it21--...--it2N |
+ | \-- we're somewhere here,
+ +-it11--...--it1N at the top level
+
+ The join buffer should store the values of
+
+ ot1.*, ot2.*, it1{i}, it2{j}.*, ot3.*, ...
+
+ that is, we should start from the first non-const top-level table.
+
+ We will need to store columns of SJ-inner tables (it_X_Y.*), but we're
+ not interested in storing the columns of materialization tables
+ themselves. Beause of that, if the first non-const top-level table is a
+ materialized table, we move to its bush_children:
+ */
+ tab= join->join_tab + join->const_tables;
+ if (tab->bush_children)
+ tab= tab->bush_children->start;
+ }
+ }
+ DBUG_ASSERT(!tab->bush_children);
+ start_tab= tab;
fields= 0;
blobs= 0;
flag_fields= 0;
@@ -216,7 +214,11 @@ void JOIN_CACHE::calc_record_fields()
data_field_ptr_count= 0;
referenced_fields= 0;
- for ( ; tab ; tab= get_next_table(tab))
+ /*
+ The following loop will get inside SJM nests, because data may be unpacked
+ to sjm-inner tables.
+ */
+ for (; tab != join_tab ; tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
tab->calc_used_field_length(FALSE);
flag_fields+= test(tab->used_null_fields || tab->used_uneven_bit_fields);
@@ -245,7 +247,8 @@ void JOIN_CACHE::calc_record_fields()
that occur in the ref expressions and marks these fields in the bitmap
tab->table->tmp_set. The function counts the number of them stored
in this cache and the total number of them stored in the previous caches
- and saves the results of the counting in 'local_key_arg_fields' and 'external_key_arg_fields' respectively.
+ and saves the results of the counting in 'local_key_arg_fields' and
+ 'external_key_arg_fields' respectively.
NOTES
The function does not do anything if no key is used to join the records
@@ -269,8 +272,8 @@ void JOIN_CACHE::collect_info_on_key_args()
cache= this;
do
{
- for (tab= cache->join_tab-cache->tables; tab ;
- tab= cache->get_next_table(tab))
+ for (tab= cache->start_tab; tab != cache->join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
uint key_args;
bitmap_clear_all(&tab->table->tmp_set);
@@ -386,7 +389,8 @@ void JOIN_CACHE::create_flag_fields()
&copy);
/* Create fields for all null bitmaps and null row flags that are needed */
- for (tab= join_tab-tables; tab; tab= get_next_table(tab))
+ for (tab= start_tab; tab != join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
TABLE *table= tab->table;
@@ -473,8 +477,8 @@ void JOIN_CACHE::create_key_arg_fields()
while (ext_key_arg_cnt)
{
cache= cache->prev_cache;
- for (tab= cache->join_tab-cache->tables; tab;
- tab= cache->get_next_table(tab))
+ for (tab= cache->start_tab; tab != cache->join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
CACHE_FIELD *copy_end;
MY_BITMAP *key_read_set= &tab->table->tmp_set;
@@ -524,7 +528,8 @@ void JOIN_CACHE::create_key_arg_fields()
/* Now create local fields that are used to build ref for this key access */
copy= field_descr+flag_fields;
- for (tab= join_tab-tables; tab; tab= get_next_table(tab))
+ for (tab= start_tab; tab != join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
length+= add_table_data_fields_to_join_cache(tab, &tab->table->tmp_set,
&data_field_count, &copy,
@@ -573,14 +578,15 @@ void JOIN_CACHE::create_key_arg_fields()
none
*/
-void JOIN_CACHE:: create_remaining_fields()
+void JOIN_CACHE::create_remaining_fields()
{
JOIN_TAB *tab;
bool all_read_fields= !is_key_access();
CACHE_FIELD *copy= field_descr+flag_fields+data_field_count;
CACHE_FIELD **copy_ptr= blob_ptr+data_field_ptr_count;
- for (tab= join_tab-tables; tab; tab= get_next_table(tab))
+ for (tab= start_tab; tab != join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
MY_BITMAP *rem_field_set;
TABLE *table= tab->table;
@@ -737,8 +743,11 @@ ulong JOIN_CACHE::get_min_join_buffer_size()
if (!min_buff_size)
{
size_t len= 0;
- for (JOIN_TAB *tab= join_tab-tables; tab < join_tab; tab++)
+ for (JOIN_TAB *tab= start_tab; tab != join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
+ {
len+= tab->get_max_used_fieldlength();
+ }
len+= get_record_max_affix_length() + get_max_key_addon_space_per_record();
size_t min_sz= len*min_records;
size_t add_sz= 0;
@@ -790,8 +799,11 @@ ulong JOIN_CACHE::get_max_join_buffer_size(bool optimize_buff_size)
size_t max_sz;
size_t min_sz= get_min_join_buffer_size();
size_t len= 0;
- for (JOIN_TAB *tab= join_tab-tables; tab < join_tab; tab++)
+ for (JOIN_TAB *tab= start_tab; tab != join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
+ {
len+= tab->get_used_fieldlength();
+ }
len+= get_record_max_affix_length();
avg_record_length= len;
len+= get_max_key_addon_space_per_record() + avg_aux_buffer_incr;
@@ -865,7 +877,9 @@ int JOIN_CACHE::alloc_buffer()
set_if_bigger(max_records, 10);
min_buff_size= get_min_join_buffer_size();
buff_size= get_max_join_buffer_size(optimize_buff_size);
- for (tab= join->join_tab+join->const_tables; tab <= join_tab; tab++)
+
+ for (tab= start_tab; tab!= join_tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
cache= tab->cache;
if (cache)
@@ -2154,10 +2168,19 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last)
join_tab->select->quick= 0;
}
- /* Prepare to retrieve all records of the joined table */
- if ((error= join_tab_scan->open()))
- goto finish; /* psergey-note: if this returns error, we will assert in net_send_statement() */
+ if ((rc= join_tab_execution_startup(join_tab)) < 0)
+ goto finish2;
+ /* Prepare to retrieve all records of the joined table */
+ if ((error= join_tab_scan->open()))
+ {
+ /*
+ TODO: if we get here, we will assert in net_send_statement(). Add test
+ coverage and fix.
+ */
+ goto finish;
+ }
+
while (!(error= join_tab_scan->next()))
{
if (join->thd->killed)
@@ -2199,6 +2222,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last)
finish:
if (error)
rc= error < 0 ? NESTED_LOOP_NO_MORE_ROWS: NESTED_LOOP_ERROR;
+finish2:
join_tab_scan->close();
return rc;
}
@@ -3219,12 +3243,7 @@ uint JOIN_CACHE_HASHED::get_next_key(uchar ** key)
int JOIN_TAB_SCAN::open()
{
- JOIN_TAB *bound= join_tab-cache->tables;
- for (JOIN_TAB *tab= join_tab-1; tab != bound && !tab->cache; tab--)
- {
- tab->status= tab->table->status;
- tab->table->status= 0;
- }
+ save_or_restore_used_tabs(join_tab, FALSE);
is_first_record= TRUE;
return join_init_read_record(join_tab);
}
@@ -3279,6 +3298,49 @@ int JOIN_TAB_SCAN::next()
}
+/*
+ Walk back in join order from join_tab until we encounter a join tab with
+ tab->cache!=NULL, and save/restore tab->table->status along the way.
+
+ @param save TRUE save
+ FALSE restore
+*/
+
+static void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save)
+{
+ JOIN_TAB *first= join_tab->bush_root_tab?
+ join_tab->bush_root_tab->bush_children->start :
+ join_tab->join->join_tab + join_tab->join->const_tables;
+
+ for (JOIN_TAB *tab= join_tab-1; tab != first && !tab->cache; tab--)
+ {
+ if (tab->bush_children)
+ {
+ for (JOIN_TAB *child= tab->bush_children->start;
+ child != tab->bush_children->end;
+ child++)
+ {
+ if (save)
+ child->table->status= child->status;
+ else
+ {
+ tab->status= tab->table->status;
+ tab->table->status= 0;
+ }
+ }
+ }
+
+ if (save)
+ tab->table->status= tab->status;
+ else
+ {
+ tab->status= tab->table->status;
+ tab->table->status= 0;
+ }
+ }
+}
+
+
/*
Perform finalizing actions for a scan over the table records
@@ -3295,9 +3357,7 @@ int JOIN_TAB_SCAN::next()
void JOIN_TAB_SCAN::close()
{
- JOIN_TAB *bound= join_tab-cache->tables;
- for (JOIN_TAB *tab= join_tab-1; tab != bound && !tab->cache; tab--)
- tab->table->status= tab->status;
+ save_or_restore_used_tabs(join_tab, TRUE);
}
@@ -3697,12 +3757,7 @@ int JOIN_TAB_SCAN_MRR::open()
/* Dynamic range access is never used with BKA */
DBUG_ASSERT(join_tab->use_quick != 2);
- JOIN_TAB *bound= join_tab-cache->tables;
- for (JOIN_TAB *tab= join_tab-1; tab != bound && !tab->cache; tab--)
- {
- tab->status= tab->table->status;
- tab->table->status= 0;
- }
+ save_or_restore_used_tabs(join_tab, FALSE);
init_mrr_buff();
diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h
index 920b7a507c1..f87cdcec649 100644
--- a/sql/sql_join_cache.h
+++ b/sql/sql_join_cache.h
@@ -121,11 +121,14 @@ protected:
*/
JOIN *join;
- /*
- Cardinality of the range of join tables whose fields can be put into the
- cache. A table from the range not necessarily contributes to the cache.
+ /*
+ JOIN_TAB of the first table that can have it's fields in the join cache.
+ That is, tables in the [start_tab, tab) range can have their fields in the
+ join cache.
+ If a join tab in the range represents an SJM-nest, then all tables from the
+ nest can have their fields in the join cache, too.
*/
- uint tables;
+ JOIN_TAB *start_tab;
/*
The total number of flag and data fields that can appear in a record
@@ -647,8 +650,6 @@ public:
buff= 0;
}
- JOIN_TAB *get_next_table(JOIN_TAB *tab);
-
friend class JOIN_CACHE_HASHED;
friend class JOIN_CACHE_BNL;
friend class JOIN_CACHE_BKA;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 3b655bac5af..d3613d0d660 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -23,6 +23,7 @@
#include <hash.h>
#include "sp.h"
#include "sp_head.h"
+#include "sql_select.h"
/*
We are using pointer to this variable for distinguishing between assignment
@@ -309,7 +310,6 @@ void lex_start(THD *thd)
lex->derived_tables= 0;
lex->lock_option= TL_READ;
lex->safe_to_cache_query= 1;
- lex->leaf_tables_insert= 0;
lex->parsing_options.reset();
lex->empty_field_list_on_rset= 0;
lex->select_lex.select_number= 1;
@@ -818,45 +818,48 @@ int MYSQLlex(void *arg, void *yythd)
yylval->lex_str.length=2;
return NULL_SYM;
}
+ /* Fall through */
case MY_LEX_CHAR: // Unknown or single char token
case MY_LEX_SKIP: // This should not happen
- if (c == '-' && lip->yyPeek() == '-' &&
+ if (c != ')')
+ lip->next_state= MY_LEX_START; // Allow signed numbers
+ return((int) c);
+
+ case MY_LEX_MINUS_OR_COMMENT:
+ if (lip->yyPeek() == '-' &&
(my_isspace(cs,lip->yyPeekn(1)) ||
my_iscntrl(cs,lip->yyPeekn(1))))
{
state=MY_LEX_COMMENT;
break;
}
+ lip->next_state= MY_LEX_START; // Allow signed numbers
+ return((int) c);
- if (c != ')')
- lip->next_state= MY_LEX_START; // Allow signed numbers
-
- if (c == ',')
- {
- /*
- Warning:
- This is a work around, to make the "remember_name" rule in
- sql/sql_yacc.yy work properly.
- The problem is that, when parsing "select expr1, expr2",
- the code generated by bison executes the *pre* action
- remember_name (see select_item) *before* actually parsing the
- first token of expr2.
- */
- lip->restart_token();
- }
- else
- {
- /*
- Check for a placeholder: it should not precede a possible identifier
- because of binlogging: when a placeholder is replaced with
- its value in a query for the binlog, the query must stay
- grammatically correct.
- */
- if (c == '?' && lip->stmt_prepare_mode &&
- !ident_map[(uchar) lip->yyPeek()])
+ case MY_LEX_PLACEHOLDER:
+ /*
+ Check for a placeholder: it should not precede a possible identifier
+ because of binlogging: when a placeholder is replaced with
+ its value in a query for the binlog, the query must stay
+ grammatically correct.
+ */
+ lip->next_state= MY_LEX_START; // Allow signed numbers
+ if (lip->stmt_prepare_mode && !ident_map[(uchar) lip->yyPeek()])
return(PARAM_MARKER);
- }
+ return((int) c);
+ case MY_LEX_COMMA:
+ lip->next_state= MY_LEX_START; // Allow signed numbers
+ /*
+ Warning:
+ This is a work around, to make the "remember_name" rule in
+ sql/sql_yacc.yy work properly.
+ The problem is that, when parsing "select expr1, expr2",
+ the code generated by bison executes the *pre* action
+ remember_name (see select_item) *before* actually parsing the
+ first token of expr2.
+ */
+ lip->restart_token();
return((int) c);
case MY_LEX_IDENT_OR_NCHAR:
@@ -1591,6 +1594,7 @@ void st_select_lex_unit::init_query()
describe= 0;
found_rows_for_union= 0;
insert_table_with_stored_vcol= 0;
+ derived= 0;
}
void st_select_lex::init_query()
@@ -1599,7 +1603,8 @@ void st_select_lex::init_query()
table_list.empty();
top_join_list.empty();
join_list= &top_join_list;
- embedding= leaf_tables= 0;
+ embedding= 0;
+ leaf_tables.empty();
item_list.empty();
join= 0;
having= prep_having= where= prep_where= 0;
@@ -1667,6 +1672,8 @@ void st_select_lex::init_select()
cond_value= having_value= Item::COND_UNDEF;
inner_refs_list.empty();
full_group_by_flag= 0;
+ insert_tables= 0;
+ merged_into= 0;
}
/*
@@ -1684,6 +1691,31 @@ void st_select_lex_node::include_down(st_select_lex_node *upper)
slave= 0;
}
+
+void st_select_lex_node::add_slave(st_select_lex_node *slave_arg)
+{
+ for (; slave; slave= slave->next)
+ if (slave == slave_arg)
+ return;
+
+ if (slave)
+ {
+ st_select_lex_node *slave_arg_slave= slave_arg->slave;
+ /* Insert in the front of list of slaves if any. */
+ slave_arg->include_neighbour(slave);
+ /* include_neighbour() sets slave_arg->slave=0, restore it. */
+ slave_arg->slave= slave_arg_slave;
+ /* Count on include_neighbour() setting the master. */
+ DBUG_ASSERT(slave_arg->master == this);
+ }
+ else
+ {
+ slave= slave_arg;
+ slave_arg->master= this;
+ }
+}
+
+
/*
include on level down (but do not link)
@@ -1735,17 +1767,29 @@ void st_select_lex_node::fast_exclude()
}
+
/*
- excluding select_lex structure (except first (first select can't be
+ Exclude a node from the tree lex structure, but leave it in the global
+ list of nodes.
+*/
+
+void st_select_lex_node::exclude_from_tree()
+{
+ if ((*prev= next))
+ next->prev= prev;
+}
+
+
+/*
+ Exclude select_lex structure (except first (first select can't be
deleted, because it is most upper select))
*/
void st_select_lex_node::exclude()
{
- //exclude from global list
+ /* exclude from global list */
fast_exclude();
- //exclude from other structures
- if ((*prev= next))
- next->prev= prev;
+ /* exclude from other structures */
+ exclude_from_tree();
/*
We do not need following statements, because prev pointer of first
list element point to master->slave
@@ -1905,18 +1949,19 @@ bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last, Item *depen
SELECT_LEX *s= this;
do
{
- if (!(s->uncacheable & UNCACHEABLE_DEPENDENT))
+ if (!(s->uncacheable & UNCACHEABLE_DEPENDENT_GENERATED))
{
// Select is dependent of outer select
s->uncacheable= (s->uncacheable & ~UNCACHEABLE_UNITED) |
- UNCACHEABLE_DEPENDENT;
+ UNCACHEABLE_DEPENDENT_GENERATED;
SELECT_LEX_UNIT *munit= s->master_unit();
munit->uncacheable= (munit->uncacheable & ~UNCACHEABLE_UNITED) |
- UNCACHEABLE_DEPENDENT;
+ UNCACHEABLE_DEPENDENT_GENERATED;
for (SELECT_LEX *sl= munit->first_select(); sl ; sl= sl->next_select())
{
if (sl != s &&
- !(sl->uncacheable & (UNCACHEABLE_DEPENDENT | UNCACHEABLE_UNITED)))
+ !(sl->uncacheable & (UNCACHEABLE_DEPENDENT_GENERATED |
+ UNCACHEABLE_UNITED)))
sl->uncacheable|= UNCACHEABLE_UNITED;
}
}
@@ -2113,9 +2158,27 @@ void st_select_lex::print_order(String *str,
{
if (order->counter_used)
{
- char buffer[20];
- size_t length= my_snprintf(buffer, 20, "%d", order->counter);
- str->append(buffer, (uint) length);
+ if (query_type != QT_VIEW_INTERNAL)
+ {
+ char buffer[20];
+ size_t length= my_snprintf(buffer, 20, "%d", order->counter);
+ str->append(buffer, (uint) length);
+ }
+ else
+ {
+ /* replace numeric reference with expression */
+ if (order->item[0]->type() == Item::INT_ITEM &&
+ order->item[0]->basic_const_item())
+ {
+ char buffer[20];
+ size_t length= my_snprintf(buffer, 20, "%d", order->counter);
+ str->append(buffer, (uint) length);
+ /* make it expression instead of integer constant */
+ str->append(STRING_WITH_LEN("+0"));
+ }
+ else
+ (*order->item)->print(str, query_type);
+ }
}
else
(*order->item)->print(str, query_type);
@@ -2141,17 +2204,6 @@ void st_select_lex::print_limit(THD *thd,
subs_type == Item_subselect::IN_SUBS ||
subs_type == Item_subselect::ALL_SUBS)
{
- DBUG_ASSERT(!item->fixed ||
- /*
- If not using materialization both:
- select_limit == 1, and there should be no offset_limit.
- */
- (((subs_type == Item_subselect::IN_SUBS) &&
- ((Item_in_subselect*)item)->exec_method ==
- Item_in_subselect::MATERIALIZATION) ?
- TRUE :
- (select_limit->val_int() == 1LL) &&
- offset_limit == 0));
return;
}
}
@@ -2963,7 +3015,11 @@ static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
thd->check_and_register_item_tree(&tbl->prep_on_expr, &tbl->on_expr);
tbl->on_expr= tbl->on_expr->copy_andor_structure(thd);
}
- fix_prepare_info_in_table_list(thd, tbl->merge_underlying_list);
+ if (tbl->is_view_or_derived() && tbl->is_merged_derived())
+ {
+ SELECT_LEX *sel= tbl->get_single_select();
+ fix_prepare_info_in_table_list(thd, sel->get_table_list());
+ }
}
}
@@ -3078,6 +3134,481 @@ bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
str, length));
}
+
+bool st_select_lex::optimize_unflattened_subqueries()
+{
+ for (SELECT_LEX_UNIT *un= first_inner_unit(); un; un= un->next_unit())
+ {
+ Item_subselect *subquery_predicate= un->item;
+
+ if (subquery_predicate)
+ {
+ if (subquery_predicate->substype() == Item_subselect::IN_SUBS)
+ {
+ Item_in_subselect *in_subs=(Item_in_subselect*)subquery_predicate;
+ if (in_subs->is_jtbm_merged)
+ continue;
+ }
+
+ for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())
+ {
+ JOIN *inner_join= sl->join;
+ if (!inner_join)
+ continue;
+ SELECT_LEX *save_select= un->thd->lex->current_select;
+ ulonglong save_options;
+ int res;
+ /* We need only 1 row to determine existence */
+ un->set_limit(un->global_parameters);
+ un->thd->lex->current_select= sl;
+ save_options= inner_join->select_options;
+ if (options & SELECT_DESCRIBE)
+ {
+ /* Optimize the subquery in the context of EXPLAIN. */
+ sl->set_explain_type();
+ sl->options|= SELECT_DESCRIBE;
+ inner_join->select_options|= SELECT_DESCRIBE;
+ }
+ res= inner_join->optimize();
+ inner_join->select_options= save_options;
+ un->thd->lex->current_select= save_select;
+ if (res)
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+
+
+/**
+ @brief Process all derived tables/views of the SELECT.
+
+ @param lex LEX of this thread
+ @param phase phases to run derived tables/views through
+
+ @details
+ This function runs specified 'phases' on all tables from the
+ table_list of this select.
+
+ @return FALSE ok.
+ @return TRUE an error occur.
+*/
+
+bool st_select_lex::handle_derived(struct st_lex *lex, uint phases)
+{
+ for (TABLE_LIST *cursor= (TABLE_LIST*) table_list.first;
+ cursor;
+ cursor= cursor->next_local)
+ {
+ if (cursor->is_view_or_derived() && cursor->handle_derived(lex, phases))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ @brief
+ Returns first unoccupied table map and table number
+
+ @param map [out] return found map
+ @param tablenr [out] return found tablenr
+
+ @details
+ Returns first unoccupied table map and table number in this select.
+ Map and table are returned in *'map' and *'tablenr' accordingly.
+
+ @retrun TRUE no free table map/table number
+ @return FALSE found free table map/table number
+*/
+
+bool st_select_lex::get_free_table_map(table_map *map, uint *tablenr)
+{
+ *map= 0;
+ *tablenr= 0;
+ TABLE_LIST *tl;
+ if (!join)
+ {
+ (*map)= 1<<1;
+ (*tablenr)++;
+ return FALSE;
+ }
+ List_iterator<TABLE_LIST> ti(leaf_tables);
+ while ((tl= ti++))
+ {
+ if (tl->table->map > *map)
+ *map= tl->table->map;
+ if (tl->table->tablenr > *tablenr)
+ *tablenr= tl->table->tablenr;
+ }
+ (*map)<<= 1;
+ (*tablenr)++;
+ if (*tablenr >= MAX_TABLES)
+ return TRUE;
+ return FALSE;
+}
+
+
+/**
+ @brief
+ Append given table to the leaf_tables list.
+
+ @param link Offset to which list in table structure to use
+ @param table Table to append
+
+ @details
+ Append given 'table' to the leaf_tables list using the 'link' offset.
+ If the 'table' is linked with other tables through next_leaf/next_local
+ chains then whole list will be appended.
+*/
+
+void st_select_lex::append_table_to_list(TABLE_LIST *TABLE_LIST::*link,
+ TABLE_LIST *table)
+{
+ TABLE_LIST *tl;
+ for (tl= leaf_tables.head(); tl->*link; tl= tl->*link) ;
+ tl->*link= table;
+}
+
+/*
+ @brief
+ Remove given table from the leaf_tables list.
+
+ @param link Offset to which list in table structure to use
+ @param table Table to remove
+
+ @details
+ Remove 'table' from the leaf_tables list using the 'link' offset.
+*/
+
+void st_select_lex::remove_table_from_list(TABLE_LIST *table)
+{
+ TABLE_LIST *tl;
+ List_iterator<TABLE_LIST> ti(leaf_tables);
+ while ((tl= ti++))
+ {
+ if (tl == table)
+ {
+ ti.remove();
+ break;
+ }
+ }
+}
+
+
+/**
+ @brief
+ Assigns new table maps to tables in the leaf_tables list
+
+ @param derived Derived table to take initial table map from
+ @param map table map to begin with
+ @param tablenr table number to begin with
+ @param parent_lex new parent select_lex
+
+ @details
+ Assign new table maps/table numbers to all tables in the leaf_tables list.
+ 'map'/'tablenr' are used for the first table and shifted to left/
+ increased for each consequent table in the leaf_tables list.
+ If the 'derived' table is given then it's table map/number is used for the
+ first table in the list and 'map'/'tablenr' are used for the second and
+ all consequent tables.
+ The 'parent_lex' is set as the new parent select_lex for all tables in the
+ list.
+*/
+
+void st_select_lex::remap_tables(TABLE_LIST *derived, table_map map,
+ uint tablenr, SELECT_LEX *parent_lex)
+{
+ bool first_table= TRUE;
+ TABLE_LIST *tl;
+ table_map first_map;
+ uint first_tablenr;
+
+ if (derived && derived->table)
+ {
+ first_map= derived->table->map;
+ first_tablenr= derived->table->tablenr;
+ }
+ else
+ {
+ first_map= map;
+ map<<= 1;
+ first_tablenr= tablenr++;
+ }
+ /*
+ Assign table bit/table number.
+ To the first table of the subselect the table bit/tablenr of the
+ derived table is assigned. The rest of tables are getting bits
+ sequentially, starting from the provided table map/tablenr.
+ */
+ List_iterator<TABLE_LIST> ti(leaf_tables);
+ while ((tl= ti++))
+ {
+ if (first_table)
+ {
+ first_table= FALSE;
+ tl->table->set_table_map(first_map, first_tablenr);
+ }
+ else
+ {
+ tl->table->set_table_map(map, tablenr);
+ tablenr++;
+ map<<= 1;
+ }
+ SELECT_LEX *old_sl= tl->select_lex;
+ tl->select_lex= parent_lex;
+ for(TABLE_LIST *emb= tl->embedding;
+ emb && emb->select_lex == old_sl;
+ emb= emb->embedding)
+ emb->select_lex= parent_lex;
+ }
+}
+
+/**
+ @brief
+ Merge a subquery into this select.
+
+ @param derived derived table of the subquery to be merged
+ @param subq_select select_lex of the subquery
+ @param map table map for assigning to merged tables from subquery
+ @param table_no table number for assigning to merged tables from subquery
+
+ @details
+ This function merges a subquery into its parent select. In short the
+ merge operation appends the subquery FROM table list to the parent's
+ FROM table list. In more details:
+ .) the top_join_list of the subquery is wrapped into a join_nest
+ and attached to 'derived'
+ .) subquery's leaf_tables list is merged with the leaf_tables
+ list of this select_lex
+ .) the table maps and table numbers of the tables merged from
+ the subquery are adjusted to reflect their new binding to
+ this select
+
+ @return TRUE an error occur
+ @return FALSE ok
+*/
+
+bool SELECT_LEX::merge_subquery(TABLE_LIST *derived, SELECT_LEX *subq_select,
+ uint table_no, table_map map)
+{
+ derived->wrap_into_nested_join(subq_select->top_join_list);
+ /* Reconnect the next_leaf chain. */
+ leaf_tables.concat(&subq_select->leaf_tables);
+
+ ftfunc_list->concat(subq_select->ftfunc_list);
+ if (join)
+ {
+ Item_in_subselect **in_subq;
+ Item_in_subselect **in_subq_end;
+ for (in_subq= subq_select->join->sj_subselects.front(),
+ in_subq_end= subq_select->join->sj_subselects.back();
+ in_subq != in_subq_end;
+ in_subq++)
+ {
+ join->sj_subselects.append(join->thd->mem_root, *in_subq);
+ (*in_subq)->emb_on_expr_nest= derived;
+ }
+ }
+ /*
+ Remove merged table from chain.
+ When merge_subquery is called at a subquery-to-semijoin transformation
+ the derived isn't in the leaf_tables list, so in this case the call of
+ remove_table_from_list does not cause any actions.
+ */
+ remove_table_from_list(derived);
+
+ /* Walk through child's tables and adjust table map, tablenr,
+ * parent_lex */
+ subq_select->remap_tables(derived, map, table_no, this);
+ subq_select->merged_into= this;
+ return FALSE;
+}
+
+
+/**
+ @brief
+ Mark tables from the leaf_tables list as belong to a derived table.
+
+ @param derived tables will be marked as belonging to this derived
+
+ @details
+ Run through the leaf_list and mark all tables as belonging to the 'derived'.
+*/
+
+void SELECT_LEX::mark_as_belong_to_derived(TABLE_LIST *derived)
+{
+ /* Mark tables as belonging to this DT */
+ TABLE_LIST *tl;
+ List_iterator<TABLE_LIST> ti(leaf_tables);
+ while ((tl= ti++))
+ {
+ tl->skip_temporary= 1;
+ tl->belong_to_derived= derived;
+ }
+}
+
+
+/**
+ @brief
+ Update used_tables cache for this select
+
+ @details
+ This function updates used_tables cache of ON expressions of all tables
+ in the leaf_tables list and of the conds expression (if any).
+*/
+
+void SELECT_LEX::update_used_tables()
+{
+ TABLE_LIST *tl;
+ List_iterator<TABLE_LIST> ti(leaf_tables);
+ while ((tl= ti++))
+ {
+ if (tl->on_expr)
+ {
+ tl->on_expr->update_used_tables();
+ tl->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);
+ }
+ TABLE_LIST *embedding= tl->embedding;
+ while (embedding)
+ {
+ if (embedding->on_expr &&
+ embedding->nested_join->join_list.head() == tl)
+ {
+ embedding->on_expr->update_used_tables();
+ embedding->on_expr->walk(&Item::eval_not_null_tables, 0, NULL);
+ }
+ tl= embedding;
+ embedding= tl->embedding;
+ }
+ }
+ if (join->conds)
+ {
+ join->conds->update_used_tables();
+ join->conds->walk(&Item::eval_not_null_tables, 0, NULL);
+ }
+}
+
+
+/**
+ Set the EXPLAIN type for this subquery.
+*/
+
+void st_select_lex::set_explain_type()
+{
+ bool is_primary= FALSE;
+ if (next_select())
+ is_primary= TRUE;
+
+ if (!is_primary && first_inner_unit())
+ {
+ /*
+ If there is at least one materialized derived|view then it's a PRIMARY select.
+ Otherwise, all derived tables/views were merged and this select is a SIMPLE one.
+ */
+ for (SELECT_LEX_UNIT *un= first_inner_unit(); un; un= un->next_unit())
+ {
+ if ((!un->derived || un->derived->is_materialized_derived()))
+ {
+ is_primary= TRUE;
+ break;
+ }
+ }
+ }
+
+ SELECT_LEX *first= master_unit()->first_select();
+ /* drop UNCACHEABLE_EXPLAIN, because it is for internal usage only */
+ uint8 is_uncacheable= (uncacheable & ~UNCACHEABLE_EXPLAIN);
+
+ type= ((&master_unit()->thd->lex->select_lex == this) ?
+ (is_primary ? "PRIMARY" : "SIMPLE"):
+ ((this == first) ?
+ ((linkage == DERIVED_TABLE_TYPE) ?
+ "DERIVED" :
+ ((is_uncacheable & UNCACHEABLE_DEPENDENT) ?
+ "DEPENDENT SUBQUERY" :
+ (is_uncacheable ? "UNCACHEABLE SUBQUERY" :
+ "SUBQUERY"))) :
+ ((is_uncacheable & UNCACHEABLE_DEPENDENT) ?
+ "DEPENDENT UNION":
+ is_uncacheable ? "UNCACHEABLE UNION":
+ "UNION")));
+ options|= SELECT_DESCRIBE;
+}
+
+
+/**
+ @brief
+ Increase estimated number of records for a derived table/view
+
+ @param records number of records to increase estimate by
+
+ @details
+ This function increases estimated number of records by the 'records'
+ for the derived table to which this select belongs to.
+*/
+
+void SELECT_LEX::increase_derived_records(ha_rows records)
+{
+ SELECT_LEX_UNIT *unit= master_unit();
+ DBUG_ASSERT(unit->derived);
+
+ select_union *result= (select_union*)unit->result;
+ result->records+= records;
+}
+
+
+/**
+ @brief
+ Mark select's derived table as a const one.
+
+ @param empty Whether select has an empty result set
+
+ @details
+ Mark derived table/view of this select as a constant one (to
+ materialize it at the optimization phase) unless this select belongs to a
+ union. Estimated number of rows is incremented if this select has non empty
+ result set.
+*/
+
+void SELECT_LEX::mark_const_derived(bool empty)
+{
+ TABLE_LIST *derived= master_unit()->derived;
+ if (!join->thd->lex->describe && derived)
+ {
+ if (!empty)
+ increase_derived_records(1);
+ if (!master_unit()->is_union() && !derived->is_merged_derived())
+ derived->fill_me= TRUE;
+ }
+}
+
+bool st_select_lex::save_leaf_tables(THD *thd)
+{
+ Query_arena *arena= thd->stmt_arena, backup;
+ if (arena->is_conventional())
+ arena= 0;
+ else
+ thd->set_n_backup_active_arena(arena, &backup);
+
+ List_iterator_fast<TABLE_LIST> li(leaf_tables);
+ TABLE_LIST *table;
+ while ((table= li++))
+ {
+ if (leaf_tables_exec.push_back(table))
+ return 1;
+ table->tablenr_exec= table->table->tablenr;
+ table->map_exec= table->table->map;
+ }
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+
+ return 0;
+}
+
+
/**
A routine used by the parser to decide whether we are specifying a full
partitioning or if only partitions to add or to split.
@@ -3095,4 +3626,3 @@ bool st_lex::is_partition_management() const
(alter_info.flags == ALTER_ADD_PARTITION ||
alter_info.flags == ALTER_REORGANIZE_PARTITION));
}
-
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index b3dccb4b9bd..5a8b5a5f361 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -417,7 +417,8 @@ public:
/*
result of this query can't be cached, bit field, can be :
- UNCACHEABLE_DEPENDENT
+ UNCACHEABLE_DEPENDENT_GENERATED
+ UNCACHEABLE_DEPENDENT_INJECTED
UNCACHEABLE_RAND
UNCACHEABLE_SIDEEFFECT
UNCACHEABLE_EXPLAIN
@@ -442,10 +443,12 @@ public:
virtual void init_query();
virtual void init_select();
void include_down(st_select_lex_node *upper);
+ void add_slave(st_select_lex_node *slave_arg);
void include_neighbour(st_select_lex_node *before);
void include_standalone(st_select_lex_node *sel, st_select_lex_node **ref);
void include_global(st_select_lex_node **plink);
void exclude();
+ void exclude_from_tree();
virtual st_select_lex_unit* master_unit()= 0;
virtual st_select_lex* outer_select()= 0;
@@ -469,6 +472,11 @@ public:
friend bool mysql_new_select(struct st_lex *lex, bool move_down);
friend bool mysql_make_view(THD *thd, File_parser *parser,
TABLE_LIST *table, uint flags);
+ friend bool mysql_derived_prepare(THD *thd, st_lex *lex,
+ TABLE_LIST *orig_table_list);
+ friend bool mysql_derived_merge(THD *thd, st_lex *lex,
+ TABLE_LIST *orig_table_list);
+ friend bool TABLE_LIST::init_derived(THD *thd, bool init_view);
private:
void fast_exclude();
};
@@ -487,13 +495,12 @@ class st_select_lex_unit: public st_select_lex_node {
protected:
TABLE_LIST result_table_list;
select_union *union_result;
- TABLE *table; /* temporary table using for appending UNION results */
-
- select_result *result;
ulonglong found_rows_for_union;
bool saved_error;
public:
+ TABLE *table; /* temporary table using for appending UNION results */
+ select_result *result;
bool prepared, // prepare phase already performed for UNION (unit)
optimized, // optimize phase already performed for UNION (unit)
executed, // already executed
@@ -520,6 +527,11 @@ public:
ha_rows select_limit_cnt, offset_limit_cnt;
/* not NULL if unit used in subselect, point to subselect item */
Item_subselect *item;
+ /*
+ TABLE_LIST representing this union in the embedding select. Used for
+ derived tables/views handling.
+ */
+ TABLE_LIST *derived;
/* thread handler */
THD *thd;
/*
@@ -556,6 +568,7 @@ public:
/* UNION methods */
bool prepare(THD *thd, select_result *result, ulong additional_options);
+ bool optimize();
bool exec();
bool cleanup();
inline void unclean() { cleaned= 0; }
@@ -572,6 +585,8 @@ public:
void set_thd(THD *thd_arg) { thd= thd_arg; }
inline bool is_union ();
+ void set_unique_exclude();
+
friend void lex_start(THD *thd);
friend int subselect_union_engine::exec();
@@ -617,8 +632,17 @@ public:
Beginning of the list of leaves in a FROM clause, where the leaves
inlcude all base tables including view tables. The tables are connected
by TABLE_LIST::next_leaf, so leaf_tables points to the left-most leaf.
+
+ List of all base tables local to a subquery including all view
+ tables. Unlike 'next_local', this in this list views are *not*
+ leaves. Created in setup_tables() -> make_leaves_list().
*/
- TABLE_LIST *leaf_tables;
+ List<TABLE_LIST> leaf_tables;
+ List<TABLE_LIST> leaf_tables_exec;
+ uint insert_tables;
+ st_select_lex *merged_into; /* select which this select is merged into */
+ /* (not 0 only for views/derived tables) */
+
const char *type; /* type of select for EXPLAIN */
SQL_I_List<ORDER> order_list; /* ORDER clause */
@@ -846,6 +870,36 @@ public:
void clear_index_hints(void) { index_hints= NULL; }
bool is_part_of_union() { return master_unit()->is_union(); }
+ /*
+ Optimize all subqueries that have not been flattened into semi-joins.
+ This functionality is a method of SELECT_LEX instead of JOIN because
+ some SQL statements as DELETE do not have a corresponding JOIN object.
+ */
+ bool optimize_unflattened_subqueries();
+ /* Set the EXPLAIN type for this subquery. */
+ void set_explain_type();
+ bool handle_derived(struct st_lex *lex, uint phases);
+ void append_table_to_list(TABLE_LIST *TABLE_LIST::*link, TABLE_LIST *table);
+ bool get_free_table_map(table_map *map, uint *tablenr);
+ void remove_table_from_list(TABLE_LIST *table);
+ void remap_tables(TABLE_LIST *derived, table_map map,
+ uint tablenr, st_select_lex *parent_lex);
+ bool merge_subquery(TABLE_LIST *derived, st_select_lex *subq_lex,
+ uint tablenr, table_map map);
+ inline bool is_mergeable()
+ {
+ return (next_select() == 0 && group_list.elements == 0 &&
+ having == 0 && with_sum_func == 0 &&
+ table_list.elements >= 1 && !(options & SELECT_DISTINCT) &&
+ select_limit == 0);
+ }
+ void mark_as_belong_to_derived(TABLE_LIST *derived);
+ void increase_derived_records(ha_rows records);
+ void update_used_tables();
+ void mark_const_derived(bool empty);
+
+ bool save_leaf_tables(THD *thd);
+
private:
/* current index hint kind. used in filling up index_hints */
enum index_hint_type current_index_hint_type;
@@ -1617,8 +1671,6 @@ typedef struct st_lex : public Query_tables_list
CHARSET_INFO *charset;
bool text_string_is_7bit;
- /* store original leaf_tables for INSERT SELECT and PS/SP */
- TABLE_LIST *leaf_tables_insert;
/** SELECT of CREATE VIEW statement */
LEX_STRING create_view_select;
@@ -1735,7 +1787,7 @@ typedef struct st_lex : public Query_tables_list
DERIVED_SUBQUERY and DERIVED_VIEW).
*/
uint8 derived_tables;
- uint8 create_view_algorithm;
+ uint16 create_view_algorithm;
uint8 create_view_check;
bool drop_if_exists, drop_temporary, local_file, one_shot_set;
bool autocommit;
@@ -1873,6 +1925,7 @@ typedef struct st_lex : public Query_tables_list
{
return (context_analysis_only &
(CONTEXT_ANALYSIS_ONLY_PREPARE |
+ CONTEXT_ANALYSIS_ONLY_VCOL_EXPR |
CONTEXT_ANALYSIS_ONLY_VIEW));
}
@@ -1922,6 +1975,8 @@ typedef struct st_lex : public Query_tables_list
switch (sql_command) {
case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI:
+ case SQLCOM_DELETE:
+ case SQLCOM_DELETE_MULTI:
case SQLCOM_INSERT:
case SQLCOM_INSERT_SELECT:
case SQLCOM_REPLACE:
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 2dade14f211..38235a10c18 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -260,11 +260,13 @@ public:
list_node *node= first;
list_node *list_first= list->first;
elements=0;
- while (node && node != list_first)
+ while (node != &end_of_list && node != list_first)
{
prev= &node->next;
node= node->next;
elements++;
+ if (node == &end_of_list)
+ return;
}
*prev= *last;
last= prev;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index d6276d2f47c..089c148778e 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -172,12 +172,15 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
+ if (mysql_handle_single_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
+ mysql_handle_single_derived(thd->lex, table_list, DT_PREPARE))
+ DBUG_RETURN(TRUE);
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list,
- &thd->lex->select_lex.leaf_tables, FALSE,
+ thd->lex->select_lex.leaf_tables, FALSE,
INSERT_ACL | UPDATE_ACL,
- INSERT_ACL | UPDATE_ACL))
+ INSERT_ACL | UPDATE_ACL, FALSE))
DBUG_RETURN(-1);
if (!table_list->table || // do not suport join view
!table_list->updatable || // and derived tables
@@ -1079,9 +1082,10 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
String &field_term, String &line_start, String &line_term,
String &enclosed_par, int escape, bool get_it_from_net,
bool is_fifo)
- :file(file_par),buffer(0),escape_char(escape)
+ :file(file_par), buff_length(tot_length), escape_char(escape),
+ found_end_of_line(false), eof(false), need_end_io_cache(false),
+ error(false), line_cuted(false), found_null(false), read_charset(cs)
{
- read_charset= cs;
field_term_ptr=(char*) field_term.ptr();
field_term_length= field_term.length();
line_term_ptr=(char*) line_term.ptr();
@@ -1108,12 +1112,9 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
(uchar) enclosed_par[0] : INT_MAX;
field_term_char= field_term_length ? (uchar) field_term_ptr[0] : INT_MAX;
line_term_char= line_term_length ? (uchar) line_term_ptr[0] : INT_MAX;
- error=eof=found_end_of_line=found_null=line_cuted=0;
- buff_length=tot_length;
-
/* Set of a stack for unget if long terminators */
- uint length=max(field_term_length,line_term_length)+1;
+ uint length= max(cs->mbmaxlen, max(field_term_length, line_term_length)) + 1;
set_if_bigger(length,line_start.length());
stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
@@ -1155,11 +1156,8 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs,
READ_INFO::~READ_INFO()
{
- if (!error)
- {
- if (need_end_io_cache)
- ::end_io_cache(&cache);
- }
+ if (need_end_io_cache)
+ ::end_io_cache(&cache);
my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));
}
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
index 21deef8c664..b0537d984c6 100644
--- a/sql/sql_olap.cc
+++ b/sql/sql_olap.cc
@@ -153,8 +153,7 @@ int handle_olaps(LEX *lex, SELECT_LEX *select_lex)
if (setup_tables(lex->thd, &select_lex->context, &select_lex->top_join_list,
- select_lex->table_list.first
- &select_lex->leaf_tables, FALSE) ||
+ FALSE, FALSE) ||
setup_fields(lex->thd, 0, select_lex->item_list, MARK_COLUMNS_READ,
&all_fields,1) ||
setup_fields(lex->thd, 0, item_list_copy, MARK_COLUMNS_READ,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e2031c129b0..f219c8d6876 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1021,18 +1021,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->query_plan_flags= QPLAN_INIT;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
thd->set_time();
- if (!thd->is_valid_time())
- {
- /*
- If the time has got past 2038 we need to shut this server down
- We do this by making sure every command is a shutdown and we
- have enough privileges to shut the server down
-
- TODO: remove this when we have full 64 bit my_time_t support
- */
- thd->security_ctx->master_access|= SHUTDOWN_ACL;
- command= COM_SHUTDOWN;
- }
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id= global_query_id;
@@ -1055,7 +1043,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
thread_running++;
- /* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
/**
@@ -1133,7 +1120,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
uint save_db_length= thd->db_length;
char *save_db= thd->db;
USER_CONN *save_user_connect= thd->user_connect;
- Security_context save_security_ctx= *thd->security_ctx;
+ Security_context save_security_ctx= *thd->security_ctx;
CHARSET_INFO *save_character_set_client=
thd->variables.character_set_client;
CHARSET_INFO *save_collation_connection=
@@ -1141,8 +1128,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
CHARSET_INFO *save_character_set_results=
thd->variables.character_set_results;
+ /* Ensure we don't free security_ctx->user in case we have to revert */
+ thd->security_ctx->user= 0;
+
if (acl_authenticate(thd, 0, packet_length))
{
+ /* Free user if allocated by acl_authenticate */
x_free(thd->security_ctx->user);
*thd->security_ctx= save_security_ctx;
thd->user_connect= save_user_connect;
@@ -1248,15 +1239,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
thd->set_query(beginning_of_next_stmt, length);
- VOID(pthread_mutex_lock(&LOCK_thread_count));
/*
Count each statement from the client.
*/
statistic_increment(thd->status_var.questions, &LOCK_status);
+ thd->set_time(); /* Reset the query start time for next query. */
+ VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id= next_query_id();
- thd->set_time(); /* Reset the query start time. */
- /* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
+ /* TODO: set thd->lex->sql_command to SQLCOM_END here */
mysql_parse(thd, beginning_of_next_stmt, length, &end_of_stmt);
}
@@ -1432,10 +1423,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
packet[0].
*/
enum mysql_enum_shutdown_level level;
- if (!thd->is_valid_time())
- level= SHUTDOWN_DEFAULT;
- else
- level= (enum mysql_enum_shutdown_level) (uchar) packet[0];
+ level= (enum mysql_enum_shutdown_level) (uchar) packet[0];
if (level == SHUTDOWN_DEFAULT)
level= SHUTDOWN_WAIT_ALL_BUFFERS; // soon default will be configurable
else if (level != SHUTDOWN_WAIT_ALL_BUFFERS)
@@ -2293,11 +2281,7 @@ mysql_execute_command(THD *thd)
goto error;
}
it= new Item_func_unix_timestamp(it);
- /*
- it is OK only emulate fix_fieds, because we need only
- value of constant
- */
- it->quick_fix_field();
+ it->fix_fields(thd, &it);
res = purge_master_logs_before_date(thd, (ulong)it->val_int());
break;
}
@@ -3235,6 +3219,10 @@ end_with_restore_list:
if (!(res= open_and_lock_tables(thd, all_tables)))
{
+ /*
+ Only the INSERT table should be merged. Other will be handled by
+ select.
+ */
/* Skip first table, which is the table we are inserting in */
TABLE_LIST *second_table= first_table->next_local;
select_lex->table_list.first= second_table;
@@ -3548,7 +3536,7 @@ end_with_restore_list:
{
#ifdef HAVE_QUERY_CACHE
if (thd->variables.query_cache_wlock_invalidate)
- query_cache.invalidate_locked_for_write(first_table);
+ query_cache.invalidate_locked_for_write(thd, first_table);
#endif /*HAVE_QUERY_CACHE*/
thd->locked_tables=thd->lock;
thd->lock=0;
@@ -5789,6 +5777,7 @@ void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat)
thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
thd->query_start_used= 0;
+ thd->query_start_sec_part_used= 0;
thd->is_fatal_error= thd->time_zone_used= 0;
/*
Clear the status flag that are expected to be cleared at the
@@ -6248,17 +6237,6 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
DBUG_RETURN(1);
}
- if (type == MYSQL_TYPE_TIMESTAMP && length)
- {
- /* Display widths are no longer supported for TIMSTAMP as of MySQL 4.1.
- In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4),
- and so on, the display width is ignored.
- */
- char buf[32];
- my_snprintf(buf, sizeof(buf), "TIMESTAMP(%s)", length);
- WARN_DEPRECATED(thd, "6.0", buf, "'TIMESTAMP'");
- }
-
if (!(new_field= new Create_field()) ||
new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
default_value, on_update_value, comment, change,
@@ -7006,7 +6984,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
#ifdef HAVE_QUERY_CACHE
if (options & REFRESH_QUERY_CACHE_FREE)
{
- query_cache.pack(); // FLUSH QUERY CACHE
+ query_cache.pack(thd); // FLUSH QUERY CACHE
options &= ~REFRESH_QUERY_CACHE; // Don't flush cache, just free memory
}
if (options & (REFRESH_TABLES | REFRESH_QUERY_CACHE))
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 1c78f6a3613..15cae73844f 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1,4 +1,5 @@
-/* Copyright 2005-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -761,6 +762,9 @@ static bool handle_list_of_fields(List_iterator<char> it,
bool result;
char *field_name;
bool is_list_empty= TRUE;
+ int fields_handled = 0;
+ char* field_name_array[MAX_KEY];
+
DBUG_ENTER("handle_list_of_fields");
while ((field_name= it++))
@@ -776,6 +780,25 @@ static bool handle_list_of_fields(List_iterator<char> it,
result= TRUE;
goto end;
}
+
+ /*
+ Check for duplicate fields in the list.
+ Assuming that there are not many fields in the partition key list.
+ If there were, it would be better to replace the for-loop
+ with a more efficient algorithm.
+ */
+
+ field_name_array[fields_handled] = field_name;
+ for (int i = 0; i < fields_handled; ++i)
+ {
+ if (my_strcasecmp(system_charset_info,
+ field_name_array[i], field_name) == 0)
+ {
+ my_error(ER_FIELD_NOT_FOUND_PART_ERROR, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+ }
+ fields_handled++;
}
if (is_list_empty)
{
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 391a574b35d..a83990d25f4 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1638,8 +1638,11 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
if (simple_open_n_lock_tables(new_thd, &tables))
{
DBUG_PRINT("error",("Can't open plugin table"));
- sql_print_error("Can't open the mysql.plugin table. Please "
- "run mysql_upgrade to create it.");
+ if (!opt_help)
+ sql_print_error("Can't open the mysql.plugin table. Please "
+ "run mysql_upgrade to create it.");
+ else
+ sql_print_warning("Could not open mysql.plugin table. Some options may be missing from the help text");
goto end;
}
table= tables.table;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index db623133cb1..ece4b8a1014 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1,4 +1,5 @@
/* Copyright (c) 2002, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -107,7 +108,7 @@ class Select_fetch_protocol_binary: public select_send
public:
Select_fetch_protocol_binary(THD *thd);
virtual bool send_fields(List<Item> &list, uint flags);
- virtual bool send_data(List<Item> &items);
+ virtual int send_data(List<Item> &items);
virtual bool send_eof();
#ifdef EMBEDDED_LIBRARY
void begin_dataset()
@@ -490,8 +491,7 @@ static void set_param_time(Item_param *param, uchar **pos, ulong len)
}
else
set_zero_time(&tm, MYSQL_TIMESTAMP_TIME);
- param->set_time(&tm, MYSQL_TIMESTAMP_TIME,
- MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
+ param->set_time(&tm, MYSQL_TIMESTAMP_TIME, MAX_TIME_FULL_WIDTH);
*pos+= length;
}
@@ -1168,7 +1168,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
If we would use locks, then we have to ensure we are not using
TL_WRITE_DELAYED as having two such locks can cause table corruption.
*/
- if (open_normal_and_derived_tables(thd, table_list, 0))
+ if (open_normal_and_derived_tables(thd, table_list, 0, DT_INIT))
goto error;
if ((values= its++))
@@ -1252,7 +1252,10 @@ static int mysql_test_update(Prepared_statement *stmt,
open_tables(thd, &table_list, &table_count, 0))
goto error;
- if (table_list->multitable_view)
+ if (mysql_handle_derived(thd->lex, DT_INIT))
+ goto error;
+
+ if (table_list->is_multitable())
{
DBUG_ASSERT(table_list->view != 0);
DBUG_PRINT("info", ("Switch to multi-update"));
@@ -1266,8 +1269,15 @@ static int mysql_test_update(Prepared_statement *stmt,
thd->fill_derived_tables() is false here for sure (because it is
preparation of PS, so we even do not check it).
*/
- if (mysql_handle_derived(thd->lex, &mysql_derived_prepare))
+ if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT) ||
+ table_list->handle_derived(thd->lex, DT_PREPARE))
+ goto error;
+
+ if (!table_list->updatable)
+ {
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE");
goto error;
+ }
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* Force privilege re-checking for views after they have been opened. */
@@ -1321,15 +1331,26 @@ error:
static bool mysql_test_delete(Prepared_statement *stmt,
TABLE_LIST *table_list)
{
+ uint table_count= 0;
THD *thd= stmt->thd;
LEX *lex= stmt->lex;
DBUG_ENTER("mysql_test_delete");
if (delete_precheck(thd, table_list) ||
- open_normal_and_derived_tables(thd, table_list, 0))
+ open_tables(thd, &table_list, &table_count, 0))
goto error;
- if (!table_list->table)
+ if (mysql_handle_derived(thd->lex, DT_INIT) ||
+ mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
+ mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
+ goto error;
+
+ if (!table_list->updatable)
+ {
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
+ goto error;
+ }
+ if (!table_list->table || !table_list->table->created)
{
my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
table_list->view_db.str, table_list->view_name.str);
@@ -1384,7 +1405,8 @@ static int mysql_test_select(Prepared_statement *stmt,
goto error;
}
- if (open_normal_and_derived_tables(thd, tables, 0))
+ if (open_normal_and_derived_tables(thd, tables, 0,
+ DT_PREPARE | DT_CREATE))
goto error;
thd->used_tables= 0; // Updated by setup_fields
@@ -1445,7 +1467,8 @@ static bool mysql_test_do_fields(Prepared_statement *stmt,
if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE))
DBUG_RETURN(TRUE);
- if (open_normal_and_derived_tables(thd, tables, 0))
+ if (open_normal_and_derived_tables(thd, tables, 0,
+ DT_PREPARE | DT_CREATE))
DBUG_RETURN(TRUE);
DBUG_RETURN(setup_fields(thd, 0, *values, MARK_COLUMNS_NONE, 0, 0));
}
@@ -1475,7 +1498,8 @@ static bool mysql_test_set_fields(Prepared_statement *stmt,
if ((tables &&
check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) ||
- open_normal_and_derived_tables(thd, tables, 0))
+ open_normal_and_derived_tables(thd, tables, 0,
+ DT_PREPARE | DT_CREATE))
goto error;
while ((var= it++))
@@ -1512,7 +1536,7 @@ static bool mysql_test_call_fields(Prepared_statement *stmt,
if ((tables &&
check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) ||
- open_normal_and_derived_tables(thd, tables, 0))
+ open_normal_and_derived_tables(thd, tables, 0, DT_PREPARE))
goto err;
while ((item= it++))
@@ -1587,6 +1611,7 @@ select_like_stmt_test_with_open(Prepared_statement *stmt,
int (*specific_prepare)(THD *thd),
ulong setup_tables_done_option)
{
+ uint table_count= 0;
DBUG_ENTER("select_like_stmt_test_with_open");
/*
@@ -1595,7 +1620,8 @@ select_like_stmt_test_with_open(Prepared_statement *stmt,
prepared EXPLAIN yet so derived tables will clean up after
themself.
*/
- if (open_normal_and_derived_tables(stmt->thd, tables, 0))
+ THD *thd= stmt->thd;
+ if (open_tables(thd, &tables, &table_count, 0))
DBUG_RETURN(TRUE);
DBUG_RETURN(select_like_stmt_test(stmt, specific_prepare,
@@ -1640,7 +1666,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
create_table->skip_temporary= true;
}
- if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0))
+ if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0,
+ DT_PREPARE | DT_CREATE))
DBUG_RETURN(TRUE);
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
@@ -1658,7 +1685,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
we validate metadata of all CREATE TABLE statements,
which keeps metadata validation code simple.
*/
- if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0))
+ if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0,
+ DT_PREPARE))
DBUG_RETURN(TRUE);
}
@@ -1693,7 +1721,7 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
if (create_view_precheck(thd, tables, view, lex->create_view_mode))
goto err;
- if (open_normal_and_derived_tables(thd, tables, 0))
+ if (open_normal_and_derived_tables(thd, tables, 0, DT_PREPARE))
goto err;
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
@@ -2429,6 +2457,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
/* Fix ORDER list */
for (order= sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr;
+ sl->handle_derived(lex, DT_REINIT);
/* clear the no_error flag for INSERT/UPDATE IGNORE */
sl->no_error= FALSE;
@@ -2472,9 +2501,6 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
}
lex->current_select= &lex->select_lex;
- /* restore original list used in INSERT ... SELECT */
- if (lex->leaf_tables_insert)
- lex->select_lex.leaf_tables= lex->leaf_tables_insert;
if (lex->result)
{
@@ -2793,6 +2819,32 @@ void mysql_sql_stmt_close(THD *thd)
}
}
+
+class Set_longdata_error_handler : public Internal_error_handler
+{
+public:
+ Set_longdata_error_handler(Prepared_statement *statement)
+ : stmt(statement)
+ { }
+
+public:
+ bool handle_error(uint sql_errno,
+ const char *message,
+ MYSQL_ERROR::enum_warning_level level,
+ THD *)
+ {
+ stmt->state= Query_arena::ERROR;
+ stmt->last_errno= sql_errno;
+ strnmov(stmt->last_error, message, MYSQL_ERRMSG_SIZE);
+
+ return TRUE;
+ }
+
+private:
+ Prepared_statement *stmt;
+};
+
+
/**
Handle long data in pieces from client.
@@ -2849,16 +2901,19 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
param= stmt->param_array[param_number];
+ Set_longdata_error_handler err_handler(stmt);
+ /*
+ Install handler that will catch any errors that can be generated
+ during execution of Item_param::set_longdata() and propagate
+ them to Statement::last_error.
+ */
+ thd->push_internal_handler(&err_handler);
#ifndef EMBEDDED_LIBRARY
- if (param->set_longdata(packet, (ulong) (packet_end - packet)))
+ param->set_longdata(packet, (ulong) (packet_end - packet));
#else
- if (param->set_longdata(thd->extra_data, thd->extra_length))
+ param->set_longdata(thd->extra_data, thd->extra_length);
#endif
- {
- stmt->state= Query_arena::ERROR;
- stmt->last_errno= ER_OUTOFMEMORY;
- sprintf(stmt->last_error, ER(ER_OUTOFMEMORY), 0);
- }
+ thd->pop_internal_handler();
general_log_print(thd, thd->command, NullS);
@@ -2899,11 +2954,11 @@ bool Select_fetch_protocol_binary::send_eof()
}
-bool
+int
Select_fetch_protocol_binary::send_data(List<Item> &fields)
{
Protocol *save_protocol= thd->protocol;
- bool rc;
+ int rc;
thd->protocol= &protocol;
rc= select_send::send_data(fields);
@@ -3320,6 +3375,13 @@ Prepared_statement::execute_loop(String *expanded_query,
bool error;
int reprepare_attempt= 0;
+ /* Check if we got an error when sending long data */
+ if (state == Query_arena::ERROR)
+ {
+ my_message(last_errno, last_error, MYF(0));
+ return TRUE;
+ }
+
if (set_parameters(expanded_query, packet, packet_end))
return TRUE;
@@ -3560,12 +3622,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
status_var_increment(thd->status_var.com_stmt_execute);
- /* Check if we got an error when sending long data */
- if (state == Query_arena::ERROR)
- {
- my_message(last_errno, last_error, MYF(0));
- return TRUE;
- }
if (flags & (uint) IS_IN_USE)
{
my_error(ER_PS_NO_RECURSION, MYF(0));
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 7bfb127815d..5d5cb6a764e 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -235,7 +235,7 @@ void PROF_MEASUREMENT::set_label(const char *status_arg,
*/
void PROF_MEASUREMENT::collect()
{
- time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
+ time_usecs= my_interval_timer() / 1e3; /* ns to us */
#ifdef HAVE_GETRUSAGE
getrusage(RUSAGE_SELF, &rusage);
#elif defined(__WIN__)
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 3da0fafb830..69dc635be16 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -245,7 +245,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
char *new_table_alias, bool skip_error)
{
int rc= 1;
- char name[FN_REFLEN + 1];
+ char new_name[FN_REFLEN + 1], old_name[FN_REFLEN + 1];
const char *new_alias, *old_alias;
frm_type_enum frm_type;
enum legacy_db_type table_type;
@@ -264,17 +264,17 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
}
DBUG_ASSERT(new_alias);
- build_table_filename(name, sizeof(name) - 1,
+ build_table_filename(new_name, sizeof(new_name) - 1,
new_db, new_alias, reg_ext, 0);
- if (!access(name,F_OK))
+ build_table_filename(old_name, sizeof(old_name) - 1,
+ ren_table->db, old_alias, reg_ext, 0);
+ if (check_table_file_presence(old_name,
+ new_name, new_db, new_alias, new_alias, TRUE))
{
- my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
DBUG_RETURN(1); // This can't be skipped
}
- build_table_filename(name, sizeof(name) - 1,
- ren_table->db, old_alias, reg_ext, 0);
- frm_type= mysql_frm_type(thd, name, &table_type);
+ frm_type= mysql_frm_type(thd, old_name, &table_type);
switch (frm_type)
{
case FRMTYPE_TABLE:
@@ -319,7 +319,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
default:
DBUG_ASSERT(0); // should never happen
case FRMTYPE_ERROR:
- my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
+ my_error(ER_FILE_NOT_FOUND, MYF(0), old_name, my_errno);
break;
}
if (rc && !skip_error)
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 596f0f5c1e6..fc472c17e57 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2006 MySQL AB & Sasha
+/* Copyright (C) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,6 +22,7 @@
#include "log_event.h"
#include "rpl_filter.h"
#include <my_dir.h>
+#include "debug_sync.h"
int max_binlog_dump_events = 0; // unlimited
my_bool opt_sporadic_binlog_dump_fail = 0;
@@ -28,6 +30,9 @@ my_bool opt_sporadic_binlog_dump_fail = 0;
static int binlog_dump_count = 0;
#endif
+extern TYPELIB binlog_checksum_typelib;
+
+
/*
fake_rotate_event() builds a fake (=which does not exist physically in any
binlog) Rotate event, which contains the name of the binlog we are going to
@@ -47,10 +52,21 @@ static int binlog_dump_count = 0;
*/
static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
- ulonglong position, const char** errmsg)
+ ulonglong position, const char** errmsg,
+ uint8 checksum_alg_arg)
{
DBUG_ENTER("fake_rotate_event");
char header[LOG_EVENT_HEADER_LEN], buf[ROTATE_HEADER_LEN+100];
+
+ /*
+ this Rotate is to be sent with checksum if and only if
+ slave's get_master_version_and_clock time handshake value
+ of master's @@global.binlog_checksum was TRUE
+ */
+
+ my_bool do_checksum= checksum_alg_arg != BINLOG_CHECKSUM_ALG_OFF &&
+ checksum_alg_arg != BINLOG_CHECKSUM_ALG_UNDEF;
+
/*
'when' (the timestamp) is set to 0 so that slave could distinguish between
real and fake Rotate events (if necessary)
@@ -60,7 +76,8 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
char* p = log_file_name+dirname_length(log_file_name);
uint ident_len = (uint) strlen(p);
- ulong event_len = ident_len + LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN;
+ ulong event_len = ident_len + LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN +
+ (do_checksum ? BINLOG_CHECKSUM_LEN : 0);
int4store(header + SERVER_ID_OFFSET, server_id);
int4store(header + EVENT_LEN_OFFSET, event_len);
int2store(header + FLAGS_OFFSET, LOG_EVENT_ARTIFICIAL_F);
@@ -71,7 +88,19 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
packet->append(header, sizeof(header));
int8store(buf+R_POS_OFFSET,position);
packet->append(buf, ROTATE_HEADER_LEN);
- packet->append(p,ident_len);
+ packet->append(p, ident_len);
+
+ if (do_checksum)
+ {
+ char b[BINLOG_CHECKSUM_LEN];
+ ha_checksum crc= my_checksum(0L, NULL, 0);
+ crc= my_checksum(crc, (uchar*)header, sizeof(header));
+ crc= my_checksum(crc, (uchar*)buf, ROTATE_HEADER_LEN);
+ crc= my_checksum(crc, (uchar*)p, ident_len);
+ int4store(b, crc);
+ packet->append(b, sizeof(b));
+ }
+
if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
{
*errmsg = "failed on my_net_write()";
@@ -153,6 +182,86 @@ static int send_file(THD *thd)
}
+/**
+ Internal to mysql_binlog_send() routine that recalculates checksum for
+ a FD event (asserted) that needs additional arranment prior sending to slave.
+*/
+inline void fix_checksum(String *packet, ulong ev_offset)
+{
+ /* recalculate the crc for this event */
+ uint data_len = uint4korr(packet->ptr() + ev_offset + EVENT_LEN_OFFSET);
+ ha_checksum crc= my_checksum(0L, NULL, 0);
+ DBUG_ASSERT(data_len ==
+ LOG_EVENT_MINIMAL_HEADER_LEN + FORMAT_DESCRIPTION_HEADER_LEN +
+ BINLOG_CHECKSUM_ALG_DESC_LEN + BINLOG_CHECKSUM_LEN);
+ crc= my_checksum(crc, (uchar *)packet->ptr() + ev_offset, data_len -
+ BINLOG_CHECKSUM_LEN);
+ int4store(packet->ptr() + ev_offset + data_len - BINLOG_CHECKSUM_LEN, crc);
+}
+
+
+static user_var_entry * get_binlog_checksum_uservar(THD * thd)
+{
+ LEX_STRING name= { C_STRING_WITH_LEN("master_binlog_checksum")};
+ user_var_entry *entry=
+ (user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
+ name.length);
+ return entry;
+}
+
+/**
+ Function for calling in mysql_binlog_send
+ to check if slave initiated checksum-handshake.
+
+ @param[in] thd THD to access a user variable
+
+ @return TRUE if handshake took place, FALSE otherwise
+*/
+
+static bool is_slave_checksum_aware(THD * thd)
+{
+ DBUG_ENTER("is_slave_checksum_aware");
+ user_var_entry *entry= get_binlog_checksum_uservar(thd);
+ DBUG_RETURN(entry? true : false);
+}
+
+/**
+ Function for calling in mysql_binlog_send
+ to get the value of @@binlog_checksum of the master at
+ time of checksum-handshake.
+
+ The value tells the master whether to compute or not, and the slave
+ to verify or not the first artificial Rotate event's checksum.
+
+ @param[in] thd THD to access a user variable
+
+ @return value of @@binlog_checksum alg according to
+ @c enum enum_binlog_checksum_alg
+*/
+
+static uint8 get_binlog_checksum_value_at_connect(THD * thd)
+{
+ uint8 ret;
+
+ DBUG_ENTER("get_binlog_checksum_value_at_connect");
+ user_var_entry *entry= get_binlog_checksum_uservar(thd);
+ if (!entry)
+ {
+ ret= BINLOG_CHECKSUM_ALG_UNDEF;
+ }
+ else
+ {
+ DBUG_ASSERT(entry->type == STRING_RESULT);
+ String str;
+ uint dummy_errors;
+ str.copy(entry->value, entry->length, &my_charset_bin, &my_charset_bin,
+ &dummy_errors);
+ ret= (uint8) find_type ((char*) str.ptr(), &binlog_checksum_typelib, 1) - 1;
+ DBUG_ASSERT(ret <= BINLOG_CHECKSUM_ALG_CRC32); // while it's just on CRC32 alg
+ }
+ DBUG_RETURN(ret);
+}
+
/*
Adjust the position pointer in the binary log file for all running slaves
@@ -327,6 +436,9 @@ Increase max_allowed_packet on master";
case LOG_READ_TRUNC:
*errmsg = "binlog truncated in the middle of event";
break;
+ case LOG_READ_CHECKSUM_FAILURE:
+ *errmsg = "event read from binlog did not pass crc check";
+ break;
default:
*errmsg = "unknown error reading log event on the master";
break;
@@ -353,10 +465,11 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
NET* net = &thd->net;
pthread_mutex_t *log_lock;
bool binlog_can_be_corrupted= FALSE;
+ uint8 current_checksum_alg= BINLOG_CHECKSUM_ALG_UNDEF;
+ int old_max_allowed_packet= thd->variables.max_allowed_packet;
#ifndef DBUG_OFF
int left_events = max_binlog_dump_events;
#endif
- int old_max_allowed_packet= thd->variables.max_allowed_packet;
DBUG_ENTER("mysql_binlog_send");
DBUG_PRINT("enter",("log_ident: '%s' pos: %ld", log_ident, (long) pos));
@@ -450,7 +563,8 @@ impossible position";
given that we want minimum modification of 4.0, we send the normal
and fake Rotates.
*/
- if (fake_rotate_event(net, packet, log_file_name, pos, &errmsg))
+ if (fake_rotate_event(net, packet, log_file_name, pos, &errmsg,
+ get_binlog_checksum_value_at_connect(thd)))
{
/*
This error code is not perfect, as fake_rotate_event() does not
@@ -480,8 +594,8 @@ impossible position";
Try to find a Format_description_log_event at the beginning of
the binlog
*/
- if (!(error = Log_event::read_log_event(&log, packet, log_lock)))
- {
+ if (!(error = Log_event::read_log_event(&log, packet, log_lock, 0)))
+ {
/*
The packet has offsets equal to the normal offsets in a binlog
event +1 (the first character is \0).
@@ -491,6 +605,23 @@ impossible position";
(*packet)[EVENT_TYPE_OFFSET+1]));
if ((uchar)(*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
{
+ current_checksum_alg= get_checksum_alg(packet->ptr() + 1,
+ packet->length() - 1);
+ DBUG_ASSERT(current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
+ current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
+ current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
+ if (!is_slave_checksum_aware(thd) &&
+ current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ {
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+ errmsg= "Slave can not handle replication events with the checksum "
+ "that master is configured to log";
+ sql_print_warning("Master is configured to log replication events "
+ "with checksum, but will not send such events to "
+ "slaves that cannot process them");
+ goto err;
+ }
binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
LOG_EVENT_BINLOG_IN_USE_F);
(*packet)[FLAGS_OFFSET+1] &= ~LOG_EVENT_BINLOG_IN_USE_F;
@@ -506,6 +637,12 @@ impossible position";
*/
int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
ST_CREATED_OFFSET+1, (ulong) 0);
+
+ /* fix the checksum due to latest changes in header */
+ if (current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ fix_checksum(packet, 1);
+
/* send it */
if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
{
@@ -544,8 +681,11 @@ impossible position";
while (!net->error && net->vio != 0 && !thd->killed)
{
- while (!(error = Log_event::read_log_event(&log, packet, log_lock)))
+ my_off_t prev_pos= pos;
+ while (!(error = Log_event::read_log_event(&log, packet, log_lock,
+ current_checksum_alg)))
{
+ prev_pos= my_b_tell(&log);
#ifndef DBUG_OFF
if (max_binlog_dump_events && !left_events--)
{
@@ -555,9 +695,44 @@ impossible position";
goto err;
}
#endif
-
- if ((uchar)(*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
+ DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
+ {
+ if ((*packet)[EVENT_TYPE_OFFSET+1] == XID_EVENT)
+ {
+ net_flush(net);
+ const char act[]=
+ "now "
+ "wait_for signal.continue";
+ DBUG_ASSERT(opt_debug_sync_timeout > 0);
+ DBUG_ASSERT(!debug_sync_set_action(thd,
+ STRING_WITH_LEN(act)));
+ const char act2[]=
+ "now "
+ "signal signal.continued";
+ DBUG_ASSERT(!debug_sync_set_action(current_thd,
+ STRING_WITH_LEN(act2)));
+ }
+ });
+
+ if ((uchar) (*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
{
+ current_checksum_alg= get_checksum_alg(packet->ptr() + 1,
+ packet->length() - 1);
+ DBUG_ASSERT(current_checksum_alg == BINLOG_CHECKSUM_ALG_OFF ||
+ current_checksum_alg == BINLOG_CHECKSUM_ALG_UNDEF ||
+ current_checksum_alg == BINLOG_CHECKSUM_ALG_CRC32);
+ if (!is_slave_checksum_aware(thd) &&
+ current_checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
+ current_checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
+ {
+ my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
+ errmsg= "Slave can not handle replication events with the checksum "
+ "that master is configured to log";
+ sql_print_warning("Master is configured to log replication events "
+ "with checksum, but will not send such events to "
+ "slaves that cannot process them");
+ goto err;
+ }
binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
LOG_EVENT_BINLOG_IN_USE_F);
(*packet)[FLAGS_OFFSET+1] &= ~LOG_EVENT_BINLOG_IN_USE_F;
@@ -575,15 +750,23 @@ impossible position";
goto err;
}
+ DBUG_EXECUTE_IF("dump_thread_wait_before_send_xid",
+ {
+ if ((*packet)[EVENT_TYPE_OFFSET+1] == XID_EVENT)
+ {
+ net_flush(net);
+ }
+ });
+
DBUG_PRINT("info", ("log event code %d",
(*packet)[LOG_EVENT_OFFSET+1] ));
- if ((uchar)(*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
+ if ((uchar) (*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
{
if (send_file(thd))
{
- errmsg = "failed in send_file()";
- my_errno= ER_UNKNOWN_ERROR;
- goto err;
+ errmsg = "failed in send_file()";
+ my_errno= ER_UNKNOWN_ERROR;
+ goto err;
}
}
}
@@ -594,8 +777,14 @@ impossible position";
here we were reading binlog that was not closed properly (as a result
of a crash ?). treat any corruption as EOF
*/
- if (binlog_can_be_corrupted && error != LOG_READ_MEM)
+ if (binlog_can_be_corrupted &&
+ (error != LOG_READ_MEM && error != LOG_READ_CHECKSUM_FAILURE &&
+ error != LOG_READ_EOF))
+ {
+ my_b_seek(&log, prev_pos);
error=LOG_READ_EOF;
+ }
+
/*
TODO: now that we are logging the offset, check to make sure
the recorded offset and the actual match.
@@ -649,7 +838,8 @@ impossible position";
*/
pthread_mutex_lock(log_lock);
- switch (error= Log_event::read_log_event(&log, packet, (pthread_mutex_t*) 0)) {
+ switch (error= Log_event::read_log_event(&log, packet, (pthread_mutex_t*) 0,
+ current_checksum_alg)) {
case 0:
/* we read successfully, so we'll need to send it to the slave */
pthread_mutex_unlock(log_lock);
@@ -750,7 +940,7 @@ impossible position";
*/
if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0 ||
fake_rotate_event(net, packet, log_file_name, BIN_LOG_HEADER_SIZE,
- &errmsg))
+ &errmsg, current_checksum_alg))
{
my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err;
@@ -1499,7 +1689,8 @@ bool mysql_show_binlog_events(THD* thd)
This code will fail on a mixed relay log (one which has Format_desc then
Rotate then Format_desc).
*/
- ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
+ ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event,
+ opt_master_verify_checksum);
if (ev)
{
if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
@@ -1521,8 +1712,12 @@ bool mysql_show_binlog_events(THD* thd)
for (event_count = 0;
(ev = Log_event::read_log_event(&log,(pthread_mutex_t*) 0,
- description_event)); )
+ description_event,
+ opt_master_verify_checksum)); )
{
+ if (ev->get_type_code() == FORMAT_DESCRIPTION_EVENT)
+ description_event->checksum_alg= ev->checksum_alg;
+
if (event_count >= limit_start &&
ev->net_send(protocol, linfo.log_file_name, pos))
{
@@ -1815,6 +2010,12 @@ static sys_var_long_ptr sys_slave_trans_retries(&vars, "slave_transaction_retrie
&slave_trans_retries);
static sys_var_sync_binlog_period sys_sync_binlog_period(&vars, "sync_binlog", &sync_binlog_period);
static sys_var_slave_skip_counter sys_slave_skip_counter(&vars, "sql_slave_skip_counter");
+static sys_var_bool_ptr sys_master_verify_checksum(&vars,
+ "master_verify_checksum",
+ &opt_master_verify_checksum);
+static sys_var_bool_ptr sys_slave_sql_verify_checksum(&vars,
+ "slave_sql_verify_checksum",
+ &opt_slave_sql_verify_checksum);
bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c23318975dc..6212f841793 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -50,26 +50,25 @@ const char *copy_to_tmp_table= "Copying to tmp table";
struct st_sargable_param;
static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
-static bool make_join_statistics(JOIN *join, TABLE_LIST *leaves, COND *conds,
- DYNAMIC_ARRAY *keyuse);
+static bool make_join_statistics(JOIN *join, List<TABLE_LIST> &leaves,
+ COND *conds, DYNAMIC_ARRAY *keyuse);
static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
JOIN_TAB *join_tab,
uint tables, COND *conds,
- COND_EQUAL *cond_equal,
table_map table_map, SELECT_LEX *select_lex,
st_sargable_param **sargables);
+static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
+ bool skip_unprefixed_keyparts);
static int sort_keyuse(KEYUSE *a,KEYUSE *b);
static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
table_map used_tables);
-bool choose_plan(JOIN *join,table_map join_tables);
-
void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables, uint idx,
bool disable_jbuf, double record_count,
POSITION *pos, POSITION *loose_scan_pos);
static void optimize_straight_join(JOIN *join, table_map join_tables);
static bool greedy_search(JOIN *join, table_map remaining_tables,
- uint depth, uint prune_level);
+ uint depth, uint prune_level);
static bool best_extension_by_limited_search(JOIN *join,
table_map remaining_tables,
uint idx, double record_count,
@@ -86,7 +85,6 @@ static int join_tab_cmp_embedded_first(const void *emb, const void* ptr1, const
static bool find_best(JOIN *join,table_map rest_tables,uint index,
double record_count,double read_time);
static uint cache_record_length(JOIN *join,uint index);
-static double prev_record_reads(JOIN *join, uint idx, table_map found_ref);
static bool get_best_combination(JOIN *join);
static store_key *get_store_key(THD *thd,
KEYUSE *keyuse, table_map used_tables,
@@ -100,10 +98,11 @@ static void revise_cache_usage(JOIN_TAB *join_tab);
static bool make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after);
static bool only_eq_ref_tables(JOIN *join, ORDER *order, table_map tables);
static void update_depend_map(JOIN *join);
-static void update_depend_map(JOIN *join, ORDER *order);
+static void update_depend_map_for_order(JOIN *join, ORDER *order);
static ORDER *remove_const(JOIN *join,ORDER *first_order,COND *cond,
bool change_list, bool *simple_order);
-static int return_zero_rows(JOIN *join, select_result *res,TABLE_LIST *tables,
+static int return_zero_rows(JOIN *join, select_result *res,
+ List<TABLE_LIST> &tables,
List<Item> &fields, bool send_row,
ulonglong select_options, const char *info,
Item *having);
@@ -174,13 +173,16 @@ static int join_ft_read_first(JOIN_TAB *tab);
static int join_ft_read_next(READ_RECORD *info);
int join_read_always_key_or_null(JOIN_TAB *tab);
int join_read_next_same_or_null(READ_RECORD *info);
-static COND *make_cond_for_table(Item *cond,table_map table,
+static COND *make_cond_for_table(THD *thd, Item *cond,table_map table,
table_map used_table,
+ uint join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond);
-static COND *make_cond_for_table_from_pred(Item *root_cond, Item *cond,
+static COND *make_cond_for_table_from_pred(THD *thd, Item *root_cond,
+ Item *cond,
table_map tables,
table_map used_table,
+ uint join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond);
@@ -211,7 +213,7 @@ static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array,
List<Item> &all_fields,
bool *all_order_by_fields_used);
static bool test_if_subpart(ORDER *a,ORDER *b);
-static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables);
+static TABLE *get_sort_by_table(ORDER *a,ORDER *b,List<TABLE_LIST> &tables);
static void calc_group_buffer(JOIN *join,ORDER *group);
static bool make_group_fields(JOIN *main_join, JOIN *curr_join);
static bool alloc_group_fields(JOIN *join,ORDER *group);
@@ -235,14 +237,13 @@ static bool update_sum_func(Item_sum **func);
static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
bool distinct, const char *message=NullS);
static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
-void get_partial_join_cost(JOIN *join, uint idx, double *read_time_arg,
- double *record_count_arg);
static uint make_join_orderinfo(JOIN *join);
-static int
-join_read_record_no_init(JOIN_TAB *tab);
+static bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array);
Item_equal *find_item_equal(COND_EQUAL *cond_equal, Field *field,
bool *inherited_fl);
+JOIN_TAB *first_depth_first_tab(JOIN* join);
+JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab);
/**
This handles SELECT with and without UNION.
@@ -291,57 +292,60 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
}
-/*
+/**
Fix fields referenced from inner selects.
- SYNOPSIS
- fix_inner_refs()
- thd Thread handle
- all_fields List of all fields used in select
- select Current select
- ref_pointer_array Array of references to Items used in current select
- group_list GROUP BY list (is NULL by default)
+ @param thd Thread handle
+ @param all_fields List of all fields used in select
+ @param select Current select
+ @param ref_pointer_array Array of references to Items used in current select
+ @param group_list GROUP BY list (is NULL by default)
- DESCRIPTION
- The function serves 3 purposes - adds fields referenced from inner
- selects to the current select list, resolves which class to use
- to access referenced item (Item_ref of Item_direct_ref) and fixes
- references (Item_ref objects) to these fields.
+ @details
+ The function serves 3 purposes
+
+ - adds fields referenced from inner query blocks to the current select list
+
+ - Decides which class to use to reference the items (Item_ref or
+ Item_direct_ref)
- If a field isn't already in the select list and the ref_pointer_array
+ - fixes references (Item_ref objects) to these fields.
+
+ If a field isn't already on the select list and the ref_pointer_array
is provided then it is added to the all_fields list and the pointer to
it is saved in the ref_pointer_array.
The class to access the outer field is determined by the following rules:
- 1. If the outer field isn't used under an aggregate function
- then the Item_ref class should be used.
- 2. If the outer field is used under an aggregate function and this
- function is aggregated in the select where the outer field was
- resolved or in some more inner select then the Item_direct_ref
- class should be used.
- It used used also if we are grouping by a subquery that refers
- this outer field.
+
+ -#. If the outer field isn't used under an aggregate function then the
+ Item_ref class should be used.
+
+ -#. If the outer field is used under an aggregate function and this
+ function is, in turn, aggregated in the query block where the outer
+ field was resolved or some query nested therein, then the
+ Item_direct_ref class should be used. Also it should be used if we are
+ grouping by a subquery containing the outer field.
+
The resolution is done here and not at the fix_fields() stage as
- it can be done only after sum functions are fixed and pulled up to
- selects where they are have to be aggregated.
+ it can be done only after aggregate functions are fixed and pulled up to
+ selects where they are to be aggregated.
+
When the class is chosen it substitutes the original field in the
Item_outer_ref object.
After this we proceed with fixing references (Item_outer_ref objects) to
this field from inner subqueries.
- RETURN
- TRUE an error occured
- FALSE ok
-*/
+ @return Status
+ @retval true An error occured.
+ @retval false OK.
+ */
bool
fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
Item **ref_pointer_array)
{
Item_outer_ref *ref;
- bool res= FALSE;
- bool direct_ref= FALSE;
/*
Mark the references from the inner_refs_list that are occurred in
@@ -358,6 +362,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
while ((ref= ref_it++))
{
+ bool direct_ref= false;
Item *item= ref->outer_ref;
Item **item_ref= ref->ref;
Item_ref *new_ref;
@@ -416,7 +421,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
return TRUE;
thd->used_tables|= item->used_tables();
}
- return res;
+ return false;
}
/**
@@ -424,7 +429,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
*/
inline int setup_without_group(THD *thd, Item **ref_pointer_array,
TABLE_LIST *tables,
- TABLE_LIST *leaves,
+ List<TABLE_LIST> &leaves,
List<Item> &fields,
List<Item> &all_fields,
COND **conds,
@@ -502,21 +507,22 @@ JOIN::prepare(Item ***rref_pointer_array,
join_list= &select_lex->top_join_list;
union_part= unit_arg->is_union();
+ if (select_lex->handle_derived(thd->lex, DT_PREPARE))
+ DBUG_RETURN(1);
+
thd->lex->current_select->is_item_list_lookup= 1;
/*
If we have already executed SELECT, then it have not sense to prevent
its table from update (see unique_table())
+ Affects only materialized derived tables.
*/
- if (thd->derived_tables_processing)
- select_lex->exclude_from_table_unique_test= TRUE;
-
/* Check that all tables, fields, conds and order are ok */
-
if (!(select_options & OPTION_SETUP_TABLES_DONE) &&
setup_tables_and_check_access(thd, &select_lex->context, join_list,
- tables_list, &select_lex->leaf_tables,
- FALSE, SELECT_ACL, SELECT_ACL))
+ tables_list, select_lex->leaf_tables,
+ FALSE, SELECT_ACL, SELECT_ACL, FALSE))
DBUG_RETURN(-1);
+
/*
TRUE if the SELECT list mixes elements with and without grouping,
and there is no GROUP BY clause. Mixing non-aggregated fields with
@@ -545,12 +551,14 @@ JOIN::prepare(Item ***rref_pointer_array,
}
}
}
+
+ table_count= select_lex->leaf_tables.elements;
- for (TABLE_LIST *table_ptr= select_lex->leaf_tables;
- table_ptr;
- table_ptr= table_ptr->next_leaf)
+ TABLE_LIST *tbl;
+ List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
+ while ((tbl= li++))
{
- tables++; /* Count the number of tables in the join. */
+ table_count++; /* Count the number of tables in the join. */
/*
If the query uses implicit grouping where the select list contains both
aggregate functions and non-aggregate fields, any non-aggregated field
@@ -558,7 +566,7 @@ JOIN::prepare(Item ***rref_pointer_array,
semantic analysis to take into account this change of nullability.
*/
if (mixed_implicit_grouping)
- table_ptr->table->maybe_null= 1;
+ tbl->table->maybe_null= 1;
}
if ((wild_num && setup_wild(thd, tables_list, fields_list, &all_fields,
@@ -580,6 +588,13 @@ JOIN::prepare(Item ***rref_pointer_array,
thd->where="having clause";
thd->lex->allow_sum_func|= 1 << select_lex_arg->nest_level;
select_lex->having_fix_field= 1;
+ /*
+ Wrap alone field in HAVING clause in case it will be outer field of subquery
+ which need persistent pointer on it, but having could be changed by optimizer
+ */
+ if (having->type() == Item::REF_ITEM &&
+ ((Item_ref *)having)->ref_type() == Item_ref::REF)
+ wrap_ident(thd, &having);
bool having_fix_rc= (!having->fixed &&
(having->fix_fields(thd, &having) ||
having->check_cols(1)));
@@ -669,10 +684,6 @@ JOIN::prepare(Item ***rref_pointer_array,
}
}
- if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
- DBUG_RETURN(-1);
-
-
/*
Check if there are references to un-aggregated columns when computing
aggregate functions with implicit grouping (there is no GROUP BY).
@@ -731,11 +742,36 @@ JOIN::prepare(Item ***rref_pointer_array,
if (!procedure && result && result->prepare(fields_list, unit_arg))
goto err; /* purecov: inspected */
+ unit= unit_arg;
+ if (prepare_stage2())
+ goto err;
+
+ DBUG_RETURN(0); // All OK
+
+err:
+ delete procedure; /* purecov: inspected */
+ procedure= 0;
+ DBUG_RETURN(-1); /* purecov: inspected */
+}
+
+
+/**
+ Second phase of prepare where we collect some statistic.
+
+ @details
+ We made this part separate to be able recalculate some statistic after
+ transforming subquery on optimization phase.
+*/
+
+bool JOIN::prepare_stage2()
+{
+ bool res= TRUE;
+ DBUG_ENTER("JOIN::prepare_stage2");
+
/* Init join struct */
count_field_types(select_lex, &tmp_table_param, all_fields, 0);
ref_pointer_array_size= all_fields.elements*sizeof(Item*);
this->group= group_list != 0;
- unit= unit_arg;
if (tmp_table_param.sum_func_count && !group_list)
implicit_grouping= TRUE;
@@ -752,15 +788,63 @@ JOIN::prepare(Item ***rref_pointer_array,
if (alloc_func_list())
goto err;
- DBUG_RETURN(0); // All OK
-
+ res= FALSE;
err:
- delete procedure; /* purecov: inspected */
- procedure= 0;
- DBUG_RETURN(-1); /* purecov: inspected */
+ DBUG_RETURN(res); /* purecov: inspected */
}
+void
+inject_jtbm_conds(JOIN *join, List<TABLE_LIST> *join_list, Item **join_where)
+{
+ TABLE_LIST *table;
+ NESTED_JOIN *nested_join;
+ List_iterator<TABLE_LIST> li(*join_list);
+ DBUG_ENTER("inject_jtbm_conds");
+
+
+ while ((table= li++))
+ {
+ Item_in_subselect *item;
+
+ if ((item= table->jtbm_subselect))
+ {
+ Item_in_subselect *subq_pred= item;
+ double rows;
+ double read_time;
+
+ subq_pred->in_strategy &= ~SUBS_IN_TO_EXISTS;
+ subq_pred->optimize(&rows, &read_time);
+
+ subq_pred->jtbm_read_time= read_time;
+ subq_pred->jtbm_record_count=rows;
+ subq_pred->is_jtbm_merged= TRUE;
+
+ subselect_hash_sj_engine *hash_sj_engine=
+ ((subselect_hash_sj_engine*)item->engine);
+
+
+ //repeat of convert_subq_to_jtbm:
+ table->table= hash_sj_engine->tmp_table;
+
+ setup_table_map(table->table, table, table->jtbm_table_no);
+
+ Item *sj_conds= hash_sj_engine->semi_join_conds;
+
+ (*join_where)= and_items(*join_where, sj_conds);
+ if (!(*join_where)->fixed)
+ (*join_where)->fix_fields(join->thd, join_where);
+ //parent_join->select_lex->where= parent_join->conds;
+ }
+
+ if ((nested_join= table->nested_join))
+ {
+ inject_jtbm_conds(join, &nested_join->join_list, join_where);
+ }
+ }
+ DBUG_VOID_RETURN;
+}
+
/**
global select optimisation.
@@ -784,15 +868,44 @@ JOIN::optimize()
if (optimized)
DBUG_RETURN(0);
optimized= 1;
-
thd_proc_info(thd, "optimizing");
set_allowed_join_cache_types();
- /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
- if (convert_join_subqueries_to_semijoins(this))
+ /* Run optimize phase for all derived tables/views used in this SELECT. */
+ if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE))
+ DBUG_RETURN(1);
+
+ if (select_lex->first_cond_optimization)
+ {
+ //Do it only for the first execution
+ /* Merge all mergeable derived tables/views in this SELECT. */
+ if (select_lex->handle_derived(thd->lex, DT_MERGE))
+ DBUG_RETURN(TRUE);
+ table_count= select_lex->leaf_tables.elements;
+ select_lex->update_used_tables();
+ }
+
+ if (transform_max_min_subquery())
DBUG_RETURN(1); /* purecov: inspected */
- /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
+
+ if (select_lex->first_cond_optimization)
+ {
+ /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
+ if (convert_join_subqueries_to_semijoins(this))
+ DBUG_RETURN(1); /* purecov: inspected */
+ /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
+ select_lex->update_used_tables();
+
+ /* Save this info for the next executions */
+ if (select_lex->save_leaf_tables(thd))
+ DBUG_RETURN(1);
+ }
+
+ table_count= select_lex->leaf_tables.elements;
+
+ if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
+ DBUG_RETURN(-1);
row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
unit->select_limit_cnt);
@@ -826,7 +939,8 @@ JOIN::optimize()
}
}
#endif
- SELECT_LEX *sel= thd->lex->current_select;
+
+ SELECT_LEX *sel= select_lex;
if (sel->first_cond_optimization)
{
/*
@@ -851,6 +965,8 @@ JOIN::optimize()
if (arena)
thd->restore_active_arena(arena, &backup);
}
+
+ inject_jtbm_conds(this, join_list, &conds);
conds= optimize_cond(this, conds, join_list, &cond_value, &cond_equal);
if (thd->is_error())
@@ -880,7 +996,7 @@ JOIN::optimize()
"Impossible HAVING" : "Impossible WHERE"));
zero_result_cause= having_value == Item::COND_FALSE ?
"Impossible HAVING" : "Impossible WHERE";
- tables= 0;
+ table_count= top_join_tab_count= 0;
error= 0;
goto setup_subq_exit;
}
@@ -889,7 +1005,8 @@ JOIN::optimize()
#ifdef WITH_PARTITION_STORAGE_ENGINE
{
TABLE_LIST *tbl;
- for (tbl= select_lex->leaf_tables; tbl; tbl= tbl->next_leaf)
+ List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
+ while ((tbl= li++))
{
/*
If tbl->embedding!=NULL that means that this table is in the inner
@@ -924,13 +1041,14 @@ JOIN::optimize()
If all items were resolved by opt_sum_query, there is no need to
open any tables.
*/
- if ((res=opt_sum_query(select_lex->leaf_tables, all_fields, conds)))
+ if ((res=opt_sum_query(thd, select_lex->leaf_tables, all_fields, conds)))
{
+ DBUG_ASSERT(res >= 0);
if (res == HA_ERR_KEY_NOT_FOUND)
{
DBUG_PRINT("info",("No matching min/max row"));
zero_result_cause= "No matching min/max row";
- tables= 0;
+ table_count= top_join_tab_count= 0;
error=0;
goto setup_subq_exit;
}
@@ -940,18 +1058,11 @@ JOIN::optimize()
DBUG_PRINT("error",("Error from opt_sum_query"));
DBUG_RETURN(1);
}
- if (res < 0)
- {
- DBUG_PRINT("info",("No matching min/max row"));
- zero_result_cause= "No matching min/max row";
- tables= 0;
- error=0;
- goto setup_subq_exit;
- }
+
DBUG_PRINT("info",("Select tables optimized away"));
zero_result_cause= "Select tables optimized away";
tables_list= 0; // All tables resolved
- const_tables= tables;
+ const_tables= top_join_tab_count= table_count;
/*
Extract all table-independent conditions and replace the WHERE
clause with them. All other conditions were computed by opt_sum_query
@@ -965,24 +1076,21 @@ JOIN::optimize()
if (conds && !(thd->lex->describe & DESCRIBE_EXTENDED))
{
COND *table_independent_conds=
- make_cond_for_table(conds, PSEUDO_TABLE_BITS, 0, FALSE, FALSE);
+ make_cond_for_table(thd, conds, PSEUDO_TABLE_BITS, 0, MAX_TABLES,
+ FALSE, FALSE);
DBUG_EXECUTE("where",
print_where(table_independent_conds,
"where after opt_sum_query()",
QT_ORDINARY););
conds= table_independent_conds;
}
- goto setup_subq_exit;
}
}
if (!tables_list)
{
DBUG_PRINT("info",("No tables"));
error= 0;
- /* Create all structures needed for materialized subquery execution. */
- if (setup_subquery_materialization())
- DBUG_RETURN(1);
- DBUG_RETURN(0);
+ goto setup_subq_exit;
}
error= -1; // Error is sent to client
sort_by_table= get_sort_by_table(order, group_list, select_lex->leaf_tables);
@@ -996,6 +1104,9 @@ JOIN::optimize()
DBUG_RETURN(1);
}
+ if (optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_WITH_KEYS))
+ drop_unused_derived_keys();
+
if (rollup.state != ROLLUP::STATE_NONE)
{
if (rollup_process_const_fields())
@@ -1007,7 +1118,7 @@ JOIN::optimize()
else
{
/* Remove distinct if only const tables */
- select_distinct= select_distinct && (const_tables != tables);
+ select_distinct= select_distinct && (const_tables != table_count);
}
thd_proc_info(thd, "preparing");
@@ -1074,8 +1185,9 @@ JOIN::optimize()
/*
Perform the optimization on fields evaluation mentioned above
for all on expressions.
- */
- for (JOIN_TAB *tab= join_tab + const_tables; tab < join_tab + tables ; tab++)
+ */
+ for (JOIN_TAB *tab= first_linear_tab(this, WITHOUT_CONST_TABLES); tab;
+ tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
if (*tab->on_expr_ref)
{
@@ -1084,26 +1196,24 @@ JOIN::optimize()
map2table);
(*tab->on_expr_ref)->update_used_tables();
}
-
-
}
/*
Perform the optimization on fields evaliation mentioned above
for all used ref items.
*/
- for (JOIN_TAB *tab= join_tab + const_tables; tab < join_tab + tables; tab++)
+ for (JOIN_TAB *tab= first_linear_tab(this, WITHOUT_CONST_TABLES); tab;
+ tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
uint key_copy_index=0;
for (uint i=0; i < tab->ref.key_parts; i++)
{
-
Item **ref_item_ptr= tab->ref.items+i;
Item *ref_item= *ref_item_ptr;
if (!ref_item->used_tables() && !(select_options & SELECT_DESCRIBE))
continue;
COND_EQUAL *equals= tab->first_inner ? tab->first_inner->cond_equal :
- cond_equal;
+ cond_equal;
ref_item= substitute_for_best_equal_field(ref_item, equals, map2table);
ref_item->update_used_tables();
if (*ref_item_ptr != ref_item)
@@ -1112,14 +1222,14 @@ JOIN::optimize()
Item *item= ref_item->real_item();
store_key *key_copy= tab->ref.key_copy[key_copy_index];
if (key_copy->type() == store_key::FIELD_STORE_KEY)
- {
+ {
store_key_field *field_copy= ((store_key_field *)key_copy);
field_copy->change_source_field((Item_field *) item);
}
}
key_copy_index++;
}
- }
+ }
if (conds && const_table_map != found_const_table_map &&
(select_options & SELECT_DESCRIBE))
@@ -1131,6 +1241,7 @@ JOIN::optimize()
{
zero_result_cause=
"Impossible WHERE noticed after reading const tables";
+ select_lex->mark_const_derived(zero_result_cause);
goto setup_subq_exit;
}
@@ -1166,7 +1277,7 @@ JOIN::optimize()
The FROM clause must contain a single non-constant table.
*/
- if (tables - const_tables == 1 && (group_list || select_distinct) &&
+ if (table_count - const_tables == 1 && (group_list || select_distinct) &&
!tmp_table_param.sum_func_count &&
(!join_tab[const_tables].select ||
!join_tab[const_tables].select->quick ||
@@ -1217,7 +1328,7 @@ JOIN::optimize()
if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE)
select_distinct=0;
}
- else if (select_distinct && tables - const_tables == 1 &&
+ else if (select_distinct && table_count - const_tables == 1 &&
rollup.state == ROLLUP::STATE_NONE)
{
/*
@@ -1346,7 +1457,7 @@ JOIN::optimize()
When the WITH ROLLUP modifier is present, we cannot skip temporary table
creation for the DISTINCT clause just because there are only const tables.
*/
- need_tmp= ((const_tables != tables &&
+ need_tmp= ((const_tables != table_count &&
((select_distinct || !simple_order || !simple_group) ||
(group_list && order) ||
test(select_options & OPTION_BUFFER_RESULT))) ||
@@ -1360,7 +1471,7 @@ JOIN::optimize()
Yet the current implementation of FORCE INDEX hints does not
allow us to do it in a clean manner.
*/
- no_jbuf_after= 1 ? tables : make_join_orderinfo(this);
+ no_jbuf_after= 1 ? table_count : make_join_orderinfo(this);
select_opts_for_readinfo=
(select_options & (SELECT_DESCRIBE | SELECT_NO_JOIN_CACHE)) |
@@ -1374,8 +1485,7 @@ JOIN::optimize()
if (!(select_options & SELECT_DESCRIBE))
init_ftfuncs(thd, select_lex, test(order));
- /* Create all structures needed for materialized subquery execution. */
- if (setup_subquery_materialization())
+ if (optimize_unflattened_subqueries())
DBUG_RETURN(1);
int res;
@@ -1392,13 +1502,16 @@ JOIN::optimize()
*/
if (need_tmp || select_distinct || group_list || order)
{
- for (uint i = const_tables; i < tables; i++)
- join_tab[i].table->prepare_for_position();
+ for (uint i= 0; i < table_count; i++)
+ {
+ if (!(table[i]->map & const_table_map))
+ table[i]->prepare_for_position();
+ }
}
DBUG_EXECUTE("info",TEST_join(this););
- if (const_tables != tables)
+ if (const_tables != table_count)
{
/*
Because filesort always does a full table scan or a quick range scan
@@ -1461,7 +1574,7 @@ JOIN::optimize()
if (select_options & SELECT_DESCRIBE)
{
error= 0;
- DBUG_RETURN(0);
+ goto derived_exit;
}
having= 0;
@@ -1479,6 +1592,40 @@ JOIN::optimize()
if (join_tab->is_using_loose_index_scan())
tmp_table_param.precomputed_group_by= TRUE;
+ error= 0;
+ DBUG_RETURN(0);
+
+setup_subq_exit:
+ /* Choose an execution strategy for this JOIN. */
+ if (!tables_list || !table_count)
+ choose_tableless_subquery_plan();
+ /*
+ Even with zero matching rows, subqueries in the HAVING clause may
+ need to be evaluated if there are aggregate functions in the query.
+ */
+ if (optimize_unflattened_subqueries())
+ DBUG_RETURN(1);
+ error= 0;
+
+derived_exit:
+ select_lex->mark_const_derived(zero_result_cause);
+ DBUG_RETURN(0);
+}
+
+
+/**
+ Create and initialize objects neeed for the execution of a query plan.
+ Evaluate constant expressions not evaluated during optimization.
+*/
+
+int JOIN::init_execution()
+{
+ DBUG_ENTER("JOIN::init_execution");
+
+ DBUG_ASSERT(optimized);
+ DBUG_ASSERT(!(select_options & SELECT_DESCRIBE));
+ initialized= true;
+
/* Create a tmp table if distinct or if the sort is too complicated */
if (need_tmp)
{
@@ -1511,7 +1658,7 @@ JOIN::optimize()
select_options,
tmp_rows_limit,
(char *) "")))
- {
+ {
DBUG_RETURN(1);
}
@@ -1573,7 +1720,7 @@ JOIN::optimize()
if (exec_tmp_table1->distinct)
{
table_map used_tables= thd->used_tables;
- JOIN_TAB *last_join_tab= join_tab+tables-1;
+ JOIN_TAB *last_join_tab= join_tab + top_join_tab_count - 1;
do
{
if (used_tables & last_join_tab->table->map)
@@ -1597,19 +1744,6 @@ JOIN::optimize()
DBUG_RETURN(-1); /* purecov: inspected */
}
- error= 0;
- DBUG_RETURN(0);
-
-setup_subq_exit:
- /*
- Even with zero matching rows, subqueries in the HAVING clause may
- need to be evaluated if there are aggregate functions in the
- query. If we have planned to materialize the subquery, we need to
- set it up properly before prematurely leaving optimize().
- */
- if (setup_subquery_materialization())
- DBUG_RETURN(1);
- error= 0;
DBUG_RETURN(0);
}
@@ -1644,9 +1778,8 @@ bool JOIN::setup_subquery_caches()
if (conds)
conds= conds->transform(&Item::expr_cache_insert_transformer,
(uchar*) thd);
- for (JOIN_TAB *tab= join_tab + const_tables;
- tab < join_tab + tables ;
- tab++)
+ for (JOIN_TAB *tab= first_linear_tab(this, WITHOUT_CONST_TABLES);
+ tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
if (tab->select_cond)
tab->select_cond=
@@ -1800,12 +1933,17 @@ JOIN::reinit()
set_items_ref_array(items0);
if (join_tab_save)
- memcpy(join_tab, join_tab_save, sizeof(JOIN_TAB) * tables);
+ memcpy(join_tab, join_tab_save, sizeof(JOIN_TAB) * table_count);
/* need to reset ref access state (see join_read_key) */
if (join_tab)
- for (uint i= 0; i < tables; i++)
- join_tab[i].ref.key_err= TRUE;
+ {
+ for (JOIN_TAB *tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
+ tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
+ {
+ tab->ref.key_err= TRUE;
+ }
+ }
if (tmp_join)
restore_tmp();
@@ -1862,7 +2000,7 @@ JOIN::save_join_tab()
if (!join_tab_save && select_lex->master_unit()->uncacheable)
{
if (!(join_tab_save= (JOIN_TAB*)thd->memdup((uchar*) join_tab,
- sizeof(JOIN_TAB) * tables)))
+ sizeof(JOIN_TAB) * table_count)))
return 1;
}
return 0;
@@ -1902,7 +2040,7 @@ JOIN::exec()
}
(void) result->prepare2(); // Currently, this cannot fail.
- if (!tables_list && (tables || !select_lex->with_sum_func))
+ if (!tables_list && (table_count || !select_lex->with_sum_func))
{ // Only test of functions
if (select_options & SELECT_DESCRIBE)
select_describe(this, FALSE, FALSE, FALSE,
@@ -1930,7 +2068,7 @@ JOIN::exec()
{
if (do_send_rows &&
(procedure ? (procedure->send_row(procedure_fields_list) ||
- procedure->end_of_records()) : result->send_data(fields_list)))
+ procedure->end_of_records()) : result->send_data(fields_list)> 0))
error= 1;
else
{
@@ -1955,9 +2093,19 @@ JOIN::exec()
FOUND_ROWS() may be called. Never reset the examined row count here.
It must be accumulated from all join iterations of all join parts.
*/
- if (tables)
+ if (table_count)
thd->limit_found_rows= 0;
+ /*
+ Evaluate expensive constant conditions that were not evaluated during
+ optimization. Do not evaluate them for EXPLAIN statements as these
+ condtions may be arbitrarily costly, and because the optimize phase
+ might not have produced a complete executable plan for EXPLAINs.
+ */
+ if (exec_const_cond && !(select_options & SELECT_DESCRIBE) &&
+ !exec_const_cond->val_int())
+ zero_result_cause= "Impossible WHERE noticed after reading const tables";
+
if (zero_result_cause)
{
(void) return_zero_rows(this, result, select_lex->leaf_tables,
@@ -1965,10 +2113,31 @@ JOIN::exec()
send_row_on_empty_set(),
select_options,
zero_result_cause,
- having);
+ having ? having : tmp_having);
DBUG_VOID_RETURN;
}
+ /*
+ Evaluate all constant expressions with subqueries in the ORDER/GROUP clauses
+ to make sure that all subqueries return a single row. The evaluation itself
+ will trigger an error if that is not the case.
+ */
+ if (exec_const_order_group_cond.elements &&
+ !(select_options & SELECT_DESCRIBE))
+ {
+ List_iterator_fast<Item> const_item_it(exec_const_order_group_cond);
+ Item *cur_const_item;
+ while ((cur_const_item= const_item_it++))
+ {
+ cur_const_item->val_str(&cur_const_item->str_value);
+ if (thd->is_error())
+ {
+ error= thd->is_error();
+ DBUG_VOID_RETURN;
+ }
+ }
+ }
+
if ((this->select_lex->options & OPTION_SCHEMA_TABLE) &&
get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC))
DBUG_VOID_RETURN;
@@ -1992,7 +2161,7 @@ JOIN::exec()
}
if (order &&
(order != group_list || !(select_options & SELECT_BIG_RESULT)) &&
- (const_tables == tables ||
+ (const_tables == table_count ||
((simple_order || skip_sort_order) &&
test_if_skip_sort_order(&join_tab[const_tables], order,
select_limit, 0,
@@ -2003,9 +2172,17 @@ JOIN::exec()
select_describe(this, need_tmp,
order != 0 && !skip_sort_order,
select_distinct,
- !tables ? "No tables used" : NullS);
+ !table_count ? "No tables used" : NullS);
DBUG_VOID_RETURN;
}
+ else
+ {
+ /* it's a const select, materialize it. */
+ select_lex->mark_const_derived(zero_result_cause);
+ }
+
+ if (!initialized && init_execution())
+ DBUG_VOID_RETURN;
JOIN *curr_join= this;
List<Item> *curr_all_fields= &all_fields;
@@ -2037,12 +2214,16 @@ JOIN::exec()
thd_proc_info(thd, copy_to_tmp_table);
DBUG_PRINT("info", ("%s", thd->proc_info));
if (!curr_join->sort_and_group &&
- curr_join->const_tables != curr_join->tables)
+ curr_join->const_tables != curr_join->table_count)
{
JOIN_TAB *first_tab= curr_join->join_tab + curr_join->const_tables;
first_tab->sorted= test(first_tab->loosescan_match_tab);
}
- if ((tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0)))
+
+ Procedure *save_proc= curr_join->procedure;
+ tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0);
+ curr_join->procedure= save_proc;
+ if (tmp_error)
{
error= tmp_error;
DBUG_VOID_RETURN;
@@ -2208,7 +2389,7 @@ JOIN::exec()
DBUG_VOID_RETURN;
curr_join->group_list= 0;
if (!curr_join->sort_and_group &&
- curr_join->const_tables != curr_join->tables)
+ curr_join->const_tables != curr_join->table_count)
{
JOIN_TAB *first_tab= curr_join->join_tab + curr_join->const_tables;
first_tab->sorted= test(first_tab->loosescan_match_tab);
@@ -2221,7 +2402,7 @@ JOIN::exec()
DBUG_VOID_RETURN;
}
end_read_record(&curr_join->join_tab->read_record);
- curr_join->const_tables= curr_join->tables; // Mark free for cleanup()
+ curr_join->const_tables= curr_join->table_count; // Mark free for cleanup()
curr_join->join_tab[0].table= 0; // Table is freed
// No sum funcs anymore
@@ -2337,9 +2518,10 @@ JOIN::exec()
table_map used_tables= (curr_join->const_table_map |
curr_table->table->map);
- Item* sort_table_cond= make_cond_for_table(curr_join->tmp_having,
+ Item* sort_table_cond= make_cond_for_table(thd, curr_join->tmp_having,
used_tables,
- (table_map)0, FALSE, FALSE);
+ (table_map)0, MAX_TABLES,
+ FALSE, FALSE);
if (sort_table_cond)
{
if (!curr_table->select)
@@ -2356,8 +2538,7 @@ JOIN::exec()
}
if (curr_table->pre_idx_push_select_cond)
{
- if (sort_table_cond->type() == Item::COND_ITEM &&
- sort_table_cond != curr_table->select->cond)
+ if (sort_table_cond->type() == Item::COND_ITEM)
sort_table_cond= sort_table_cond->copy_andor_structure(thd);
if (!(curr_table->pre_idx_push_select_cond=
new Item_cond_and(curr_table->pre_idx_push_select_cond,
@@ -2375,9 +2556,10 @@ JOIN::exec()
DBUG_EXECUTE("where",print_where(curr_table->select->cond,
"select and having",
QT_ORDINARY););
- curr_join->tmp_having= make_cond_for_table(curr_join->tmp_having,
+ curr_join->tmp_having= make_cond_for_table(thd, curr_join->tmp_having,
~ (table_map) 0,
- ~used_tables, FALSE, FALSE);
+ ~used_tables, MAX_TABLES,
+ FALSE, FALSE);
DBUG_EXECUTE("where",print_where(curr_join->tmp_having,
"having after sort",
QT_ORDINARY););
@@ -2393,7 +2575,7 @@ JOIN::exec()
WHERE clause for any tables after the sorted one.
*/
JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables+1];
- JOIN_TAB *end_table= &curr_join->join_tab[curr_join->tables];
+ JOIN_TAB *end_table= &curr_join->join_tab[curr_join->top_join_tab_count];
for (; curr_table < end_table ; curr_table++)
{
/*
@@ -2431,7 +2613,7 @@ JOIN::exec()
curr_join->group_list ? TRUE : FALSE))
DBUG_VOID_RETURN;
sortorder= curr_join->sortorder;
- if (curr_join->const_tables != curr_join->tables &&
+ if (curr_join->const_tables != curr_join->table_count &&
!curr_join->join_tab[curr_join->const_tables].table->sort.io_cache)
{
/*
@@ -2453,7 +2635,7 @@ JOIN::exec()
curr_join->fields= curr_fields_list;
curr_join->procedure= procedure;
- if (is_top_level_join() && thd->cursor && tables != const_tables)
+ if (is_top_level_join() && thd->cursor && table_count != const_tables)
{
/*
We are here if this is JOIN::exec for the last select of the main unit
@@ -2520,9 +2702,11 @@ JOIN::destroy()
{
if (join_tab != tmp_join->join_tab)
{
- JOIN_TAB *tab, *end;
- for (tab= join_tab, end= tab+tables ; tab != end ; tab++)
+ for (JOIN_TAB *tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
+ tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
+ {
tab->cleanup();
+ }
}
tmp_join->tmp_join= 0;
/*
@@ -2727,51 +2911,6 @@ err:
}
-/**
- Setup for execution all subqueries of a query, for which the optimizer
- chose hash semi-join.
-
- @details Iterate over all subqueries of the query, and if they are under an
- IN predicate, and the optimizer chose to compute it via hash semi-join:
- - try to initialize all data structures needed for the materialized execution
- of the IN predicate,
- - if this fails, then perform the IN=>EXISTS transformation which was
- previously blocked during JOIN::prepare.
-
- This method is part of the "code generation" query processing phase.
-
- This phase must be called after substitute_for_best_equal_field() because
- that function may replace items with other items from a multiple equality,
- and we need to reference the correct items in the index access method of the
- IN predicate.
-
- @return Operation status
- @retval FALSE success.
- @retval TRUE error occurred.
-*/
-
-bool JOIN::setup_subquery_materialization()
-{
- for (SELECT_LEX_UNIT *un= select_lex->first_inner_unit(); un;
- un= un->next_unit())
- {
- for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())
- {
- Item_subselect *subquery_predicate= sl->master_unit()->item;
- if (subquery_predicate &&
- subquery_predicate->substype() == Item_subselect::IN_SUBS)
- {
- Item_in_subselect *in_subs= (Item_in_subselect*) subquery_predicate;
- if (in_subs->exec_method == Item_in_subselect::MATERIALIZATION &&
- in_subs->setup_engine())
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-
/*****************************************************************************
Create JOIN_TABS, make a guess about the table types,
Approximate how many records will be used in each table
@@ -2830,12 +2969,11 @@ typedef struct st_sargable_param
*/
static bool
-make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
- DYNAMIC_ARRAY *keyuse_array)
+make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
+ COND *conds, DYNAMIC_ARRAY *keyuse_array)
{
- int error;
+ int error= 0;
TABLE *table;
- TABLE_LIST *tables= tables_arg;
uint i,table_count,const_count,key;
table_map found_const_table_map, all_table_map, found_ref, refs;
key_map const_ref, eq_part;
@@ -2846,10 +2984,14 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
table_map no_rows_const_tables= 0;
SARGABLE_PARAM *sargables= 0;
JOIN_TAB *stat_vector[MAX_TABLES+1];
+ List_iterator<TABLE_LIST> ti(tables_list);
+ TABLE_LIST *tables;
DBUG_ENTER("make_join_statistics");
- table_count=join->tables;
- stat=(JOIN_TAB*) join->thd->calloc(sizeof(JOIN_TAB)*table_count);
+ LINT_INIT(table); /* inited in all loops */
+ table_count=join->table_count;
+
+ stat=(JOIN_TAB*) join->thd->calloc(sizeof(JOIN_TAB)*(table_count));
stat_ref=(JOIN_TAB**) join->thd->alloc(sizeof(JOIN_TAB*)*MAX_TABLES);
table_vector=(TABLE**) join->thd->alloc(sizeof(TABLE*)*(table_count*2));
if (!stat || !stat_ref || !table_vector)
@@ -2861,9 +3003,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
found_const_table_map= all_table_map=0;
const_count=0;
- for (s= stat, i= 0;
- tables;
- s++, tables= tables->next_leaf, i++)
+ for (s= stat, i= 0; (tables= ti++); s++, i++)
{
TABLE_LIST *embedding= tables->embedding;
stat_vector[i]=s;
@@ -2873,7 +3013,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
s->needed_reg.init();
table_vector[i]=s->table=table=tables->table;
table->pos_in_table_list= tables;
- error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
+ error= tables->fetch_number_of_rows();
if (error)
{
table->file->print_error(error, MYF(0));
@@ -2885,11 +3025,10 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
table->reginfo.not_exists_optimize=0;
bzero((char*) table->const_key_parts, sizeof(key_part_map)*table->s->keys);
all_table_map|= table->map;
+ s->preread_init_done= FALSE;
s->join=join;
- s->info=0; // For describe
s->dependent= tables->dep_tables;
- s->key_dependent= 0;
if (tables->schema_table)
table->file->stats.records= 2;
table->quick_condition_rows= table->file->stats.records;
@@ -2899,9 +3038,11 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
{
/* s is the only inner table of an outer join */
#ifdef WITH_PARTITION_STORAGE_ENGINE
- if ((!table->file->stats.records || table->no_partitions_used) && !embedding)
+ if (!table->is_filled_at_execution() &&
+ (!table->file->stats.records || table->no_partitions_used) && !embedding)
#else
- if (!table->file->stats.records && !embedding)
+ if (!table->is_filled_at_execution() &&
+ !table->file->stats.records && !embedding)
#endif
{ // Empty table
s->dependent= 0; // Ignore LEFT JOIN depend.
@@ -2935,7 +3076,8 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
#else
const bool no_partitions_used= FALSE;
#endif
- if ((table->s->system || table->file->stats.records <= 1 ||
+ if (!table->is_filled_at_execution() &&
+ (table->s->system || table->file->stats.records <= 1 ||
no_partitions_used) &&
!s->dependent &&
(table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) &&
@@ -2945,6 +3087,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
no_rows_const_tables |= table->map;
}
}
+
stat_vector[i]=0;
join->outer_join=outer_join;
@@ -2968,6 +3111,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
if (bitmap_is_set(stat[j].dependent, i) &&
bitmap_is_set(stat[i].dependent, k))
bitmap_set_bit(stat[j].dependent, k);
+ }
}
}
*/
@@ -2988,7 +3132,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
{
if (s->dependent & s->table->map)
{
- join->tables=0; // Don't use join->table
+ join->table_count=0; // Don't use join->table
my_message(ER_WRONG_OUTER_JOIN, ER(ER_WRONG_OUTER_JOIN), MYF(0));
goto error;
}
@@ -2997,10 +3141,24 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
}
if (conds || outer_join)
- if (update_ref_and_keys(join->thd, keyuse_array, stat, join->tables,
- conds, join->cond_equal,
- ~outer_join, join->select_lex, &sargables))
+ {
+ if (update_ref_and_keys(join->thd, keyuse_array, stat, join->table_count,
+ conds, ~outer_join, join->select_lex, &sargables))
+ goto error;
+ /*
+ Keyparts without prefixes may be useful if this JOIN is a subquery, and
+ if the subquery may be executed via the IN-EXISTS strategy.
+ */
+ bool skip_unprefixed_keyparts=
+ !(join->is_in_subquery() &&
+ ((Item_in_subselect*)join->unit->item)->in_strategy & SUBS_IN_TO_EXISTS);
+
+ if (keyuse_array->elements &&
+ sort_and_filter_keyuse(join->thd, keyuse_array,
+ skip_unprefixed_keyparts))
goto error;
+ DBUG_EXECUTE("opt", print_keyuse_array(keyuse_array););
+ }
join->const_table_map= no_rows_const_tables;
join->const_tables= const_count;
@@ -3047,6 +3205,9 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
{
table=s->table;
+ if (table->is_filled_at_execution())
+ continue;
+
/*
If equi-join condition by a key is null rejecting and after a
substitution of a const table the key value happens to be null
@@ -3204,15 +3365,27 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
for (s=stat ; s < stat_end ; s++)
{
+ s->startup_cost= 0;
if (s->type == JT_SYSTEM || s->type == JT_CONST)
{
/* Only one matching row */
- s->found_records=s->records=s->read_time=1; s->worst_seeks=1.0;
+ s->found_records= s->records= 1;
+ s->read_time=1.0;
+ s->worst_seeks=1.0;
continue;
}
/* Approximate found rows and time to read them */
- s->found_records=s->records=s->table->file->stats.records;
- s->read_time=(ha_rows) s->table->file->scan_time();
+ if (s->table->is_filled_at_execution())
+ {
+ get_delayed_table_estimates(s->table, &s->records, &s->read_time,
+ &s->startup_cost);
+ s->found_records= s->records;
+ table->quick_condition_rows=s->records;
+ }
+ else
+ {
+ s->scan_time();
+ }
/*
Set a max range of how many seeks we can expect when using keys
@@ -3235,10 +3408,11 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
Don't do range analysis if we're on the inner side of an outer join (2).
Do range analysis if we're on the inner side of a semi-join (3).
*/
- if (!s->const_keys.is_clear_all() && // (1)
- (!s->table->pos_in_table_list->embedding || // (2)
- (s->table->pos_in_table_list->embedding && // (3)
- s->table->pos_in_table_list->embedding->sj_on_expr))) // (3)
+ if (!s->const_keys.is_clear_all() && // (1)
+ (!s->table->pos_in_table_list->embedding || // (2)
+ (s->table->pos_in_table_list->embedding && // (3)
+ s->table->pos_in_table_list->embedding->sj_on_expr)) && // (3)
+ !s->table->is_filled_at_execution())
{
ha_rows records;
SQL_SELECT *select;
@@ -3276,7 +3450,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
if (records != HA_POS_ERROR)
{
s->found_records=records;
- s->read_time= (ha_rows) (s->quick ? s->quick->read_time : 0.0);
+ s->read_time= s->quick ? s->quick->read_time : 0.0;
}
delete select;
}
@@ -3287,28 +3461,51 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
join->join_tab=stat;
join->map2table=stat_ref;
- join->table= join->all_tables=table_vector;
+ join->table= table_vector;
join->const_tables=const_count;
join->found_const_table_map=found_const_table_map;
- if (join->const_tables != join->tables)
+ if (join->const_tables != join->table_count)
optimize_keyuse(join, keyuse_array);
if (optimize_semijoin_nests(join, all_table_map))
DBUG_RETURN(TRUE); /* purecov: inspected */
- /* Find an optimal join order of the non-constant tables. */
- if (join->const_tables != join->tables)
- {
- if (choose_plan(join, all_table_map & ~join->const_table_map))
- goto error;
- }
- else
{
- memcpy((uchar*) join->best_positions,(uchar*) join->positions,
- sizeof(POSITION)*join->const_tables);
- join->best_read=1.0;
+ ha_rows records= 1;
+ SELECT_LEX_UNIT *unit= join->select_lex->master_unit();
+
+ /* Find an optimal join order of the non-constant tables. */
+ if (join->const_tables != join->table_count)
+ {
+ if (choose_plan(join, all_table_map & ~join->const_table_map))
+ goto error;
+ }
+ else
+ {
+ memcpy((uchar*) join->best_positions,(uchar*) join->positions,
+ sizeof(POSITION)*join->const_tables);
+ join->record_count= 1.0;
+ join->best_read=1.0;
+ }
+
+ if (!(join->select_options & SELECT_DESCRIBE) &&
+ unit->derived && unit->derived->is_materialized_derived())
+ {
+ /*
+ Calculate estimated number of rows for materialized derived
+ table/view.
+ */
+ for (i= 0; i < join->table_count ; i++)
+ records*= join->best_positions[i].records_read ?
+ (ha_rows)join->best_positions[i].records_read : 1;
+ join->select_lex->increase_derived_records(records);
+ }
}
+
+ if (join->choose_subquery_plan(all_table_map & ~join->const_table_map))
+ goto error;
+
/* Generate an execution plan from the found optimal join order. */
DBUG_RETURN(join->thd->killed || get_best_combination(join));
@@ -3319,8 +3516,12 @@ error:
may not be assigned yet by this function (which is building join_tab).
Dangling TABLE::reginfo.join_tab may cause part_of_refkey to choke.
*/
- for (tables= tables_arg; tables; tables= tables->next_leaf)
- tables->table->reginfo.join_tab= NULL;
+ {
+ TABLE_LIST *table;
+ List_iterator<TABLE_LIST> ti(tables_list);
+ while ((table= ti++))
+ table->table->reginfo.join_tab= NULL;
+ }
DBUG_RETURN (1);
}
@@ -3567,6 +3768,7 @@ static uint get_semi_join_select_list_index(Field *field)
@param field Field used in comparision
@param eq_func True if we used =, <=> or IS NULL
@param value Value used for comparison with field
+ @param num_values Number of values[] that we are comparing against
@param usable_tables Tables which can be used for key optimization
@param sargables IN/OUT Array of found sargable candidates
@@ -3585,8 +3787,11 @@ add_key_field(JOIN *join,
table_map usable_tables, SARGABLE_PARAM **sargables)
{
uint optimize= 0;
- if (eq_func && join->is_allowed_hash_join_access() &&
- field->hash_join_is_possible())
+ if (eq_func &&
+ ((join->is_allowed_hash_join_access() &&
+ field->hash_join_is_possible()) ||
+ (field->table->pos_in_table_list->is_materialized_derived() &&
+ !field->table->created)))
{
optimize= KEY_OPTIMIZE_EQ;
}
@@ -3621,7 +3826,7 @@ add_key_field(JOIN *join,
else
{
JOIN_TAB *stat=field->table->reginfo.join_tab;
- key_map possible_keys=field->key_start;
+ key_map possible_keys=field->get_possible_keys();
possible_keys.intersect(field->table->keys_in_use_for_query);
stat[0].keys.merge(possible_keys); // Add possible keys
@@ -3660,49 +3865,21 @@ add_key_field(JOIN *join,
(*sargables)->arg_value= value;
(*sargables)->num_values= num_values;
}
+
/*
- We can't always use indexes when comparing a string index to a
- number. cmp_type() is checked to allow compare of dates to numbers.
- eq_func is NEVER true when num_values > 1
+ We can't use indexes when comparing a string index to a
+ number or two strings if the effective collation
+ of the operation differ from the field collation.
*/
if (!eq_func)
- {
- /*
- Additional optimization: if we're processing
- "t.key BETWEEN c1 AND c1" then proceed as if we were processing
- "t.key = c1".
- TODO: This is a very limited fix. A more generic fix is possible.
- There are 2 options:
- A) Make equality propagation code be able to handle BETWEEN
- (including cases like t1.key BETWEEN t2.key AND t3.key)
- B) Make range optimizer to infer additional "t.key = c" equalities
- and use them in equality propagation process (see details in
- OptimizerKBAndTodo)
- */
- if ((cond->functype() != Item_func::BETWEEN) ||
- ((Item_func_between*) cond)->negated ||
- !value[0]->eq(value[1], field->binary()))
- return;
- eq_func= TRUE;
- }
+ return;
- if (field->result_type() == STRING_RESULT)
+ if (field->cmp_type() == STRING_RESULT)
{
- if ((*value)->result_type() != STRING_RESULT)
- {
- if (field->cmp_type() != (*value)->result_type())
- return;
- }
- else
- {
- /*
- We can't use indexes if the effective collation
- of the operation differ from the field collation.
- */
- if (field->cmp_type() == STRING_RESULT &&
- ((Field_str*)field)->charset() != cond->compare_collation())
+ if ((*value)->cmp_type() != STRING_RESULT)
return;
- }
+ if (((Field_str*)field)->charset() != cond->compare_collation())
+ return;
}
}
}
@@ -3811,7 +3988,7 @@ is_local_field (Item *field)
{
return field->real_item()->type() == Item::FIELD_ITEM
&& !(field->used_tables() & OUTER_REF_TABLE_BIT)
- && !((Item_field *)field->real_item())->depended_from;
+ && !((Item_field *)field->real_item())->get_depended_from();
}
@@ -3831,7 +4008,6 @@ is_local_field (Item *field)
The primary reason for having and_level attribute is the OR operation which
uses and_level to mark KEY_FIELDs that should get into the result of the OR
operation
-
*/
static void
@@ -3908,9 +4084,65 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
case Item_func::OPTIMIZE_KEY:
{
Item **values;
- // BETWEEN, IN, NE
- if (is_local_field (cond_func->key_item()) &&
- !(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
+ /*
+ Build list of possible keys for 'a BETWEEN low AND high'.
+ It is handled similar to the equivalent condition
+ 'a >= low AND a <= high':
+ */
+ if (cond_func->functype() == Item_func::BETWEEN)
+ {
+ Item_field *field_item;
+ bool equal_func= FALSE;
+ uint num_values= 2;
+ values= cond_func->arguments();
+
+ bool binary_cmp= (values[0]->real_item()->type() == Item::FIELD_ITEM)
+ ? ((Item_field*)values[0]->real_item())->field->binary()
+ : TRUE;
+
+ /*
+ Additional optimization: If 'low = high':
+ Handle as if the condition was "t.key = low".
+ */
+ if (!((Item_func_between*)cond_func)->negated &&
+ values[1]->eq(values[2], binary_cmp))
+ {
+ equal_func= TRUE;
+ num_values= 1;
+ }
+
+ /*
+ Append keys for 'field <cmp> value[]' if the
+ condition is of the form::
+ '<field> BETWEEN value[1] AND value[2]'
+ */
+ if (is_local_field(values[0]))
+ {
+ field_item= (Item_field *) (values[0]->real_item());
+ add_key_equal_fields(join, key_fields, *and_level, cond_func,
+ field_item, equal_func, &values[1],
+ num_values, usable_tables, sargables);
+ }
+ /*
+ Append keys for 'value[0] <cmp> field' if the
+ condition is of the form:
+ 'value[0] BETWEEN field1 AND field2'
+ */
+ for (uint i= 1; i <= num_values; i++)
+ {
+ if (is_local_field(values[i]))
+ {
+ field_item= (Item_field *) (values[i]->real_item());
+ add_key_equal_fields(join, key_fields, *and_level, cond_func,
+ field_item, equal_func, values,
+ 1, usable_tables, sargables);
+ }
+ }
+ } // if ( ... Item_func::BETWEEN)
+
+ // IN, NE
+ else if (is_local_field (cond_func->key_item()) &&
+ !(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
{
values= cond_func->arguments()+1;
if (cond_func->functype() == Item_func::NE_FUNC &&
@@ -3924,21 +4156,6 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
cond_func->argument_count()-1,
usable_tables, sargables);
}
- if (cond_func->functype() == Item_func::BETWEEN)
- {
- values= cond_func->arguments();
- for (uint i= 1 ; i < cond_func->argument_count() ; i++)
- {
- Item_field *field_item;
- if (is_local_field (cond_func->arguments()[i]))
- {
- field_item= (Item_field *) (cond_func->arguments()[i]->real_item());
- add_key_equal_fields(join, key_fields, *and_level, cond_func,
- field_item, 0, values, 1, usable_tables,
- sargables);
- }
- }
- }
break;
}
case Item_func::OPTIMIZE_OP:
@@ -3949,7 +4166,8 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
if (is_local_field (cond_func->arguments()[0]))
{
add_key_equal_fields(join, key_fields, *and_level, cond_func,
- (Item_field*) (cond_func->arguments()[0])->real_item(),
+ (Item_field*) (cond_func->arguments()[0])->
+ real_item(),
equal_func,
cond_func->arguments()+1, 1, usable_tables,
sargables);
@@ -3958,7 +4176,8 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
cond_func->functype() != Item_func::LIKE_FUNC)
{
add_key_equal_fields(join, key_fields, *and_level, cond_func,
- (Item_field*) (cond_func->arguments()[1])->real_item(),
+ (Item_field*) (cond_func->arguments()[1])->
+ real_item(),
equal_func,
cond_func->arguments(),1,usable_tables,
sargables);
@@ -3974,8 +4193,9 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
if (unlikely(!tmp)) // Should never be true
return;
add_key_equal_fields(join, key_fields, *and_level, cond_func,
- (Item_field*) (cond_func->arguments()[0])->real_item(),
- cond_func->functype() == Item_func::ISNULL_FUNC,
+ (Item_field*) (cond_func->arguments()[0])->
+ real_item(),
+ cond_func->functype() == Item_func::ISNULL_FUNC,
&tmp, 1, usable_tables, sargables);
}
break;
@@ -4072,10 +4292,6 @@ add_keyuse(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field,
}
else
{
- /*
- If this is a key use for hash join then keypart of
- the added element actually contains the field number.
- */
keyuse.keypart= field->field_index;
keyuse.keypart_map= (key_part_map) 0;
}
@@ -4216,6 +4432,9 @@ sort_keyuse(KEYUSE *a,KEYUSE *b)
return (int) (a->table->tablenr - b->table->tablenr);
if (a->key != b->key)
return (int) (a->key - b->key);
+ if (a->key == MAX_KEY && b->key == MAX_KEY &&
+ a->used_tables != b->used_tables)
+ return (int) ((ulong) a->used_tables - (ulong) b->used_tables);
if (a->keypart != b->keypart)
return (int) (a->keypart - b->keypart);
// Place const values before other ones
@@ -4322,11 +4541,10 @@ static void add_key_fields_for_nj(JOIN *join, TABLE_LIST *nested_join_table,
static bool
update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
- uint tables, COND *cond, COND_EQUAL *cond_equal,
- table_map normal_tables, SELECT_LEX *select_lex,
- SARGABLE_PARAM **sargables)
+ uint tables, COND *cond, table_map normal_tables,
+ SELECT_LEX *select_lex, SARGABLE_PARAM **sargables)
{
- uint and_level,i,found_eq_constant;
+ uint and_level,i;
KEY_FIELD *key_fields, *end, *field;
uint sz;
uint m= max(select_lex->max_equal_elems,1);
@@ -4366,19 +4584,21 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
if (my_init_dynamic_array(keyuse,sizeof(KEYUSE),20,64))
return TRUE;
+
if (cond)
{
+ KEY_FIELD *saved_field= field;
add_key_fields(join_tab->join, &end, &and_level, cond, normal_tables,
sargables);
for (; field != end ; field++)
{
- if (add_key_part(keyuse,field))
- return TRUE;
+
/* Mark that we can optimize LEFT JOIN */
if (field->val->type() == Item::NULL_ITEM &&
!field->field->real_maybe_null())
field->field->table->reginfo.not_exists_optimize=1;
}
+ field= saved_field;
}
for (i=0 ; i < tables ; i++)
{
@@ -4422,73 +4642,85 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
return TRUE;
}
- /*
- Sort the array of possible keys and remove the following key parts:
- - ref if there is a keypart which is a ref and a const.
- (e.g. if there is a key(a,b) and the clause is a=3 and b=7 and b=t2.d,
- then we skip the key part corresponding to b=t2.d)
- - keyparts without previous keyparts
- (e.g. if there is a key(a,b,c) but only b < 5 (or a=2 and c < 3) is
- used in the query, we drop the partial key parts from consideration).
- Special treatment for ft-keys.
- */
- if (keyuse->elements)
- {
- KEYUSE key_end,*prev,*save_pos,*use;
+ return FALSE;
+}
- my_qsort(keyuse->buffer,keyuse->elements,sizeof(KEYUSE),
- (qsort_cmp) sort_keyuse);
- bzero((char*) &key_end,sizeof(key_end)); /* Add for easy testing */
- if (insert_dynamic(keyuse,(uchar*) &key_end))
- return TRUE;
+/**
+ Sort the array of possible keys and remove the following key parts:
+ - ref if there is a keypart which is a ref and a const.
+ (e.g. if there is a key(a,b) and the clause is a=3 and b=7 and b=t2.d,
+ then we skip the key part corresponding to b=t2.d)
+ - keyparts without previous keyparts
+ (e.g. if there is a key(a,b,c) but only b < 5 (or a=2 and c < 3) is
+ used in the query, we drop the partial key parts from consideration).
+ Special treatment for ft-keys.
+*/
+
+static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
+ bool skip_unprefixed_keyparts)
+{
+ KEYUSE key_end, *prev, *save_pos, *use;
+ uint found_eq_constant, i;
+
+ DBUG_ASSERT(keyuse->elements);
+
+ my_qsort(keyuse->buffer, keyuse->elements, sizeof(KEYUSE),
+ (qsort_cmp) sort_keyuse);
- use=save_pos=dynamic_element(keyuse,0,KEYUSE*);
- prev= &key_end;
- found_eq_constant=0;
- for (i=0 ; i < keyuse->elements-1 ; i++,use++)
+ bzero((char*) &key_end, sizeof(key_end)); /* Add for easy testing */
+ if (insert_dynamic(keyuse, (uchar*) &key_end))
+ return TRUE;
+
+ if (optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_WITH_KEYS))
+ generate_derived_keys(keyuse);
+
+ use= save_pos= dynamic_element(keyuse,0,KEYUSE*);
+ prev= &key_end;
+ found_eq_constant= 0;
+ for (i=0 ; i < keyuse->elements-1 ; i++,use++)
+ {
+ if (!use->is_for_hash_join())
{
- if (!use->is_for_hash_join())
+ if (!use->used_tables && use->optimize != KEY_OPTIMIZE_REF_OR_NULL)
+ use->table->const_key_parts[use->key]|= use->keypart_map;
+ if (use->keypart != FT_KEYPART)
{
- if (!use->used_tables && use->optimize != KEY_OPTIMIZE_REF_OR_NULL)
- use->table->const_key_parts[use->key]|= use->keypart_map;
- if (use->keypart != FT_KEYPART)
+ if (use->key == prev->key && use->table == prev->table)
{
- if (use->key == prev->key && use->table == prev->table)
- {
- if (prev->keypart+1 < use->keypart ||
- (prev->keypart == use->keypart && found_eq_constant))
- continue; /* remove */
- }
- else if (use->keypart != 0) // First found must be 0
- continue;
+ if ((prev->keypart+1 < use->keypart && skip_unprefixed_keyparts) ||
+ (prev->keypart == use->keypart && found_eq_constant))
+ continue; /* remove */
}
-
- prev= use;
- found_eq_constant= !use->used_tables;
- use->table->reginfo.join_tab->checked_keys.set_bit(use->key);
+ else if (use->keypart != 0 && skip_unprefixed_keyparts)
+ continue; /* remove - first found must be 0 */
}
- /*
- Old gcc used a memcpy(), which is undefined if save_pos==use:
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19410
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39480
- This also disables a valgrind warning, so better to have the test.
- */
- if (save_pos != use)
- *save_pos= *use;
- /* Save ptr to first use */
- if (!use->table->reginfo.join_tab->keyuse)
- use->table->reginfo.join_tab->keyuse= save_pos;
- save_pos++;
- }
- i=(uint) (save_pos-(KEYUSE*) keyuse->buffer);
- VOID(set_dynamic(keyuse,(uchar*) &key_end,i));
- keyuse->elements=i;
- }
- DBUG_EXECUTE("opt", print_keyuse_array(keyuse););
+
+ prev= use;
+ found_eq_constant= !use->used_tables;
+ use->table->reginfo.join_tab->checked_keys.set_bit(use->key);
+ }
+ /*
+ Old gcc used a memcpy(), which is undefined if save_pos==use:
+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19410
+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39480
+ This also disables a valgrind warning, so better to have the test.
+ */
+ if (save_pos != use)
+ *save_pos= *use;
+ /* Save ptr to first use */
+ if (!use->table->reginfo.join_tab->keyuse)
+ use->table->reginfo.join_tab->keyuse= save_pos;
+ save_pos++;
+ }
+ i= (uint) (save_pos-(KEYUSE*) keyuse->buffer);
+ VOID(set_dynamic(keyuse,(uchar*) &key_end,i));
+ keyuse->elements= i;
+
return FALSE;
}
+
/**
Update some values in keyuse for faster choose_plan() loop.
*/
@@ -4514,10 +4746,10 @@ static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array)
~OUTER_REF_TABLE_BIT)))
{
uint tablenr;
- for (tablenr=0 ; ! (map & 1) ; map>>=1, tablenr++) ;
+ tablenr= my_count_bits(map);
if (map == 1) // Only one table
{
- TABLE *tmp_table=join->all_tables[tablenr];
+ TABLE *tmp_table=join->table[tablenr];
keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
}
}
@@ -4778,8 +5010,8 @@ best_access_path(JOIN *join,
if (!(keyuse->used_tables & ~join->const_table_map))
const_part|= keyuse->keypart_map;
- double tmp2= prev_record_reads(join, idx, (found_ref |
- keyuse->used_tables));
+ double tmp2= prev_record_reads(join->positions, idx,
+ (found_ref | keyuse->used_tables));
if (tmp2 < best_prev_record_reads)
{
best_part_found_ref= keyuse->used_tables & ~join->const_table_map;
@@ -4819,7 +5051,7 @@ best_access_path(JOIN *join,
Really, there should be records=0.0 (yes!)
but 1.0 would be probably safer
*/
- tmp= prev_record_reads(join, idx, found_ref);
+ tmp= prev_record_reads(join->positions, idx, found_ref);
records= 1.0;
}
else
@@ -4834,7 +5066,7 @@ best_access_path(JOIN *join,
max_key_part= (uint) ~0;
if ((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME)
{
- tmp = prev_record_reads(join, idx, found_ref);
+ tmp = prev_record_reads(join->positions, idx, found_ref);
records=1.0;
}
else
@@ -5074,8 +5306,9 @@ best_access_path(JOIN *join,
else
tmp= best_time; // Do nothing
}
- loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp);
+ tmp += s->startup_cost;
+ loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp);
} /* not ft_key */
if (tmp + 0.0001 < best_time - records/(double) TIME_FOR_COMPARE)
{
@@ -5152,13 +5385,19 @@ best_access_path(JOIN *join,
Since we have a 'ref' access path, and FORCE INDEX instructs us to
choose it over ALL/index, there is no need to consider a full table
scan.
+ (5) Non-flattenable semi-joins: don't consider doing a scan of temporary
+ table if we had an option to make lookups into it. In real-world cases,
+ lookups are cheaper than full scans, but when the table is small, they
+ can be [considered to be] more expensive, which causes lookups not to
+ be used for cases with small datasets, which is annoying.
*/
if ((records >= s->found_records || best > s->read_time) && // (1)
!(s->quick && best_key && s->quick->index == best_key->key && // (2)
best_max_key_part >= s->table->quick_key_parts[best_key->key]) &&// (2)
!((s->table->file->ha_table_flags() & HA_TABLE_SCAN_ON_INDEX) && // (3)
! s->table->covering_keys.is_clear_all() && best_key && !s->quick) &&// (3)
- !(s->table->force_index && best_key && !s->quick)) // (4)
+ !(s->table->force_index && best_key && !s->quick) && // (4)
+ !(best_key && s->table->pos_in_table_list->jtbm_subselect)) // (5)
{ // Check full join
ha_rows rnd_records= matching_candidates_in_table(s, found_constraint);
@@ -5188,7 +5427,7 @@ best_access_path(JOIN *join,
else
{
/* Estimate cost of reading table. */
- tmp= s->table->file->scan_time();
+ tmp= s->scan_time();
if ((s->table->map & join->outer_join) || disable_jbuf) // Can't use join cache
{
/*
@@ -5217,6 +5456,7 @@ best_access_path(JOIN *join,
}
}
+ tmp += s->startup_cost;
/*
We estimate the cost of evaluating WHERE clause for found records
as record_count * rnd_records / TIME_FOR_COMPARE. This cost plus
@@ -5240,7 +5480,7 @@ best_access_path(JOIN *join,
join->outer_join)));
}
}
-
+
/* Update the cost information for the current partial plan */
pos->records_read= records;
pos->read_time= best;
@@ -5318,7 +5558,7 @@ choose_plan(JOIN *join, table_map join_tables)
jtab_sort_func= straight_join ? join_tab_cmp_straight : join_tab_cmp;
}
my_qsort2(join->best_ref + join->const_tables,
- join->tables - join->const_tables, sizeof(JOIN_TAB*),
+ join->table_count - join->const_tables, sizeof(JOIN_TAB*),
jtab_sort_func, (void*)join->emb_sjm_nest);
join->cur_sj_inner_tables= 0;
@@ -5494,7 +5734,7 @@ join_tab_cmp_embedded_first(const void *emb, const void* ptr1, const void* ptr2
static uint
determine_search_depth(JOIN *join)
{
- uint table_count= join->tables - join->const_tables;
+ uint table_count= join->table_count - join->const_tables;
uint search_depth;
/* TODO: this value should be determined dynamically, based on statistics: */
uint max_tables_for_exhaustive_opt= 7;
@@ -5540,6 +5780,7 @@ optimize_straight_join(JOIN *join, table_map join_tables)
{
JOIN_TAB *s;
uint idx= join->const_tables;
+ bool disable_jbuf= join->thd->variables.join_cache_level == 0;
double record_count= 1.0;
double read_time= 0.0;
POSITION loose_scan_pos;
@@ -5547,7 +5788,7 @@ optimize_straight_join(JOIN *join, table_map join_tables)
for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++)
{
/* Find the best access method from 's' to the current partial plan */
- best_access_path(join, s, join_tables, idx, FALSE, record_count,
+ best_access_path(join, s, join_tables, idx, disable_jbuf, record_count,
join->positions + idx, &loose_scan_pos);
/* compute the cost of the new plan extended with 's' */
@@ -5566,6 +5807,7 @@ optimize_straight_join(JOIN *join, table_map join_tables)
read_time+= record_count; // We have to make a temp table
memcpy((uchar*) join->best_positions, (uchar*) join->positions,
sizeof(POSITION)*idx);
+ join->record_count= record_count;
join->best_read= read_time;
}
@@ -5747,40 +5989,102 @@ greedy_search(JOIN *join,
}
-/*
- Calculate a cost of given partial join order
+/**
+ Get cost of execution and fanout produced by selected tables in the join
+ prefix (where prefix is defined as prefix in depth-first traversal)
- SYNOPSIS
- get_partial_join_cost()
- join IN Join to use. join->positions holds the
- partial join order
- idx IN # tables in the partial join order
- read_time_arg OUT Store read time here
- record_count_arg OUT Store record count here
-
- DESCRIPTION
-
- This is needed for semi-join materialization code. The idea is that
- we detect sj-materialization after we've put all sj-inner tables into
- the join prefix
+ @param end_tab_idx The number of last tab to be taken into
+ account (in depth-first traversal prefix)
+ @param filter_map Bitmap of tables whose cost/fanout are to
+ be taken into account.
+ @param read_time_arg [out] store read time here
+ @param record_count_arg [out] store record count here
- prefix-tables semi-join-inner-tables tN
- ^--we're here
+ @note
- and we'll need to get the cost of prefix-tables prefix again.
+ @returns
+ read_time_arg and record_count_arg contain the computed cost and fanout
*/
-void get_partial_join_cost(JOIN *join, uint n_tables, double *read_time_arg,
- double *record_count_arg)
+void JOIN::get_partial_cost_and_fanout(uint end_tab_idx,
+ table_map filter_map,
+ double *read_time_arg,
+ double *record_count_arg)
{
double record_count= 1;
double read_time= 0.0;
- for (uint i= join->const_tables; i < n_tables + join->const_tables ; i++)
+ double sj_inner_fanout= 1.0;
+ JOIN_TAB *end_tab= NULL;
+ JOIN_TAB *tab;
+ uint i;
+ uint last_sj_table= MAX_TABLES;
+
+ /*
+ Handle a special case where the join is degenerate, and produces no
+ records
+ */
+ if (table_count == 0)
+ {
+ *read_time_arg= 0.0;
+ /*
+ We return 1, because
+ - it is the pessimistic estimate (there might be grouping)
+ - it's safer, as we're less likely to hit the edge cases in
+ calculations.
+ */
+ *record_count_arg=1.0;
+ }
+
+ for (tab= first_depth_first_tab(this), i= const_tables;
+ tab;
+ tab= next_depth_first_tab(this, tab), i++)
{
- if (join->best_positions[i].records_read)
+ end_tab= tab;
+ if (i == end_tab_idx)
+ break;
+ }
+
+ for (tab= first_depth_first_tab(this), i= const_tables;
+ tab;
+ tab= next_depth_first_tab(this, tab), i++)
+ {
+ /*
+ We've entered the SJM nest that contains the end_tab. The caller is
+ actually
+ - interested in fanout inside the nest (because that's how many times
+ we'll invoke the attached WHERE conditions)
+ - not interested in cost
+ */
+ if (end_tab->bush_root_tab && end_tab->bush_root_tab == tab)
{
- record_count *= join->best_positions[i].records_read;
- read_time += join->best_positions[i].read_time;
+ /* Ok, end_tab is inside SJM nest and we're entering that nest now */
+ record_count= 1.0;
+ read_time= 0.0;
+ }
+
+ /*
+ Ignore fanout (but not cost) from sj-inner tables, as long as
+ the range that processes them finishes before the end_tab
+ */
+ if (tab->sj_strategy != SJ_OPT_NONE)
+ {
+ sj_inner_fanout= 1.0;
+ last_sj_table= i + tab->n_sj_tables;
+ }
+
+ if (tab->records_read && (tab->table->map & filter_map))
+ {
+ record_count *= tab->records_read;
+ read_time += tab->read_time;
+ if (tab->emb_sj_nest)
+ sj_inner_fanout *= tab->records_read;
+ }
+
+ if (i == last_sj_table)
+ {
+ record_count /= sj_inner_fanout;
+ sj_inner_fanout= 1.0;
+ last_sj_table= MAX_TABLES;
}
}
*read_time_arg= read_time;// + record_count / TIME_FOR_COMPARE;
@@ -5788,6 +6092,34 @@ void get_partial_join_cost(JOIN *join, uint n_tables, double *read_time_arg,
}
+/*
+ Get prefix cost and fanout. This function is different from
+ get_partial_cost_and_fanout:
+ - it operates on a JOIN that haven't yet finished its optimization phase (in
+ particular, fix_semijoin_strategies_for_picked_join_order() and
+ get_best_combination() haven't been called)
+ - it assumes the the join prefix doesn't have any semi-join plans
+
+ These assumptions are met by the caller of the function.
+*/
+
+void JOIN::get_prefix_cost_and_fanout(uint n_tables,
+ double *read_time_arg,
+ double *record_count_arg)
+{
+ double record_count= 1;
+ double read_time= 0.0;
+ for (uint i= const_tables; i < n_tables + const_tables ; i++)
+ {
+ if (best_positions[i].records_read)
+ {
+ record_count *= best_positions[i].records_read;
+ read_time += best_positions[i].read_time;
+ }
+ }
+ *read_time_arg= read_time;// + record_count / TIME_FOR_COMPARE;
+ *record_count_arg= record_count;
+}
/**
@@ -5932,6 +6264,7 @@ best_extension_by_limited_search(JOIN *join,
JOIN_TAB *s;
double best_record_count= DBL_MAX;
double best_read_time= DBL_MAX;
+ bool disable_jbuf= join->thd->variables.join_cache_level == 0;
DBUG_EXECUTE("opt", print_plan(join, idx, record_count, read_time, read_time,
"part_plan"););
@@ -5957,8 +6290,8 @@ best_extension_by_limited_search(JOIN *join,
/* Find the best access method from 's' to the current partial plan */
POSITION loose_scan_pos;
- best_access_path(join, s, remaining_tables, idx, FALSE, record_count,
- join->positions + idx, &loose_scan_pos);
+ best_access_path(join, s, remaining_tables, idx, disable_jbuf,
+ record_count, join->positions + idx, &loose_scan_pos);
/* Compute the cost of extending the plan with 's' */
@@ -6046,6 +6379,7 @@ best_extension_by_limited_search(JOIN *join,
{
memcpy((uchar*) join->best_positions, (uchar*) join->positions,
sizeof(POSITION) * (idx + 1));
+ join->record_count= current_record_count;
join->best_read= current_read_time - 0.001;
}
DBUG_EXECUTE("opt", print_plan(join, idx+1,
@@ -6102,6 +6436,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
JOIN_TAB *s;
double best_record_count=DBL_MAX,best_read_time=DBL_MAX;
+ bool disable_jbuf= join->thd->variables.join_cache_level == 0;
for (JOIN_TAB **pos=join->best_ref+idx ; (s=*pos) ; pos++)
{
table_map real_table_bit=s->table->map;
@@ -6110,7 +6445,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
{
double records, best;
POSITION loose_scan_pos;
- best_access_path(join, s, rest_tables, idx, FALSE, record_count,
+ best_access_path(join, s, rest_tables, idx, disable_jbuf, record_count,
join->positions + idx, &loose_scan_pos);
records= join->positions[idx].records_read;
best= join->positions[idx].read_time;
@@ -6197,8 +6532,8 @@ void JOIN_TAB::calc_used_field_length(bool max_fl)
set_if_smaller(rec_length, table->file->stats.mean_rec_length);
/*
- psergey-todo: why we don't count here rowid that we might need to store
- when using DuplicateElimination?
+ TODO: why we don't count here rowid that we might need to store when
+ using DuplicateElimination?
*/
used_fields=fields;
used_fieldlength=rec_length;
@@ -6232,10 +6567,11 @@ int JOIN_TAB::make_scan_filter()
Item *cond= is_inner_table_of_outer_join() ?
*get_first_inner_table()->on_expr_ref : join->conds;
-
+
if (cond &&
- (tmp=make_cond_for_table(cond, join->const_table_map | table->map,
- table->map, FALSE, TRUE)))
+ (tmp= make_cond_for_table(join->thd, cond,
+ join->const_table_map | table->map,
+ table->map, MAX_TABLES, FALSE, TRUE)))
{
DBUG_EXECUTE("where",print_where(tmp,"cache", QT_ORDINARY););
if (!(cache_select=
@@ -6347,12 +6683,12 @@ cache_record_length(JOIN *join,uint idx)
Expected number of row combinations
*/
-static double
-prev_record_reads(JOIN *join, uint idx, table_map found_ref)
+double
+prev_record_reads(POSITION *positions, uint idx, table_map found_ref)
{
double found=1.0;
- POSITION *pos_end= join->positions - 1;
- for (POSITION *pos= join->positions + idx - 1; pos != pos_end; pos--)
+ POSITION *pos_end= positions - 1;
+ for (POSITION *pos= positions + idx - 1; pos != pos_end; pos--)
{
if (pos->table->table->map & found_ref)
{
@@ -6382,6 +6718,210 @@ prev_record_reads(JOIN *join, uint idx, table_map found_ref)
/*
+ Enumerate join tabs in breadth-first fashion, including const tables.
+*/
+
+JOIN_TAB *first_breadth_first_tab(JOIN *join)
+{
+ return join->join_tab; /* There's always one (i.e. first) table */
+}
+
+
+JOIN_TAB *next_breadth_first_tab(JOIN *join, JOIN_TAB *tab)
+{
+ if (!tab->bush_root_tab)
+ {
+ /* We're at top level. Get the next top-level tab */
+ tab++;
+ if (tab < join->join_tab + join->top_join_tab_count)
+ return tab;
+
+ /* No more top-level tabs. Switch to enumerating SJM nest children */
+ tab= join->join_tab;
+ }
+ else
+ {
+ /* We're inside of an SJM nest */
+ if (!tab->last_leaf_in_bush)
+ {
+ /* There's one more table in the nest, return it. */
+ return ++tab;
+ }
+ else
+ {
+ /*
+ There are no more tables in this nest. Get out of it and then we'll
+ proceed to the next nest.
+ */
+ tab= tab->bush_root_tab + 1;
+ }
+ }
+
+ /*
+ Ok, "tab" points to a top-level table, and we need to find the next SJM
+ nest and enter it.
+ */
+ for (; tab < join->join_tab + join->top_join_tab_count; tab++)
+ {
+ if (tab->bush_children)
+ return tab->bush_children->start;
+ }
+ return NULL;
+}
+
+
+JOIN_TAB *first_top_level_tab(JOIN *join, enum enum_with_const_tables with_const)
+{
+ JOIN_TAB *tab= join->join_tab;
+ if (with_const == WITH_CONST_TABLES)
+ {
+ if (join->const_tables == join->table_count)
+ return NULL;
+ tab += join->const_tables;
+ }
+ return tab;
+}
+
+
+JOIN_TAB *next_top_level_tab(JOIN *join, JOIN_TAB *tab)
+{
+ tab= next_breadth_first_tab(join, tab);
+ if (tab && tab->bush_root_tab)
+ tab= NULL;
+ return tab;
+}
+
+
+JOIN_TAB *first_linear_tab(JOIN *join, enum enum_with_const_tables const_tbls)
+{
+ JOIN_TAB *first= join->join_tab;
+ if (const_tbls == WITHOUT_CONST_TABLES)
+ first+= join->const_tables;
+ if (first < join->join_tab + join->top_join_tab_count)
+ return first;
+ return NULL; /* All tables were const tables */
+}
+
+
+/*
+ A helper function to loop over all join's join_tab in sequential fashion
+
+ DESCRIPTION
+ Depending on include_bush_roots parameter, JOIN_TABs that represent
+ SJM-scan/lookups are either returned or omitted.
+
+ SJM-Bush children are returned right after (or in place of) their container
+ join tab (TODO: does anybody depend on this? A: make_join_readinfo() seems
+ to)
+
+ For example, if we have this structure:
+
+ ot1--ot2--sjm1----------------ot3-...
+ |
+ +--it1--it2--it3
+
+ calls to next_linear_tab( include_bush_roots=TRUE) will return:
+
+ ot1 ot2 sjm1 it1 it2 it3 ot3 ...
+
+ while calls to next_linear_tab( include_bush_roots=FALSE) will return:
+
+ ot1 ot2 it1 it2 it3 ot3 ...
+
+ (note that sjm1 won't be returned).
+*/
+
+JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab,
+ enum enum_with_bush_roots include_bush_roots)
+{
+ if (include_bush_roots == WITH_BUSH_ROOTS && tab->bush_children)
+ {
+ /* This JOIN_TAB is a SJM nest; Start from first table in nest */
+ return tab->bush_children->start;
+ }
+
+ DBUG_ASSERT(!tab->last_leaf_in_bush || tab->bush_root_tab);
+
+ if (tab->bush_root_tab) /* Are we inside an SJM nest */
+ {
+ /* Inside SJM nest */
+ if (!tab->last_leaf_in_bush)
+ return tab+1; /* Return next in nest */
+ /* Continue from the sjm on the top level */
+ tab= tab->bush_root_tab;
+ }
+
+ /* If no more JOIN_TAB's on the top level */
+ if (++tab == join->join_tab + join->top_join_tab_count)
+ return NULL;
+
+ if (include_bush_roots == WITHOUT_BUSH_ROOTS && tab->bush_children)
+ {
+ /* This JOIN_TAB is a SJM nest; Start from first table in nest */
+ tab= tab->bush_children->start;
+ }
+ return tab;
+}
+
+
+/*
+ Start to iterate over all join tables in bush-children-first order, excluding
+ the const tables (see next_depth_first_tab() comment for details)
+*/
+
+JOIN_TAB *first_depth_first_tab(JOIN* join)
+{
+ JOIN_TAB* tab;
+ /* This means we're starting the enumeration */
+ if (join->const_tables == join->top_join_tab_count)
+ return NULL;
+
+ tab= join->join_tab + join->const_tables;
+
+ return (tab->bush_children) ? tab->bush_children->start : tab;
+}
+
+
+/*
+ A helper function to iterate over all join tables in bush-children-first order
+
+ DESCRIPTION
+
+ For example, for this join plan
+
+ ot1--ot2--sjm1------------ot3-...
+ |
+ |
+ it1--it2--it3
+
+ call to first_depth_first_tab() will return ot1, and subsequent calls to
+ next_depth_first_tab() will return:
+
+ ot2 it1 it2 it3 sjm ot3 ...
+*/
+
+JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab)
+{
+ /* If we're inside SJM nest and have reached its end, get out */
+ if (tab->last_leaf_in_bush)
+ return tab->bush_root_tab;
+
+ /* Move to next tab in the array we're traversing */
+ tab++;
+
+ if (tab == join->join_tab +join->top_join_tab_count)
+ return NULL; /* Outside SJM nest and reached EOF */
+
+ if (tab->bush_children)
+ return tab->bush_children->start;
+
+ return tab;
+}
+
+
+static Item * const null_ptr= NULL;
+
+/*
Set up join struct according to the picked join order in
SYNOPSIS
@@ -6396,6 +6936,11 @@ prev_record_reads(JOIN *join, uint idx, table_map found_ref)
- create join->join_tab array and put there the JOIN_TABs in the join order
- create data structures describing ref access methods.
+ NOTE
+ In this function we switch from pre-join-optimization JOIN_TABs to
+ post-join-optimization JOIN_TABs. This is achieved by copying the entire
+ JOIN_TAB objects.
+
RETURN
FALSE OK
TRUE Out of memory
@@ -6404,7 +6949,7 @@ prev_record_reads(JOIN *join, uint idx, table_map found_ref)
static bool
get_best_combination(JOIN *join)
{
- uint i,tablenr;
+ uint tablenr;
table_map used_tables;
JOIN_TAB *join_tab,*j;
KEYUSE *keyuse;
@@ -6412,7 +6957,7 @@ get_best_combination(JOIN *join)
THD *thd=join->thd;
DBUG_ENTER("get_best_combination");
- table_count=join->tables;
+ table_count=join->table_count;
if (!(join->join_tab=join_tab=
(JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*table_count)))
DBUG_RETURN(TRUE);
@@ -6423,10 +6968,71 @@ get_best_combination(JOIN *join)
fix_semijoin_strategies_for_picked_join_order(join);
+ JOIN_TAB_RANGE *root_range;
+ if (!(root_range= new JOIN_TAB_RANGE))
+ DBUG_RETURN(TRUE);
+ root_range->start= join->join_tab;
+ /* root_range->end will be set later */
+ join->join_tab_ranges.empty();
+
+ if (join->join_tab_ranges.push_back(root_range))
+ DBUG_RETURN(TRUE);
+
+ JOIN_TAB *sjm_nest_end= NULL;
+ JOIN_TAB *sjm_nest_root= NULL;
+
for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++)
{
TABLE *form;
+ POSITION *cur_pos= &join->best_positions[tablenr];
+ if (cur_pos->sj_strategy == SJ_OPT_MATERIALIZE ||
+ cur_pos->sj_strategy == SJ_OPT_MATERIALIZE_SCAN)
+ {
+ /*
+ Ok, we've entered an SJ-Materialization semi-join (note that this can't
+ be done recursively, semi-joins are not allowed to be nested).
+ 1. Put into main join order a JOIN_TAB that represents a lookup or scan
+ in the temptable.
+ */
+ bzero(j, sizeof(JOIN_TAB));
+ j->join= join;
+ j->table= NULL; //temporary way to tell SJM tables from others.
+ j->ref.key = -1;
+ j->on_expr_ref= (Item**) &null_ptr;
+ j->keys= key_map(1); /* The unique index is always in 'possible keys' in EXPLAIN */
+
+ /*
+ 2. Proceed with processing SJM nest's join tabs, putting them into the
+ sub-order
+ */
+ SJ_MATERIALIZATION_INFO *sjm= cur_pos->table->emb_sj_nest->sj_mat_info;
+ j->records= j->records_read= (ha_rows)(sjm->is_sj_scan? sjm->rows : 1);
+ JOIN_TAB *jt;
+ JOIN_TAB_RANGE *jt_range;
+ if (!(jt= (JOIN_TAB*)join->thd->alloc(sizeof(JOIN_TAB)*sjm->tables)) ||
+ !(jt_range= new JOIN_TAB_RANGE))
+ DBUG_RETURN(TRUE);
+ jt_range->start= jt;
+ jt_range->end= jt + sjm->tables;
+ join->join_tab_ranges.push_back(jt_range);
+ j->bush_children= jt_range;
+ sjm_nest_end= jt + sjm->tables;
+ sjm_nest_root= j;
+
+ j= jt;
+ }
+
*j= *join->best_positions[tablenr].table;
+
+#if 0
+/* SJ-Materialization is represented with join tab ranges */
+ if (j->sj_strategy == SJ_OPT_MATERIALIZE ||
+ j->sj_strategy == SJ_OPT_MATERIALIZE)
+ j->sj_strategy= SJ_OPT_NONE;
+#endif
+
+ j->bush_root_tab= sjm_nest_root;
+
form=join->table[tablenr]=j->table;
used_tables|= form->map;
form->reginfo.join_tab=j;
@@ -6434,14 +7040,14 @@ get_best_combination(JOIN *join)
form->reginfo.not_exists_optimize=0; // Only with LEFT JOIN
DBUG_PRINT("info",("type: %d", j->type));
if (j->type == JT_CONST)
- continue; // Handled in make_join_stat..
+ goto loop_end; // Handled in make_join_stat..
j->loosescan_match_tab= NULL; //non-nulls will be set later
j->ref.key = -1;
j->ref.key_parts=0;
if (j->type == JT_SYSTEM)
- continue;
+ goto loop_end;
if ( !(keyuse= join->best_positions[tablenr].key) ||
(join->best_positions[tablenr].sj_strategy == SJ_OPT_LOOSE_SCAN))
{
@@ -6452,10 +7058,27 @@ get_best_combination(JOIN *join)
}
else if (create_ref_for_key(join, j, keyuse, used_tables))
DBUG_RETURN(TRUE); // Something went wrong
+ loop_end:
+ /*
+ Save records_read in JOIN_TAB so that select_describe()/etc don't have
+ to access join->best_positions[].
+ */
+ j->records_read= (ha_rows)join->best_positions[tablenr].records_read;
+ join->map2table[j->table->tablenr]= j;
+
+ /* If we've reached the end of sjm nest, switch back to main sequence */
+ if (j + 1 == sjm_nest_end)
+ {
+ j->last_leaf_in_bush= TRUE;
+ j= sjm_nest_root;
+ sjm_nest_root= NULL;
+ sjm_nest_end= NULL;
+ }
}
+ root_range->end= j;
- for (i=0 ; i < table_count ; i++)
- join->map2table[join->join_tab[i].table->tablenr]=join->join_tab+i;
+ join->top_join_tab_count= join->join_tab_ranges.head()->end -
+ join->join_tab_ranges.head()->start;
update_depend_map(join);
DBUG_RETURN(0);
}
@@ -6649,8 +7272,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
if (keyuse->null_rejecting)
j->ref.null_rejecting |= 1 << i;
keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables;
- if (!keyuse->used_tables &&
- !(join->select_options & SELECT_DESCRIBE))
+ if (!keyuse->used_tables && !thd->lex->describe)
{ // Compare against constant
store_key_item tmp(thd,
keyinfo->key_part[i].field,
@@ -6727,9 +7349,10 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables,
}
else if (keyuse->val->type() == Item::FIELD_ITEM ||
(keyuse->val->type() == Item::REF_ITEM &&
- ((Item_ref*)keyuse->val)->ref_type() == Item_ref::OUTER_REF &&
- (*(Item_ref**)((Item_ref*)keyuse->val)->ref)->ref_type() ==
- Item_ref::DIRECT_REF &&
+ ((((Item_ref*)keyuse->val)->ref_type() == Item_ref::OUTER_REF &&
+ (*(Item_ref**)((Item_ref*)keyuse->val)->ref)->ref_type() ==
+ Item_ref::DIRECT_REF) ||
+ ((Item_ref*)keyuse->val)->ref_type() == Item_ref::VIEW_REF) &&
keyuse->val->real_item()->type() == Item::FIELD_ITEM))
return new store_key_field(thd,
key_part->field,
@@ -6802,7 +7425,8 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table)
join_tab= parent->join_tab_reexec;
table= &parent->table_reexec[0]; parent->table_reexec[0]= temp_table;
- tables= 1;
+ table_count= top_join_tab_count= 1;
+
const_tables= 0;
const_table_map= 0;
eliminated_tables= 0;
@@ -6839,6 +7463,7 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table)
join_tab->ref.key = -1;
join_tab->not_used_in_distinct=0;
join_tab->read_first_record= join_init_read_record;
+ join_tab->preread_init_done= FALSE;
join_tab->join= this;
join_tab->ref.key_parts= 0;
join_tab->keep_current_rowid= FALSE;
@@ -6847,6 +7472,9 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table)
join_tab->loosescan_match_tab= NULL;
join_tab->emb_sj_nest= NULL;
join_tab->pre_idx_push_select_cond= NULL;
+ join_tab->bush_root_tab= NULL;
+ join_tab->bush_children= NULL;
+ join_tab->last_leaf_in_bush= FALSE;
bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record));
temp_table->status=0;
temp_table->null_row=0;
@@ -6854,7 +7482,7 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table)
}
-inline void add_cond_and_fix(Item **e1, Item *e2)
+inline void add_cond_and_fix(THD *thd, Item **e1, Item *e2)
{
if (*e1)
{
@@ -6864,7 +7492,7 @@ inline void add_cond_and_fix(Item **e1, Item *e2)
if ((res= new Item_cond_and(*e1, e2)))
{
*e1= res;
- res->quick_fix_field();
+ res->fix_fields(thd, 0);
res->update_used_tables();
}
}
@@ -6927,9 +7555,11 @@ inline void add_cond_and_fix(Item **e1, Item *e2)
static void add_not_null_conds(JOIN *join)
{
DBUG_ENTER("add_not_null_conds");
- for (uint i=join->const_tables ; i < join->tables ; i++)
+
+ for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
- JOIN_TAB *tab=join->join_tab+i;
if (tab->type == JT_REF || tab->type == JT_EQ_REF ||
tab->type == JT_REF_OR_NULL)
{
@@ -6968,14 +7598,14 @@ static void add_not_null_conds(JOIN *join)
COND *new_cond= referred_tab->join == join ?
referred_tab->select_cond :
join->outer_ref_cond;
- add_cond_and_fix(&new_cond, notnull);
+ add_cond_and_fix(join->thd, &new_cond, notnull);
if (referred_tab->join == join)
referred_tab->set_select_cond(new_cond, __LINE__);
else
join->outer_ref_cond= new_cond;
}
else
- add_cond_and_fix(tab->first_inner->on_expr_ref, notnull);
+ add_cond_and_fix(join->thd, tab->first_inner->on_expr_ref, notnull);
}
}
}
@@ -7058,14 +7688,21 @@ add_found_match_trig_cond(JOIN_TAB *tab, COND *cond, JOIN_TAB *root_tab)
This function can be called only after the execution plan
has been chosen.
*/
+
static void
make_outerjoin_info(JOIN *join)
{
DBUG_ENTER("make_outerjoin_info");
- for (uint i=join->const_tables ; i < join->tables ; i++)
+ for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES); tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
- JOIN_TAB *tab=join->join_tab+i;
TABLE *table=tab->table;
+ /*
+ psergey: The following is probably incorrect, fix it when we get
+ semi+outer joins processing to work:
+ */
+ if (!table)
+ continue;
TABLE_LIST *tbl= table->pos_in_table_list;
TABLE_LIST *embedding= tbl->embedding;
@@ -7085,7 +7722,7 @@ make_outerjoin_info(JOIN *join)
for ( ; embedding ; embedding= embedding->embedding)
{
/* Ignore sj-nests: */
- if (!embedding->on_expr)
+ if (!(embedding->on_expr && embedding->outer_join))
continue;
NESTED_JOIN *nested_join= embedding->nested_join;
if (!nested_join->counter)
@@ -7136,9 +7773,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
*/
if (cond) /* Because of QUICK_GROUP_MIN_MAX_SELECT */
{ /* there may be a select without a cond. */
- if (join->tables > 1)
+ if (join->table_count > 1)
cond->update_used_tables(); // Tablenr may have changed
- if (join->const_tables == join->tables &&
+ if (join->const_tables == join->table_count &&
thd->lex->current_select->master_unit() ==
&thd->lex->unit) // not upper level SELECT
join->const_table_map|=RAND_TABLE_BIT;
@@ -7151,51 +7788,32 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
there inside the triggers.
*/
{ // Check const tables
- COND *const_cond=
- make_cond_for_table(cond,
+ join->exec_const_cond=
+ make_cond_for_table(thd, cond,
join->const_table_map,
- (table_map) 0, TRUE, FALSE);
+ (table_map) 0, MAX_TABLES, FALSE, FALSE);
/* Add conditions added by add_not_null_conds(). */
for (uint i= 0 ; i < join->const_tables ; i++)
- add_cond_and_fix(&const_cond, join->join_tab[i].select_cond);
+ add_cond_and_fix(thd, &join->exec_const_cond,
+ join->join_tab[i].select_cond);
- DBUG_EXECUTE("where",print_where(const_cond,"constants", QT_ORDINARY););
- for (JOIN_TAB *tab= join->join_tab+join->const_tables;
- tab < join->join_tab+join->tables ; tab++)
+ DBUG_EXECUTE("where",print_where(join->exec_const_cond,"constants",
+ QT_ORDINARY););
+ if (join->exec_const_cond && !join->exec_const_cond->is_expensive() &&
+ !join->exec_const_cond->val_int())
{
- if (*tab->on_expr_ref)
- {
- JOIN_TAB *cond_tab= tab->first_inner;
- COND *tmp= make_cond_for_table(*tab->on_expr_ref,
- join->const_table_map,
- (table_map) 0, FALSE, FALSE);
- if (!tmp)
- continue;
- tmp= new Item_func_trig_cond(tmp, &cond_tab->not_null_compl);
- if (!tmp)
- DBUG_RETURN(1);
- tmp->quick_fix_field();
- COND *new_cond= !cond_tab->select_cond ? tmp :
- new Item_cond_and(cond_tab->select_cond, tmp);
- cond_tab->set_select_cond(new_cond, __LINE__);
- if (!cond_tab->select_cond)
- DBUG_RETURN(1);
- cond_tab->select_cond->update_used_tables();
- cond_tab->select_cond->quick_fix_field();
- }
- }
- if (const_cond && !const_cond->val_int())
- {
- DBUG_PRINT("info",("Found impossible WHERE condition"));
- DBUG_RETURN(1); // Impossible const condition
+ DBUG_PRINT("info",("Found impossible WHERE condition"));
+ join->exec_const_cond= NULL;
+ DBUG_RETURN(1); // Impossible const condition
}
- COND *outer_ref_cond= make_cond_for_table(cond,
+ COND *outer_ref_cond= make_cond_for_table(thd, cond,
+ OUTER_REF_TABLE_BIT,
OUTER_REF_TABLE_BIT,
- (table_map) 0, FALSE, FALSE);
+ MAX_TABLES, FALSE, FALSE);
if (outer_ref_cond)
{
- add_cond_and_fix(&outer_ref_cond, join->outer_ref_cond);
+ add_cond_and_fix(thd, &outer_ref_cond, join->outer_ref_cond);
join->outer_ref_cond= outer_ref_cond;
}
}
@@ -7209,16 +7827,22 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
OUTER_REF_TABLE_BIT | RAND_TABLE_BIT);
JOIN_TAB *tab;
table_map current_map;
- for (uint i=join->const_tables ; i < join->tables ; i++)
+ uint i= join->const_tables;
+ for (tab= first_depth_first_tab(join); tab;
+ tab= next_depth_first_tab(join, tab), i++)
{
bool is_hj;
- tab= join->join_tab+i;
/*
first_inner is the X in queries like:
SELECT * FROM t1 LEFT OUTER JOIN (t2 JOIN t3) ON X
*/
- JOIN_TAB *first_inner_tab= tab->first_inner;
- current_map= tab->table->map;
+ JOIN_TAB *first_inner_tab= tab->first_inner;
+
+ if (tab->table)
+ current_map= tab->table->map;
+ else
+ current_map= tab->bush_children->start->emb_sj_nest->sj_inner_tables;
+
bool use_quick_range=0;
COND *tmp;
@@ -7241,7 +7865,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
Following force including random expression in last table condition.
It solve problem with select like SELECT * FROM t1 WHERE rand() > 0.5
*/
- if (i == join->tables-1)
+ if (tab == join->join_tab + join->top_join_tab_count - 1)
current_map|= OUTER_REF_TABLE_BIT | RAND_TABLE_BIT;
used_tables|=current_map;
@@ -7261,16 +7885,30 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
We will use join cache here : prevent sorting of the first
table only and sort at the end.
*/
- if (i != join->const_tables && join->tables > join->const_tables + 1)
+ if (i != join->const_tables && join->table_count > join->const_tables + 1)
join->full_join= 1;
}
tmp= NULL;
+
if (cond)
- tmp= make_cond_for_table(cond, used_tables, current_map, FALSE, FALSE);
- /* Add conditions added by add_not_null_conds(). */
- if (tab->select_cond)
- add_cond_and_fix(&tmp, tab->select_cond);
+ {
+ if (tab->bush_children)
+ {
+ // Reached the materialization tab
+ tmp= make_cond_after_sjm(cond, cond, save_used_tables, used_tables);
+ used_tables= save_used_tables | used_tables;
+ save_used_tables= 0;
+ }
+ else
+ {
+ tmp= make_cond_for_table(thd, cond, used_tables, current_map, i,
+ FALSE, FALSE);
+ }
+ /* Add conditions added by add_not_null_conds(). */
+ if (tab->select_cond)
+ add_cond_and_fix(thd, &tmp, tab->select_cond);
+ }
is_hj= (tab->type == JT_REF || tab->type == JT_EQ_REF) &&
(join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT) &&
@@ -7309,9 +7947,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
if (tmp || !cond || tab->type == JT_REF || tab->type == JT_REF_OR_NULL ||
tab->type == JT_EQ_REF || first_inner_tab)
{
- DBUG_EXECUTE("where",
- print_where(tmp,tab->table->alias.c_ptr(),
- QT_ORDINARY););
+ DBUG_EXECUTE("where",print_where(tmp,
+ tab->table? tab->table->alias.c_ptr() :"sjm-nest",
+ QT_ORDINARY););
SQL_SELECT *sel= tab->select= ((SQL_SELECT*)
thd->memdup((uchar*) select,
sizeof(*select)));
@@ -7335,15 +7973,20 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
tab->set_select_cond(tmp, __LINE__);
/* Push condition to storage engine if this is enabled
and the condition is not guarded */
- if (thd->variables.engine_condition_pushdown && !first_inner_tab)
+ if (tab->table)
{
- COND *push_cond=
- make_cond_for_table(tmp, current_map, current_map, FALSE, FALSE);
- if (push_cond)
+ tab->table->file->pushed_cond= NULL;
+ if (thd->variables.engine_condition_pushdown && !first_inner_tab)
{
- /* Push condition to handler */
- if (!tab->table->file->cond_push(push_cond))
- tab->table->file->pushed_cond= push_cond;
+ COND *push_cond=
+ make_cond_for_table(thd, tmp, current_map, current_map,
+ MAX_TABLES, FALSE, FALSE);
+ if (push_cond)
+ {
+ /* Push condition to handler */
+ if (!tab->table->file->cond_push(push_cond))
+ tab->table->file->pushed_cond= push_cond;
+ }
}
}
}
@@ -7355,7 +7998,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
sel->head=tab->table;
DBUG_EXECUTE("where",
- print_where(tmp,tab->table->alias.c_ptr(),
+ print_where(tmp,
+ tab->table ? tab->table->alias.c_ptr() :
+ "(sjm-nest)",
QT_ORDINARY););
if (tab->quick)
{
@@ -7363,7 +8008,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
with key reading */
if ((tab->needed_reg.is_clear_all() && tab->type != JT_EQ_REF
&& tab->type != JT_FT &&
- (tab->type != JT_REF ||
+ ((tab->type != JT_REF && tab->type != JT_CONST) ||
(uint) tab->ref.key == tab->quick->index)) || is_hj)
{
sel->quick=tab->quick; // Use value from get_quick_...
@@ -7376,7 +8021,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
tab->quick=0;
}
- uint ref_key=(uint) sel->head->reginfo.join_tab->ref.key+1;
+ uint ref_key= sel->head? (uint) sel->head->reginfo.join_tab->ref.key+1 : 0;
if (i == join->const_tables && ref_key)
{
if (!tab->const_keys.is_clear_all() &&
@@ -7395,12 +8040,12 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
the index if we are using limit and this is the first table
*/
- if ((cond &&
- (!tab->keys.is_subset(tab->const_keys) && i > 0)) ||
- (!tab->const_keys.is_clear_all() && i == join->const_tables &&
- join->unit->select_limit_cnt <
- join->best_positions[i].records_read &&
- !(join->select_options & OPTION_FOUND_ROWS)))
+ if (!tab->table->is_filled_at_execution() &&
+ ((cond && (!tab->keys.is_subset(tab->const_keys) && i > 0)) ||
+ (!tab->const_keys.is_clear_all() && i == join->const_tables &&
+ join->unit->select_limit_cnt <
+ join->best_positions[i].records_read &&
+ !(join->select_options & OPTION_FOUND_ROWS))))
{
/* Join with outer join condition */
COND *orig_cond=sel->cond;
@@ -7417,7 +8062,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
sel->cond->quick_fix_field();
if (sel->test_quick_select(thd, tab->keys,
- (used_tables & ~ current_map) | OUTER_REF_TABLE_BIT,
+ ((used_tables & ~ current_map) |
+ OUTER_REF_TABLE_BIT),
(join->select_options &
OPTION_FOUND_ROWS ?
HA_POS_ERROR :
@@ -7473,7 +8119,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
/*
- Push down conditions from all on expressions.
+ Push down conditions from all ON expressions.
Each of these conditions are guarded by a variable
that turns if off just before null complemented row for
outer joins is formed. Thus, the condition from an
@@ -7482,15 +8128,16 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
*/
/* First push down constant conditions from on expressions */
- for (JOIN_TAB *join_tab= join->join_tab+join->const_tables;
- join_tab < join->join_tab+join->tables ; join_tab++)
+ for (JOIN_TAB *join_tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ join_tab;
+ join_tab= next_linear_tab(join, join_tab, WITH_BUSH_ROOTS))
{
if (*join_tab->on_expr_ref)
{
JOIN_TAB *cond_tab= join_tab->first_inner;
- COND *tmp= make_cond_for_table(*join_tab->on_expr_ref,
+ COND *tmp= make_cond_for_table(thd, *join_tab->on_expr_ref,
join->const_table_map,
- (table_map) 0, FALSE, FALSE);
+ (table_map) 0, MAX_TABLES, FALSE, FALSE);
if (!tmp)
continue;
tmp= new Item_func_trig_cond(tmp, &cond_tab->not_null_compl);
@@ -7508,10 +8155,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
}
}
- /* Push down non-constant conditions from on expressions */
+ /* Push down non-constant conditions from ON expressions */
+ //JOIN_TAB *first_tab= join->join_tab+join->const_tables;
JOIN_TAB *last_tab= tab;
while (first_inner_tab && first_inner_tab->last_inner == last_tab)
- {
+ {
/*
Table tab is the last inner table of an outer join.
An on expression is always attached to it.
@@ -7520,14 +8168,29 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
table_map used_tables2= (join->const_table_map |
OUTER_REF_TABLE_BIT | RAND_TABLE_BIT);
- for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++)
+ for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ tab;
+ tab= (tab == last_tab)? NULL: next_linear_tab(join, tab,
+ WITH_BUSH_ROOTS))
{
+ if (!tab->table)
+ {
+ /*
+ psergey-todo: this is probably incorrect, fix this when we get
+ correct processing for outer joins + semi joins
+ */
+ continue;
+ }
current_map= tab->table->map;
used_tables2|= current_map;
- COND *tmp_cond= make_cond_for_table(on_expr, used_tables2,
- current_map, FALSE, FALSE);
+ /*
+ psergey: have put the MAX_TABLES below. It's bad, will need to fix it.
+ */
+ COND *tmp_cond= make_cond_for_table(thd, on_expr, used_tables2,
+ current_map, /*(tab - first_tab)*/ MAX_TABLES,
+ FALSE, FALSE);
if (tab == first_inner_tab && tab->on_precond)
- add_cond_and_fix(&tmp_cond, tab->on_precond);
+ add_cond_and_fix(thd, &tmp_cond, tab->on_precond);
if (tmp_cond)
{
JOIN_TAB *cond_tab= tab < first_inner_tab ? first_inner_tab : tab;
@@ -7567,44 +8230,154 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
(*sel_cond_ref)->update_used_tables();
if (cond_tab->select)
cond_tab->select->cond= cond_tab->select_cond;
- }
+ }
}
first_inner_tab= first_inner_tab->first_upper;
}
+ }
+ }
+ DBUG_RETURN(0);
+}
- if (save_used_tables && !(used_tables &
- ~(tab->emb_sj_nest->sj_inner_tables |
- join->const_table_map | PSEUDO_TABLE_BITS)))
+
+static
+uint get_next_field_for_derived_key(uchar *arg)
+{
+ KEYUSE *keyuse= *(KEYUSE **) arg;
+ if (!keyuse)
+ return (uint) (-1);
+ TABLE *table= keyuse->table;
+ uint key= keyuse->key;
+ uint fldno= keyuse->keypart;
+ uint keypart= keyuse->keypart_map == (key_part_map) 1 ?
+ 0 : (keyuse-1)->keypart+1;
+ for ( ;
+ keyuse->table == table && keyuse->key == key && keyuse->keypart == fldno;
+ keyuse++)
+ keyuse->keypart= keypart;
+ if (keyuse->key != key)
+ keyuse= 0;
+ return fldno;
+}
+
+
+static
+bool generate_derived_keys_for_table(KEYUSE *keyuse, uint count, uint keys)
+{
+ TABLE *table= keyuse->table;
+ if (table->alloc_keys(keys))
+ return TRUE;
+ uint keyno= 0;
+ KEYUSE *first_keyuse= keyuse;
+ uint prev_part= (uint) (-1);
+ uint parts= 0;
+ uint i= 0;
+ do
+ {
+ keyuse->key= keyno;
+ keyuse->keypart_map= (key_part_map) (1 << parts);
+ keyuse++;
+ if (++i == count || keyuse->used_tables != first_keyuse->used_tables)
+ {
+ if (table->add_tmp_key(keyno, ++parts,
+ get_next_field_for_derived_key,
+ (uchar *) &first_keyuse,
+ FALSE))
+ return TRUE;
+ table->reginfo.join_tab->keys.set_bit(keyno);
+ first_keyuse= keyuse;
+ keyno++;
+ parts= 0;
+ }
+ else if (keyuse->keypart != prev_part)
+ {
+ parts++;
+ prev_part= keyuse->keypart;
+ }
+ } while (keyno < keys);
+ return FALSE;
+}
+
+
+static
+bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array)
+{
+ KEYUSE *keyuse= dynamic_element(keyuse_array, 0, KEYUSE*);
+ uint elements= keyuse_array->elements;
+ TABLE *prev_table= 0;
+ for (uint i= 0; i < elements; i++, keyuse++)
+ {
+ if (!keyuse->table)
+ break;
+ KEYUSE *first_table_keyuse= NULL;
+ table_map last_used_tables= 0;
+ uint count= 0;
+ uint keys= 0;
+ TABLE_LIST *derived= NULL;
+ if (keyuse->table != prev_table)
+ derived= keyuse->table->pos_in_table_list;
+ while (derived && derived->is_materialized_derived() &&
+ keyuse->key == MAX_KEY)
+ {
+ if (keyuse->table != prev_table)
{
- /*
- We have reached the end of semi join nest. That is, the join order
- looks like this:
-
- outer_tbl1 SJ-Materialize(inner_tbl1 ... inner_tblN) outer_tbl ...
- ^
- \-we're here
- At this point, we need to produce two conditions
- - A condition that can be checked when we have all of the sj-inner
- tables (inner_tbl1 ... inner_tblN). This will be used while doing
- materialization.
- - A condition that can be checked when we have all of the tables
- in the prefix (both inner and outer).
- */
- tab->emb_sj_nest->sj_mat_info->join_cond=
- cond ?
- make_cond_after_sjm(cond, cond, save_used_tables, used_tables):
- NULL;
- used_tables= save_used_tables | used_tables;
- save_used_tables= 0;
+ prev_table= keyuse->table;
+ first_table_keyuse= keyuse;
+ last_used_tables= keyuse->used_tables;
+ count= 0;
+ keys= 0;
+ }
+ else if (keyuse->used_tables != last_used_tables)
+ {
+ keys++;
+ last_used_tables= keyuse->used_tables;
+ }
+ count++;
+ keyuse++;
+ if (keyuse->table != prev_table)
+ {
+ if (generate_derived_keys_for_table(first_table_keyuse, count, ++keys))
+ return TRUE;
+ keyuse--;
+ derived= NULL;
}
-
}
}
- DBUG_RETURN(0);
+ return FALSE;
}
/*
+ @brief
+ Drops unused keys for each materialized derived table/view
+
+ @details
+ For materialized derived tables only ref access can be used, it employs
+ only one index, thus we don't need the rest. For each materialized derived
+ table/view call TABLE::use_index to save one index chosen by the optimizer
+ and free others. No key is chosen then all keys will be dropped.
+*/
+
+void JOIN::drop_unused_derived_keys()
+{
+ JOIN_TAB *tab;
+ for (tab= first_linear_tab(this, WITHOUT_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(this, tab, WITHOUT_BUSH_ROOTS))
+ {
+
+ TABLE *table=tab->table;
+ if (!table)
+ continue;
+ if (!table->pos_in_table_list->is_materialized_derived() ||
+ table->max_keys <= 1)
+ continue;
+ table->use_index(tab->ref.key);
+ tab->ref.key= 0;
+ }
+}
+
+/*
Determine {after which table we'll produce ordered set}
SYNOPSIS
@@ -7628,11 +8401,17 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
static uint make_join_orderinfo(JOIN *join)
{
+ /*
+ This function needs to be fixed to take into account that we now have SJM
+ nests.
+ */
+ DBUG_ASSERT(0);
+
JOIN_TAB *tab;
if (join->need_tmp)
- return join->tables;
+ return join->table_count;
tab= join->get_sort_by_join_tab();
- return tab ? tab-join->join_tab : join->tables;
+ return tab ? tab-join->join_tab : join->table_count;
}
/*
@@ -7806,7 +8585,7 @@ void revise_cache_usage(JOIN_TAB *join_tab)
SYNOPSIS
end_sj_materialize()
join The join
- join_tab Last join table
+ join_tab Points to right after the last join_tab in materialization bush
end_of_records FALSE <=> This call is made to pass another record
combination
TRUE <=> EOF (no action)
@@ -7824,7 +8603,7 @@ void revise_cache_usage(JOIN_TAB *join_tab)
NESTED_LOOP_ERROR
*/
-static enum_nested_loop_state
+enum_nested_loop_state
end_sj_materialize(JOIN *join, JOIN_TAB *join_tab, bool end_of_records)
{
int error;
@@ -7999,6 +8778,7 @@ static
uint check_join_cache_usage(JOIN_TAB *tab,
ulonglong options,
uint no_jbuf_after,
+ uint table_index,
JOIN_TAB *prev_tab)
{
COST_VECT cost;
@@ -8014,11 +8794,14 @@ uint check_join_cache_usage(JOIN_TAB *tab,
!(join->allowed_join_cache_types & JOIN_CACHE_HASHED_BIT);
bool no_bka_cache=
!(join->allowed_join_cache_types & JOIN_CACHE_BKA_BIT);
- uint i= tab - join->join_tab;
join->return_tab= 0;
- if (cache_level == 0 || i == join->const_tables || !prev_tab)
+ /*
+ Don't use join cache if @@join_cache_level==0 or this table is the first
+ one join suborder (either at top level or inside a bush)
+ */
+ if (cache_level == 0 || !prev_tab)
return 0;
if (force_unlinked_cache && (cache_level%2 == 0))
@@ -8026,10 +8809,7 @@ uint check_join_cache_usage(JOIN_TAB *tab,
if (options & SELECT_NO_JOIN_CACHE)
goto no_join_cache;
- /*
- psergey-todo: why the below when execution code seems to handle the
- "range checked for each record" case?
- */
+
if (tab->use_quick == 2)
goto no_join_cache;
@@ -8052,11 +8832,16 @@ uint check_join_cache_usage(JOIN_TAB *tab,
}
/*
- Don't use join buffering if we're dictated not to by no_jbuf_after (this
- ...)
+ Don't use join buffering if we're dictated not to by no_jbuf_after
+ (This is not meaningfully used currently)
+ */
+ if (table_index > no_jbuf_after)
+ goto no_join_cache;
+
+ /*
+ TODO: BNL join buffer should be perfectly ok with tab->bush_children.
*/
- if (!(i <= no_jbuf_after) || tab->loosescan_match_tab ||
- sj_is_materialize_strategy(join->best_positions[i].sj_strategy))
+ if (tab->loosescan_match_tab || tab->bush_children)
goto no_join_cache;
for (JOIN_TAB *first_inner= tab->first_inner; first_inner;
@@ -8186,6 +8971,9 @@ no_join_cache:
join join whose tables are to be checked
options options of the join
no_jbuf_after don't use join buffering after table with this number
+ (The tables are assumed to be numbered in
+ first_linear_tab(join, WITHOUT_CONST_TABLES),
+ next_linear_tab(join, WITH_CONST_TABLES) order).
DESCRIPTION
For each table after the first non-constant table the function checks
@@ -8209,29 +8997,36 @@ no_join_cache:
void check_join_cache_usage_for_tables(JOIN *join, ulonglong options,
uint no_jbuf_after)
{
- JOIN_TAB *first_sjm_table= NULL;
- JOIN_TAB *last_sjm_table= NULL;
+ JOIN_TAB *tab;
+ JOIN_TAB *prev_tab;
- for (uint i= join->const_tables; i < join->tables; i++)
- join->join_tab[i].used_join_cache_level= join->max_allowed_join_cache_level;
-
- for (uint i= join->const_tables; i < join->tables; i++)
+ for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
- JOIN_TAB *tab= join->join_tab+i;
-
- if (sj_is_materialize_strategy(join->best_positions[i].sj_strategy))
- {
- first_sjm_table= tab;
- last_sjm_table= tab + join->best_positions[i].n_sj_tables;
- for (JOIN_TAB *sjm_tab= first_sjm_table;
- sjm_tab != last_sjm_table; sjm_tab++)
- sjm_tab->first_sjm_sibling= first_sjm_table;
- }
- if (!(tab >= first_sjm_table && tab < last_sjm_table))
- tab->first_sjm_sibling= NULL;
-
+ tab->used_join_cache_level= join->max_allowed_join_cache_level;
+ }
+
+ uint idx= join->const_tables;
+ for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
+ {
+restart:
tab->icp_other_tables_ok= TRUE;
tab->idx_cond_fact_out= TRUE;
+
+ /*
+ Check if we have a preceding join_tab, as something that will feed us
+ records that we could buffer. We don't have it, if
+ - this is the first non-const table in the join order,
+ - this is the first table inside an SJM nest.
+ */
+ prev_tab= tab - 1;
+ if (tab == join->join_tab + join->const_tables ||
+ (tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab))
+ prev_tab= NULL;
+
switch (tab->type) {
case JT_SYSTEM:
case JT_CONST:
@@ -8241,16 +9036,25 @@ void check_join_cache_usage_for_tables(JOIN *join, ulonglong options,
case JT_ALL:
tab->used_join_cache_level= check_join_cache_usage(tab, options,
no_jbuf_after,
- tab == last_sjm_table ?
- first_sjm_table :
- tab-1);
+ idx,
+ prev_tab);
tab->use_join_cache= test(tab->used_join_cache_level);
+ /*
+ psergey-merge: todo: raise the question that this is really stupid that
+ we can first allocate a join buffer, then decide not to use it and free
+ it.
+ */
if (join->return_tab)
- i= join->return_tab-join->join_tab-1; // always >= 0
+ {
+ tab= join->return_tab;
+ goto restart;
+ }
break;
default:
tab->used_join_cache_level= 0;
- }
+ }
+ if (!tab->bush_children)
+ idx++;
}
}
@@ -8280,8 +9084,8 @@ void check_join_cache_usage_for_tables(JOIN *join, ulonglong options,
static bool
make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
{
+ JOIN_TAB *tab;
uint i;
-
DBUG_ENTER("make_join_readinfo");
bool statistics= test(!(join->select_options & SELECT_DESCRIBE));
@@ -8290,36 +9094,67 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
if (!join->select_lex->sj_nests.is_empty() &&
setup_semijoin_dups_elimination(join, options, no_jbuf_after))
DBUG_RETURN(TRUE); /* purecov: inspected */
+
+ /* For const tables, set partial_join_cardinality to 1. */
+ for (tab= join->join_tab; tab != join->join_tab + join->const_tables; tab++)
+ tab->partial_join_cardinality= 1;
- for (i= 0; i < join->const_tables; i++)
- join->join_tab[i].partial_join_cardinality= 1;
-
- for (i=join->const_tables ; i < join->tables ; i++)
+ JOIN_TAB *prev_tab= NULL;
+ for (tab= first_linear_tab(join, WITHOUT_CONST_TABLES), i= join->const_tables;
+ tab;
+ prev_tab=tab, tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
/*
The approximation below for partial join cardinality is not good because
- it does not take into account some pushdown predicates
- - it does not differentiate between inner joins, outer joins and semi-joins.
+ - it does not differentiate between inner joins, outer joins and
+ semi-joins.
Later it should be improved.
*/
- JOIN_TAB *tab=join->join_tab+i;
+
+ if (tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab)
+ prev_tab= NULL;
+ DBUG_ASSERT(tab->bush_children || tab->table == join->best_positions[i].table->table);
+
tab->partial_join_cardinality= join->best_positions[i].records_read *
- (i ? (tab-1)->partial_join_cardinality : 1);
+ (prev_tab? prev_tab->partial_join_cardinality : 1);
+ if (!tab->bush_children)
+ i++;
}
check_join_cache_usage_for_tables(join, options, no_jbuf_after);
-
- for (i=join->const_tables ; i < join->tables ; i++)
+
+ JOIN_TAB *first_tab;
+ for (tab= first_tab= first_linear_tab(join, WITHOUT_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
- JOIN_TAB *tab=join->join_tab+i;
+ if (tab->bush_children)
+ {
+ if (setup_sj_materialization(tab))
+ return TRUE;
+ }
+
TABLE *table=tab->table;
uint jcl= tab->used_join_cache_level;
tab->read_record.table= table;
tab->read_record.file=table->file;
tab->read_record.unlock_row= rr_unlock_row;
- tab->next_select=sub_select; /* normal select */
tab->sorted= sorted;
sorted= 0; // only first must be sorted
+
+
+ /*
+ We should not set tab->next_select for the last table in the
+ SMJ-nest, as setup_sj_materialization() has already set it to
+ end_sj_materialize.
+ */
+ if (!(tab->bush_root_tab &&
+ tab->bush_root_tab->bush_children->end == tab + 1))
+ {
+ tab->next_select=sub_select; /* normal select */
+ }
+
if (tab->loosescan_match_tab)
{
@@ -8328,20 +9163,6 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
return TRUE; /* purecov: inspected */
tab->sorted= TRUE;
}
-
- /*
- SJ-Materialization
- */
- if (sj_is_materialize_strategy(join->best_positions[i].sj_strategy))
- {
- if (i == join->const_tables)
- join->first_select= sub_select_sjm;
- else
- tab[-1].next_select= sub_select_sjm;
-
- if (setup_sj_materialization(tab))
- return TRUE;
- }
table->status=STATUS_NO_RECORD;
pick_table_access_method (tab);
@@ -8411,8 +9232,9 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
}
else
{
- tab->read_first_record= join_init_read_record;
- if (i == join->const_tables)
+ if (!tab->bush_children)
+ tab->read_first_record= join_init_read_record;
+ if (tab == first_tab)
{
if (tab->select && tab->select->quick)
{
@@ -8434,14 +9256,16 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
if (tab->select && tab->select->quick)
{
if (statistics)
- status_var_increment(join->thd->status_var.select_full_range_join_count);
+ status_var_increment(join->thd->status_var.
+ select_full_range_join_count);
}
else
{
join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
if (statistics)
{
- status_var_increment(join->thd->status_var.select_full_join_count);
+ status_var_increment(join->thd->status_var.
+ select_full_join_count);
join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
}
}
@@ -8455,17 +9279,19 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
else if (!table->covering_keys.is_clear_all() &&
!(tab->select && tab->select->quick))
{ // Only read index tree
+#ifdef BAD_OPTIMIZATION
/*
- It has turned out that the below change, while speeding things
- up for disk-bound loads, slows them down for cases when the data
- is in disk cache (see BUG#35850):
- // See bug #26447: "Using the clustered index for a table scan
- // is always faster than using a secondary index".
+ It has turned out that the below change, while speeding things
+ up for disk-bound loads, slows them down for cases when the data
+ is in disk cache (see BUG#35850):
+ See bug #26447: "Using the clustered index for a table scan
+ is always faster than using a secondary index".
+ */
if (table->s->primary_key != MAX_KEY &&
table->file->primary_key_is_clustered())
tab->index= table->s->primary_key;
else
- */
+#endif
tab->index=find_shortest_key(table, & table->covering_keys);
tab->read_first_record= join_read_first;
/* Read with index_first / index_next */
@@ -8479,23 +9305,28 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
break;
case JT_FT:
break;
+ /* purecov: begin deadcode */
default:
- DBUG_PRINT("error",("Table type %d found",tab->type)); /* purecov: deadcode */
- break; /* purecov: deadcode */
+ DBUG_PRINT("error",("Table type %d found",tab->type));
+ break;
case JT_UNKNOWN:
case JT_MAYBE_REF:
- abort(); /* purecov: deadcode */
+ abort();
+ /* purecov: end */
}
}
- join->join_tab[join->tables-1].next_select=0; /* Set by do_select */
+ uint n_top_tables= join->join_tab_ranges.head()->end -
+ join->join_tab_ranges.head()->start;
+
+ join->join_tab[n_top_tables - 1].next_select=0; /* Set by do_select */
-/*
+ /*
If a join buffer is used to join a table the ordering by an index
for the first non-constant table cannot be employed anymore.
*/
- for (i=join->const_tables ; i < join->tables ; i++)
+ for (tab= join->join_tab + join->const_tables ;
+ tab != join->join_tab + n_top_tables ; tab++)
{
- JOIN_TAB *tab=join->join_tab+i;
if (tab->use_join_cache)
{
JOIN_TAB *sort_by_tab= join->group && join->simple_group &&
@@ -8541,9 +9372,8 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
bool error_if_full_join(JOIN *join)
{
- for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables;
- tab < end;
- tab++)
+ for (JOIN_TAB *tab=first_top_level_tab(join, WITH_CONST_TABLES); tab;
+ tab= next_top_level_tab(join, tab))
{
if (tab->type == JT_ALL && (!tab->select || !tab->select->quick))
{
@@ -8560,10 +9390,17 @@ bool error_if_full_join(JOIN *join)
/**
cleanup JOIN_TAB.
+
+ DESCRIPTION
+ This is invoked when we've finished all join executions.
*/
void JOIN_TAB::cleanup()
{
+ DBUG_ENTER("JOIN_TAB::cleanup");
+ DBUG_PRINT("enter", ("table %s.%s",
+ (table ? table->s->db.str : "?"),
+ (table ? table->s->table_name.str : "?")));
delete select;
select= 0;
delete quick;
@@ -8578,6 +9415,15 @@ void JOIN_TAB::cleanup()
{
table->disable_keyread();
table->file->ha_index_or_rnd_end();
+ preread_init_done= FALSE;
+ if (table->pos_in_table_list &&
+ table->pos_in_table_list->jtbm_subselect)
+ {
+ end_read_record(&read_record);
+ //psergey-merge:
+ table->pos_in_table_list->jtbm_subselect->cleanup();
+ DBUG_VOID_RETURN;
+ }
/*
We need to reset this for next select
(Tested in part_of_refkey)
@@ -8585,10 +9431,71 @@ void JOIN_TAB::cleanup()
table->reginfo.join_tab= 0;
}
end_read_record(&read_record);
+ DBUG_VOID_RETURN;
}
/**
+ Estimate the time to get rows of the joined table
+*/
+
+double JOIN_TAB::scan_time()
+{
+ double res;
+ if (table->created)
+ {
+ if (table->is_filled_at_execution())
+ {
+ get_delayed_table_estimates(table, &records, &read_time,
+ &startup_cost);
+ found_records= records;
+ table->quick_condition_rows= records;
+ }
+ else
+ {
+ found_records= records= table->file->stats.records;
+ read_time= table->file->scan_time();
+ /*
+ table->quick_condition_rows has already been set to
+ table->file->stats.records
+ */
+ }
+ res= read_time;
+ }
+ else
+ {
+ found_records= records=table->file->stats.records;
+ read_time= found_records ? found_records: 10;// TODO:fix this stub
+ res= read_time;
+ }
+ return res;
+}
+
+/**
+ Initialize the join_tab before reading.
+ Currently only derived table/view materialization is done here.
+*/
+bool JOIN_TAB::preread_init()
+{
+ TABLE_LIST *derived= table->pos_in_table_list;
+ if (!derived || !derived->is_materialized_derived())
+ {
+ preread_init_done= TRUE;
+ return FALSE;
+ }
+
+ /* Materialize derived table/view. */
+ if (!derived->get_unit()->executed &&
+ mysql_handle_single_derived(join->thd->lex,
+ derived, DT_CREATE | DT_FILL))
+ return TRUE;
+ preread_init_done= TRUE;
+ return FALSE;
+}
+
+
+
+/**
Build a TABLE_REF structure for index lookup in the temporary table
@param thd Thread handle
@@ -8705,7 +9612,8 @@ void JOIN::join_free()
Optimization: if not EXPLAIN and we are done with the JOIN,
free all tables.
*/
- bool full= (!select_lex->uncacheable && !thd->lex->describe);
+ bool full= (!(select_lex->uncacheable) &&
+ !thd->lex->describe);
bool can_unlock= full;
DBUG_ENTER("JOIN::join_free");
@@ -8769,15 +9677,16 @@ void JOIN::join_free()
void JOIN::cleanup(bool full)
{
DBUG_ENTER("JOIN::cleanup");
+ DBUG_PRINT("enter", ("full %u", (uint) full));
if (table)
{
- JOIN_TAB *tab,*end;
+ JOIN_TAB *tab;
/*
Only a sorted table may be cached. This sorted table is always the
first non const table in join->table
*/
- if (tables > const_tables) // Test for not-const tables
+ if (table_count > const_tables) // Test for not-const tables
{
free_io_cache(table[const_tables]);
filesort_free_buffers(table[const_tables],full);
@@ -8785,16 +9694,24 @@ void JOIN::cleanup(bool full)
if (full)
{
- for (tab= join_tab, end= tab+tables; tab != end; tab++)
+ for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
+ tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
+ {
tab->cleanup();
+ }
table= 0;
}
else
{
- for (tab= join_tab, end= tab+tables; tab != end; tab++)
+ for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
+ tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
if (tab->table)
+ {
+ DBUG_PRINT("info", ("close index: %s.%s", tab->table->s->db.str,
+ tab->table->s->table_name.str));
tab->table->file->ha_index_or_rnd_end();
+ }
}
}
}
@@ -8856,6 +9773,8 @@ void JOIN::cleanup(bool full)
SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b ORDER BY t1.a,t2.c
SELECT * FROM t1,t2 WHERE t1.a=t2.a ORDER BY t2.b,t1.a
@endcode
+
+ TODO: this function checks ORDER::used, which can only have a value of 0.
*/
static bool
@@ -8929,9 +9848,8 @@ only_eq_ref_tables(JOIN *join,ORDER *order,table_map tables)
static void update_depend_map(JOIN *join)
{
- JOIN_TAB *join_tab=join->join_tab, *end=join_tab+join->tables;
-
- for (; join_tab != end ; join_tab++)
+ for (JOIN_TAB *join_tab= first_linear_tab(join, WITH_CONST_TABLES); join_tab;
+ join_tab= next_linear_tab(join, join_tab, WITH_BUSH_ROOTS))
{
TABLE_REF *ref= &join_tab->ref;
table_map depend_map=0;
@@ -8942,11 +9860,11 @@ static void update_depend_map(JOIN *join)
ref->depend_map=depend_map & ~OUTER_REF_TABLE_BIT;
depend_map&= ~OUTER_REF_TABLE_BIT;
for (JOIN_TAB **tab=join->map2table;
- depend_map ;
- tab++,depend_map>>=1 )
+ depend_map ;
+ tab++,depend_map>>=1 )
{
if (depend_map & 1)
- ref->depend_map|=(*tab)->ref.depend_map;
+ ref->depend_map|=(*tab)->ref.depend_map;
}
}
}
@@ -8954,7 +9872,7 @@ static void update_depend_map(JOIN *join)
/** Update the dependency map for the sort order. */
-static void update_depend_map(JOIN *join, ORDER *order)
+static void update_depend_map_for_order(JOIN *join, ORDER *order)
{
for (; order ; order=order->next)
{
@@ -9001,21 +9919,30 @@ static ORDER *
remove_const(JOIN *join,ORDER *first_order, COND *cond,
bool change_list, bool *simple_order)
{
- if (join->tables == join->const_tables)
+ if (join->table_count == join->const_tables)
return change_list ? 0 : first_order; // No need to sort
ORDER *order,**prev_ptr;
- table_map first_table= join->join_tab[join->const_tables].table->map;
+ table_map first_table;
table_map not_const_tables= ~join->const_table_map;
table_map ref;
+ bool first_is_base_table= FALSE;
DBUG_ENTER("remove_const");
+
+ LINT_INIT(first_table); /* protected by first_is_base_table */
+ if (join->join_tab[join->const_tables].table)
+ {
+ first_table= join->join_tab[join->const_tables].table->map;
+ first_is_base_table= TRUE;
+ }
+
prev_ptr= &first_order;
*simple_order= *join->join_tab[join->const_tables].on_expr_ref ? 0 : 1;
/* NOTE: A variable of not_const_tables ^ first_table; breaks gcc 2.7 */
- update_depend_map(join, first_order);
+ update_depend_map_for_order(join, first_order);
for (order=first_order; order ; order=order->next)
{
table_map order_tables=order->item[0]->used_tables();
@@ -9030,16 +9957,21 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
table for all queries containing more than one table, ROLLUP, and an
outer join.
*/
- (join->tables > 1 && join->rollup.state == ROLLUP::STATE_INITED &&
+ (join->table_count > 1 && join->rollup.state == ROLLUP::STATE_INITED &&
join->outer_join))
*simple_order=0; // Must do a temp table to sort
else if (!(order_tables & not_const_tables))
{
- if (order->item[0]->with_subselect &&
- !(join->select_lex->options & SELECT_DESCRIBE))
- order->item[0]->val_str(&order->item[0]->str_value);
+ if (order->item[0]->with_subselect)
+ {
+ /*
+ Delay the evaluation of constant ORDER and/or GROUP expressions that
+ contain subqueries until the execution phase.
+ */
+ join->exec_const_order_group_cond.push_back(order->item[0]);
+ }
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
- continue; // skip const item
+ continue;
}
else
{
@@ -9053,7 +9985,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
continue;
}
- if ((ref=order_tables & (not_const_tables ^ first_table)))
+ if (first_is_base_table && (ref=order_tables & (not_const_tables ^ first_table)))
{
if (!(order_tables & first_table) &&
only_eq_ref_tables(join,first_order, ref))
@@ -9079,7 +10011,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
static int
-return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
+return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables,
List<Item> &fields, bool send_row, ulonglong select_options,
const char *info, Item *having)
{
@@ -9095,7 +10027,9 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
if (send_row)
{
- for (TABLE_LIST *table= tables; table; table= table->next_leaf)
+ List_iterator<TABLE_LIST> ti(tables);
+ TABLE_LIST *table;
+ while ((table= ti++))
mark_as_null_row(table->table); // All fields are NULL
if (having && having->val_int() == 0)
send_row=0;
@@ -9110,7 +10044,7 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
Item *item;
while ((item= it++))
item->no_rows_in_result();
- send_error= result->send_data(fields);
+ send_error= result->send_data(fields) > 0;
}
if (!send_error)
result->send_eof(); // Should be safe
@@ -9129,8 +10063,11 @@ static void clear_tables(JOIN *join)
must clear only the non-const tables, as const tables
are not re-calculated.
*/
- for (uint i=join->const_tables ; i < join->tables ; i++)
- mark_as_null_row(join->table[i]); // All fields are NULL
+ for (uint i= 0 ; i < join->table_count ; i++)
+ {
+ if (!(join->table[i]->map & join->const_table_map))
+ mark_as_null_row(join->table[i]); // All fields are NULL
+ }
}
/*****************************************************************************
@@ -9297,21 +10234,21 @@ static bool check_simple_equality(Item *left_item, Item *right_item,
if (left_item->type() == Item::REF_ITEM &&
((Item_ref*)left_item)->ref_type() == Item_ref::VIEW_REF)
{
- if (((Item_ref*)left_item)->depended_from)
+ if (((Item_ref*)left_item)->get_depended_from())
return FALSE;
left_item= left_item->real_item();
}
if (right_item->type() == Item::REF_ITEM &&
((Item_ref*)right_item)->ref_type() == Item_ref::VIEW_REF)
{
- if (((Item_ref*)right_item)->depended_from)
+ if (((Item_ref*)right_item)->get_depended_from())
return FALSE;
right_item= right_item->real_item();
}
if (left_item->type() == Item::FIELD_ITEM &&
right_item->type() == Item::FIELD_ITEM &&
- !((Item_field*)left_item)->depended_from &&
- !((Item_field*)right_item)->depended_from)
+ !((Item_field*)left_item)->get_depended_from() &&
+ !((Item_field*)right_item)->get_depended_from())
{
/* The predicate the form field1=field2 is processed */
@@ -9394,16 +10331,16 @@ static bool check_simple_equality(Item *left_item, Item *right_item,
Item_field *field_item= 0;
Item *orig_field_item= 0;
if (left_item->type() == Item::FIELD_ITEM &&
- !((Item_field*)left_item)->depended_from &&
- right_item->const_item())
+ !((Item_field*)left_item)->get_depended_from() &&
+ right_item->const_item() && !right_item->is_expensive())
{
orig_field_item= left_item;
field_item= (Item_field *) left_item;
const_item= right_item;
}
else if (right_item->type() == Item::FIELD_ITEM &&
- !((Item_field*)right_item)->depended_from &&
- left_item->const_item())
+ !((Item_field*)right_item)->get_depended_from() &&
+ left_item->const_item() && !left_item->is_expensive())
{
orig_field_item= right_item;
field_item= (Item_field *) right_item;
@@ -9787,10 +10724,9 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
as soon the field is not of a string type or the field reference is
an argument of a comparison predicate.
*/
- uchar is_subst_valid= (uchar) 1;
- uchar *is_subst_valid_ptr= &is_subst_valid;
+ uchar* is_subst_valid= (uchar *) Item::ANY_SUBST;
cond= cond->compile(&Item::subst_argument_checker,
- &is_subst_valid_ptr,
+ &is_subst_valid,
&Item::equal_fields_propagator,
(uchar *) inherited);
cond->update_used_tables();
@@ -9969,7 +10905,25 @@ static int compare_fields_by_table_order(Item *field1,
if (outer_ref)
return cmp;
JOIN_TAB **idx= (JOIN_TAB **) table_join_idx;
- cmp= idx[f2->field->table->tablenr]-idx[f1->field->table->tablenr];
+
+ JOIN_TAB *tab1= idx[f1->field->table->tablenr];
+ JOIN_TAB *tab2= idx[f2->field->table->tablenr];
+
+ /*
+ if one of the table is inside a merged SJM nest and another one isn't,
+ compare SJM bush roots of the tables.
+ */
+ if (tab1->bush_root_tab != tab2->bush_root_tab)
+ {
+ if (tab1->bush_root_tab)
+ tab1= tab1->bush_root_tab;
+
+ if (tab2->bush_root_tab)
+ tab2= tab2->bush_root_tab;
+ }
+
+ cmp= tab2 - tab1;
+
if (!cmp)
{
JOIN_TAB *tab= idx[f1->field->table->tablenr];
@@ -10094,7 +11048,9 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
/*
Pick the "head" item: the constant one or the first in the join order
- that's not inside some SJM nest.
+ (if the first in the join order happends to be inside an SJM nest, that's
+ ok, because this is where the value will be unpacked after
+ materialization).
*/
if (item_const)
head= item_const;
@@ -10159,8 +11115,16 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
{
if (eq_item)
eq_list.push_back(eq_item);
+
+ /*
+ If we're inside an SJM-nest (current_sjm!=NULL), and the multi-equality
+ doesn't include a constant, we should produce equality with the first
+ of the equals in this SJM.
- Item *head_item= current_sjm? current_sjm_head: head;
+ In other cases, get the "head" item, which is either first of the
+ equals on top level, or the constant.
+ */
+ Item *head_item= (!item_const && current_sjm)? current_sjm_head: head;
Item *head_real_item= head_item->real_item();
if (head_real_item->type() == Item::FIELD_ITEM)
head_item= head_real_item;
@@ -10819,14 +11783,16 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
{
TABLE_LIST *tbl;
List_iterator<TABLE_LIST> it(nested_join->join_list);
+ List<TABLE_LIST> repl_list;
while ((tbl= it++))
{
tbl->embedding= table->embedding;
if (!tbl->embedding && !tbl->on_expr && tbl->table)
tbl->table->maybe_null= FALSE;
tbl->join_list= table->join_list;
+ repl_list.push_back(tbl);
}
- li.replace(nested_join->join_list);
+ li.replace(repl_list);
/* Need to update the name resolution table chain when flattening joins */
fix_name_res= TRUE;
table= *li.ref();
@@ -11198,6 +12164,20 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
*outer_rec_count= rec_count;
for (i= first_tab; i <= last_tab; i++)
reopt_remaining_tables |= join->positions[i].table->table->map;
+
+ /*
+ best_access_path() optimization depends on the value of
+ join->cur_sj_inner_tables. Our goal in this function is to do a
+ re-optimization with disabled join buffering, but no other changes.
+ In order to achieve this, cur_sj_inner_tables needs have the same
+ value it had during the original invocations of best_access_path.
+
+ We know that this function, optimize_wo_join_buffering() is called to
+ re-optimize semi-join join order range, which allows to conclude that
+ the "original" value of cur_sj_inner_tables was 0.
+ */
+ table_map save_cur_sj_inner_tables= join->cur_sj_inner_tables;
+ join->cur_sj_inner_tables= 0;
for (i= first_tab; i <= last_tab; i++)
{
@@ -11224,6 +12204,8 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
if (!rs->emb_sj_nest)
*outer_rec_count *= pos.records_read;
}
+ join->cur_sj_inner_tables= save_cur_sj_inner_tables;
+
*reopt_cost= cost;
}
@@ -11406,7 +12388,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
}
}
}
- if (cond->const_item())
+ if (cond->const_item() && !cond->is_expensive())
{
*cond_value= eval_const_cond(cond) ? Item::COND_TRUE : Item::COND_FALSE;
return (COND*) 0;
@@ -11432,40 +12414,36 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
return cond; // Point at next and level
}
-/*
+/**
Check if equality can be used in removing components of GROUP BY/DISTINCT
- SYNOPSIS
- test_if_equality_guarantees_uniqueness()
- l the left comparison argument (a field if any)
- r the right comparison argument (a const of any)
-
- DESCRIPTION
- Checks if an equality predicate can be used to take away
- DISTINCT/GROUP BY because it is known to be true for exactly one
- distinct value (e.g. <expr> == <const>).
- Arguments must be of the same type because e.g.
- <string_field> = <int_const> may match more than 1 distinct value from
- the column.
- We must take into consideration and the optimization done for various
- string constants when compared to dates etc (see Item_int_with_ref) as
- well as the collation of the arguments.
+ @param l the left comparison argument (a field if any)
+ @param r the right comparison argument (a const of any)
- RETURN VALUE
- TRUE can be used
- FALSE cannot be used
+ @details
+ Checks if an equality predicate can be used to take away
+ DISTINCT/GROUP BY because it is known to be true for exactly one
+ distinct value (e.g. <expr> == <const>).
+ Arguments must be compared in the native type of the left argument
+ and (for strings) in the native collation of the left argument.
+ Otherwise, for example,
+ <string_field> = <int_const> may match more than 1 distinct value or
+ the <string_field>.
+
+ @note We don't need to aggregate l and r collations here, because r -
+ the constant item - has already been converted to a proper collation
+ for comparison. We only need to compare this collation with field's collation.
+
+ @retval true can be used
+ @retval false cannot be used
*/
static bool
test_if_equality_guarantees_uniqueness(Item *l, Item *r)
{
return r->const_item() &&
- /* elements must be compared as dates */
- (Arg_comparator::can_compare_as_dates(l, r, 0) ||
- /* or of the same result type */
- (r->result_type() == l->result_type() &&
- /* and must have the same collation if compared as strings */
- (l->result_type() != STRING_RESULT ||
- l->collation.collation == r->collation.collation)));
+ item_cmp_type(l->cmp_type(), r->cmp_type()) == l->cmp_type() &&
+ (l->cmp_type() != STRING_RESULT ||
+ l->collation.collation == r->collation.collation);
}
/**
@@ -11647,15 +12625,12 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
case STRING_RESULT:
DBUG_ASSERT(item->collation.collation);
- enum enum_field_types type;
/*
DATE/TIME and GEOMETRY fields have STRING_RESULT result type.
To preserve type they needed to be handled separately.
*/
- if ((type= item->field_type()) == MYSQL_TYPE_DATETIME ||
- type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE ||
- type == MYSQL_TYPE_NEWDATE ||
- type == MYSQL_TYPE_TIMESTAMP || type == MYSQL_TYPE_GEOMETRY)
+ if (item->cmp_type() == TIME_RESULT ||
+ item->field_type() == MYSQL_TYPE_GEOMETRY)
new_field= item->tmp_table_field_from_field_type(table, 1);
/*
Make sure that the blob fits into a Field_varstring which has
@@ -11796,13 +12771,29 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
If item have to be able to store NULLs but underlaid field can't do it,
create_tmp_field_from_field() can't be used for tmp field creation.
*/
- if (field->maybe_null && field->in_rollup && !field->field->maybe_null())
+ if (((field->maybe_null && field->in_rollup) ||
+ (orig_item && orig_item->maybe_null)) && /* for outer joined views/dt*/
+ !field->field->maybe_null())
{
+ bool save_maybe_null= FALSE;
+ /*
+ The item the ref points to may have maybe_null flag set while
+ the ref doesn't have it. This may happen for outer fields
+ when the outer query decided at some point after name resolution phase
+ that this field might be null. Take this into account here.
+ */
+ if (orig_item)
+ {
+ save_maybe_null= item->maybe_null;
+ item->maybe_null= orig_item->maybe_null;
+ }
result= create_tmp_field_from_item(thd, item, table, NULL,
modify_item, convert_blob_length);
*from_field= field->field;
if (result && modify_item)
field->result_field= result;
+ if (orig_item)
+ item->maybe_null= save_maybe_null;
}
else if (table_cant_handle_bit_fields && field->field->type() ==
MYSQL_TYPE_BIT)
@@ -11956,7 +12947,7 @@ TABLE *
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields,
ulonglong select_options, ha_rows rows_limit,
- char *table_alias)
+ char *table_alias, bool do_not_open)
{
MEM_ROOT *mem_root_save, own_root;
TABLE *table;
@@ -12117,7 +13108,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
init_tmp_table_share(thd, share, "", 0, tmpname, tmpname);
share->blob_field= blob_field;
share->blob_ptr_size= portable_sizeof_char_ptr;
- share->db_low_byte_first=1; // True for HEAP, MyISAM and Maria
share->table_charset= param->table_charset;
share->primary_key= MAX_KEY; // Indicate no primary key
share->keys_for_keyread.init();
@@ -12234,7 +13224,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
for distinct, as we want the distinct index to be
usable in this case too.
*/
- item->marker == 4 || param->bit_fields_as_long, // psergey-feb17
+ item->marker == 4 || param->bit_fields_as_long,
force_copy_fields,
param->convert_blob_length);
@@ -12242,10 +13232,30 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
{
if (thd->is_fatal_error)
goto err; // Got OOM
- continue; // Some kindf of const item
+ continue; // Some kind of const item
}
if (type == Item::SUM_FUNC_ITEM)
- ((Item_sum *) item)->result_field= new_field;
+ {
+ Item_sum *agg_item= (Item_sum *) item;
+ /*
+ Update the result field only if it has never been set, or if the
+ created temporary table is not to be used for subquery
+ materialization.
+
+ The reason is that for subqueries that require materialization as part
+ of their plan, we create the 'external' temporary table needed for IN
+ execution, after the 'internal' temporary table needed for grouping.
+ Since both the external and the internal temporary tables are created
+ for the same list of SELECT fields of the subquery, setting
+ 'result_field' for each invocation of create_tmp_table overrides the
+ previous value of 'result_field'.
+
+ The condition below prevents the creation of the external temp table
+ to override the 'result_field' that was set for the internal temp table.
+ */
+ if (!agg_item->result_field || !param->materialized_subquery)
+ agg_item->result_field= new_field;
+ }
tmp_from_field++;
reclength+=new_field->pack_length();
if (!(new_field->flags & NOT_NULL_FLAG))
@@ -12508,8 +13518,10 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
share->keys=1;
share->uniques= test(using_unique_constraint);
table->key_info= table->s->key_info= keyinfo;
+ table->keys_in_use_for_query.set_bit(0);
+ share->keys_in_use.set_bit(0);
keyinfo->key_part=key_part_info;
- keyinfo->flags=HA_NOSAME;
+ keyinfo->flags=HA_NOSAME | HA_BINARY_PACK_KEY | HA_PACK_KEY;
keyinfo->usable_key_parts=keyinfo->key_parts= param->group_parts;
keyinfo->key_length=0;
keyinfo->rec_per_key=0;
@@ -12523,6 +13535,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
bool maybe_null=(*cur_group->item)->maybe_null;
key_part_info->null_bit=0;
key_part_info->field= field;
+ if (cur_group == group)
+ field->key_start.set_bit(0);
key_part_info->offset= field->offset(table->record[0]);
key_part_info->length= (uint16) field->key_length();
key_part_info->type= (uint8) field->key_type();
@@ -12592,9 +13606,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_parts * sizeof(KEY_PART_INFO))))
goto err;
bzero((void*) key_part_info, keyinfo->key_parts * sizeof(KEY_PART_INFO));
+ table->keys_in_use_for_query.set_bit(0);
+ share->keys_in_use.set_bit(0);
table->key_info= table->s->key_info= keyinfo;
keyinfo->key_part=key_part_info;
- keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL;
+ keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL | HA_BINARY_PACK_KEY | HA_PACK_KEY;
keyinfo->key_length= 0; // Will compute the sum of the parts below.
keyinfo->name= (char*) "distinct_key";
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
@@ -12628,8 +13644,14 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
i < field_count;
i++, reg_field++, key_part_info++)
{
- key_part_info->null_bit=0;
key_part_info->field= *reg_field;
+ (*reg_field)->flags |= PART_KEY_FLAG;
+ if (key_part_info == keyinfo->key_part)
+ (*reg_field)->key_start.set_bit(0);
+ key_part_info->null_bit= (*reg_field)->null_bit;
+ key_part_info->null_offset= (uint) ((*reg_field)->null_ptr -
+ (uchar*) table->record[0]);
+
key_part_info->offset= (*reg_field)->offset(table->record[0]);
key_part_info->length= (uint16) (*reg_field)->pack_length();
/* TODO:
@@ -12662,15 +13684,17 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (thd->is_fatal_error) // If end of memory
goto err; /* purecov: inspected */
share->db_record_offset= 1;
- if (share->db_type() == TMP_ENGINE_HTON)
- {
- if (create_internal_tmp_table(table, param->keyinfo, param->start_recinfo,
- &param->recinfo, select_options))
- goto err;
- }
- DBUG_PRINT("info", ("skip_create_table: %d", (int)param->skip_create_table));
- if (!param->skip_create_table)
+ table->used_for_duplicate_elimination= (param->sum_func_count == 0 &&
+ (table->group || table->distinct));
+
+ if (!do_not_open)
{
+ if (share->db_type() == TMP_ENGINE_HTON)
+ {
+ if (create_internal_tmp_table(table, param->keyinfo, param->start_recinfo,
+ &param->recinfo, select_options))
+ goto err;
+ }
if (open_tmp_table(table))
goto err;
}
@@ -12830,6 +13854,7 @@ bool open_tmp_table(TABLE *table)
}
table->db_stat= HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
(void) table->file->extra(HA_EXTRA_QUICK); /* Faster */
+ table->created= TRUE;
return(0);
}
@@ -12960,11 +13985,23 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
OPTION_BIG_TABLES)
create_info.data_file_length= ~(ulonglong) 0;
+ /*
+ The logic for choosing the record format:
+ The STATIC_RECORD format is the fastest one, because it's so simple,
+ so we use this by default for short rows.
+ BLOCK_RECORD caches both row and data, so this is generally faster than
+ DYNAMIC_RECORD. The one exception is when we write to tmp table and
+ want to use keys for duplicate elimination as with BLOCK RECORD
+ we first write the row, then check for key conflicts and then we have to
+ delete the row. The cases when this can happen is when there is
+ a group by and no sum functions or if distinct is used.
+ */
if ((error= maria_create(share->table_name.str,
table->no_rows ? NO_RECORD :
(share->reclength < 64 &&
!share->blob_fields ? STATIC_RECORD :
- BLOCK_RECORD),
+ table->used_for_duplicate_elimination ?
+ DYNAMIC_RECORD : BLOCK_RECORD),
share->keys, &keydef,
(uint) (*recinfo-start_recinfo),
start_recinfo,
@@ -13138,6 +14175,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
}
status_var_increment(table->in_use->status_var.created_tmp_disk_tables);
share->db_record_offset= 1;
+ table->created= TRUE;
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
@@ -13209,7 +14247,8 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table,
new_table.no_rows= table->no_rows;
if (create_internal_tmp_table(&new_table, table->key_info, start_recinfo,
- recinfo, thd->lex->select_lex.options |
+ recinfo,
+ thd->lex->select_lex.options |
thd->options))
goto err2;
if (open_tmp_table(&new_table))
@@ -13301,7 +14340,7 @@ free_tmp_table(THD *thd, TABLE *entry)
save_proc_info=thd->proc_info;
thd_proc_info(thd, "removing tmp table");
- if (entry->file)
+ if (entry->file && entry->created)
{
if (entry->db_stat)
entry->file->ha_drop_table(entry->s->table_name.str);
@@ -13446,14 +14485,13 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
}
/* Set up select_end */
Next_select_func end_select= setup_end_select_func(join);
- if (join->tables)
+ if (join->table_count)
{
- join->join_tab[join->tables-1].next_select= end_select;
-
+ join->join_tab[join->top_join_tab_count - 1].next_select= end_select;
join_tab=join->join_tab+join->const_tables;
}
join->send_records=0;
- if (join->tables == join->const_tables)
+ if (join->table_count == join->const_tables)
{
/*
HAVING will be checked after processing aggregate functions,
@@ -13484,22 +14522,23 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
With implicit grouping all fields of special row produced for an
empty result are NULL. See return_zero_rows() for the same behavior.
*/
- for (TABLE_LIST *table= join->select_lex->leaf_tables;
- table; table= table->next_leaf)
+ TABLE_LIST *table;
+ List_iterator_fast<TABLE_LIST> li(join->select_lex->leaf_tables);
+ while ((table= li++))
mark_as_null_row(table->table);
- rc= join->result->send_data(*columns_list);
+ rc= join->result->send_data(*columns_list) > 0;
}
}
}
else
{
- DBUG_ASSERT(join->tables);
+ DBUG_ASSERT(join->table_count);
if (join->outer_ref_cond && !join->outer_ref_cond->val_int())
error= NESTED_LOOP_NO_MORE_ROWS;
else
- error= join->first_select(join,join_tab,0);
+ error= sub_select(join,join_tab,0);
if (error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS)
- error= join->first_select(join,join_tab,1);
+ error= sub_select(join,join_tab,1);
if (error == NESTED_LOOP_QUERY_LIMIT)
error= NESTED_LOOP_OK; /* select_limit used */
}
@@ -13566,143 +14605,6 @@ int rr_sequential_and_unpack(READ_RECORD *info)
/*
- Semi-join materialization join function
-
- SYNOPSIS
- sub_select_sjm()
- join The join
- join_tab The first table in the materialization nest
- end_of_records FALSE <=> This call is made to pass another record
- combination
- TRUE <=> EOF
-
- DESCRIPTION
- This is a join execution function that does materialization of a join
- suborder before joining it to the rest of the join.
-
- The table pointed by join_tab is the first of the materialized tables.
- This function first creates the materialized table and then switches to
- joining the materialized table with the rest of the join.
-
- The materialized table can be accessed in two ways:
- - index lookups
- - full table scan
-
- RETURN
- One of enum_nested_loop_state values
-*/
-
-enum_nested_loop_state
-sub_select_sjm(JOIN *join, JOIN_TAB *join_tab, bool end_of_records)
-{
- int res;
- enum_nested_loop_state rc;
-
- DBUG_ENTER("sub_select_sjm");
-
- if (!join_tab->emb_sj_nest)
- {
- /*
- We're handling GROUP BY/ORDER BY, this is the first table, and we've
- actually executed the join already and now we're just reading the
- result of the join from the temporary table.
- Bypass to regular join handling.
- Yes, it would be nicer if sub_select_sjm wasn't called at all in this
- case but there's no easy way to arrange this.
- */
- rc= sub_select(join, join_tab, end_of_records);
- DBUG_RETURN(rc);
- }
-
- SJ_MATERIALIZATION_INFO *sjm= join_tab->emb_sj_nest->sj_mat_info;
- if (end_of_records)
- {
- rc= (*join_tab[sjm->tables - 1].next_select)(join,
- join_tab + sjm->tables,
- end_of_records);
- DBUG_RETURN(rc);
- }
- if (!sjm->materialized)
- {
- /*
- Do the materialization. First, put end_sj_materialize after the last
- inner table so we can catch record combinations of sj-inner tables.
- */
- Next_select_func next_func= join_tab[sjm->tables - 1].next_select;
- join_tab[sjm->tables - 1].next_select= end_sj_materialize;
-
- /*
- Now run the join for the inner tables. The first call is to run the
- join, the second one is to signal EOF (this is essential for some
- join strategies, e.g. it will make join buffering flush the records)
- */
- if ((rc= sub_select(join, join_tab, FALSE)) < 0 ||
- (rc= sub_select(join, join_tab, TRUE/*EOF*/)) < 0)
- {
- join_tab[sjm->tables - 1].next_select= next_func;
- DBUG_RETURN(rc); /* it's NESTED_LOOP_(ERROR|KILLED)*/
- }
- join_tab[sjm->tables - 1].next_select= next_func;
-
- /*
- Ok, materialization finished. Initialize the access to the temptable
- */
- sjm->materialized= TRUE;
- join_tab->read_record.read_record= join_no_more_records;
- if (sjm->is_sj_scan)
- {
- /* Initialize full scan */
- JOIN_TAB *last_tab= join_tab + (sjm->tables - 1);
- init_read_record(&last_tab->read_record, join->thd,
- sjm->table, NULL, TRUE, TRUE, FALSE);
-
- DBUG_ASSERT(last_tab->read_record.read_record == rr_sequential);
- last_tab->read_first_record= join_read_record_no_init;
- last_tab->read_record.copy_field= sjm->copy_field;
- last_tab->read_record.copy_field_end= sjm->copy_field +
- sjm->sjm_table_cols.elements;
- last_tab->read_record.read_record= rr_sequential_and_unpack;
- }
- }
- else
- {
- if (sjm->is_sj_scan)
- {
- /* Reset the cursor for a new scan over the table */
- if (sjm->table->file->ha_rnd_init(TRUE))
- DBUG_RETURN(NESTED_LOOP_ERROR);
- }
- }
-
- if (sjm->is_sj_scan)
- {
- /* Do full scan of the materialized table */
- JOIN_TAB *last_tab= join_tab + (sjm->tables - 1);
-
- Item *save_cond= last_tab->select_cond;
- last_tab->set_select_cond(sjm->join_cond, __LINE__);
-
- rc= sub_select(join, last_tab, end_of_records);
- last_tab->set_select_cond(save_cond, __LINE__);
- DBUG_RETURN(rc);
- }
- else
- {
- /* Do index lookup in the materialized table */
- if ((res= join_read_key2(join_tab->join->thd, join_tab,
- sjm->table, sjm->tab_ref)) == 1)
- DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
- if (res || !sjm->in_equality->val_int())
- DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS);
- }
- rc= (*join_tab[sjm->tables - 1].next_select)(join,
- join_tab + sjm->tables,
- end_of_records);
- DBUG_RETURN(rc);
-}
-
-
-/*
Fill the join buffer with partial records, retrieve all full matches for them
SYNOPSIS
@@ -13924,10 +14826,13 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
do_sj_reset(join_tab->flush_weedout_table);
}
+ if (!join_tab->preread_init_done && join_tab->preread_init())
+ DBUG_RETURN(NESTED_LOOP_ERROR);
+
if (join->resume_nested_loop)
{
/* If not the last table, plunge down the nested loop */
- if (join_tab < join->join_tab + join->tables - 1)
+ if (join_tab < join->join_tab + join->top_join_tab_count - 1)
rc= (*join_tab->next_select)(join, join_tab + 1, 0);
else
{
@@ -13954,6 +14859,10 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
}
join->thd->row_count= 0;
+ if (rc != NESTED_LOOP_NO_MORE_ROWS &&
+ (rc= join_tab_execution_startup(join_tab)) < 0)
+ DBUG_RETURN(rc);
+
if (join_tab->loosescan_match_tab)
join_tab->loosescan_match_tab->found_match= FALSE;
@@ -14298,13 +15207,21 @@ static int
join_read_const_table(JOIN_TAB *tab, POSITION *pos)
{
int error;
+ TABLE_LIST *tbl;
DBUG_ENTER("join_read_const_table");
TABLE *table=tab->table;
table->const_table=1;
table->null_row=0;
table->status=STATUS_NO_RECORD;
- if (tab->type == JT_SYSTEM)
+ if (tab->table->pos_in_table_list->is_materialized_derived() &&
+ !tab->table->pos_in_table_list->fill_me)
+ {
+ //TODO: don't get here at all
+ /* Skip materialized derived tables/views. */
+ DBUG_RETURN(0);
+ }
+ else if (tab->type == JT_SYSTEM)
{
if ((error=join_read_system(tab)))
{ // Info for DESCRIBE
@@ -14368,26 +15285,27 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
if (!table->null_row)
table->maybe_null=0;
- /* Check appearance of new constant items in Item_equal objects */
- JOIN *join= tab->join;
- if (join->conds)
- update_const_equal_items(join->conds, tab);
- TABLE_LIST *tbl;
- for (tbl= join->select_lex->leaf_tables; tbl; tbl= tbl->next_leaf)
{
- TABLE_LIST *embedded;
- TABLE_LIST *embedding= tbl;
- do
- {
- embedded= embedding;
- if (embedded->on_expr)
- update_const_equal_items(embedded->on_expr, tab);
- embedding= embedded->embedding;
+ JOIN *join= tab->join;
+ List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
+ /* Check appearance of new constant items in Item_equal objects */
+ if (join->conds)
+ update_const_equal_items(join->conds, tab);
+ while ((tbl= ti++))
+ {
+ TABLE_LIST *embedded;
+ TABLE_LIST *embedding= tbl;
+ do
+ {
+ embedded= embedding;
+ if (embedded->on_expr)
+ update_const_equal_items(embedded->on_expr, tab);
+ embedding= embedded->embedding;
+ }
+ while (embedding &&
+ embedding->nested_join->join_list.head() == embedded);
}
- while (embedding &&
- embedding->nested_join->join_list.head() == embedded);
}
-
DBUG_RETURN(0);
}
@@ -14734,19 +15652,36 @@ int join_init_read_record(JOIN_TAB *tab)
{
if (tab->select && tab->select->quick && tab->select->quick->reset())
return 1;
+ if (!tab->preread_init_done && tab->preread_init())
+ return 1;
if (init_read_record(&tab->read_record, tab->join->thd, tab->table,
tab->select,1,1, FALSE))
return 1;
return (*tab->read_record.read_record)(&tab->read_record);
}
-static int
+int
join_read_record_no_init(JOIN_TAB *tab)
{
+ Copy_field *save_copy, *save_copy_end;
+
+ /*
+ init_read_record resets all elements of tab->read_record().
+ Remember things that we don't want to have reset.
+ */
+ save_copy= tab->read_record.copy_field;
+ save_copy_end= tab->read_record.copy_field_end;
+
+ init_read_record(&tab->read_record, tab->join->thd, tab->table,
+ tab->select,1,1, FALSE);
+
+ tab->read_record.copy_field= save_copy;
+ tab->read_record.copy_field_end= save_copy_end;
+ tab->read_record.read_record= rr_sequential_and_unpack;
+
return (*tab->read_record.read_record)(&tab->read_record);
}
-
static int
join_read_first(JOIN_TAB *tab)
{
@@ -14924,23 +15859,28 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_ENTER("end_send");
if (!end_of_records)
{
- int error;
if (join->having && join->having->val_int() == 0)
DBUG_RETURN(NESTED_LOOP_OK); // Didn't match having
- error=0;
if (join->procedure)
- error=join->procedure->send_row(join->procedure_fields_list);
- else if (join->do_send_rows)
- error=join->result->send_data(*join->fields);
- if (error)
- DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
+ {
+ if (join->procedure->send_row(join->procedure_fields_list))
+ DBUG_RETURN(NESTED_LOOP_ERROR);
+ DBUG_RETURN(NESTED_LOOP_OK);
+ }
+ if (join->do_send_rows)
+ {
+ int error;
+ /* result < 0 if row was not accepted and should not be counted */
+ if ((error= join->result->send_data(*join->fields)))
+ DBUG_RETURN(error < 0 ? NESTED_LOOP_OK : NESTED_LOOP_ERROR);
+ }
if (++join->send_records >= join->unit->select_limit_cnt &&
join->do_send_rows)
{
if (join->select_options & OPTION_FOUND_ROWS)
{
JOIN_TAB *jt=join->join_tab;
- if ((join->tables == 1) && !join->tmp_table && !join->sort_and_group
+ if ((join->table_count == 1) && !join->tmp_table && !join->sort_and_group
&& !join->send_group_parts && !join->having && !jt->select_cond &&
!(jt->select && jt->select->quick) &&
(jt->table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) &&
@@ -15043,7 +15983,15 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
else
{
if (join->do_send_rows)
- error=join->result->send_data(*join->fields) ? 1 : 0;
+ {
+ error= join->result->send_data(*join->fields);
+ if (error < 0)
+ {
+ /* Duplicate row, don't count */
+ join->send_records--;
+ error= 0;
+ }
+ }
join->send_records++;
}
if (join->rollup.state != ROLLUP::STATE_NONE && error <= 0)
@@ -15248,7 +16196,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
table->file->print_error(error, MYF(0));/* purecov: inspected */
DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */
}
- join->join_tab[join->tables-1].next_select=end_unique_update;
+ join->join_tab[join->top_join_tab_count-1].next_select=end_unique_update;
}
join->send_records++;
DBUG_RETURN(NESTED_LOOP_OK);
@@ -15394,9 +16342,23 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
Check if "left_item=right_item" equality is guaranteed to be true by use of
[eq]ref access on left_item->field->table.
- @return
- TRUE if right_item is used removable reference key on left_item
- FALSE otherwise
+ SYNOPSIS
+ test_if_ref()
+ root_cond
+ left_item
+ right_item
+
+ DESCRIPTION
+ Check if the given "left_item = right_item" equality is guaranteed to be
+ true by use of [eq_]ref access method.
+
+ We need root_cond as we can't remove ON expressions even if employed ref
+ access guarantees that they are true. This is because TODO
+
+ RETURN
+ TRUE if right_item is used removable reference key on left_item
+ FALSE Otherwise
+
*/
bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item)
@@ -15435,7 +16397,7 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item)
{
/*
We can remove binary fields and numerical fields except float,
- as float comparison isn't 100 % secure
+ as float comparison isn't 100 % safe
We have to keep normal strings to be able to check for end spaces
*/
if (field->binary() &&
@@ -15452,71 +16414,78 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item)
}
-
-/*
- Extract a condition that can be checked after reading given table
-
- SYNOPSIS
- make_cond_for_table()
- cond Condition to analyze
- tables Tables for which "current field values" are available
- used_table Table that we're extracting the condition for (may
- also include PSEUDO_TABLE_BITS
- exclude_expensive_cond Do not push expensive conditions
- retain_ref_cond Retain ref conditions
-
- DESCRIPTION
- Extract the condition that can be checked after reading the table
- specified in 'used_table', given that current-field values for tables
- specified in 'tables' bitmap are available.
-
- The function assumes that
- - Constant parts of the condition has already been checked.
- - Condition that could be checked for tables in 'tables' has already
- been checked.
-
- The function takes into account that some parts of the condition are
- guaranteed to be true by employed 'ref' access methods (the code that
- does this is located at the end, search down for "EQ_FUNC").
-
-
- SEE ALSO
- make_cond_for_info_schema uses similar algorithm
-
- RETURN
- Extracted condition
-*/
+/**
+ Extract a condition that can be checked after reading given table
+ @fn make_cond_for_table()
+
+ @param cond Condition to analyze
+ @param tables Tables for which "current field values" are available
+ @param used_table Table that we're extracting the condition for
+ tables Tables for which "current field values" are available (this
+ includes used_table)
+ (may also include PSEUDO_TABLE_BITS, and may be zero)
+ @param join_tab_idx_arg
+ The index of the JOIN_TAB this Item is being extracted
+ for. MAX_TABLES if there is no corresponding JOIN_TAB.
+ @param exclude_expensive_cond
+ Do not push expensive conditions
+ @param retain_ref_cond
+ Retain ref conditions
+
+ @retval <>NULL Generated condition
+ @retval =NULL Already checked, OR error
+
+ @details
+ Extract the condition that can be checked after reading the table
+ specified in 'used_table', given that current-field values for tables
+ specified in 'tables' bitmap are available.
+ If 'used_table' is 0
+ - extract conditions for all tables in 'tables'.
+ - extract conditions are unrelated to any tables
+ in the same query block/level(i.e. conditions
+ which have used_tables == 0).
+
+ The function assumes that
+ - Constant parts of the condition has already been checked.
+ - Condition that could be checked for tables in 'tables' has already
+ been checked.
+
+ The function takes into account that some parts of the condition are
+ guaranteed to be true by employed 'ref' access methods (the code that
+ does this is located at the end, search down for "EQ_FUNC").
+
+ @note
+ Make sure to keep the implementations of make_cond_for_table() and
+ make_cond_after_sjm() synchronized.
+ make_cond_for_info_schema() uses similar algorithm as well.
+*/
static Item *
-make_cond_for_table(Item *cond, table_map tables, table_map used_table,
- bool exclude_expensive_cond, bool retain_ref_cond)
+make_cond_for_table(THD *thd, Item *cond, table_map tables,
+ table_map used_table,
+ uint join_tab_idx_arg,
+ bool exclude_expensive_cond __attribute__((unused)),
+ bool retain_ref_cond)
{
- return make_cond_for_table_from_pred(cond, cond, tables, used_table,
+ return make_cond_for_table_from_pred(thd, cond, cond, tables, used_table,
+ join_tab_idx_arg,
exclude_expensive_cond,
retain_ref_cond);
}
-
+
+
static Item *
-make_cond_for_table_from_pred(Item *root_cond, Item *cond,
+make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
table_map tables, table_map used_table,
- bool exclude_expensive_cond,
+ uint join_tab_idx_arg,
+ bool exclude_expensive_cond __attribute__
+ ((unused)),
bool retain_ref_cond)
{
- if (used_table && !(cond->used_tables() & used_table) &&
- /*
- Exclude constant conditions not checked at optimization time if
- the table we are pushing conditions to is the first one.
- As a result, such conditions are not considered as already checked
- and will be checked at execution time, attached to the first table.
-
- psergey: TODO: "used_table & 1" doesn't make sense in nearly any
- context. Look at setup_table_map(), table bits reflect the order
- the tables were encountered by the parser. Check what we should
- replace this condition with.
- */
- !((used_table & 1) && cond->is_expensive()))
+ if (used_table && !(cond->used_tables() & used_table))
return (COND*) 0; // Already checked
+
if (cond->type() == Item::COND_ITEM)
{
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
@@ -15529,8 +16498,9 @@ make_cond_for_table_from_pred(Item *root_cond, Item *cond,
Item *item;
while ((item=li++))
{
- Item *fix=make_cond_for_table_from_pred(root_cond, item,
+ Item *fix=make_cond_for_table_from_pred(thd, root_cond, item,
tables, used_table,
+ join_tab_idx_arg,
exclude_expensive_cond,
retain_ref_cond);
if (fix)
@@ -15543,10 +16513,11 @@ make_cond_for_table_from_pred(Item *root_cond, Item *cond,
return new_cond->argument_list()->head();
default:
/*
- Item_cond_and do not need fix_fields for execution, its parameters
- are fixed or do not need fix_fields, too
+ Call fix_fields to propagate all properties of the children to
+ the new parent Item. This should not be expensive because all
+ children of Item_cond_and should be fixed by now.
*/
- new_cond->quick_fix_field();
+ new_cond->fix_fields(thd, 0);
new_cond->used_tables_cache=
((Item_cond_and*) cond)->used_tables_cache &
tables;
@@ -15562,8 +16533,9 @@ make_cond_for_table_from_pred(Item *root_cond, Item *cond,
Item *item;
while ((item=li++))
{
- Item *fix=make_cond_for_table_from_pred(root_cond, item,
+ Item *fix=make_cond_for_table_from_pred(thd, root_cond, item,
tables, 0L,
+ join_tab_idx_arg,
exclude_expensive_cond,
retain_ref_cond);
if (!fix)
@@ -15571,10 +16543,11 @@ make_cond_for_table_from_pred(Item *root_cond, Item *cond,
new_cond->argument_list()->push_back(fix);
}
/*
- Item_cond_and do not need fix_fields for execution, its parameters
- are fixed or do not need fix_fields, too
+ Call fix_fields to propagate all properties of the children to
+ the new parent Item. This should not be expensive because all
+ children of Item_cond_and should be fixed by now.
*/
- new_cond->quick_fix_field();
+ new_cond->fix_fields(thd, 0);
new_cond->used_tables_cache= ((Item_cond_or*) cond)->used_tables_cache;
new_cond->top_level_item();
return new_cond;
@@ -15586,16 +16559,15 @@ make_cond_for_table_from_pred(Item *root_cond, Item *cond,
table_count times, we mark each item that we have examined with the result
of the test
*/
- if ((cond->marker == 3 && !retain_ref_cond) ||
- (cond->used_tables() & ~tables) ||
- /*
- When extracting constant conditions, treat expensive conditions as
- non-constant, so that they are not evaluated at optimization time.
- */
- (!used_table && exclude_expensive_cond && cond->is_expensive()))
+ if ((cond->marker == 3 && !retain_ref_cond) ||
+ (cond->used_tables() & ~tables))
return (COND*) 0; // Can't check this yet
+
if (cond->marker == 2 || cond->eq_cmp_result() == Item::COND_OK)
+ {
+ cond->set_join_tab_idx(join_tab_idx_arg);
return cond; // Not boolean op
+ }
if (cond->type() == Item::FUNC_ITEM &&
((Item_func*) cond)->functype() == Item_func::EQ_FUNC)
@@ -15616,18 +16588,33 @@ make_cond_for_table_from_pred(Item *root_cond, Item *cond,
}
}
cond->marker=2;
+ cond->set_join_tab_idx(join_tab_idx_arg);
return cond;
}
+/*
+ The difference of this from make_cond_for_table() is that we're in the
+ following state:
+ 1. conditions referring to 'tables' have been checked
+ 2. conditions referring to sjm_tables have been checked, too
+ 3. We need condition that couldn't be checked in #1 or #2 but
+ can be checked when we get both (tables | sjm_tables).
+*/
static COND *
make_cond_after_sjm(Item *root_cond, Item *cond, table_map tables,
table_map sjm_tables)
{
+ /*
+ We assume that conditions that refer to only join prefix tables or
+ sjm_tables have already been checked.
+ */
if ((!(cond->used_tables() & ~tables) ||
!(cond->used_tables() & ~sjm_tables)))
return (COND*) 0; // Already checked
+
+ /* AND/OR recursive descent */
if (cond->type() == Item::COND_ITEM)
{
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
@@ -16148,20 +17135,26 @@ find_field_in_item_list (Field *field, void *data)
*/
static bool
-test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
+test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit_arg,
bool no_changes, const key_map *map)
{
int ref_key;
uint ref_key_parts;
- int order_direction;
+ int order_direction= 0;
uint used_key_parts;
TABLE *table=tab->table;
SQL_SELECT *select=tab->select;
key_map usable_keys;
- QUICK_SELECT_I *save_quick= 0;
- COND *orig_select_cond= 0;
+ QUICK_SELECT_I *save_quick= select ? select->quick : 0;
+ Item *orig_cond= 0;
+ bool orig_cond_saved= false;
+ int best_key= -1;
+ bool changed_key= false;
+ ha_rows best_select_limit;
DBUG_ENTER("test_if_skip_sort_order");
+
LINT_INIT(ref_key_parts);
+ LINT_INIT(best_select_limit);
/*
Keys disabled by ALTER TABLE ... DISABLE KEYS should have already
@@ -16179,7 +17172,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
usable_keys.intersect(((Item_field*) item)->field->part_of_sortkey);
if (usable_keys.is_clear_all())
- goto use_filesort; // No usable keys
+ goto use_filesort; // No usable keys
}
ref_key= -1;
@@ -16194,7 +17187,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
else if (select && select->quick) // Range found by opt_range
{
int quick_type= select->quick->get_type();
- save_quick= select->quick;
/*
assume results are not ordered when index merge is used
TODO: sergeyp: Results of all index merge selects actually are ordered
@@ -16228,14 +17220,14 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
if (table->covering_keys.is_set(ref_key))
usable_keys.intersect(table->covering_keys);
if (tab->pre_idx_push_select_cond)
- orig_select_cond= tab->set_cond(tab->pre_idx_push_select_cond);
+ {
+ orig_cond= tab->set_cond(tab->pre_idx_push_select_cond);
+ orig_cond_saved= true;
+ }
if ((new_ref_key= test_if_subkey(order, table, ref_key, ref_key_parts,
&usable_keys)) < MAX_KEY)
{
- /* Found key that can be used to retrieve data in sorted order */
- //psergey-mrr:if (tab->pre_idx_push_select_cond)
- // tab->select_cond= tab->select->cond= tab->pre_idx_push_select_cond;
if (tab->ref.key >= 0)
{
/*
@@ -16262,25 +17254,41 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
The range optimizer constructed QUICK_RANGE for ref_key, and
we want to use instead new_ref_key as the index. We can't
just change the index of the quick select, because this may
- result in an incosistent QUICK_SELECT object. Below we
+ result in an inconsistent QUICK_SELECT object. Below we
create a new QUICK_SELECT from scratch so that all its
- parameres are set correctly by the range optimizer.
+ parameters are set correctly by the range optimizer.
*/
key_map new_ref_key_map;
+ COND *save_cond;
+ bool res;
new_ref_key_map.clear_all(); // Force the creation of quick select
new_ref_key_map.set_bit(new_ref_key); // only for new_ref_key.
- if (select->test_quick_select(tab->join->thd, new_ref_key_map, 0,
- (tab->join->select_options &
- OPTION_FOUND_ROWS) ?
- HA_POS_ERROR :
- tab->join->unit->select_limit_cnt,0,
- TRUE) <=
- 0)
+ /* Reset quick; This will be restored in 'use_filesort' if needed */
+ select->quick= 0;
+ save_cond= select->cond;
+ if (select->pre_idx_push_select_cond)
+ select->cond= select->pre_idx_push_select_cond;
+ res= select->test_quick_select(tab->join->thd, new_ref_key_map, 0,
+ (tab->join->select_options &
+ OPTION_FOUND_ROWS) ?
+ HA_POS_ERROR :
+ tab->join->unit->select_limit_cnt,0,
+ TRUE) <= 0;
+ if (res)
+ {
+ select->cond= save_cond;
goto use_filesort;
+ }
+ /*
+ We don't restore select->cond as we want to use the
+ original condition as index condition pushdown is not
+ active for the new index.
+ */
}
ref_key= new_ref_key;
- }
+ changed_key= true;
+ }
}
/* Check if we get the rows in requested sorted order by using the key */
if (usable_keys.is_set(ref_key) &&
@@ -16302,7 +17310,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
int best_key_direction;
ha_rows best_records;
double read_time;
- int best_key= -1;
bool is_best_covering= FALSE;
double fanout= 1;
JOIN *join= tab->join;
@@ -16319,7 +17326,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
resolved with a key; This is because filesort() is usually faster than
retrieving all rows through an index.
*/
- if (select_limit >= table_records)
+ if (select_limit_arg >= table_records)
{
keys= *table->file->keys_to_use_for_scanning();
keys.merge(table->covering_keys);
@@ -16341,12 +17348,13 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
ref_key_quick_rows= table->quick_rows[ref_key];
read_time= join->best_positions[tablenr].read_time;
- for (uint i= tablenr+1; i < join->tables; i++)
+ for (uint i= tablenr+1; i < join->table_count; i++)
fanout*= join->best_positions[i].records_read; // fanout is always >= 1
for (nr=0; nr < table->s->keys ; nr++)
{
int direction;
+ ha_rows select_limit= select_limit_arg;
if (keys.is_set(nr) &&
(direction= test_if_order_by_key(order, table, nr, &used_key_parts)))
@@ -16358,9 +17366,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
DBUG_ASSERT (ref_key != (int) nr);
- bool is_covering= table->covering_keys.is_set(nr) ||
- (nr == table->s->primary_key &&
- table->file->primary_key_is_clustered());
+ bool is_covering= (table->covering_keys.is_set(nr) ||
+ (table->file->index_flags(nr, 0, 1) &
+ HA_CLUSTERED_INDEX));
/*
Don't use an index scan with ORDER BY without limit.
@@ -16439,7 +17447,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
select_limit= table_records;
else
select_limit= (ha_rows) (select_limit*rec_per_key);
- }
+ } /* group */
+
/*
If tab=tk is not the last joined table tn then to get first
L records from the result set we can expect to retrieve
@@ -16483,8 +17492,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
index_scan_time= select_limit/rec_per_key *
min(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
+ if ((ref_key < 0 && (group || table->force_index || is_covering)) ||
index_scan_time < read_time)
{
ha_rows quick_records= table_records;
@@ -16496,7 +17504,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
if (best_key < 0 ||
(select_limit <= min(quick_records,best_records) ?
keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
+ quick_records < best_records) ||
+ (!is_best_covering && is_covering))
{
best_key= nr;
best_key_parts= keyinfo->key_parts;
@@ -16504,6 +17513,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
best_records= quick_records;
is_best_covering= is_covering;
best_key_direction= direction;
+ best_select_limit= select_limit;
}
}
}
@@ -16513,165 +17523,215 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache, except in case that chosen
- index is clustered primary key.
+ index is clustered key.
*/
- if ((select_limit >= table_records) &&
- (tab->type == JT_ALL &&
- tab->join->tables > tab->join->const_tables + 1) &&
- ((unsigned) best_key != table->s->primary_key ||
- !table->file->primary_key_is_clustered()))
- DBUG_RETURN(0);
+ if (best_key < 0 ||
+ ((select_limit_arg >= table_records) &&
+ (tab->type == JT_ALL &&
+ tab->join->table_count > tab->join->const_tables + 1) &&
+ !(table->file->index_flags(best_key, 0, 1) & HA_CLUSTERED_INDEX)))
+ goto use_filesort;
- if (best_key >= 0)
+ if (table->quick_keys.is_set(best_key) && best_key != ref_key)
{
- bool quick_created= FALSE;
- if (table->quick_keys.is_set(best_key) && best_key != ref_key)
- {
- key_map map;
- map.clear_all(); // Force the creation of quick select
- map.set_bit(best_key); // only best_key.
- quick_created=
- select->test_quick_select(join->thd, map, 0,
- join->select_options & OPTION_FOUND_ROWS ?
- HA_POS_ERROR :
- join->unit->select_limit_cnt,
- TRUE, FALSE) > 0;
- }
- if (!no_changes)
- {
- /*
- If ref_key used index tree reading only ('Using index' in EXPLAIN),
- and best_key doesn't, then revert the decision.
- */
- if (!table->covering_keys.is_set(best_key))
- table->disable_keyread();
- if (!quick_created)
- {
- tab->index= best_key;
- tab->read_first_record= best_key_direction > 0 ?
- join_read_first:join_read_last;
- tab->type=JT_NEXT; // Read with index_first(), index_next()
- if (select && select->quick)
- {
- delete select->quick;
- select->quick= 0;
- }
- if (table->covering_keys.is_set(best_key) && ! table->key_read)
- table->enable_keyread();
- if (tab->pre_idx_push_select_cond)
- {
- COND *tmp_cond= tab->pre_idx_push_select_cond;
- if (orig_select_cond)
- {
- tmp_cond= and_conds(tmp_cond, orig_select_cond);
- tmp_cond->quick_fix_field();
- }
- tab->set_cond(tmp_cond);
- /* orig_select_cond was merged, no need to restore original one. */
- orig_select_cond= 0;
- }
- table->file->ha_index_or_rnd_end();
- if (join->select_options & SELECT_DESCRIBE)
- {
- tab->ref.key= -1;
- tab->ref.key_parts= 0;
- if (select_limit < table_records)
- tab->limit= select_limit;
- }
- }
- else if (tab->type != JT_ALL)
- {
- /*
- We're about to use a quick access to the table.
- We need to change the access method so as the quick access
- method is actually used.
- */
- DBUG_ASSERT(tab->select->quick);
- tab->type=JT_ALL;
- tab->use_quick=1;
- tab->ref.key= -1;
- tab->ref.key_parts=0; // Don't use ref key.
- tab->read_first_record= join_init_read_record;
- if (tab->is_using_loose_index_scan())
- join->tmp_table_param.precomputed_group_by= TRUE;
- /*
- TODO: update the number of records in join->best_positions[tablenr]
- */
- }
- }
- order_direction= best_key_direction;
- /*
- saved_best_key_parts is actual number of used keyparts found by the
- test_if_order_by_key function. It could differ from keyinfo->key_parts,
- thus we have to restore it in case of desc order as it affects
- QUICK_SELECT_DESC behaviour.
- */
- used_key_parts= (order_direction == -1) ?
- saved_best_key_parts : best_key_parts;
+ key_map map;
+ map.clear_all(); // Force the creation of quick select
+ map.set_bit(best_key); // only best_key.
+ select->quick= 0;
+ select->test_quick_select(join->thd, map, 0,
+ join->select_options & OPTION_FOUND_ROWS ?
+ HA_POS_ERROR :
+ join->unit->select_limit_cnt,
+ TRUE, FALSE);
}
- else
- goto use_filesort;
- }
+ order_direction= best_key_direction;
+ /*
+ saved_best_key_parts is actual number of used keyparts found by the
+ test_if_order_by_key function. It could differ from keyinfo->key_parts,
+ thus we have to restore it in case of desc order as it affects
+ QUICK_SELECT_DESC behaviour.
+ */
+ used_key_parts= (order_direction == -1) ?
+ saved_best_key_parts : best_key_parts;
+ changed_key= true;
+ }
check_reverse_order:
+ DBUG_ASSERT(order_direction != 0);
+
if (order_direction == -1) // If ORDER BY ... DESC
{
+ int quick_type;
if (select && select->quick)
{
/*
Don't reverse the sort order, if it's already done.
(In some cases test_if_order_by_key() can be called multiple times
*/
- if (!select->quick->reverse_sorted())
+ if (select->quick->reverse_sorted())
+ goto skipped_filesort;
+
+ quick_type= select->quick->get_type();
+ if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
+ quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
+ quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
+ quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
+ quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
+ {
+ tab->limit= 0;
+ goto use_filesort; // Use filesort
+ }
+ }
+ }
+
+ /*
+ Update query plan with access pattern for doing ordered access
+ according to what we have decided above.
+ */
+ if (!no_changes) // We are allowed to update QEP
+ {
+ if (best_key >= 0)
+ {
+ bool quick_created=
+ (select && select->quick && select->quick!=save_quick);
+
+ /*
+ If ref_key used index tree reading only ('Using index' in EXPLAIN),
+ and best_key doesn't, then revert the decision.
+ */
+ if (!table->covering_keys.is_set(best_key))
+ table->disable_keyread();
+ if (!quick_created)
+ {
+ if (select) // Throw any existing quick select
+ select->quick= 0; // Cleanup either reset to save_quick,
+ // or 'delete save_quick'
+ tab->index= best_key;
+ tab->read_first_record= order_direction > 0 ?
+ join_read_first:join_read_last;
+ tab->type=JT_NEXT; // Read with index_first(), index_next()
+
+ if (table->covering_keys.is_set(best_key) && ! table->key_read)
+ table->enable_keyread();
+ if (tab->pre_idx_push_select_cond)
+ {
+ tab->set_cond(tab->pre_idx_push_select_cond);
+ /*
+ orig_cond is a part of pre_idx_push_cond,
+ no need to restore it.
+ */
+ orig_cond= 0;
+ orig_cond_saved= false;
+ }
+ table->file->ha_index_or_rnd_end();
+ if (tab->join->select_options & SELECT_DESCRIBE)
+ {
+ tab->ref.key= -1;
+ tab->ref.key_parts= 0;
+ if (best_select_limit < table->file->stats.records)
+ tab->limit= best_select_limit;
+ }
+ }
+ else if (tab->type != JT_ALL)
+ {
+ /*
+ We're about to use a quick access to the table.
+ We need to change the access method so as the quick access
+ method is actually used.
+ */
+ DBUG_ASSERT(tab->select->quick);
+ tab->type=JT_ALL;
+ tab->use_quick=1;
+ tab->ref.key= -1;
+ tab->ref.key_parts=0; // Don't use ref key.
+ tab->read_first_record= join_init_read_record;
+ if (tab->is_using_loose_index_scan())
+ tab->join->tmp_table_param.precomputed_group_by= TRUE;
+
+ /*
+ Restore the original condition as changes done by pushdown
+ condition are not relevant anymore
+ */
+ if (tab->select && tab->select->pre_idx_push_select_cond)
+ tab->set_cond(tab->select->pre_idx_push_select_cond);
+
+ /*
+ TODO: update the number of records in join->best_positions[tablenr]
+ */
+ }
+ } // best_key >= 0
+
+ if (order_direction == -1) // If ORDER BY ... DESC
+ {
+ if (select && select->quick)
{
QUICK_SELECT_DESC *tmp;
bool error= FALSE;
- int quick_type= select->quick->get_type();
- if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
- quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
- quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
- quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
- quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
+
+ /* ORDER BY range_key DESC */
+ tmp= new QUICK_SELECT_DESC((QUICK_RANGE_SELECT*)(select->quick),
+ used_key_parts, &error);
+ if (tmp && select->quick == save_quick)
+ save_quick= 0; // ::QUICK_SELECT_DESC consumed it
+
+ if (!tmp || error)
{
+ delete tmp;
tab->limit= 0;
- select->quick= save_quick;
- goto use_filesort; // Use filesort
+ goto use_filesort; // Reverse sort failed -> filesort
}
-
- /* ORDER BY range_key DESC */
- tmp= new QUICK_SELECT_DESC((QUICK_RANGE_SELECT*)(select->quick),
- used_key_parts, &error);
- if (!tmp || error)
- {
- delete tmp;
- select->quick= save_quick;
- tab->limit= 0;
- goto use_filesort; // Reverse sort not supported
- }
- select->quick=tmp;
+ select->quick= tmp;
}
- }
- else if (tab->type != JT_NEXT && tab->type != JT_REF_OR_NULL &&
- tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
- {
- /*
- SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
+ else if (tab->type != JT_NEXT && tab->type != JT_REF_OR_NULL &&
+ tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
+ {
+ /*
+ SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
- Use a traversal function that starts by reading the last row
- with key part (A) and then traverse the index backwards.
- */
- tab->read_first_record= join_read_last_key;
- tab->read_record.read_record= join_read_prev_same;
+ Use a traversal function that starts by reading the last row
+ with key part (A) and then traverse the index backwards.
+ */
+ tab->read_first_record= join_read_last_key;
+ tab->read_record.read_record= join_read_prev_same;
+ }
}
+ else if (select && select->quick)
+ select->quick->need_sorted_output();
+
+ } // QEP has been modified
+
+ /*
+ Cleanup:
+ We may have both a 'select->quick' and 'save_quick' (original)
+ at this point. Delete the one that we wan't use.
+ */
+
+skipped_filesort:
+ // Keep current (ordered) select->quick
+ if (select && save_quick != select->quick)
+ {
+ delete save_quick;
+ save_quick= NULL;
}
- else if (select && select->quick)
- select->quick->need_sorted_output();
- if (orig_select_cond)
- tab->set_cond(orig_select_cond);
+ /*
+ orig_cond is a part of pre_idx_push_cond,
+ no need to restore it.
+ */
+ orig_cond= 0;
+ orig_cond_saved= false;
+ if (orig_cond_saved && !changed_key)
+ tab->set_cond(orig_cond);
DBUG_RETURN(1);
+
use_filesort:
- if (orig_select_cond)
- tab->set_cond(orig_select_cond);
+ // Restore original save_quick
+ if (select && select->quick != save_quick)
+ {
+ delete select->quick;
+ select->quick= save_quick;
+ }
+ if (orig_cond_saved)
+ tab->set_cond(orig_cond);
DBUG_RETURN(0);
}
@@ -16717,12 +17777,15 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
JOIN_TAB *tab;
DBUG_ENTER("create_sort_index");
- if (join->tables == join->const_tables)
+ if (join->table_count == join->const_tables)
DBUG_RETURN(0); // One row, no need to sort
tab= join->join_tab + join->const_tables;
table= tab->table;
select= tab->select;
+ /* Currently ORDER BY ... LIMIT is not supported in subqueries. */
+ DBUG_ASSERT(join->group_list || !join->is_in_subquery());
+
/*
When there is SQL_BIG_RESULT do not sort using index for GROUP BY,
and thus force sorting on disk unless a group min-max optimization
@@ -16782,6 +17845,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))
goto err;
+ if (!tab->preread_init_done && tab->preread_init())
+ goto err;
if (table->s->tmp_table)
table->file->info(HA_STATUS_VARIABLE); // Get record count
table->sort.found_records=filesort(thd, table,join->sortorder, length,
@@ -16834,7 +17899,8 @@ static bool fix_having(JOIN *join, Item **having)
table_map used_tables= join->const_table_map | table->table->map;
DBUG_EXECUTE("where",print_where(*having,"having", QT_ORDINARY););
- Item* sort_table_cond=make_cond_for_table(*having, used_tables, used_tables,
+ Item* sort_table_cond= make_cond_for_table(join->thd, *having, used_tables,
+ used_tables, MAX_TABLES,
FALSE, FALSE);
if (sort_table_cond)
{
@@ -16853,8 +17919,9 @@ static bool fix_having(JOIN *join, Item **having)
DBUG_EXECUTE("where",print_where(table->select_cond,
"select and having",
QT_ORDINARY););
- *having= make_cond_for_table(*having,~ (table_map) 0,~used_tables,
- FALSE, FALSE);
+ *having= make_cond_for_table(join->thd, *having,
+ ~ (table_map) 0,~used_tables,
+ MAX_TABLES, FALSE, FALSE);
DBUG_EXECUTE("where",
print_where(*having,"having after make_cond", QT_ORDINARY););
}
@@ -17341,7 +18408,7 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
order->in_field_list= 1;
order->counter= count;
order->counter_used= 1;
- return FALSE;
+ return FALSE;
}
/* Lookup the current GROUP/ORDER field in the SELECT clause. */
select_item= find_item_in_list(order_item, fields, &counter,
@@ -17786,8 +18853,10 @@ test_if_subpart(ORDER *a,ORDER *b)
*/
static TABLE *
-get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables)
+get_sort_by_table(ORDER *a,ORDER *b, List<TABLE_LIST> &tables)
{
+ TABLE_LIST *table;
+ List_iterator<TABLE_LIST> ti(tables);
table_map map= (table_map) 0;
DBUG_ENTER("get_sort_by_table");
@@ -17805,11 +18874,11 @@ get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables)
if (!map || (map & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT)))
DBUG_RETURN(0);
- for (; !(map & tables->table->map); tables= tables->next_leaf) ;
- if (map != tables->table->map)
+ while ((table= ti++) && !(map & table->table->map)) ;
+ if (map != table->table->map)
DBUG_RETURN(0); // More than one table
- DBUG_PRINT("exit",("sort by table: %d",tables->table->tablenr));
- DBUG_RETURN(tables->table);
+ DBUG_PRINT("exit",("sort by table: %d",table->table->tablenr));
+ DBUG_RETURN(table->table);
}
@@ -18602,6 +19671,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
if (join_tab->select->cond)
error=(int) cond->add(join_tab->select->cond);
join_tab->select->cond= cond;
+ if (join_tab->select->pre_idx_push_select_cond)
+ join_tab->select->pre_idx_push_select_cond= cond;
join_tab->set_select_cond(cond, __LINE__);
}
else if ((join_tab->select= make_select(join_tab->table, 0, 0, cond, 0,
@@ -19004,6 +20075,7 @@ int JOIN::rollup_send_data(uint idx)
uint i;
for (i= send_group_parts ; i-- > idx ; )
{
+ int res= 0;
/* Get reference pointers to sum functions in place */
memcpy((char*) ref_pointer_array,
(char*) rollup.ref_pointer_arrays[i],
@@ -19011,9 +20083,10 @@ int JOIN::rollup_send_data(uint idx)
if ((!having || having->val_int()))
{
if (send_records < unit->select_limit_cnt && do_send_rows &&
- result->send_data(rollup.fields[i]))
+ (res= result->send_data(rollup.fields[i])) > 0)
return 1;
- send_records++;
+ if (!res)
+ send_records++;
}
}
/* Restore ref_pointer_array */
@@ -19209,20 +20282,24 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
if (result->send_data(item_list))
join->error= 1;
}
- else
+ else if (!join->select_lex->master_unit()->derived ||
+ join->select_lex->master_unit()->derived->is_materialized_derived())
{
table_map used_tables=0;
- uchar sjm_nests[MAX_TABLES];
- uint sjm_nests_cur=0;
- uint sjm_nests_end= 0;
- uint end_table= join->tables;
bool printing_materialize_nest= FALSE;
uint select_id= join->select_lex->select_number;
- for (uint i=0 ; i < end_table ; i++)
+ for (JOIN_TAB *tab= first_breadth_first_tab(join); tab;
+ tab= next_breadth_first_tab(join, tab))
{
- JOIN_TAB *tab=join->join_tab+i;
+ if (tab->bush_root_tab)
+ {
+ JOIN_TAB *first_sibling= tab->bush_root_tab->bush_children->start;
+ select_id= first_sibling->emb_sj_nest->sj_subq_pred->get_identifier();
+ printing_materialize_nest= TRUE;
+ }
+
TABLE *table=tab->table;
TABLE_LIST *table_list= tab->table->pos_in_table_list;
char buff[512];
@@ -19262,84 +20339,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
join->select_lex->type;
item_list.push_back(new Item_string(stype, strlen(stype), cs));
- /*
- Special processing for SJ-Materialization nests: print the fake table
- and delay printing of the SJM nest contents until later.
- */
- uint sj_strategy= join->best_positions[i].sj_strategy;
- if (sj_is_materialize_strategy(sj_strategy) &&
- !printing_materialize_nest)
- {
- /* table */
- int len= my_snprintf(table_name_buffer,
- sizeof(table_name_buffer)-1,
- "subselect%d",
- tab->emb_sj_nest->sj_subq_pred->get_identifier());
- item_list.push_back(new Item_string(table_name_buffer, len, cs));
- /* partitions */
- if (join->thd->lex->describe & DESCRIBE_PARTITIONS)
- item_list.push_back(item_null);
- /* type */
- uint type= (sj_strategy == SJ_OPT_MATERIALIZE_SCAN)? JT_ALL : JT_EQ_REF;
- item_list.push_back(new Item_string(join_type_str[type],
- strlen(join_type_str[type]),
- cs));
- /* possible_keys */
- item_list.push_back(new Item_string("unique_key",
- strlen("unique_key"), cs));
- if (sj_strategy == SJ_OPT_MATERIALIZE_SCAN)
- {
- item_list.push_back(item_null); /* key */
- item_list.push_back(item_null); /* key_len */
- item_list.push_back(item_null); /* ref */
- }
- else
- {
- /* key */
- item_list.push_back(new Item_string("unique_key", strlen("unique_key"), cs));
- /* key_len */
- uint klen= tab->emb_sj_nest->sj_mat_info->table->key_info[0].key_length;
- uint buflen= longlong10_to_str(klen, keylen_str_buf, 10) - keylen_str_buf;
- item_list.push_back(new Item_string(keylen_str_buf, buflen, cs));
- /* ref */
- item_list.push_back(new Item_string("func", strlen("func"), cs));
- }
- /* rows */
- ha_rows rows= (ha_rows) ((sj_strategy == SJ_OPT_MATERIALIZE_SCAN)?
- tab->emb_sj_nest->sj_mat_info->rows : 1.0);
- item_list.push_back(new Item_int((longlong)rows,
- MY_INT64_NUM_DECIMAL_DIGITS));
- /* filtered */
- if (join->thd->lex->describe & DESCRIBE_EXTENDED)
- item_list.push_back(new Item_float(1.0, 2));
-
- /* Extra */
- if (need_tmp_table)
- {
- need_tmp_table=0;
- extra.append(STRING_WITH_LEN("; Using temporary"));
- }
- if (need_order)
- {
- need_order=0;
- extra.append(STRING_WITH_LEN("; Using filesort"));
- }
- /* Skip initial "; "*/
- const char *str= extra.ptr();
- uint32 extra_len= extra.length();
- if (extra_len)
- {
- str += 2;
- extra_len -= 2;
- }
- item_list.push_back(new Item_string(str, extra_len, cs));
-
- /* Register the nest for further processing: */
- sjm_nests[sjm_nests_end++]= i;
- i += join->best_positions[i].n_sj_tables-1;
- goto loop_end;
- }
-
if ((tab->type == JT_ALL || tab->type == JT_HASH) &&
tab->select && tab->select->quick)
{
@@ -19362,6 +20361,16 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
table->derived_select_number);
item_list.push_back(new Item_string(table_name_buffer, len, cs));
}
+ else if (tab->bush_children)
+ {
+ JOIN_TAB *ctab= tab->bush_children->start;
+ /* table */
+ int len= my_snprintf(table_name_buffer,
+ sizeof(table_name_buffer)-1,
+ "<subquery%d>",
+ ctab->emb_sj_nest->sj_subq_pred->get_identifier());
+ item_list.push_back(new Item_string(table_name_buffer, len, cs));
+ }
else
{
TABLE_LIST *real_table= table->pos_in_table_list;
@@ -19477,7 +20486,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
else
{
- if (table_list->schema_table &&
+ if (table_list && /* SJM bushes don't have table_list */
+ table_list->schema_table &&
table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
{
const char *tmp_buff;
@@ -19508,7 +20518,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
/* Add "rows" field to item_list. */
- if (table_list->schema_table)
+ if (table_list /* SJM bushes don't have table_list */ &&
+ table_list->schema_table)
{
/* in_rows */
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
@@ -19527,12 +20538,23 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
examined_rows= tab->limit;
else
{
- tab->table->file->info(HA_STATUS_VARIABLE);
- examined_rows= tab->table->file->stats.records;
+ if (!tab->table->pos_in_table_list ||
+ tab->table->is_filled_at_execution()) // temporary, is_filled_at_execution
+ {
+ examined_rows= tab->records;
+ }
+ else
+ {
+ /*
+ handler->info(HA_STATUS_VARIABLE) has been called in
+ make_join_statistics()
+ */
+ examined_rows= tab->table->file->stats.records;
+ }
}
}
else
- examined_rows=(ha_rows)join->best_positions[i].records_read;
+ examined_rows=(ha_rows)tab->records_read;
item_list.push_back(new Item_int((longlong) (ulonglong) examined_rows,
MY_INT64_NUM_DECIMAL_DIGITS));
@@ -19540,21 +20562,10 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
/* Add "filtered" field to item_list. */
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
{
- /*
- psergey-todo:
- in the code above, we cast to integer when asssigning to
- examined_rows.
- In the code below, we may divide original value but result of
- conversion of the same value to integer, which may produce a
- value that's greater than 100%, which looks very odd.
- I'm not fixing this right away because that might trigger a wave
- of small EXPLAIN EXTENDED output changes, which I don't have time
- to deal with right now.
- */
float f= 0.0;
if (examined_rows)
- f= (float) (100.0 * join->best_positions[i].records_read /
- examined_rows);
+ f= (float) (100.0 * tab->records_read / examined_rows);
+ set_if_smaller(f, 100.0);
item_list.push_back(new Item_float(f, 2));
}
}
@@ -19639,7 +20650,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
extra.append(STRING_WITH_LEN("; Using where"));
}
}
- if (table_list->schema_table &&
+ if (table_list /* SJM bushes don't have table_list */ &&
+ table_list->schema_table &&
table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
{
if (!table_list->table_open_method)
@@ -19736,25 +20748,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
}
- /*
- if (sj_is_materialize_strategy(sj_strategy))
- {
- if (join->best_positions[i].n_sj_tables == 1)
- extra.append(STRING_WITH_LEN("; Materialize"));
- else
- {
- last_sjm_table= i + join->best_positions[i].n_sj_tables - 1;
- extra.append(STRING_WITH_LEN("; Start materialize"));
- }
- if (sj_strategy == SJ_OPT_MATERIALIZE_SCAN)
- extra.append(STRING_WITH_LEN("; Scan"));
- }
- else if (last_sjm_table == i)
- {
- extra.append(STRING_WITH_LEN("; End materialize"));
- }
- */
-
for (uint part= 0; part < tab->ref.key_parts; part++)
{
if (tab->ref.cond_guards[part])
@@ -19780,14 +20773,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
item_list.push_back(new Item_string(str, len, cs));
}
- loop_end:
- if (i+1 == end_table && sjm_nests_cur != sjm_nests_end)
- {
- printing_materialize_nest= TRUE;
- i= sjm_nests[sjm_nests_cur++] - 1;
- end_table= (i+1) + join->best_positions[i+1].n_sj_tables;
- select_id= join->join_tab[i+1].emb_sj_nest->sj_subq_pred->get_identifier();
- }
// For next iteration
used_tables|=table->map;
@@ -19835,28 +20820,12 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
bool res= 0;
SELECT_LEX *first= unit->first_select();
- for (SELECT_LEX *sl= first;
- sl;
- sl= sl->next_select())
- {
- // drop UNCACHEABLE_EXPLAIN, because it is for internal usage only
- uint8 uncacheable= (sl->uncacheable & ~UNCACHEABLE_EXPLAIN);
- sl->type= (((&thd->lex->select_lex)==sl)?
- (sl->first_inner_unit() || sl->next_select() ?
- "PRIMARY" : "SIMPLE"):
- ((sl == first)?
- ((sl->linkage == DERIVED_TABLE_TYPE) ?
- "DERIVED":
- ((uncacheable & UNCACHEABLE_DEPENDENT) ?
- "DEPENDENT SUBQUERY":
- (uncacheable?"UNCACHEABLE SUBQUERY":
- "SUBQUERY"))):
- ((uncacheable & UNCACHEABLE_DEPENDENT) ?
- "DEPENDENT UNION":
- uncacheable?"UNCACHEABLE UNION":
- "UNION")));
+ for (SELECT_LEX *sl= first; sl; sl= sl->next_select())
+ {
+ sl->set_explain_type();
sl->options|= SELECT_DESCRIBE;
}
+
if (unit->is_union())
{
unit->fake_select_lex->select_number= UINT_MAX; // jost for initialization
@@ -20041,6 +21010,14 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
print_join(thd, eliminated_tables, str, &nested_join->join_list, query_type);
str->append(')');
}
+ else if (jtbm_subselect)
+ {
+ str->append(STRING_WITH_LEN(" <materialize> ("));
+ subselect_hash_sj_engine *hash_engine;
+ hash_engine= (subselect_hash_sj_engine*)jtbm_subselect->engine;
+ hash_engine->materialize_engine->print(str, query_type);
+ str->append(')');
+ }
else
{
const char *cmp_name; // Name to compare with alias
@@ -20272,6 +21249,8 @@ bool JOIN::change_result(select_result *res)
{
DBUG_ENTER("JOIN::change_result");
result= res;
+ if (tmp_join)
+ tmp_join->result= res;
if (!procedure && (result->prepare(fields_list, select_lex->master_unit()) ||
result->prepare2()))
{
@@ -20315,5 +21294,154 @@ void JOIN::set_allowed_join_cache_types()
/**
+ Save a query execution plan so that the caller can revert to it if needed,
+ and reset the current query plan so that it can be reoptimized.
+
+ @param save_to The object into which the current query plan state is saved
+*/
+
+void JOIN::save_query_plan(Join_plan_state *save_to)
+{
+ if (keyuse.elements)
+ {
+ DYNAMIC_ARRAY tmp_keyuse;
+ /* Swap the current and the backup keyuse internal arrays. */
+ tmp_keyuse= keyuse;
+ keyuse= save_to->keyuse; /* keyuse is reset to an empty array. */
+ save_to->keyuse= tmp_keyuse;
+
+ for (uint i= 0; i < table_count; i++)
+ {
+ save_to->join_tab_keyuse[i]= join_tab[i].keyuse;
+ join_tab[i].keyuse= NULL;
+ save_to->join_tab_checked_keys[i]= join_tab[i].checked_keys;
+ join_tab[i].checked_keys.clear_all();
+ }
+ }
+ memcpy((uchar*) save_to->best_positions, (uchar*) best_positions,
+ sizeof(POSITION) * (table_count + 1));
+ memset(best_positions, 0, sizeof(POSITION) * (table_count + 1));
+}
+
+
+/**
+ Restore a query execution plan previously saved by the caller.
+
+ @param The object from which the current query plan state is restored.
+*/
+
+void JOIN::restore_query_plan(Join_plan_state *restore_from)
+{
+ if (restore_from->keyuse.elements)
+ {
+ DYNAMIC_ARRAY tmp_keyuse;
+ tmp_keyuse= keyuse;
+ keyuse= restore_from->keyuse;
+ restore_from->keyuse= tmp_keyuse;
+
+ for (uint i= 0; i < table_count; i++)
+ {
+ join_tab[i].keyuse= restore_from->join_tab_keyuse[i];
+ join_tab[i].checked_keys= restore_from->join_tab_checked_keys[i];
+ }
+
+ }
+ memcpy((uchar*) best_positions, (uchar*) restore_from->best_positions,
+ sizeof(POSITION) * (table_count + 1));
+}
+
+
+/**
+ Reoptimize a query plan taking into account an additional conjunct to the
+ WHERE clause.
+
+ @param added_where An extra conjunct to the WHERE clause to reoptimize with
+ @param join_tables The set of tables to reoptimize
+ @param save_to If != NULL, save here the state of the current query plan
+
+ @notes
+ Given a query plan that was already optimized taking into account some WHERE
+ clause 'C', reoptimize this plan with a new WHERE clause 'C AND added_where'.
+ The reoptimization works as follows:
+
+ 1. Call update_ref_and_keys *only* for the new conditions 'added_where'
+ that are about to be injected into the query.
+ 2. Expand if necessary the original KEYUSE array JOIN::keyuse to
+ accommodate the new REF accesses computed for the 'added_where' condition.
+ 3. Add the new KEYUSEs into JOIN::keyuse.
+ 4. Re-sort and re-filter the JOIN::keyuse array with the newly added
+ KEYUSE elements.
+
+ @retval REOPT_NEW_PLAN there is a new plan.
+ @retval REOPT_OLD_PLAN no new improved plan was produced, use the old one.
+ @retval REOPT_ERROR an irrecovarable error occured during reoptimization.
+*/
+
+JOIN::enum_reopt_result
+JOIN::reoptimize(Item *added_where, table_map join_tables,
+ Join_plan_state *save_to)
+{
+ DYNAMIC_ARRAY added_keyuse;
+ SARGABLE_PARAM *sargables= 0; /* Used only as a dummy parameter. */
+ uint org_keyuse_elements;
+
+ /* Re-run the REF optimizer to take into account the new conditions. */
+ if (update_ref_and_keys(thd, &added_keyuse, join_tab, table_count, added_where,
+ ~outer_join, select_lex, &sargables))
+ {
+ delete_dynamic(&added_keyuse);
+ return REOPT_ERROR;
+ }
+
+ if (!added_keyuse.elements)
+ {
+ delete_dynamic(&added_keyuse);
+ return REOPT_OLD_PLAN;
+ }
+
+ if (save_to)
+ save_query_plan(save_to);
+
+ if (!keyuse.buffer &&
+ my_init_dynamic_array(&keyuse, sizeof(KEYUSE), 20, 64))
+ {
+ delete_dynamic(&added_keyuse);
+ return REOPT_ERROR;
+ }
+
+ org_keyuse_elements= save_to ? save_to->keyuse.elements : keyuse.elements;
+ allocate_dynamic(&keyuse, org_keyuse_elements + added_keyuse.elements);
+
+ /* If needed, add the access methods from the original query plan. */
+ if (save_to)
+ {
+ DBUG_ASSERT(!keyuse.elements);
+ memcpy(keyuse.buffer,
+ save_to->keyuse.buffer,
+ (size_t) save_to->keyuse.elements * keyuse.size_of_element);
+ keyuse.elements= save_to->keyuse.elements;
+ }
+
+ /* Add the new access methods to the keyuse array. */
+ memcpy(keyuse.buffer + keyuse.elements * keyuse.size_of_element,
+ added_keyuse.buffer,
+ (size_t) added_keyuse.elements * added_keyuse.size_of_element);
+ keyuse.elements+= added_keyuse.elements;
+ /* added_keyuse contents is copied, and it is no longer needed. */
+ delete_dynamic(&added_keyuse);
+
+ if (sort_and_filter_keyuse(thd, &keyuse, true))
+ return REOPT_ERROR;
+ optimize_keyuse(this, &keyuse);
+
+ /* Re-run the join optimizer to compute a new query plan. */
+ if (choose_plan(this, join_tables))
+ return REOPT_ERROR;
+
+ return REOPT_NEW_PLAN;
+}
+
+
+/**
@} (end of group Query_Optimizer)
*/
diff --git a/sql/sql_select.h b/sql/sql_select.h
index f0eda9671cb..abb9a98030e 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -165,13 +165,25 @@ enum enum_nested_loop_state
typedef enum_nested_loop_state
(*Next_select_func)(JOIN *, struct st_join_table *, bool);
+
+/*
+ Function prototype for reading first record for a join tab
+
+ RETURN
+ 0 - OK
+ -1 - Record not found
+ Other - A fatal error
+*/
typedef int (*Read_record_func)(struct st_join_table *tab);
+
Next_select_func setup_end_select_func(JOIN *join);
int rr_sequential(READ_RECORD *info);
+int rr_sequential_and_unpack(READ_RECORD *info);
class JOIN_CACHE;
class SJ_TMP_TABLE;
+class JOIN_TAB_RANGE;
typedef struct st_join_table {
st_join_table() {} /* Remove gcc warning */
@@ -200,6 +212,21 @@ typedef struct st_join_table {
st_join_table *last_inner; /**< last table table for embedding outer join */
st_join_table *first_upper; /**< first inner table for embedding outer join */
st_join_table *first_unmatched; /**< used for optimization purposes only */
+
+ /*
+ For join tabs that are inside an SJM bush: root of the bush
+ */
+ st_join_table *bush_root_tab;
+
+ /* TRUE <=> This join_tab is inside an SJM bush and is the last leaf tab here */
+ bool last_leaf_in_bush;
+
+ /*
+ ptr - this is a bush, and ptr points to description of child join_tab
+ range
+ NULL - this join tab has no bush children
+ */
+ JOIN_TAB_RANGE *bush_children;
/* Special content for EXPLAIN 'Extra' column or NULL if none */
const char *info;
@@ -237,7 +264,13 @@ typedef struct st_join_table {
method (but not 'index' for some reason), i.e. this matches method which
E(#records) is in found_records.
*/
- ha_rows read_time;
+ double read_time;
+
+ /* psergey-todo: make the below have type double, like POSITION::records_read? */
+ ha_rows records_read;
+
+ /* Startup cost for execution */
+ double startup_cost;
double partial_join_cardinality;
@@ -330,11 +363,13 @@ typedef struct st_join_table {
/*
Semi-join strategy to be used for this join table. This is a copy of
POSITION::sj_strategy field. This field is set up by the
- fix_semijion_strategies_for_picked_join_order.
+ fix_semijoin_strategies_for_picked_join_order.
*/
uint sj_strategy;
- struct st_join_table *first_sjm_sibling;
+ uint n_sj_tables;
+
+ bool preread_init_done;
void cleanup();
inline bool is_using_loose_index_scan()
@@ -441,6 +476,8 @@ typedef struct st_join_table {
{
return (is_hash_join_key_no(key) ? hj_key : table->key_info+key);
}
+ double scan_time();
+ bool preread_init();
} JOIN_TAB;
@@ -450,9 +487,6 @@ enum_nested_loop_state sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool
end_of_records);
enum_nested_loop_state sub_select(JOIN *join,JOIN_TAB *join_tab, bool
end_of_records);
-enum_nested_loop_state sub_select_sjm(JOIN *join, JOIN_TAB *join_tab,
- bool end_of_records);
-
enum_nested_loop_state
end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
bool end_of_records);
@@ -554,6 +588,8 @@ typedef struct st_position
*/
table_map firstmatch_need_tables;
+ bool in_firstmatch_prefix() { return (first_firstmatch_table != MAX_TABLES); }
+ void invalidate_firstmatch_prefix() { first_firstmatch_table= MAX_TABLES; }
/* Duplicate Weedout strategy */
/* The first table that the strategy will need to handle */
@@ -600,26 +636,99 @@ inline bool sj_is_materialize_strategy(uint strategy)
return strategy >= SJ_OPT_MATERIALIZE;
}
+class JOIN_TAB_RANGE: public Sql_alloc
+{
+public:
+ JOIN_TAB *start;
+ JOIN_TAB *end;
+};
+
class JOIN :public Sql_alloc
{
+private:
JOIN(const JOIN &rhs); /**< not implemented */
JOIN& operator=(const JOIN &rhs); /**< not implemented */
+
+protected:
+
+ /**
+ The subset of the state of a JOIN that represents an optimized query
+ execution plan. Allows saving/restoring different JOIN plans for the same
+ query.
+ */
+ class Join_plan_state {
+ public:
+ DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */
+ POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */
+ /* Copies of the JOIN_TAB::keyuse pointers for each JOIN_TAB. */
+ KEYUSE *join_tab_keyuse[MAX_TABLES];
+ /* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */
+ key_map join_tab_checked_keys[MAX_TABLES];
+ public:
+ Join_plan_state()
+ {
+ keyuse.elements= 0;
+ keyuse.buffer= NULL;
+ }
+ Join_plan_state(JOIN *join);
+ ~Join_plan_state()
+ {
+ delete_dynamic(&keyuse);
+ }
+ };
+
+ /* Results of reoptimizing a JOIN via JOIN::reoptimize(). */
+ enum enum_reopt_result {
+ REOPT_NEW_PLAN, /* there is a new reoptimized plan */
+ REOPT_OLD_PLAN, /* no new improved plan can be found, use the old one */
+ REOPT_ERROR, /* an irrecovarable error occured during reoptimization */
+ REOPT_NONE /* not yet reoptimized */
+ };
+
+ /* Support for plan reoptimization with rewritten conditions. */
+ enum_reopt_result reoptimize(Item *added_where, table_map join_tables,
+ Join_plan_state *save_to);
+ void save_query_plan(Join_plan_state *save_to);
+ void restore_query_plan(Join_plan_state *restore_from);
+ /* Choose a subquery plan for a table-less subquery. */
+ bool choose_tableless_subquery_plan();
+
public:
- JOIN_TAB *join_tab,**best_ref;
+ JOIN_TAB *join_tab, **best_ref;
JOIN_TAB **map2table; ///< mapping between table indexes and JOIN_TABs
JOIN_TAB *join_tab_save; ///< saved join_tab for subquery reexecution
+
+ List<JOIN_TAB_RANGE> join_tab_ranges;
+
+ /*
+ Base tables participating in the join. After join optimization is done, the
+ tables are stored in the join order (but the only really important part is
+ that const tables are first).
+ */
TABLE **table;
- TABLE **all_tables;
/**
The table which has an index that allows to produce the requried ordering.
A special value of 0x1 means that the ordering will be produced by
passing 1st non-const table to filesort(). NULL means no such table exists.
*/
TABLE *sort_by_table;
- uint tables; /**< Number of tables in the join */
+ /*
+ Number of tables in the join.
+ (In MySQL, it is named 'tables' and is also the number of elements in
+ join->join_tab array. In MariaDB, the latter is not true, so we've renamed
+ the variable)
+ */
+ uint table_count;
uint outer_tables; /**< Number of tables that are not inside semijoin */
uint const_tables;
+ /*
+ Number of tables in the top join_tab array. Normally this matches
+ (join_tab_ranges.head()->end - join_tab_ranges.head()->start).
+
+ We keep it here so that it is saved/restored with JOIN::restore_tmp.
+ */
+ uint top_join_tab_count;
uint send_group_parts;
bool group; /**< If query contains GROUP BY clause */
/**
@@ -646,7 +755,8 @@ public:
/* Tables removed by table elimination. Set to 0 before the elimination. */
table_map eliminated_tables;
/*
- Bitmap of all inner tables from outer joins
+ Bitmap of all inner tables from outer joins (set at start of
+ make_join_statistics)
*/
table_map outer_join;
ha_rows send_records,found_records,examined_rows,row_limit, select_limit;
@@ -695,13 +805,19 @@ public:
/* We also maintain a stack of join optimization states in * join->positions[] */
/******* Join optimization state members end *******/
- Next_select_func first_select;
/*
The cost of best complete join plan found so far during optimization,
after optimization phase - cost of picked join order (not taking into
account the changes made by test_if_skip_sort_order()).
*/
double best_read;
+ /*
+ Estimated result rows (fanout) of the join operation. If this is a subquery
+ that is reexecuted multiple times, this value includes the estiamted # of
+ reexecutions. This value is equal to the multiplication of all
+ join->positions[i].records_read of a JOIN.
+ */
+ double record_count;
List<Item> *fields;
List<Cached_item> group_fields, group_fields_cache;
TABLE *tmp_table;
@@ -815,6 +931,19 @@ public:
List<TABLE_LIST> *join_list; ///< list of joined tables in reverse order
COND_EQUAL *cond_equal;
COND_EQUAL *having_equal;
+ /*
+ Constant codition computed during optimization, but evaluated during
+ join execution. Typically expensive conditions that should not be
+ evaluated at optimization time.
+ */
+ Item *exec_const_cond;
+ /*
+ Constant ORDER and/or GROUP expressions that contain subqueries. Such
+ expressions need to evaluated to verify that the subquery indeed
+ returns a single row. The evaluation of such expressions is delayed
+ until query execution.
+ */
+ List<Item> exec_const_order_group_cond;
SQL_SELECT *select; ///<created in optimisation phase
JOIN_TAB *return_tab; ///<used only for outer joins
Item **ref_pointer_array; ///<used pointer reference for this select
@@ -825,9 +954,20 @@ public:
bool union_part; ///< this subselect is part of union
bool optimized; ///< flag to avoid double optimization in EXPLAIN
+ bool initialized; ///< flag to avoid double init_execution calls
+ /*
+ Subqueries that will need to be converted to semi-join nests, including
+ those converted to jtbm nests. The list is emptied when conversion is done.
+ */
Array<Item_in_subselect> sj_subselects;
-
+ /*
+ Additional WHERE and HAVING predicates to be considered for IN=>EXISTS
+ subquery transformation of a JOIN object.
+ */
+ Item *in_to_exists_where;
+ Item *in_to_exists_having;
+
/* Temporary tables used to weed-out semi-join duplicates */
List<TABLE> sj_tmp_tables;
/* SJM nests that are executed with SJ-Materialization strategy */
@@ -860,7 +1000,8 @@ public:
{
join_tab= join_tab_save= 0;
table= 0;
- tables= 0;
+ table_count= 0;
+ top_join_tab_count= 0;
const_tables= 0;
eliminated_tables= 0;
join_list= 0;
@@ -901,8 +1042,10 @@ public:
ref_pointer_array_size= 0;
zero_result_cause= 0;
optimized= 0;
+ initialized= 0;
cond_equal= 0;
having_equal= 0;
+ exec_const_cond= 0;
group_optimized_away= 0;
no_rows_in_result_called= 0;
@@ -915,22 +1058,25 @@ public:
rollup.state= ROLLUP::STATE_NONE;
no_const_tables= FALSE;
- first_select= sub_select;
outer_ref_cond= 0;
+ in_to_exists_where= NULL;
+ in_to_exists_having= NULL;
}
int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num,
COND *conds, uint og_num, ORDER *order, ORDER *group,
Item *having, ORDER *proc_param, SELECT_LEX *select,
SELECT_LEX_UNIT *unit);
+ bool prepare_stage2();
int optimize();
int reinit();
+ int init_execution();
void exec();
int destroy();
void restore_tmp();
bool alloc_func_list();
bool flatten_subqueries();
- bool setup_subquery_materialization();
+ bool optimize_unflattened_subqueries();
bool make_sum_func_list(List<Item> &all_fields, List<Item> &send_fields,
bool before_group_by, bool recompute= FALSE);
@@ -966,7 +1112,7 @@ public:
bool init_save_join_tab();
bool send_row_on_empty_set()
{
- return (do_send_rows && implicit_grouping &&
+ return (do_send_rows && implicit_grouping && !group_optimized_away &&
having_value != Item::COND_FALSE);
}
bool change_result(select_result *result);
@@ -977,8 +1123,9 @@ public:
}
inline table_map all_tables_map()
{
- return (table_map(1) << tables) - 1;
+ return (table_map(1) << table_count) - 1;
}
+ void drop_unused_derived_keys();
/*
Return the table for which an index scan can be used to satisfy
the sort order needed by the ORDER BY/(implicit) GROUP BY clause
@@ -999,7 +1146,21 @@ public:
return test(allowed_join_cache_types & JOIN_CACHE_HASHED_BIT) &&
max_allowed_join_cache_level > JOIN_CACHE_HASHED_BIT;
}
-
+ bool choose_subquery_plan(table_map join_tables);
+ void get_partial_cost_and_fanout(uint end_tab_idx,
+ table_map filter_map,
+ double *read_time_arg,
+ double *record_count_arg);
+ void get_prefix_cost_and_fanout(uint n_tables,
+ double *read_time_arg,
+ double *record_count_arg);
+ /* defined in opt_subselect.cc */
+ bool transform_max_min_subquery();
+ /* True if this JOIN is a subquery under an IN predicate. */
+ bool is_in_subquery()
+ {
+ return (unit->item && unit->item->is_in_predicate());
+ }
private:
/**
TRUE if the query contains an aggregate function but has no GROUP
@@ -1010,6 +1171,15 @@ private:
void cleanup_item_list(List<Item> &items) const;
};
+enum enum_with_bush_roots { WITH_BUSH_ROOTS, WITHOUT_BUSH_ROOTS};
+enum enum_with_const_tables { WITH_CONST_TABLES, WITHOUT_CONST_TABLES};
+
+JOIN_TAB *first_linear_tab(JOIN *join, enum enum_with_const_tables const_tbls);
+JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab,
+ enum enum_with_bush_roots include_bush_roots);
+
+JOIN_TAB *first_top_level_tab(JOIN *join, enum enum_with_const_tables with_const);
+JOIN_TAB *next_top_level_tab(JOIN *join, JOIN_TAB *tab);
typedef struct st_select_check {
uint const_ref,reg_ref;
@@ -1037,7 +1207,8 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field,
/* functions from opt_sum.cc */
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
-int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds);
+int opt_sum_query(THD* thd,
+ List<TABLE_LIST> &tables, List<Item> &all_fields, COND *conds);
/* from sql_delete.cc, used by opt_range.cc */
extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b);
@@ -1233,6 +1404,9 @@ protected:
if (!inited)
{
inited=1;
+ TABLE *table= to_field->table;
+ my_bitmap_map *old_map= dbug_tmp_use_all_columns(table,
+ table->write_set);
if ((res= item->save_in_field(to_field, 1)))
{
if (!err)
@@ -1244,6 +1418,7 @@ protected:
*/
if (!err && to_field->table->in_use->is_error())
err= 1; /* STORE_KEY_FATAL */
+ dbug_tmp_restore_column_map(table->write_set, old_map);
}
null_key= to_field->is_null() || item->null_value;
return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
@@ -1257,14 +1432,13 @@ int safe_index_read(JOIN_TAB *tab);
COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
int test_if_item_cache_changed(List<Cached_item> &list);
int join_init_read_record(JOIN_TAB *tab);
+int join_read_record_no_init(JOIN_TAB *tab);
void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key);
inline Item * and_items(Item* cond, Item *item)
{
return (cond? (new Item_cond_and(cond, item)) : item);
}
-bool choose_plan(JOIN *join,table_map join_tables);
-void get_partial_join_cost(JOIN *join, uint n_tables, double *read_time_arg,
- double *record_count_arg);
+bool choose_plan(JOIN *join, table_map join_tables);
void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
table_map last_remaining_tables,
bool first_alt, uint no_jbuf_before,
@@ -1297,7 +1471,7 @@ void push_index_cond(JOIN_TAB *tab, uint keyno);
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields,
ulonglong select_options, ha_rows rows_limit,
- char* alias);
+ char* alias, bool do_not_open=FALSE);
void free_tmp_table(THD *thd, TABLE *entry);
bool create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
ENGINE_COLUMNDEF *start_recinfo,
@@ -1309,5 +1483,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
ulonglong options);
bool open_tmp_table(TABLE *table);
void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps);
+double prev_record_reads(POSITION *positions, uint idx, table_map found_ref);
+void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist);
#endif /* SQL_SELECT_INCLUDED */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 833b695e4bf..0cf7a9b1dc2 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -755,7 +755,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
{
Show_create_error_handler view_error_suppressor(thd, table_list);
thd->push_internal_handler(&view_error_suppressor);
- bool error= open_normal_and_derived_tables(thd, table_list, 0);
+ bool error= open_normal_and_derived_tables(thd, table_list, 0,
+ DT_PREPARE | DT_CREATE);
thd->pop_internal_handler();
if (error && (thd->killed || thd->main_da.is_error()))
DBUG_RETURN(TRUE);
@@ -930,7 +931,8 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
DBUG_ENTER("mysqld_list_fields");
DBUG_PRINT("enter",("table: %s",table_list->table_name));
- if (open_normal_and_derived_tables(thd, table_list, 0))
+ if (open_normal_and_derived_tables(thd, table_list, 0,
+ DT_PREPARE | DT_CREATE))
DBUG_VOID_RETURN;
table= table_list->table;
@@ -1744,7 +1746,7 @@ view_store_options(THD *thd, TABLE_LIST *table, String *buff)
static void append_algorithm(TABLE_LIST *table, String *buff)
{
buff->append(STRING_WITH_LEN("ALGORITHM="));
- switch ((int8)table->algorithm) {
+ switch ((int16)table->algorithm) {
case VIEW_ALGORITHM_UNDEFINED:
buff->append(STRING_WITH_LEN("UNDEFINED "));
break;
@@ -2000,7 +2002,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
TABLE *table= tables->table;
CHARSET_INFO *cs= system_charset_info;
char *user;
- ulonglong unow= my_micro_time();
+ my_hrtime_t unow= my_hrtime();
DBUG_ENTER("fill_process_list");
user= thd->security_ctx->master_access & PROCESS_ACL ?
@@ -2058,8 +2060,10 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
table->field[4]->store(command_name[tmp->command].str,
command_name[tmp->command].length, cs);
/* MYSQL_TIME */
- const ulonglong utime= tmp->start_utime ? unow - tmp->start_utime : 0;
- table->field[5]->store(utime / 1000000, TRUE);
+ const ulonglong utime= (tmp->start_time ?
+ (unow.val - tmp->start_time * HRTIME_RESOLUTION -
+ tmp->start_time_sec_part) : 0);
+ table->field[5]->store(utime / HRTIME_RESOLUTION, TRUE);
/* STATE */
#ifndef EMBEDDED_LIBRARY
val= (char*) (tmp->net.reading_or_writing ?
@@ -2096,7 +2100,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
pthread_mutex_unlock(&tmp->LOCK_thd_data);
/* TIME_MS */
- table->field[8]->store((double)(utime / 1000.0));
+ table->field[8]->store((double)(utime / (HRTIME_RESOLUTION / 1000.0)));
if (schema_table_store_record(thd, table))
{
@@ -3441,8 +3445,9 @@ fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'
*/
lex->sql_command= SQLCOM_SHOW_FIELDS;
- res= open_normal_and_derived_tables(thd, show_table_list,
- MYSQL_LOCK_IGNORE_FLUSH);
+ res= (open_normal_and_derived_tables(thd, show_table_list,
+ MYSQL_LOCK_IGNORE_FLUSH,
+ DT_PREPARE | DT_CREATE));
lex->sql_command= save_sql_command;
/*
get_all_tables() returns 1 on failure and 0 on success thus
@@ -3792,6 +3797,15 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
it.rewind(); /* To get access to new elements in basis list */
while ((db_name= it++))
{
+ LEX_STRING orig_db_name;
+
+ /*
+ db_name can be changed in make_table_list() func.
+ We need copy of db_name because it can change case.
+ */
+ if (!thd->make_lex_string(&orig_db_name, db_name->str,
+ db_name->length, FALSE))
+ goto err;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!(check_access(thd,SELECT_ACL, db_name->str,
&thd->col_access, 0, 1, with_i_schema) ||
@@ -3859,17 +3873,13 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
}
int res;
- LEX_STRING tmp_lex_string, orig_db_name;
+ LEX_STRING tmp_lex_string;
/*
Set the parent lex of 'sel' because it is needed by
sel.init_query() which is called inside make_table_list.
*/
thd->no_warnings_for_error= 1;
sel.parent_lex= lex;
- /* db_name can be changed in make_table_list() func */
- if (!thd->make_lex_string(&orig_db_name, db_name->str,
- db_name->length, FALSE))
- goto err;
if (make_table_list(thd, &sel, db_name, table_name))
goto err;
TABLE_LIST *show_table_list= sel.table_list.first;
@@ -3879,8 +3889,9 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
show_table_list->i_s_requested_object=
schema_table->i_s_requested_object;
DEBUG_SYNC(thd, "before_open_in_get_all_tables");
- res= open_normal_and_derived_tables(thd, show_table_list,
- MYSQL_LOCK_IGNORE_FLUSH);
+ res= (open_normal_and_derived_tables(thd, show_table_list,
+ MYSQL_LOCK_IGNORE_FLUSH,
+ DT_PREPARE | DT_CREATE));
lex->sql_command= save_sql_command;
/*
XXX: show_table_list has a flag i_is_requested,
@@ -4217,21 +4228,21 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
{
thd->variables.time_zone->gmt_sec_to_TIME(&time,
(my_time_t) file->stats.create_time);
- table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[14]->store_time(&time);
table->field[14]->set_notnull();
}
if (file->stats.update_time)
{
thd->variables.time_zone->gmt_sec_to_TIME(&time,
(my_time_t) file->stats.update_time);
- table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[15]->store_time(&time);
table->field[15]->set_notnull();
}
if (file->stats.check_time)
{
thd->variables.time_zone->gmt_sec_to_TIME(&time,
(my_time_t) file->stats.check_time);
- table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[16]->store_time(&time);
table->field[16]->set_notnull();
}
if (file->ha_table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM))
@@ -4337,7 +4348,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
end=strmov(end,grant_types.type_names[bitnr]);
}
}
- table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
+ table->field[18]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
#endif
table->field[1]->store(db_name->str, db_name->length, cs);
@@ -4346,7 +4357,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
cs);
table->field[4]->store((longlong) count, TRUE);
field->sql_type(type);
- table->field[14]->store(type.ptr(), type.length(), cs);
+ table->field[15]->store(type.ptr(), type.length(), cs);
/*
MySQL column type has the following format:
base_type [(dimension)] [unsigned] [zerofill].
@@ -4393,6 +4404,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
They are set to -1 if they should not be set (we should return NULL)
*/
+ field_length= -1;
decimals= field->decimals();
switch (field->type()) {
case MYSQL_TYPE_NEWDECIMAL:
@@ -4421,8 +4433,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
if (decimals == NOT_FIXED_DEC)
decimals= -1; // return NULL
break;
+ case MYSQL_TYPE_TIME:
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATETIME:
+ table->field[12]->store((longlong) field->decimals(), TRUE);
+ table->field[12]->set_notnull();
+ break;
default:
- field_length= decimals= -1;
break;
}
@@ -4430,40 +4447,44 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
{
table->field[10]->store((longlong) field_length, TRUE);
table->field[10]->set_notnull();
- }
- if (decimals >= 0)
- {
- table->field[11]->store((longlong) decimals, TRUE);
- table->field[11]->set_notnull();
+ if (decimals >= 0)
+ {
+ table->field[11]->store((longlong) decimals, TRUE);
+ table->field[11]->set_notnull();
+ }
}
if (field->has_charset())
{
pos=(uchar*) field->charset()->csname;
- table->field[12]->store((const char*) pos,
- strlen((const char*) pos), cs);
- table->field[12]->set_notnull();
- pos=(uchar*) field->charset()->name;
table->field[13]->store((const char*) pos,
strlen((const char*) pos), cs);
table->field[13]->set_notnull();
+ pos=(uchar*) field->charset()->name;
+ table->field[14]->store((const char*) pos,
+ strlen((const char*) pos), cs);
+ table->field[14]->set_notnull();
}
pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
- table->field[15]->store((const char*) pos,
+ table->field[16]->store((const char*) pos,
strlen((const char*) pos), cs);
if (field->unireg_check == Field::NEXT_NUMBER)
- table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs);
+ table->field[17]->store(STRING_WITH_LEN("auto_increment"), cs);
if (show_table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_DN_FIELD)
- table->field[16]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"),
+ table->field[17]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"),
cs);
if (field->vcol_info)
- table->field[16]->store(STRING_WITH_LEN("VIRTUAL"), cs);
-
- table->field[18]->store(field->comment.str, field->comment.length, cs);
+ {
+ if (field->stored_in_db)
+ table->field[17]->store(STRING_WITH_LEN("PERSISTENT"), cs);
+ else
+ table->field[17]->store(STRING_WITH_LEN("VIRTUAL"), cs);
+ }
+ table->field[19]->store(field->comment.str, field->comment.length, cs);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
}
@@ -4715,10 +4736,10 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
bzero((char *)&time, sizeof(time));
((Field_timestamp *) proc_table->field[12])->get_time(&time);
- table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[15]->store_time(&time);
bzero((char *)&time, sizeof(time));
((Field_timestamp *) proc_table->field[13])->get_time(&time);
- table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[16]->store_time(&time);
copy_field_as_string(table->field[17], proc_table->field[14]);
copy_field_as_string(table->field[18], proc_table->field[15]);
table->field[19]->store(definer.ptr(), definer.length(), cs);
@@ -5347,21 +5368,21 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
{
thd->variables.time_zone->gmt_sec_to_TIME(&time,
(my_time_t)stat_info.create_time);
- table->field[18]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[18]->store_time(&time);
table->field[18]->set_notnull();
}
if (stat_info.update_time)
{
thd->variables.time_zone->gmt_sec_to_TIME(&time,
(my_time_t)stat_info.update_time);
- table->field[19]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[19]->store_time(&time);
table->field[19]->set_notnull();
}
if (stat_info.check_time)
{
thd->variables.time_zone->gmt_sec_to_TIME(&time,
(my_time_t)stat_info.check_time);
- table->field[20]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ table->field[20]->store_time(&time);
table->field[20]->set_notnull();
}
if (file->ha_table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM))
@@ -5742,15 +5763,13 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
/* starts & ends . STARTS is always set - see sql_yacc.yy */
et.time_zone->gmt_sec_to_TIME(&time, et.starts);
sch_table->field[ISE_STARTS]->set_notnull();
- sch_table->field[ISE_STARTS]->
- store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[ISE_STARTS]->store_time(&time);
if (!et.ends_null)
{
et.time_zone->gmt_sec_to_TIME(&time, et.ends);
sch_table->field[ISE_ENDS]->set_notnull();
- sch_table->field[ISE_ENDS]->
- store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[ISE_ENDS]->store_time(&time);
}
}
else
@@ -5760,8 +5779,7 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
et.time_zone->gmt_sec_to_TIME(&time, et.execute_at);
sch_table->field[ISE_EXECUTE_AT]->set_notnull();
- sch_table->field[ISE_EXECUTE_AT]->
- store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[ISE_EXECUTE_AT]->store_time(&time);
}
/* status */
@@ -5791,21 +5809,19 @@ copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
sch_table->field[ISE_ON_COMPLETION]->
store(STRING_WITH_LEN("PRESERVE"), scs);
- number_to_datetime(et.created, &time, 0, &not_used);
+ number_to_datetime(et.created, 0, &time, 0, &not_used);
DBUG_ASSERT(not_used==0);
- sch_table->field[ISE_CREATED]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[ISE_CREATED]->store_time(&time);
- number_to_datetime(et.modified, &time, 0, &not_used);
+ number_to_datetime(et.modified, 0, &time, 0, &not_used);
DBUG_ASSERT(not_used==0);
- sch_table->field[ISE_LAST_ALTERED]->
- store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[ISE_LAST_ALTERED]->store_time(&time);
if (et.last_executed)
{
et.time_zone->gmt_sec_to_TIME(&time, et.last_executed);
sch_table->field[ISE_LAST_EXECUTED]->set_notnull();
- sch_table->field[ISE_LAST_EXECUTED]->
- store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[ISE_LAST_EXECUTED]->store_time(&time);
}
sch_table->field[ISE_EVENT_COMMENT]->
@@ -6207,14 +6223,23 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
break;
case MYSQL_TYPE_DATE:
+ if (!(item=new Item_return_date_time(fields_info->field_name,
+ MAX_DATE_WIDTH,
+ fields_info->field_type)))
+ DBUG_RETURN(0);
+ break;
case MYSQL_TYPE_TIME:
+ if (!(item=new Item_return_date_time(fields_info->field_name,
+ MAX_TIME_FULL_WIDTH,
+ fields_info->field_type)))
+ DBUG_RETURN(0);
+ break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
if (!(item=new Item_return_date_time(fields_info->field_name,
+ MAX_DATETIME_WIDTH,
fields_info->field_type)))
- {
DBUG_RETURN(0);
- }
break;
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
@@ -6400,7 +6425,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
- int fields_arr[]= {3, 14, 13, 6, 15, 5, 16, 17, 18, -1};
+ int fields_arr[]= {3, 15, 14, 6, 16, 5, 17, 18, 19, -1};
int *field_num= fields_arr;
ST_FIELD_INFO *field_info;
Name_resolution_context *context= &thd->lex->select_lex.context;
@@ -6408,9 +6433,9 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
- if (!thd->lex->verbose && (*field_num == 13 ||
- *field_num == 17 ||
- *field_num == 18))
+ if (!thd->lex->verbose && (*field_num == 14 ||
+ *field_num == 18 ||
+ *field_num == 19))
continue;
Item_field *field= new Item_field(context,
NullS, NullS, field_info->field_name);
@@ -6615,14 +6640,15 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
bool get_schema_tables_result(JOIN *join,
enum enum_schema_table_state executed_place)
{
- JOIN_TAB *tmp_join_tab= join->join_tab+join->tables;
THD *thd= join->thd;
LEX *lex= thd->lex;
bool result= 0;
DBUG_ENTER("get_schema_tables_result");
thd->no_warnings_for_error= 1;
- for (JOIN_TAB *tab= join->join_tab; tab < tmp_join_tab; tab++)
+ for (JOIN_TAB *tab= first_linear_tab(join, WITH_CONST_TABLES);
+ tab;
+ tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
if (!tab->table || !tab->table->pos_in_table_list)
break;
@@ -6879,6 +6905,8 @@ ST_FIELD_INFO columns_fields_info[]=
0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
{"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
+ {"DATETIME_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
+ 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
{"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1, 0,
OPEN_FRM_ONLY},
{"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1, "Collation",
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index b359b2a7168..60f80fc52e8 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -52,11 +52,33 @@ bool String::real_alloc(uint32 arg_length)
}
-/*
-** Check that string is big enough. Set string[alloc_length] to 0
-** (for C functions)
-*/
+/**
+ Allocates a new buffer on the heap for this String.
+
+ - If the String's internal buffer is privately owned and heap allocated,
+ one of the following is performed.
+
+ - If the requested length is greater than what fits in the buffer, a new
+ buffer is allocated, data moved and the old buffer freed.
+
+ - If the requested length is less or equal to what fits in the buffer, a
+ null character is inserted at the appropriate position.
+ - If the String does not keep a private buffer on the heap, such a buffer
+ will be allocated and the string copied accoring to its length, as found
+ in String::length().
+
+ For C compatibility, the new string buffer is null terminated.
+
+ @param alloc_length The requested string size in characters, excluding any
+ null terminator.
+
+ @retval false Either the copy operation is complete or, if the size of the
+ new buffer is smaller than the currently allocated buffer (if one exists),
+ no allocation occured.
+
+ @retval true An error occured when attempting to allocate memory.
+*/
bool String::realloc(uint32 alloc_length)
{
if (Alloced_length <= alloc_length)
@@ -189,6 +211,17 @@ bool String::copy()
return FALSE;
}
+/**
+ Copies the internal buffer from str. If this String has a private heap
+ allocated buffer where new data does not fit, a new buffer is allocated
+ before copying and the old buffer freed. Character set information is also
+ copied.
+
+ @param str The string whose internal buffer is to be copied.
+
+ @retval false Success.
+ @retval true Memory allocation failed.
+*/
bool String::copy(const String &str)
{
if (alloc(str.str_length))
@@ -544,11 +577,11 @@ uint32 String::numchars()
return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
}
-int String::charpos(int i,uint32 offset)
+int String::charpos(longlong i,uint32 offset)
{
if (i <= 0)
- return i;
- return str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
+ return (int)i;
+ return (int)str_charset->cset->charpos(str_charset,Ptr+offset,Ptr+str_length,(size_t)i);
}
int String::strstr(const String &s,uint32 offset)
diff --git a/sql/sql_string.h b/sql/sql_string.h
index c9eaf924e4d..61198af1261 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -120,6 +120,9 @@ public:
inline const char *ptr() const { return Ptr; }
inline char *c_ptr()
{
+ DBUG_ASSERT(!alloced || !Ptr || !Alloced_length ||
+ (Alloced_length >= (str_length + 1)));
+
if (!Ptr || Ptr[str_length]) /* Should be safe */
(void) realloc(str_length);
return Ptr;
@@ -148,6 +151,16 @@ public:
Alloced_length=str.Alloced_length-offset;
str_charset=str.str_charset;
}
+
+
+ /**
+ Points the internal buffer to the supplied one. The old buffer is freed.
+ @param str Pointer to the new buffer.
+ @param arg_length Length of the new buffer in characters, excluding any
+ null character.
+ @param cs Character set to use for interpreting string data.
+ @note The new buffer will not be null terminated.
+ */
inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs)
{
free();
@@ -176,6 +189,18 @@ public:
{ return set_int((longlong)num, true, cs); }
bool set_real(double num,uint decimals, CHARSET_INFO *cs);
+ /* Move handling of buffer from some other object to String */
+ void reassociate(char *ptr, uint32 length, uint32 alloced_length,
+ CHARSET_INFO *cs)
+ {
+ free();
+ Ptr= ptr;
+ str_length= length;
+ Alloced_length= alloced_length;
+ str_charset= cs;
+ alloced= ptr != 0;
+ }
+
/*
PMG 2004.11.12
This is a method that works the same as perl's "chop". It simply
@@ -318,7 +343,7 @@ public:
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
friend class Field;
uint32 numchars();
- int charpos(int i,uint32 offset=0);
+ int charpos(longlong i,uint32 offset=0);
int reserve(uint32 space_needed)
{
@@ -432,8 +457,9 @@ public:
}
};
-static inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str,
- char *end)
+static inline bool check_if_only_end_space(CHARSET_INFO *cs,
+ const char *str,
+ const char *end)
{
return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 222991b1ed2..9d71f2482b4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -36,17 +36,15 @@ const char *primary_key_name="PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end);
-static int copy_data_between_tables(TABLE *from,TABLE *to,
- List<Create_field> &create, bool ignore,
- uint order_num, ORDER *order,
- ha_rows *copied,ha_rows *deleted,
- enum enum_enable_or_disable keys_onoff,
- bool error_if_not_empty);
+static int copy_data_between_tables(TABLE *,TABLE *, List<Create_field> &, bool,
+ uint, ORDER *, ha_rows *,ha_rows *,
+ enum enum_enable_or_disable, bool);
static bool prepare_blob_field(THD *thd, Create_field *sql_field);
static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
static int mysql_prepare_create_table(THD *, HA_CREATE_INFO *, Alter_info *,
- bool, uint *, handler *, KEY **, uint *, int);
+ bool, uint *, handler *, KEY **, uint *,
+ int);
static bool mysql_prepare_alter_table(THD *, TABLE *, HA_CREATE_INFO *,
Alter_info *);
static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list);
@@ -3217,11 +3215,19 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
{
column->length*= sql_field->charset->mbmaxlen;
- if (key->type == Key::SPATIAL && column->length)
+ if (key->type == Key::SPATIAL)
{
- my_error(ER_WRONG_SUB_KEY, MYF(0));
- DBUG_RETURN(TRUE);
- }
+ if (column->length)
+ {
+ my_error(ER_WRONG_SUB_KEY, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+ if (!f_is_geom(sql_field->pack_flag))
+ {
+ my_error(ER_SPATIAL_MUST_HAVE_GEOM_COL, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+ }
if (f_is_blob(sql_field->pack_flag) ||
(f_is_geom(sql_field->pack_flag) && key->type != Key::SPATIAL))
@@ -3659,6 +3665,68 @@ static inline int write_create_table_bin_log(THD *thd,
}
+/**
+ Check that there is no frm file for given table
+
+ @param old_path path to the old frm file
+ @param path path to the frm file in new encoding
+ @param db database name
+ @param table_name table name
+ @param alias table name for error message (for new encoding)
+ @param issue_error should we issue error messages
+
+ @retval FALSE there is no frm file
+ @retval TRUE there is frm file
+*/
+
+bool check_table_file_presence(char *old_path,
+ char *path,
+ const char *db,
+ const char *table_name,
+ const char *alias,
+ bool issue_error)
+{
+ if (!access(path,F_OK))
+ {
+ if (issue_error)
+ my_error(ER_TABLE_EXISTS_ERROR,MYF(0),alias);
+ return TRUE;
+ }
+ {
+ /*
+ Check if file of the table in 5.0 file name encoding exists.
+
+ Except case when it is the same table.
+ */
+ char tbl50[FN_REFLEN];
+#ifdef _WIN32
+ if (check_if_legal_tablename(table_name) != 0)
+ {
+ /*
+ Check for reserved device names for which access() returns 0
+ (CON, AUX etc).
+ */
+ return FALSE;
+ }
+#endif
+ strxmov(tbl50, mysql_data_home, "/", db, "/", table_name, NullS);
+ fn_format(tbl50, tbl50, "", reg_ext, MY_UNPACK_FILENAME);
+ if (!access(tbl50, F_OK) &&
+ (old_path == NULL ||
+ strcmp(old_path, tbl50) != 0))
+ {
+ if (issue_error)
+ {
+ strxmov(tbl50, MYSQL50_TABLE_NAME_PREFIX, table_name, NullS);
+ my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tbl50);
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
/*
Create a table
@@ -3944,11 +4012,12 @@ bool mysql_create_table_no_lock(THD *thd,
VOID(pthread_mutex_lock(&LOCK_open));
if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
{
- if (!access(path,F_OK))
+ if (check_table_file_presence(NULL, path, db, table_name, table_name,
+ !(create_info->options &
+ HA_LEX_CREATE_IF_NOT_EXISTS)))
{
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
goto warn;
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto unlock_and_end;
}
/*
@@ -4668,8 +4737,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->no_warnings_for_error= no_warnings_for_error;
if (view_operator_func == NULL)
table->required_type=FRMTYPE_TABLE;
-
+ if (lex->sql_command == SQLCOM_CHECK ||
+ lex->sql_command == SQLCOM_REPAIR ||
+ lex->sql_command == SQLCOM_ANALYZE ||
+ lex->sql_command == SQLCOM_OPTIMIZE)
+ thd->prepare_derived_at_open= TRUE;
open_and_lock_tables(thd, table);
+ thd->prepare_derived_at_open= FALSE;
thd->no_warnings_for_error= 0;
table->next_global= save_next_global;
table->next_local= save_next_local;
@@ -4767,7 +4841,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
else
/* Default failure code is corrupt table */
result_code= HA_ADMIN_CORRUPT;
- goto send_result;
+ goto send_result;
}
if (table->view)
@@ -5856,10 +5930,10 @@ compare_tables(TABLE *table,
DBUG_RETURN(0);
}
- if ((create_info->fileds_option_struct=
- (void**)thd->calloc(sizeof(void*) * table->s->fields)) == NULL ||
- (create_info->indexes_option_struct=
- (void**)thd->calloc(sizeof(void*) * table->s->keys)) == NULL)
+ if ((create_info->fields_option_struct= (ha_field_option_struct**)
+ thd->calloc(sizeof(void*) * table->s->fields)) == NULL ||
+ (create_info->indexes_option_struct= (ha_index_option_struct**)
+ thd->calloc(sizeof(void*) * table->s->keys)) == NULL)
DBUG_RETURN(1);
/*
@@ -5880,7 +5954,7 @@ compare_tables(TABLE *table,
tmp_new_field= tmp_new_field_it++)
{
DBUG_ASSERT(i < table->s->fields);
- create_info->fileds_option_struct[i]= tmp_new_field->option_struct;
+ create_info->fields_option_struct[i]= tmp_new_field->option_struct;
/* reset common markers of how field changed */
field->flags&= ~(FIELD_IS_RENAMED | FIELD_IN_ADD_INDEX);
@@ -6607,6 +6681,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
TABLE *table, *new_table= 0, *name_lock= 0;
int error= 0;
char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1];
+ char old_name_buff[FN_REFLEN + 1];
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
char index_file[FN_REFLEN], data_file[FN_REFLEN];
char path[FN_REFLEN + 1];
@@ -6836,10 +6911,12 @@ view_err:
build_table_filename(new_name_buff, sizeof(new_name_buff) - 1,
new_db, new_name_buff, reg_ext, 0);
- if (!access(new_name_buff, F_OK))
+ build_table_filename(old_name_buff, sizeof(old_name_buff) - 1,
+ db, table_name, reg_ext, 0);
+ if (check_table_file_presence(old_name_buff, new_name_buff, new_db,
+ new_name, new_alias, TRUE))
{
/* Table will be closed in do_command() */
- my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
goto err;
}
}
@@ -7917,7 +7994,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (order)
{
- if (to->s->primary_key != MAX_KEY && to->file->primary_key_is_clustered())
+ if (to->s->primary_key != MAX_KEY &&
+ to->file->ha_table_flags() & HA_TABLE_SCAN_ON_INDEX)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
my_snprintf(warn_buff, sizeof(warn_buff),
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index af89b3cd525..cdab2ee8a6f 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -166,58 +166,67 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
void
TEST_join(JOIN *join)
{
- uint i,ref;
+ uint ref;
+ int i;
+ List_iterator<JOIN_TAB_RANGE> it(join->join_tab_ranges);
+ JOIN_TAB_RANGE *jt_range;
DBUG_ENTER("TEST_join");
- /*
- Assemble results of all the calls to full_name() first,
- in order not to garble the tabular output below.
- */
- String ref_key_parts[MAX_TABLES];
- for (i= 0; i < join->tables; i++)
- {
- JOIN_TAB *tab= join->join_tab + i;
- for (ref= 0; ref < tab->ref.key_parts; ref++)
- {
- ref_key_parts[i].append(tab->ref.items[ref]->full_name());
- ref_key_parts[i].append(" ");
- }
- }
-
DBUG_LOCK_FILE;
VOID(fputs("\nInfo about JOIN\n",DBUG_FILE));
- for (i=0 ; i < join->tables ; i++)
+
+ while ((jt_range= it++))
{
- JOIN_TAB *tab=join->join_tab+i;
- TABLE *form=tab->table;
- char key_map_buff[128];
- fprintf(DBUG_FILE,"%-16.16s type: %-7s q_keys: %s refs: %d key: %d len: %d\n",
- form->alias.c_ptr(),
- join_type_str[tab->type],
- tab->keys.print(key_map_buff),
- tab->ref.key_parts,
- tab->ref.key,
- tab->ref.key_length);
- if (tab->select)
+ /*
+ Assemble results of all the calls to full_name() first,
+ in order not to garble the tabular output below.
+ */
+ String ref_key_parts[MAX_TABLES];
+ int tables_in_range= jt_range->end - jt_range->start;
+ for (i= 0; i < tables_in_range; i++)
{
- char buf[MAX_KEY/8+1];
- if (tab->use_quick == 2)
- fprintf(DBUG_FILE,
- " quick select checked for each record (keys: %s)\n",
- tab->select->quick_keys.print(buf));
- else if (tab->select->quick)
+ JOIN_TAB *tab= jt_range->start + i;
+ for (ref= 0; ref < tab->ref.key_parts; ref++)
{
- fprintf(DBUG_FILE, " quick select used:\n");
- tab->select->quick->dbug_dump(18, FALSE);
+ ref_key_parts[i].append(tab->ref.items[ref]->full_name());
+ ref_key_parts[i].append(" ");
}
- else
- VOID(fputs(" select used\n",DBUG_FILE));
}
- if (tab->ref.key_parts)
+
+ for (i= 0; i < tables_in_range; i++)
{
- fprintf(DBUG_FILE,
+ JOIN_TAB *tab= jt_range->start + i;
+ TABLE *form=tab->table;
+ char key_map_buff[128];
+ fprintf(DBUG_FILE,"%-16.16s type: %-7s q_keys: %s refs: %d key: %d len: %d\n",
+ form->alias.c_ptr(),
+ join_type_str[tab->type],
+ tab->keys.print(key_map_buff),
+ tab->ref.key_parts,
+ tab->ref.key,
+ tab->ref.key_length);
+ if (tab->select)
+ {
+ char buf[MAX_KEY/8+1];
+ if (tab->use_quick == 2)
+ fprintf(DBUG_FILE,
+ " quick select checked for each record (keys: %s)\n",
+ tab->select->quick_keys.print(buf));
+ else if (tab->select->quick)
+ {
+ fprintf(DBUG_FILE, " quick select used:\n");
+ tab->select->quick->dbug_dump(18, FALSE);
+ }
+ else
+ VOID(fputs(" select used\n",DBUG_FILE));
+ }
+ if (tab->ref.key_parts)
+ {
+ fprintf(DBUG_FILE,
" refs: %s\n", ref_key_parts[i].c_ptr_safe());
+ }
}
+ VOID(fputs("\n",DBUG_FILE));
}
DBUG_UNLOCK_FILE;
DBUG_VOID_RETURN;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index a94ad9f3b4b..50505dd94a9 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -49,7 +49,7 @@ int select_union::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
}
-bool select_union::send_data(List<Item> &values)
+int select_union::send_data(List<Item> &values)
{
if (unit->offset_limit_cnt)
{ // using limit offset,count
@@ -62,6 +62,14 @@ bool select_union::send_data(List<Item> &values)
if ((write_err= table->file->ha_write_row(table->record[0])))
{
+ if (write_err == HA_ERR_FOUND_DUPP_KEY)
+ {
+ /*
+ Inform upper level that we found a duplicate key, that should not
+ be counted as part of limit
+ */
+ return -1;
+ }
/* create_internal_tmp_table_from_heap will generate error if needed */
if (table->file->is_fatal_error(write_err, HA_CHECK_DUP) &&
create_internal_tmp_table_from_heap(thd, table,
@@ -104,6 +112,7 @@ bool select_union::flush()
options create options
table_alias name of the temporary table
bit_fields_as_long convert bit fields to ulonglong
+ create_table whether to physically create result table
DESCRIPTION
Create a temporary table that is used to store the result of a UNION,
@@ -118,7 +127,7 @@ bool
select_union::create_result_table(THD *thd_arg, List<Item> *column_types,
bool is_union_distinct, ulonglong options,
const char *alias,
- bool bit_fields_as_long)
+ bool bit_fields_as_long, bool create_table)
{
DBUG_ASSERT(table == 0);
tmp_table_param.init();
@@ -127,10 +136,19 @@ select_union::create_result_table(THD *thd_arg, List<Item> *column_types,
if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types,
(ORDER*) 0, is_union_distinct, 1,
- options, HA_POS_ERROR, (char*) alias)))
+ options, HA_POS_ERROR, (char*) alias,
+ !create_table)))
return TRUE;
- table->file->extra(HA_EXTRA_WRITE_CACHE);
- table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
+
+ table->keys_in_use_for_query.clear_all();
+ for (uint i=0; i < table->s->fields; i++)
+ table->field[i]->flags &= ~PART_KEY_FLAG;
+
+ if (create_table)
+ {
+ table->file->extra(HA_EXTRA_WRITE_CACHE);
+ table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
+ }
return FALSE;
}
@@ -184,6 +202,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg)
{
(*order->item)->walk(&Item::change_context_processor, 0,
(uchar*) &fake_select_lex->context);
+ (*order->item)->walk(&Item::set_fake_select_as_master_processor, 0,
+ (uchar*) fake_select_lex);
}
}
@@ -268,6 +288,18 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit);
+ /*
+ Remove all references from the select_lex_units to the subqueries that
+ are inside the ORDER BY clause.
+ */
+ if (can_skip_order_by)
+ {
+ for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next)
+ {
+ (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
+ }
+ }
+
saved_error= join->prepare(&sl->ref_pointer_array,
sl->table_list.first,
sl->with_wild,
@@ -282,6 +314,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
(is_union_select ? NULL :
thd_arg->lex->proc_list.first),
sl, this);
+
/* There are no * in the statement anymore (for PS) */
sl->with_wild= 0;
last_procedure= join->procedure;
@@ -336,6 +369,8 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
List_iterator_fast<Item> tp(types);
Item *type;
ulonglong create_options;
+ uint save_tablenr= 0;
+ table_map save_map= 0;
while ((type= tp++))
{
@@ -388,12 +423,22 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
create_options= create_options | TMP_TABLE_FORCE_MYISAM;
if (union_result->create_result_table(thd, &types, test(union_distinct),
- create_options, "", FALSE))
+ create_options, "", FALSE, TRUE))
goto err;
+ if (fake_select_lex && !fake_select_lex->first_cond_optimization)
+ {
+ save_tablenr= result_table_list.tablenr_exec;
+ save_map= result_table_list.map_exec;
+ }
bzero((char*) &result_table_list, sizeof(result_table_list));
result_table_list.db= (char*) "";
result_table_list.table_name= result_table_list.alias= (char*) "union";
result_table_list.table= table= union_result->table;
+ if (fake_select_lex && !fake_select_lex->first_cond_optimization)
+ {
+ result_table_list.tablenr_exec= save_tablenr;
+ result_table_list.map_exec= save_map;
+ }
thd_arg->lex->current_select= lex_select_save;
if (!item_list.elements)
@@ -457,18 +502,21 @@ err:
}
-bool st_select_lex_unit::exec()
+/**
+ Run optimization phase.
+
+ @return FALSE unit successfully passed optimization phase.
+ @return TRUE an error occur.
+*/
+bool st_select_lex_unit::optimize()
{
SELECT_LEX *lex_select_save= thd->lex->current_select;
SELECT_LEX *select_cursor=first_select();
- ulonglong add_rows=0;
- ha_rows examined_rows= 0;
- DBUG_ENTER("st_select_lex_unit::exec");
+ DBUG_ENTER("st_select_lex_unit::optimize");
- if (executed && !uncacheable && !describe)
+ if (optimized && !uncacheable && !describe)
DBUG_RETURN(FALSE);
- executed= 1;
-
+
if (uncacheable || !item || !item->assigned() || describe)
{
if (item)
@@ -489,7 +537,6 @@ bool st_select_lex_unit::exec()
}
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
{
- ha_rows records_at_start= 0;
thd->lex->current_select= sl;
if (optimized)
@@ -516,6 +563,66 @@ bool st_select_lex_unit::exec()
sl->join->select_options=
(select_limit_cnt == HA_POS_ERROR || sl->braces) ?
sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union;
+
+ saved_error= sl->join->optimize();
+ }
+
+ if (saved_error)
+ {
+ thd->lex->current_select= lex_select_save;
+ DBUG_RETURN(saved_error);
+ }
+ }
+ }
+ optimized= 1;
+
+ thd->lex->current_select= lex_select_save;
+ DBUG_RETURN(saved_error);
+}
+
+
+bool st_select_lex_unit::exec()
+{
+ SELECT_LEX *lex_select_save= thd->lex->current_select;
+ SELECT_LEX *select_cursor=first_select();
+ ulonglong add_rows=0;
+ ha_rows examined_rows= 0;
+ DBUG_ENTER("st_select_lex_unit::exec");
+
+ if (executed && !uncacheable && !describe)
+ DBUG_RETURN(FALSE);
+ executed= 1;
+
+ saved_error= optimize();
+
+ if (uncacheable || !item || !item->assigned() || describe)
+ {
+ for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
+ {
+ ha_rows records_at_start= 0;
+ thd->lex->current_select= sl;
+
+ {
+ set_limit(sl);
+ if (sl == global_parameters || describe)
+ {
+ offset_limit_cnt= 0;
+ /*
+ We can't use LIMIT at this stage if we are using ORDER BY for the
+ whole query
+ */
+ if (sl->order_list.first || describe)
+ select_limit_cnt= HA_POS_ERROR;
+ }
+
+ /*
+ When using braces, SQL_CALC_FOUND_ROWS affects the whole query:
+ we don't calculate found_rows() per union part.
+ Otherwise, SQL_CALC_FOUND_ROWS should be done on all sub parts.
+ */
+ sl->join->select_options=
+ (select_limit_cnt == HA_POS_ERROR || sl->braces) ?
+ sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union;
saved_error= sl->join->optimize();
}
if (!saved_error)
@@ -568,7 +675,6 @@ bool st_select_lex_unit::exec()
}
}
}
- optimized= 1;
/* Send result to 'result' */
saved_error= TRUE;
@@ -690,7 +796,8 @@ bool st_select_lex_unit::cleanup()
if ((join= fake_select_lex->join))
{
join->tables_list= 0;
- join->tables= 0;
+ join->table_count= 0;
+ join->top_join_tab_count= 0;
}
error|= fake_select_lex->cleanup();
/*
@@ -843,3 +950,27 @@ void st_select_lex::cleanup_all_joins(bool full)
for (sl= unit->first_select(); sl; sl= sl->next_select())
sl->cleanup_all_joins(full);
}
+
+
+/**
+ Set exclude_from_table_unique_test for selects of this unit and all
+ underlying selects.
+
+ @note used to exclude materialized derived tables (views) from unique
+ table check.
+*/
+
+void st_select_lex_unit::set_unique_exclude()
+{
+ for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
+ {
+ sl->exclude_from_table_unique_test= TRUE;
+ for (SELECT_LEX_UNIT *unit= sl->first_inner_unit();
+ unit;
+ unit= unit->next_unit())
+ {
+ unit->set_unique_exclude();
+ }
+ }
+}
+
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 0a4d3a4ba80..4821fc2bd8f 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -229,7 +229,11 @@ int mysql_update(THD *thd,
if (open_tables(thd, &table_list, &table_count, 0))
DBUG_RETURN(1);
- if (table_list->multitable_view)
+ //Prepare views so they are handled correctly.
+ if (mysql_handle_derived(thd->lex, DT_INIT))
+ DBUG_RETURN(1);
+
+ if (table_list->is_multitable())
{
DBUG_ASSERT(table_list->view != 0);
DBUG_PRINT("info", ("Switch to multi-update"));
@@ -244,15 +248,19 @@ int mysql_update(THD *thd,
DBUG_RETURN(1);
close_tables_for_reopen(thd, &table_list);
}
-
- if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
- (thd->fill_derived_tables() &&
- mysql_handle_derived(thd->lex, &mysql_derived_filling)))
+ if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
+ DBUG_RETURN(1);
+ if (table_list->handle_derived(thd->lex, DT_PREPARE))
DBUG_RETURN(1);
thd_proc_info(thd, "init");
table= table_list->table;
+ if (!table_list->updatable)
+ {
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE");
+ DBUG_RETURN(1);
+ }
/* Calculate "table->covering_keys" based on the WHERE */
table->covering_keys= table->s->keys_in_use;
table->quick_keys.clear_all();
@@ -271,13 +279,17 @@ int mysql_update(THD *thd,
table_list->grant.want_privilege= table->grant.want_privilege= want_privilege;
table_list->register_want_access(want_privilege);
#endif
+ /* 'Unfix' fields to allow correct marking by the setup_fields function. */
+ if (table_list->is_view())
+ unfix_fields(fields);
+
if (setup_fields_with_no_wrap(thd, 0, fields, MARK_COLUMNS_WRITE, 0, 0))
DBUG_RETURN(1); /* purecov: inspected */
if (table_list->view && check_fields(thd, fields))
{
DBUG_RETURN(1);
}
- if (!table_list->updatable || check_key_in_view(thd, table_list))
+ if (check_key_in_view(thd, table_list))
{
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE");
DBUG_RETURN(1);
@@ -307,6 +319,10 @@ int mysql_update(THD *thd,
DBUG_RETURN(1); /* purecov: inspected */
}
+ /* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
+ if (select_lex->optimize_unflattened_subqueries())
+ DBUG_RETURN(TRUE);
+
if (select_lex->inner_refs_list.elements &&
fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
DBUG_RETURN(1);
@@ -865,6 +881,11 @@ int mysql_update(THD *thd,
}
thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
thd->abort_on_warning= 0;
+ if (thd->lex->current_select->first_cond_optimization)
+ {
+ thd->lex->current_select->save_leaf_tables(thd);
+ thd->lex->current_select->first_cond_optimization= 0;
+ }
DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
err:
@@ -925,8 +946,8 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
if (setup_tables_and_check_access(thd, &select_lex->context,
&select_lex->top_join_list,
table_list,
- &select_lex->leaf_tables,
- FALSE, UPDATE_ACL, SELECT_ACL) ||
+ select_lex->leaf_tables,
+ FALSE, UPDATE_ACL, SELECT_ACL, TRUE) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
select_lex->setup_ref_array(thd, order_num) ||
setup_order(thd, select_lex->ref_pointer_array,
@@ -963,8 +984,8 @@ static table_map get_table_map(List<Item> *items)
Item_field *item;
table_map map= 0;
- while ((item= (Item_field *) item_it++))
- map|= item->used_tables();
+ while ((item= (Item_field *) item_it++))
+ map|= item->all_used_tables();
DBUG_PRINT("info", ("table_map: 0x%08lx", (long) map));
return map;
}
@@ -986,7 +1007,7 @@ int mysql_multi_update_prepare(THD *thd)
{
LEX *lex= thd->lex;
TABLE_LIST *table_list= lex->query_tables;
- TABLE_LIST *tl, *leaves;
+ TABLE_LIST *tl;
List<Item> *fields= &lex->select_lex.item_list;
table_map tables_for_update;
bool update_view= 0;
@@ -1009,19 +1030,24 @@ reopen_tables:
/* open tables and create derived ones, but do not lock and fill them */
if (((original_multiupdate || need_reopen) &&
open_tables(thd, &table_list, &table_count, 0)) ||
- mysql_handle_derived(lex, &mysql_derived_prepare))
+ mysql_handle_derived(lex, DT_INIT))
DBUG_RETURN(TRUE);
/*
setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables()
second time, but this call will do nothing (there are check for second
call in setup_tables()).
*/
+ //We need to merge for insert prior to prepare.
+ if (mysql_handle_list_of_derived(lex, table_list, DT_MERGE_FOR_INSERT))
+ DBUG_RETURN(1);
+ if (mysql_handle_derived(lex, DT_PREPARE))
+ DBUG_RETURN(TRUE);
if (setup_tables_and_check_access(thd, &lex->select_lex.context,
&lex->select_lex.top_join_list,
table_list,
- &lex->select_lex.leaf_tables, FALSE,
- UPDATE_ACL, SELECT_ACL))
+ lex->select_lex.leaf_tables, FALSE,
+ UPDATE_ACL, SELECT_ACL, TRUE))
DBUG_RETURN(TRUE);
if (setup_fields_with_no_wrap(thd, 0, *fields, MARK_COLUMNS_WRITE, 0, 0))
@@ -1046,8 +1072,8 @@ reopen_tables:
/*
Setup timestamp handling and locking mode
*/
- leaves= lex->select_lex.leaf_tables;
- for (tl= leaves; tl; tl= tl->next_leaf)
+ List_iterator<TABLE_LIST> ti(lex->select_lex.leaf_tables);
+ while ((tl= ti++))
{
TABLE *table= tl->table;
/* Only set timestamp column if this is not modified */
@@ -1089,7 +1115,7 @@ reopen_tables:
for (tl= table_list; tl; tl= tl->next_local)
{
/* Check access privileges for table */
- if (!tl->derived)
+ if (!tl->is_derived())
{
uint want_privilege= tl->updating ? UPDATE_ACL : SELECT_ACL;
if (check_access(thd, want_privilege,
@@ -1103,7 +1129,7 @@ reopen_tables:
/* check single table update for view compound from several tables */
for (tl= table_list; tl; tl= tl->next_local)
{
- if (tl->effective_algorithm == VIEW_ALGORITHM_MERGE)
+ if (tl->is_merged_derived())
{
TABLE_LIST *for_update= 0;
if (tl->check_single_table(&for_update, tables_for_update, tl))
@@ -1158,6 +1184,8 @@ reopen_tables:
*/
unit->unclean();
}
+ // Reset 'prepared' flags for all derived tables/views
+ mysql_handle_list_of_derived(thd->lex, table_list, DT_REINIT);
/*
Also we need to cleanup Natural_join_column::table_field items.
@@ -1180,7 +1208,8 @@ reopen_tables:
*/
lex->select_lex.exclude_from_table_unique_test= TRUE;
/* We only need SELECT privilege for columns in the values list */
- for (tl= leaves; tl; tl= tl->next_leaf)
+ ti.rewind();
+ while ((tl= ti++))
{
TABLE *table= tl->table;
TABLE_LIST *tlist;
@@ -1209,10 +1238,6 @@ reopen_tables:
*/
lex->select_lex.exclude_from_table_unique_test= FALSE;
- if (thd->fill_derived_tables() &&
- mysql_handle_derived(lex, &mysql_derived_filling))
- DBUG_RETURN(TRUE);
-
DBUG_RETURN (FALSE);
}
@@ -1235,7 +1260,7 @@ bool mysql_multi_update(THD *thd,
DBUG_ENTER("mysql_multi_update");
if (!(result= new multi_update(table_list,
- thd->lex->select_lex.leaf_tables,
+ &thd->lex->select_lex.leaf_tables,
fields, values,
handle_duplicates, ignore)))
DBUG_RETURN(TRUE);
@@ -1270,7 +1295,7 @@ bool mysql_multi_update(THD *thd,
multi_update::multi_update(TABLE_LIST *table_list,
- TABLE_LIST *leaves_list,
+ List<TABLE_LIST> *leaves_list,
List<Item> *field_list, List<Item> *value_list,
enum enum_duplicates handle_duplicates_arg,
bool ignore_arg)
@@ -1288,6 +1313,7 @@ multi_update::multi_update(TABLE_LIST *table_list,
int multi_update::prepare(List<Item> &not_used_values,
SELECT_LEX_UNIT *lex_unit)
+
{
TABLE_LIST *table_ref;
SQL_I_List<TABLE_LIST> update;
@@ -1297,12 +1323,20 @@ int multi_update::prepare(List<Item> &not_used_values,
List_iterator_fast<Item> value_it(*values);
uint i, max_fields;
uint leaf_table_count= 0;
+ List_iterator<TABLE_LIST> ti(*leaves);
DBUG_ENTER("multi_update::prepare");
thd->count_cuted_fields= CHECK_FIELD_WARN;
thd->cuted_fields=0L;
thd_proc_info(thd, "updating main table");
+ SELECT_LEX *select_lex= lex_unit->first_select();
+ if (select_lex->first_cond_optimization)
+ {
+ if (select_lex->handle_derived(thd->lex, DT_MERGE))
+ DBUG_RETURN(TRUE);
+ }
+
tables_to_update= get_table_map(fields);
if (!tables_to_update)
@@ -1316,7 +1350,7 @@ int multi_update::prepare(List<Item> &not_used_values,
TABLE::tmp_set by pointing TABLE::read_set to it and then restore it after
setup_fields().
*/
- for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf)
+ while ((table_ref= ti++))
{
TABLE *table= table_ref->table;
if (tables_to_update & table->map)
@@ -1334,7 +1368,8 @@ int multi_update::prepare(List<Item> &not_used_values,
int error= setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0);
- for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf)
+ ti.rewind();
+ while ((table_ref= ti++))
{
TABLE *table= table_ref->table;
if (tables_to_update & table->map)
@@ -1363,7 +1398,8 @@ int multi_update::prepare(List<Item> &not_used_values,
*/
update.empty();
- for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf)
+ ti.rewind();
+ while ((table_ref= ti++))
{
/* TODO: add support of view of join support */
TABLE *table=table_ref->table;
@@ -1589,9 +1625,9 @@ loop_end:
{
table_map unupdated_tables= table_ref->check_option->used_tables() &
~first_table_for_update->map;
- for (TABLE_LIST *tbl_ref =leaves;
- unupdated_tables && tbl_ref;
- tbl_ref= tbl_ref->next_leaf)
+ List_iterator<TABLE_LIST> ti(*leaves);
+ TABLE_LIST *tbl_ref;
+ while ((tbl_ref= ti++) && unupdated_tables)
{
if (unupdated_tables & tbl_ref->table->map)
unupdated_tables&= ~tbl_ref->table->map;
@@ -1689,7 +1725,7 @@ multi_update::~multi_update()
}
-bool multi_update::send_data(List<Item> &not_used_values)
+int multi_update::send_data(List<Item> &not_used_values)
{
TABLE_LIST *cur_table;
DBUG_ENTER("multi_update::send_data");
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 0f7b7637744..89ccfd10a45 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -248,7 +248,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view)
view->definer.user= decoy.definer.user;
lex->definer= &view->definer;
}
- if (lex->create_view_algorithm == VIEW_ALGORITHM_UNDEFINED)
+ if (lex->create_view_algorithm == DTYPE_ALGORITHM_UNDEFINED)
lex->create_view_algorithm= (uint8) decoy.algorithm;
if (lex->create_view_suid == VIEW_SUID_DEFAULT)
lex->create_view_suid= decoy.view_suid ?
@@ -843,7 +843,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
ulong sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
thd->variables.sql_mode&= ~MODE_ANSI_QUOTES;
- lex->unit.print(&view_query, QT_ORDINARY);
+ lex->unit.print(&view_query, QT_VIEW_INTERNAL);
lex->unit.print(&is_query, QT_IS);
thd->variables.sql_mode|= sql_mode;
@@ -876,7 +876,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_VIEW_MERGE,
ER(ER_WARN_VIEW_MERGE));
- lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED;
+ lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED;
}
view->algorithm= lex->create_view_algorithm;
view->definer.user= lex->definer->user;
@@ -1460,7 +1460,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
List_iterator_fast<TABLE_LIST> ti(view_select->top_join_list);
- table->effective_algorithm= VIEW_ALGORITHM_MERGE;
+ table->derived_type= VIEW_ALGORITHM_MERGE;
DBUG_PRINT("info", ("algorithm: MERGE"));
table->updatable= (table->updatable_view != 0);
table->effective_with_check=
@@ -1474,67 +1474,10 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
/* prepare view context */
lex->select_lex.context.resolve_in_table_list_only(view_main_select_tables);
lex->select_lex.context.outer_context= 0;
- lex->select_lex.context.select_lex= table->select_lex;
lex->select_lex.select_n_having_items+=
table->select_lex->select_n_having_items;
- /*
- Tables of the main select of the view should be marked as belonging
- to the same select as original view (again we can use LEX::select_lex
- for this purprose because we don't support MERGE algorithm for views
- with unions).
- */
- for (tbl= lex->select_lex.get_table_list(); tbl; tbl= tbl->next_local)
- tbl->select_lex= table->select_lex;
-
- {
- if (view_main_select_tables->next_local)
- {
- table->multitable_view= TRUE;
- if (table->belong_to_view)
- table->belong_to_view->multitable_view= TRUE;
- }
- /* make nested join structure for view tables */
- NESTED_JOIN *nested_join;
- if (!(nested_join= table->nested_join=
- (NESTED_JOIN *) thd->calloc(sizeof(NESTED_JOIN))))
- goto err;
- nested_join->join_list= view_select->top_join_list;
-
- /* re-nest tables of VIEW */
- ti.rewind();
- while ((tbl= ti++))
- {
- tbl->join_list= &nested_join->join_list;
- tbl->embedding= table;
- }
- }
-
- /* Store WHERE clause for post-processing in setup_underlying */
table->where= view_select->where;
- /*
- Add subqueries units to SELECT into which we merging current view.
- unit(->next)* chain starts with subqueries that are used by this
- view and continues with subqueries that are used by other views.
- We must not add any subquery twice (otherwise we'll form a loop),
- to do this we remember in end_unit the first subquery that has
- been already added.
-
- NOTE: we do not support UNION here, so we take only one select
- */
- SELECT_LEX_NODE *end_unit= table->select_lex->slave;
- SELECT_LEX_UNIT *next_unit;
- for (SELECT_LEX_UNIT *unit= lex->select_lex.first_inner_unit();
- unit;
- unit= next_unit)
- {
- if (unit == end_unit)
- break;
- SELECT_LEX_NODE *save_slave= unit->slave;
- next_unit= unit->next_unit();
- unit->include_down(table->select_lex);
- unit->slave= save_slave; // fix include_down initialisation
- }
/*
We can safely ignore the VIEW's ORDER BY if we merge into union
@@ -1551,23 +1494,22 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
goto ok;
}
- table->effective_algorithm= VIEW_ALGORITHM_TMPTABLE;
+ table->derived_type= VIEW_ALGORITHM_TMPTABLE;
DBUG_PRINT("info", ("algorithm: TEMPORARY TABLE"));
view_select->linkage= DERIVED_TABLE_TYPE;
table->updatable= 0;
table->effective_with_check= VIEW_CHECK_NONE;
old_lex->subqueries= TRUE;
- /* SELECT tree link */
- lex->unit.include_down(table->select_lex);
- lex->unit.slave= view_select; // fix include_down initialisation
-
table->derived= &lex->unit;
}
else
goto err;
ok:
+ /* SELECT tree link */
+ lex->unit.include_down(table->select_lex);
+ lex->unit.slave= view_select; // fix include_down initialisation
/* global SELECT list linking */
end= view_select; // primary SELECT_LEX is always last
end->link_next= old_lex->all_selects_list;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index fbced869951..3337b1b487e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -34,6 +34,7 @@
#define YYINITDEPTH 100
#define YYMAXDEPTH 3200 /* Because of 64K stack */
#define Lex (YYTHD->lex)
+
#define Select Lex->current_select
#include "mysql_priv.h"
#include "slave.h"
@@ -671,6 +672,8 @@ static bool add_create_index (LEX *lex, Key::Keytype type, const char *name,
sp_head *sphead;
struct p_elem_val *p_elem_value;
enum index_hint_type index_hint;
+ DYNCALL_CREATE_DEF *dyncol_def;
+ List<DYNCALL_CREATE_DEF> *dyncol_def_list;
}
%{
@@ -679,10 +682,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%pure_parser /* We have threads */
/*
- Currently there are 169 shift/reduce conflicts.
+ Currently there are 171 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 169
+%expect 171
/*
Comments for TOKENS.
@@ -770,6 +773,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token COLLATE_SYM /* SQL-2003-R */
%token COLLATION_SYM /* SQL-2003-N */
%token COLUMNS
+%token COLUMN_ADD_SYM
+%token COLUMN_CREATE_SYM
+%token COLUMN_DELETE_SYM
+%token COLUMN_EXISTS_SYM
+%token COLUMN_GET_SYM
+%token COLUMN_LIST_SYM
%token COLUMN_SYM /* SQL-2003-R */
%token COMMENT_SYM
%token COMMITTED_SYM /* SQL-2003-N */
@@ -1338,7 +1347,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_natural_language_mode opt_query_expansion
opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment
ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt
- optional_flush_tables_arguments
+ optional_flush_tables_arguments opt_dyncol_type dyncol_type
+ opt_time_precision
%type <ulong_num>
ulong_num real_ulong_num merge_insert_types
@@ -1438,6 +1448,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <boolfunc2creator> comp_op
+%type <dyncol_def> dyncall_create_element
+
+%type <dyncol_def_list> dyncall_create_list
+
%type <NONE>
query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename
@@ -1931,7 +1945,7 @@ create:
| CREATE
{
Lex->create_view_mode= VIEW_CREATE_NEW;
- Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED;
+ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED;
Lex->create_view_suid= TRUE;
}
view_or_trigger_or_sp_or_event
@@ -2070,7 +2084,7 @@ opt_ev_status:
ev_starts:
/* empty */
{
- Item *item= new (YYTHD->mem_root) Item_func_now_local();
+ Item *item= new (YYTHD->mem_root) Item_func_now_local(0);
if (item == NULL)
MYSQL_YYABORT;
Lex->event_parse_data->item_starts= item;
@@ -5202,7 +5216,7 @@ type:
{ $$=MYSQL_TYPE_YEAR; }
| DATE_SYM
{ $$=MYSQL_TYPE_DATE; }
- | TIME_SYM
+ | TIME_SYM opt_field_length
{ $$=MYSQL_TYPE_TIME; }
| TIMESTAMP opt_field_length
{
@@ -5217,7 +5231,7 @@ type:
$$=MYSQL_TYPE_TIMESTAMP;
}
}
- | DATETIME
+ | DATETIME opt_field_length
{ $$=MYSQL_TYPE_DATETIME; }
| TINYBLOB
{
@@ -5410,9 +5424,9 @@ attribute:
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
| DEFAULT now_or_signed_literal { Lex->default_value=$2; }
- | ON UPDATE_SYM NOW_SYM optional_braces
+ | ON UPDATE_SYM NOW_SYM opt_time_precision
{
- Item *item= new (YYTHD->mem_root) Item_func_now_local();
+ Item *item= new (YYTHD->mem_root) Item_func_now_local($4);
if (item == NULL)
MYSQL_YYABORT;
Lex->on_update_value= item;
@@ -5482,9 +5496,9 @@ attribute:
;
now_or_signed_literal:
- NOW_SYM optional_braces
+ NOW_SYM opt_time_precision
{
- $$= new (YYTHD->mem_root) Item_func_now_local();
+ $$= new (YYTHD->mem_root) Item_func_now_local($2);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -5979,7 +5993,7 @@ alter:
my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW");
MYSQL_YYABORT;
}
- lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED;
+ lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED;
lex->create_view_mode= VIEW_ALTER;
}
view_tail
@@ -7091,6 +7105,12 @@ select_alias:
| TEXT_STRING_sys { $$=$1; }
;
+opt_time_precision:
+ /* empty */ { $$= 0; }
+ | '(' ')' { $$= 0; }
+ | '(' real_ulong_num ')' { $$= $2; };
+ ;
+
optional_braces:
/* empty */ {}
| '(' ')' {}
@@ -7506,6 +7526,133 @@ all_or_any:
| ANY_SYM { $$ = 0; }
;
+opt_dyncol_type:
+ /* empty */
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_NULL; /* automatic type */
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | AS dyncol_type { $$= $2; }
+ ;
+
+dyncol_type:
+ INT_SYM
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_INT;
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | UNSIGNED INT_SYM
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_UINT;
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | DOUBLE_SYM
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_DOUBLE;
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | REAL
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_DOUBLE;
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | FLOAT_SYM
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_DOUBLE;
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | DECIMAL_SYM float_options
+ {
+ $$= DYN_COL_DECIMAL;
+ Lex->charset= NULL;
+ }
+ | char opt_binary
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_STRING;
+ lex->length= lex->dec= 0;
+ }
+ | nchar
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_STRING;
+ lex->charset= national_charset_info;
+ lex->length= lex->dec= 0;
+ }
+ | DATE_SYM
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_DATE;
+ lex->charset= NULL;
+ lex->length= lex->dec= 0;
+ }
+ | TIME_SYM opt_field_length
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_TIME;
+ lex->charset= NULL;
+ lex->dec= lex->length;
+ lex->length= 0;
+ }
+ | DATETIME opt_field_length
+ {
+ LEX *lex= Lex;
+ $$= DYN_COL_DATETIME;
+ lex->charset= NULL;
+ lex->dec= lex->length;
+ lex->length= 0;
+ }
+ ;
+
+dyncall_create_element:
+ expr ',' expr opt_dyncol_type
+ {
+ LEX *lex= Lex;
+ $$= (DYNCALL_CREATE_DEF *)
+ alloc_root(YYTHD->mem_root, sizeof(DYNCALL_CREATE_DEF));
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ $$->num= $1;
+ $$->value= $3;
+ $$->type= (DYNAMIC_COLUMN_TYPE)$4;
+ $$->cs= lex->charset;
+ if (lex->length)
+ $$->len= strtoul(lex->length, NULL, 10);
+ else
+ $$->len= 0;
+ if (lex->dec)
+ $$->frac= strtoul(lex->dec, NULL, 10);
+ else
+ $$->len= 0;
+ }
+
+dyncall_create_list:
+ dyncall_create_element
+ {
+ $$= new (YYTHD->mem_root) List<DYNCALL_CREATE_DEF>;
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ $$->push_back($1);
+ }
+ | dyncall_create_list ',' dyncall_create_element
+ {
+ $1->push_back($3);
+ $$= $1;
+ }
+ ;
+
simple_expr:
simple_ident
| function_call_keyword
@@ -7769,13 +7916,13 @@ function_call_keyword:
}
| TIME_SYM '(' expr ')'
{
- $$= new (YYTHD->mem_root) Item_time_typecast($3);
+ $$= new (YYTHD->mem_root) Item_time_typecast($3, AUTO_SEC_PART_DIGITS);
if ($$ == NULL)
MYSQL_YYABORT;
}
| TIMESTAMP '(' expr ')'
{
- $$= new (YYTHD->mem_root) Item_datetime_typecast($3);
+ $$= new (YYTHD->mem_root) Item_datetime_typecast($3, AUTO_SEC_PART_DIGITS);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -7882,16 +8029,9 @@ function_call_nonkeyword:
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
}
- | CURTIME optional_braces
- {
- $$= new (YYTHD->mem_root) Item_func_curtime_local();
- if ($$ == NULL)
- MYSQL_YYABORT;
- Lex->safe_to_cache_query=0;
- }
- | CURTIME '(' expr ')'
+ | CURTIME opt_time_precision
{
- $$= new (YYTHD->mem_root) Item_func_curtime_local($3);
+ $$= new (YYTHD->mem_root) Item_func_curtime_local($2);
if ($$ == NULL)
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
@@ -7922,16 +8062,9 @@ function_call_nonkeyword:
if ($$ == NULL)
MYSQL_YYABORT;
}
- | NOW_SYM optional_braces
- {
- $$= new (YYTHD->mem_root) Item_func_now_local();
- if ($$ == NULL)
- MYSQL_YYABORT;
- Lex->safe_to_cache_query=0;
- }
- | NOW_SYM '(' expr ')'
+ | NOW_SYM opt_time_precision
{
- $$= new (YYTHD->mem_root) Item_func_now_local($3);
+ $$= new (YYTHD->mem_root) Item_func_now_local($2);
if ($$ == NULL)
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
@@ -7979,7 +8112,7 @@ function_call_nonkeyword:
if ($$ == NULL)
MYSQL_YYABORT;
}
- | SYSDATE optional_braces
+ | SYSDATE opt_time_precision
{
/*
Unlike other time-related functions, SYSDATE() is
@@ -7990,19 +8123,9 @@ function_call_nonkeyword:
*/
Lex->set_stmt_unsafe();
if (global_system_variables.sysdate_is_now == 0)
- $$= new (YYTHD->mem_root) Item_func_sysdate_local();
- else
- $$= new (YYTHD->mem_root) Item_func_now_local();
- if ($$ == NULL)
- MYSQL_YYABORT;
- Lex->safe_to_cache_query=0;
- }
- | SYSDATE '(' expr ')'
- {
- if (global_system_variables.sysdate_is_now == 0)
- $$= new (YYTHD->mem_root) Item_func_sysdate_local($3);
+ $$= new (YYTHD->mem_root) Item_func_sysdate_local($2);
else
- $$= new (YYTHD->mem_root) Item_func_now_local($3);
+ $$= new (YYTHD->mem_root) Item_func_now_local($2);
if ($$ == NULL)
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
@@ -8026,20 +8149,65 @@ function_call_nonkeyword:
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
}
- | UTC_TIME_SYM optional_braces
+ | UTC_TIME_SYM opt_time_precision
{
- $$= new (YYTHD->mem_root) Item_func_curtime_utc();
+ $$= new (YYTHD->mem_root) Item_func_curtime_utc($2);
if ($$ == NULL)
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
}
- | UTC_TIMESTAMP_SYM optional_braces
+ | UTC_TIMESTAMP_SYM opt_time_precision
{
- $$= new (YYTHD->mem_root) Item_func_now_utc();
+ $$= new (YYTHD->mem_root) Item_func_now_utc($2);
if ($$ == NULL)
MYSQL_YYABORT;
Lex->safe_to_cache_query=0;
}
+ |
+ COLUMN_ADD_SYM '(' expr ',' dyncall_create_list ')'
+ {
+ $$= create_func_dyncol_add(YYTHD, $3, *$5);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ |
+ COLUMN_DELETE_SYM '(' expr ',' expr_list ')'
+ {
+ $$= create_func_dyncol_delete(YYTHD, $3, *$5);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ |
+ COLUMN_EXISTS_SYM '(' expr ',' expr ')'
+ {
+ $$= new (YYTHD->mem_root) Item_func_dyncol_exists($3, $5);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ |
+ COLUMN_LIST_SYM '(' expr ')'
+ {
+ $$= new (YYTHD->mem_root) Item_func_dyncol_list($3);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ |
+ COLUMN_CREATE_SYM '(' dyncall_create_list ')'
+ {
+ $$= create_func_dyncol_create(YYTHD, *$3);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ |
+ COLUMN_GET_SYM '(' expr ',' expr AS cast_type ')'
+ {
+ LEX *lex= Lex;
+ $$= create_func_dyncol_get(YYTHD, $3, $5, $7,
+ lex->length, lex->dec,
+ lex->charset);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
;
/*
@@ -8641,6 +8809,8 @@ cast_type:
{ $$=ITEM_CAST_CHAR; Lex->dec= 0; }
| NCHAR_SYM opt_field_length
{ $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; Lex->dec=0; }
+ | INT_SYM
+ { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
| SIGNED_SYM
{ $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
| SIGNED_SYM INT_SYM
@@ -8651,13 +8821,24 @@ cast_type:
{ $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
| DATE_SYM
{ $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
- | TIME_SYM
- { $$=ITEM_CAST_TIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
- | DATETIME
- { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; }
+ | TIME_SYM opt_field_length
+ {
+ $$=ITEM_CAST_TIME;
+ LEX *lex= Lex;
+ lex->charset= NULL; lex->dec= lex->length; lex->length= (char*)0;
+ }
+ | DATETIME opt_field_length
+ {
+ $$=ITEM_CAST_DATETIME;
+ LEX *lex= Lex;
+ lex->charset= NULL; lex->dec= lex->length; lex->length= (char*)0;
+ }
| DECIMAL_SYM float_options
{ $$=ITEM_CAST_DECIMAL; Lex->charset= NULL; }
- ;
+ | DOUBLE_SYM
+ { Lex->charset= NULL; Lex->length= Lex->dec= 0;}
+ opt_precision
+ { $$=ITEM_CAST_DOUBLE; }
opt_expr_list:
/* empty */ { $$= NULL; }
@@ -11887,6 +12068,12 @@ keyword:
| CHECKSUM_SYM {}
| CHECKPOINT_SYM {}
| CLOSE_SYM {}
+ | COLUMN_ADD_SYM {}
+ | COLUMN_CREATE_SYM {}
+ | COLUMN_DELETE_SYM {}
+ | COLUMN_EXISTS_SYM {}
+ | COLUMN_GET_SYM {}
+ | COLUMN_LIST_SYM {}
| COMMENT_SYM {}
| COMMIT_SYM {}
| CONTAINS_SYM {}
@@ -13553,7 +13740,7 @@ view_replace:
view_algorithm:
ALGORITHM_SYM EQ UNDEFINED_SYM
- { Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; }
+ { Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
| ALGORITHM_SYM EQ MERGE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
| ALGORITHM_SYM EQ TEMPTABLE_SYM
diff --git a/sql/structs.h b/sql/structs.h
index 86d1f12424e..29ccde3fb03 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -70,6 +70,7 @@ typedef struct st_key_part_info { /* Info about a key part */
} KEY_PART_INFO ;
class engine_option_value;
+struct ha_index_option_struct;
typedef struct st_key {
uint key_length; /* Tot length of key */
@@ -104,7 +105,7 @@ typedef struct st_key {
struct st_table *table;
/** reference to the list of options or NULL */
engine_option_value *option_list;
- void *option_struct; /* structure with parsed options */
+ ha_index_option_struct *option_struct; /* structure with parsed options */
} KEY;
diff --git a/sql/table.cc b/sql/table.cc
index 41fb9a1c8b4..8427ca6e112 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1,4 +1,5 @@
-/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -775,8 +776,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->db_record_offset= 1;
if (db_create_options & HA_OPTION_LONG_BLOB_PTR)
share->blob_ptr_size= portable_sizeof_char_ptr;
- /* Set temporarily a good value for db_low_byte_first */
- share->db_low_byte_first= test(legacy_db_type != DB_TYPE_ISAM);
error=4;
share->max_rows= uint4korr(head+18);
share->min_rows= uint4korr(head+22);
@@ -1695,7 +1694,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->can_cmp_whole_record= (share->blob_fields == 0 &&
share->varchar_fields == 0);
- share->db_low_byte_first= handler_file->low_byte_first();
share->column_bitmap_size= bitmap_buffer_size(share->fields);
if (!(bitmaps= (my_bitmap_map*) alloc_root(&share->mem_root,
@@ -1842,7 +1840,9 @@ bool fix_vcol_expr(THD *thd,
save_use_only_table_context= thd->lex->use_only_table_context;
thd->lex->use_only_table_context= TRUE;
/* Fix fields referenced to by the virtual column function */
+ thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VCOL_EXPR;
error= func_expr->fix_fields(thd, (Item**)0);
+ thd->lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_VCOL_EXPR;
/* Restore the original context*/
thd->lex->use_only_table_context= save_use_only_table_context;
context->table_list= save_table_list;
@@ -1993,7 +1993,12 @@ bool unpack_vcol_info_from_frm(THD *thd,
vcol_arena= table->expr_arena;
if (!vcol_arena)
{
- Query_arena expr_arena(&table->mem_root, Query_arena::INITIALIZED);
+ /*
+ We need to use CONVENTIONAL_EXECUTION here to ensure that
+ any new items created by fix_fields() are not reverted.
+ */
+ Query_arena expr_arena(&table->mem_root,
+ Query_arena::CONVENTIONAL_EXECUTION);
if (!(vcol_arena= (Query_arena *) alloc_root(&table->mem_root,
sizeof(Query_arena))))
goto err;
@@ -3508,129 +3513,112 @@ void TABLE_LIST::calc_md5(char *buffer)
/**
- @brief Set underlying table for table place holder of view.
-
- @details
-
- Replace all views that only use one table with the table itself. This
- allows us to treat the view as a simple table and even update it (it is a
- kind of optimization).
+ @brief
+ Create field translation for mergeable derived table/view.
- @note
+ @param thd Thread handle
- This optimization is potentially dangerous as it makes views
- masquerade as base tables: Views don't have the pointer TABLE_LIST::table
- set to non-@c NULL.
+ @details
+ Create field translation for mergeable derived table/view.
- We may have the case where a view accesses tables not normally accessible
- in the current Security_context (only in the definer's
- Security_context). According to the table's GRANT_INFO (TABLE::grant),
- access is fulfilled, but this is implicitly meant in the definer's security
- context. Hence we must never look at only a TABLE's GRANT_INFO without
- looking at the one of the referring TABLE_LIST.
+ @return FALSE ok.
+ @return TRUE an error occur.
*/
-void TABLE_LIST::set_underlying_merge()
+bool TABLE_LIST::create_field_translation(THD *thd)
{
- TABLE_LIST *tbl;
+ Item *item;
+ Field_translator *transl;
+ SELECT_LEX *select= get_single_select();
+ List_iterator_fast<Item> it(select->item_list);
+ uint field_count= 0;
+ Query_arena *arena= thd->stmt_arena, backup;
+ bool res= FALSE;
- if ((tbl= merge_underlying_list))
+ used_items.empty();
+
+ if (field_translation)
{
- /* This is a view. Process all tables of view */
- DBUG_ASSERT(view && effective_algorithm == VIEW_ALGORITHM_MERGE);
- do
+ /*
+ Update items in the field translation aftet view have been prepared.
+ It's needed because some items in the select list, like IN subselects,
+ might be substituted for optimized ones.
+ */
+ if (is_view() && get_unit()->prepared && !field_translation_updated)
{
- if (tbl->merge_underlying_list) // This is a view
+ while ((item= it++))
{
- DBUG_ASSERT(tbl->view &&
- tbl->effective_algorithm == VIEW_ALGORITHM_MERGE);
- /*
- This is the only case where set_ancestor is called on an object
- that may not be a view (in which case ancestor is 0)
- */
- tbl->merge_underlying_list->set_underlying_merge();
+ field_translation[field_count++].item= item;
}
- } while ((tbl= tbl->next_local));
-
- if (!multitable_view)
- {
- table= merge_underlying_list->table;
- schema_table= merge_underlying_list->schema_table;
+ field_translation_updated= TRUE;
}
+
+ return FALSE;
+ }
+
+ if (arena->is_conventional())
+ arena= 0; // For easier test
+ else
+ thd->set_n_backup_active_arena(arena, &backup);
+
+ /* Create view fields translation table */
+
+ if (!(transl=
+ (Field_translator*)(thd->stmt_arena->
+ alloc(select->item_list.elements *
+ sizeof(Field_translator)))))
+ {
+ res= TRUE;
+ goto exit;
}
+
+ while ((item= it++))
+ {
+ transl[field_count].name= item->name;
+ transl[field_count++].item= item;
+ }
+ field_translation= transl;
+ field_translation_end= transl + field_count;
+
+exit:
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+
+ return res;
}
-/*
- setup fields of placeholder of merged VIEW
+/**
+ @brief
+ Create field translation for mergeable derived table/view.
- SYNOPSIS
- TABLE_LIST::setup_underlying()
- thd - thread handler
+ @param thd Thread handle
- DESCRIPTION
- It is:
- - preparing translation table for view columns
- If there are underlying view(s) procedure first will be called for them.
+ @details
+ Create field translation for mergeable derived table/view.
- RETURN
- FALSE - OK
- TRUE - error
+ @return FALSE ok.
+ @return TRUE an error occur.
*/
bool TABLE_LIST::setup_underlying(THD *thd)
{
DBUG_ENTER("TABLE_LIST::setup_underlying");
- if (!field_translation && merge_underlying_list)
+ if (!view || (!field_translation && merge_underlying_list))
{
- Field_translator *transl;
- SELECT_LEX *select= &view->select_lex;
- Item *item;
- TABLE_LIST *tbl;
- List_iterator_fast<Item> it(select->item_list);
- uint field_count= 0;
-
- if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*) &field_count))
- {
- DBUG_RETURN(TRUE);
- }
-
- for (tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
- {
- if (tbl->merge_underlying_list &&
- tbl->setup_underlying(thd))
- {
- DBUG_RETURN(TRUE);
- }
- }
-
- /* Create view fields translation table */
-
- if (!(transl=
- (Field_translator*)(thd->stmt_arena->
- alloc(select->item_list.elements *
- sizeof(Field_translator)))))
- {
+ SELECT_LEX *select= get_single_select();
+
+ if (create_field_translation(thd))
DBUG_RETURN(TRUE);
- }
-
- while ((item= it++))
- {
- transl[field_count].name= item->name;
- transl[field_count++].item= item;
- }
- field_translation= transl;
- field_translation_end= transl + field_count;
- /* TODO: use hash for big number of fields */
/* full text function moving to current select */
- if (view->select_lex.ftfunc_list->elements)
+ if (select->ftfunc_list->elements)
{
Item_func_match *ifm;
SELECT_LEX *current_select= thd->lex->current_select;
List_iterator_fast<Item_func_match>
- li(*(view->select_lex.ftfunc_list));
+ li(*(select_lex->ftfunc_list));
while ((ifm= li++))
current_select->ftfunc_list->push_front(ifm);
}
@@ -3640,7 +3628,7 @@ bool TABLE_LIST::setup_underlying(THD *thd)
/*
- Prepare where expression of view
+ Prepare where expression of derived table/view
SYNOPSIS
TABLE_LIST::prep_where()
@@ -3664,7 +3652,8 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
{
- if (tbl->view && tbl->prep_where(thd, conds, no_where_clause))
+ if (tbl->is_view_or_derived() &&
+ tbl->prep_where(thd, conds, no_where_clause))
{
DBUG_RETURN(TRUE);
}
@@ -3672,6 +3661,8 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
if (where)
{
+ if (where->fixed)
+ where->update_used_tables();
if (!where->fixed && where->fix_fields(thd, &where))
{
DBUG_RETURN(TRUE);
@@ -3704,7 +3695,13 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds,
}
}
if (tbl == 0)
+ {
+ if (*conds && !(*conds)->fixed)
+ (*conds)->fix_fields(thd, conds);
*conds= and_conds(*conds, where->copy_andor_structure(thd));
+ if (*conds && !(*conds)->fixed)
+ (*conds)->fix_fields(thd, conds);
+ }
if (arena)
thd->restore_active_arena(arena, &backup);
where_processed= TRUE;
@@ -3743,10 +3740,11 @@ merge_on_conds(THD *thd, TABLE_LIST *table, bool is_cascaded)
DBUG_PRINT("info", ("alias: %s", table->alias));
if (table->on_expr)
cond= table->on_expr->copy_andor_structure(thd);
- if (!table->nested_join)
+ if (!table->view)
DBUG_RETURN(cond);
- List_iterator<TABLE_LIST> li(table->nested_join->join_list);
- while (TABLE_LIST *tbl= li++)
+ for (TABLE_LIST *tbl= (TABLE_LIST*)table->view->select_lex.table_list.first;
+ tbl;
+ tbl= tbl->next_local)
{
if (tbl->view && !is_cascaded)
continue;
@@ -3786,7 +3784,7 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type)
{
DBUG_ENTER("TABLE_LIST::prep_check_option");
bool is_cascaded= check_opt_type == VIEW_CHECK_CASCADED;
-
+ TABLE_LIST *merge_underlying_list= view->select_lex.get_table_list();
for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
{
/* see comment of check_opt_type parameter */
@@ -3803,7 +3801,6 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type)
if (where)
{
- DBUG_ASSERT(where->fixed);
check_option= where->copy_andor_structure(thd);
}
if (is_cascaded)
@@ -3899,10 +3896,14 @@ void TABLE_LIST::hide_view_error(THD *thd)
TABLE_LIST *TABLE_LIST::find_underlying_table(TABLE *table_to_find)
{
/* is this real table and table which we are looking for? */
- if (table == table_to_find && merge_underlying_list == 0)
+ if (table == table_to_find && view == 0)
return this;
+ if (!view)
+ return 0;
- for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
+ for (TABLE_LIST *tbl= view->select_lex.get_table_list();
+ tbl;
+ tbl= tbl->next_local)
{
TABLE_LIST *result;
if ((result= tbl->find_underlying_table(table_to_find)))
@@ -3984,7 +3985,12 @@ bool TABLE_LIST::check_single_table(TABLE_LIST **table_arg,
table_map map,
TABLE_LIST *view_arg)
{
- for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
+ if (!select_lex)
+ return FALSE;
+ DBUG_ASSERT(is_merged_derived());
+ for (TABLE_LIST *tbl= get_single_select()->get_table_list();
+ tbl;
+ tbl= tbl->next_local)
{
if (tbl->table)
{
@@ -4026,8 +4032,10 @@ bool TABLE_LIST::set_insert_values(MEM_ROOT *mem_root)
}
else
{
- DBUG_ASSERT(view && merge_underlying_list);
- for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
+ DBUG_ASSERT(is_view_or_derived() && is_merged_derived());
+ for (TABLE_LIST *tbl= (TABLE_LIST*)view->select_lex.table_list.first;
+ tbl;
+ tbl= tbl->next_local)
if (tbl->set_insert_values(mem_root))
return TRUE;
}
@@ -4053,7 +4061,7 @@ bool TABLE_LIST::set_insert_values(MEM_ROOT *mem_root)
*/
bool TABLE_LIST::is_leaf_for_name_resolution()
{
- return (view || is_natural_join || is_join_columns_complete ||
+ return (is_merged_derived() || is_natural_join || is_join_columns_complete ||
!nested_join);
}
@@ -4191,7 +4199,11 @@ void TABLE_LIST::register_want_access(ulong want_access)
if (table)
table->grant.want_privilege= want_access;
}
- for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
+ if (!view)
+ return;
+ for (TABLE_LIST *tbl= view->select_lex.get_table_list();
+ tbl;
+ tbl= tbl->next_local)
tbl->register_want_access(want_access);
}
@@ -4421,14 +4433,23 @@ const char *Natural_join_column::db_name()
DBUG_ASSERT(!strcmp(table_ref->db,
table_ref->table->s->db.str) ||
(table_ref->schema_table &&
- table_ref->table->s->db.str[0] == 0));
+ table_ref->table->s->db.str[0] == 0) ||
+ table_ref->is_materialized_derived());
return table_ref->db;
}
GRANT_INFO *Natural_join_column::grant()
{
- if (view_field)
+/* if (view_field)
+ return &(table_ref->grant);
+ return &(table_ref->table->grant);*/
+ /*
+ Have to check algorithm because merged derived also has
+ field_translation.
+ */
+//if (table_ref->effective_algorithm == DTYPE_ALGORITHM_MERGE)
+ if (table_ref->is_merged_derived())
return &(table_ref->grant);
return &(table_ref->table->grant);
}
@@ -4509,7 +4530,17 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
{
DBUG_RETURN(field);
}
- Item *item= new Item_direct_view_ref(view, field_ref, name);
+ Item *item= new Item_direct_view_ref(&view->view->select_lex.context,
+ field_ref, view->alias,
+ name, view);
+ /*
+ Force creation of nullable item for the result tmp table for outer joined
+ views/derived tables.
+ */
+ if (view->outer_join)
+ item->maybe_null= TRUE;
+ /* Save item in case we will need to fall back to materialization. */
+ view->used_items.push_back(item);
DBUG_RETURN(item);
}
@@ -4563,8 +4594,7 @@ void Field_iterator_table_ref::set_field_iterator()
/* This is a merge view, so use field_translation. */
else if (table_ref->field_translation)
{
- DBUG_ASSERT(table_ref->view &&
- table_ref->effective_algorithm == VIEW_ALGORITHM_MERGE);
+ DBUG_ASSERT(table_ref->is_merged_derived());
field_it= &view_field_it;
DBUG_PRINT("info", ("field_it for '%s' is Field_iterator_view",
table_ref->alias));
@@ -5188,15 +5218,16 @@ void st_table::mark_virtual_columns_for_write(bool insert_fl)
/**
+ @brief
Allocate space for keys
- @param key_count number of keys to allocate.
+ @param key_count number of keys to allocate
@details
- Allocates space enough to fit 'key_count' keys for this table.
+ The function allocates memory to fit 'key_count' keys for this table.
- @return FALSE space was successfully allocated.
- @return TRUE an error occur.
+ @return FALSE space was successfully allocated
+ @return TRUE an error occur
*/
bool TABLE::alloc_keys(uint key_count)
@@ -5255,22 +5286,24 @@ void TABLE::create_key_part_by_field(KEY *keyinfo,
/**
- Add a key to a temporary table
+ @brief
+ Add one key to a temporary table
@param key the number of the key
@param key_parts number of components of the key
@param next_field_no the call-back function that returns the number of
the field used as the next component of the key
@param arg the argument for the above function
- @param unique Is it unique index
+ @param unique TRUE <=> it is a unique index
@details
- The function adds a new key to the table that is assumed to be
- temprary table. The call-back function must at each call must return
- the number of the field that used as next component of this key
+ The function adds a new key to the table that is assumed to be a temporary
+ table. At each its invocation the call-back function must return
+ the number of the field that is used as the next component of this key.
@return FALSE is a success
@return TRUE if a failure
+
*/
bool TABLE::add_tmp_key(uint key, uint key_parts,
@@ -5321,6 +5354,31 @@ bool TABLE::add_tmp_key(uint key, uint key_parts,
return FALSE;
}
+/*
+ @brief
+ Drop all indexes except specified one.
+
+ @param key_to_save the key to save
+
+ @details
+ Drop all indexes on this table except 'key_to_save'. The saved key becomes
+ key #0. Memory occupied by key parts of dropped keys are freed.
+ If the 'key_to_save' is negative then all keys are freed.
+*/
+
+void TABLE::use_index(int key_to_save)
+{
+ uint i= 1;
+ DBUG_ASSERT(!created && key_to_save < (int)s->keys);
+ if (key_to_save >= 0)
+ /* Save the given key. */
+ memcpy(key_info, key_info + key_to_save, sizeof(KEY));
+ else
+ /* Drop all keys; */
+ i= 0;
+
+ s->keys= (key_to_save < 0) ? 0 : 1;
+}
/**
@brief Check if this is part of a MERGE table with attached children.
@@ -5340,6 +5398,19 @@ bool st_table::is_children_attached(void)
(parent && parent->children_attached));
}
+
+/*
+ Return TRUE if the table is filled at execution phase
+
+ (and so, the optimizer must not do anything that depends on the contents of
+ the table, like range analysis or constant table detection)
+*/
+
+bool st_table::is_filled_at_execution()
+{
+ return test(pos_in_table_list->jtbm_subselect);
+}
+
/*
Cleanup this table for re-execution.
@@ -5370,6 +5441,7 @@ void TABLE_LIST::reinit_before_use(THD *thd)
parent_embedding->nested_join->join_list.head() == embedded);
}
+
/*
Return subselect that contains the FROM list this table is taken from
@@ -5641,6 +5713,297 @@ int update_virtual_fields(THD *thd, TABLE *table, bool for_write)
DBUG_RETURN(0);
}
+/*
+ @brief Reset const_table flag
+
+ @detail
+ Reset const_table flag for this table. If this table is a merged derived
+ table/view the flag is recursively reseted for all tables of the underlying
+ select.
+*/
+
+void TABLE_LIST::reset_const_table()
+{
+ table->const_table= 0;
+ if (is_merged_derived())
+ {
+ SELECT_LEX *select_lex= get_unit()->first_select();
+ TABLE_LIST *tl;
+ List_iterator<TABLE_LIST> ti(select_lex->leaf_tables);
+ while ((tl= ti++))
+ tl->reset_const_table();
+ }
+}
+
+
+/*
+ @brief Run derived tables/view handling phases on underlying select_lex.
+
+ @param lex LEX for this thread
+ @param phases derived tables/views handling phases to run
+ (set of DT_XXX constants)
+ @details
+ This function runs this derived table through specified 'phases'.
+ Underlying tables of this select are handled prior to this derived.
+ 'lex' is passed as an argument to called functions.
+
+ @return TRUE on error
+ @return FALSE ok
+*/
+
+bool TABLE_LIST::handle_derived(struct st_lex *lex, uint phases)
+{
+ SELECT_LEX_UNIT *unit= get_unit();
+ if (unit)
+ {
+ for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
+ if (sl->handle_derived(lex, phases))
+ return TRUE;
+ return mysql_handle_single_derived(lex, this, phases);
+ }
+ return FALSE;
+}
+
+
+/**
+ @brief
+ Return unit of this derived table/view
+
+ @return reference to a unit if it's a derived table/view.
+ @return 0 when it's not a derived table/view.
+*/
+
+st_select_lex_unit *TABLE_LIST::get_unit()
+{
+ return (view ? &view->unit : derived);
+}
+
+
+/**
+ @brief
+ Return select_lex of this derived table/view
+
+ @return select_lex of this derived table/view.
+ @return 0 when it's not a derived table.
+*/
+
+st_select_lex *TABLE_LIST::get_single_select()
+{
+ SELECT_LEX_UNIT *unit= get_unit();
+ return (unit ? unit->first_select() : 0);
+}
+
+
+/**
+ @brief
+ Attach a join table list as a nested join to this TABLE_LIST.
+
+ @param join_list join table list to attach
+
+ @details
+ This function wraps 'join_list' into a nested_join of this table, thus
+ turning it to a nested join leaf.
+*/
+
+void TABLE_LIST::wrap_into_nested_join(List<TABLE_LIST> &join_list)
+{
+ TABLE_LIST *tl;
+ /*
+ Walk through derived table top list and set 'embedding' to point to
+ the nesting table.
+ */
+ nested_join->join_list.empty();
+ List_iterator_fast<TABLE_LIST> li(join_list);
+ nested_join->join_list= join_list;
+ while ((tl= li++))
+ {
+ tl->embedding= this;
+ tl->join_list= &nested_join->join_list;
+ }
+}
+
+
+/**
+ @brief
+ Initialize this derived table/view
+
+ @param thd Thread handle
+
+ @details
+ This function makes initial preparations of this derived table/view for
+ further processing:
+ if it's a derived table this function marks it either as mergeable or
+ materializable
+ creates temporary table for name resolution purposes
+ creates field translation for mergeable derived table/view
+
+ @return TRUE an error occur
+ @return FALSE ok
+*/
+
+bool TABLE_LIST::init_derived(THD *thd, bool init_view)
+{
+ SELECT_LEX *first_select= get_single_select();
+ SELECT_LEX_UNIT *unit= get_unit();
+
+ if (!unit)
+ return FALSE;
+ /*
+ Check whether we can merge this derived table into main select.
+ Depending on the result field translation will or will not
+ be created.
+ */
+ TABLE_LIST *first_table= (TABLE_LIST *) first_select->table_list.first;
+ if (first_select->table_list.elements > 1 ||
+ (first_table && first_table->is_multitable()))
+ set_multitable();
+
+ unit->derived= this;
+ if (init_view && !view)
+ {
+ /* This is all what we can do for a derived table for now. */
+ set_derived();
+ }
+
+ if (!is_view())
+ {
+ /* A subquery might be forced to be materialized due to a side-effect. */
+ if (!is_materialized_derived() && first_select->is_mergeable() &&
+ optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_MERGE) &&
+ !(thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
+ thd->lex->sql_command == SQLCOM_DELETE_MULTI))
+ set_merged_derived();
+ else
+ set_materialized_derived();
+ }
+ /*
+ Derived tables/view are materialized prior to UPDATE, thus we can skip
+ them from table uniqueness check
+ */
+ if (is_materialized_derived())
+ {
+ unit->master_unit()->set_unique_exclude();
+ }
+ /*
+ Create field translation for mergeable derived tables/views.
+ For derived tables field translation can be created only after
+ unit is prepared so all '*' are get unrolled.
+ */
+ if (is_merged_derived())
+ {
+ if (is_view() || unit->prepared)
+ create_field_translation(thd);
+ }
+
+ return FALSE;
+}
+
+
+/**
+ @brief
+ Retrieve number of rows in the table
+
+ @details
+ Retrieve number of rows in the table referred by this TABLE_LIST and
+ store it in the table's stats.records variable. If this TABLE_LIST refers
+ to a materialized derived table/view then the estimated number of rows of
+ the derived table/view is used instead.
+
+ @return 0 ok
+ @return non zero error
+*/
+
+int TABLE_LIST::fetch_number_of_rows()
+{
+ int error= 0;
+ if (is_materialized_derived() && !fill_me)
+
+ {
+ table->file->stats.records= ((select_union*)derived->result)->records;
+ set_if_bigger(table->file->stats.records, 2);
+ }
+ else
+ error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
+ return error;
+}
+
+/*
+ Procedure of keys generation for result tables of materialized derived
+ tables/views.
+
+ A key is generated for each equi-join pair derived table-another table.
+ Each generated key consists of fields of derived table used in equi-join.
+ Example:
+
+ SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt JOIN
+ t1 ON tt.f1=t1.f3 and tt.f2.=t1.f4;
+ In this case for the derived table tt one key will be generated. It will
+ consist of two parts f1 and f2.
+ Example:
+
+ SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt JOIN
+ t1 ON tt.f1=t1.f3 JOIN
+ t2 ON tt.f2=t2.f4;
+ In this case for the derived table tt two keys will be generated.
+ One key over f1 field, and another key over f2 field.
+ Currently optimizer may choose to use only one such key, thus the second
+ one will be dropped after range optimizer is finished.
+ See also JOIN::drop_unused_derived_keys function.
+ Example:
+
+ SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt JOIN
+ t1 ON tt.f1=a_function(t1.f3);
+ In this case for the derived table tt one key will be generated. It will
+ consist of one field - f1.
+*/
+
+
+
+/*
+ @brief
+ Change references to underlying items of a merged derived table/view
+ for fields in derived table's result table.
+
+ @return FALSE ok
+ @return TRUE Out of memory
+*/
+bool TABLE_LIST::change_refs_to_fields()
+{
+ List_iterator<Item> li(used_items);
+ Item_direct_ref *ref;
+ Field_iterator_view field_it;
+ THD *thd= table->in_use;
+ DBUG_ASSERT(is_merged_derived());
+
+ if (!used_items.elements)
+ return FALSE;
+
+ materialized_items= (Item**)thd->calloc(sizeof(void*) * table->s->fields);
+
+ while ((ref= (Item_direct_ref*)li++))
+ {
+ uint idx;
+ Item *orig_item= *ref->ref;
+ field_it.set(this);
+ for (idx= 0; !field_it.end_of_fields(); field_it.next(), idx++)
+ {
+ if (field_it.item() == orig_item)
+ break;
+ }
+ DBUG_ASSERT(!field_it.end_of_fields());
+ if (!materialized_items[idx])
+ {
+ materialized_items[idx]= new Item_field(table->field[idx]);
+ if (!materialized_items[idx])
+ return TRUE;
+ }
+ ref->ref= materialized_items + idx;
+ }
+
+ return FALSE;
+}
+
+
/*****************************************************************************
** Instansiate templates
*****************************************************************************/
diff --git a/sql/table.h b/sql/table.h
index d43f5c85849..4205b81dc12 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -66,7 +66,8 @@ typedef struct st_order {
bool counter_used; /* parameter was counter of columns */
Field *field; /* If tmp-table group */
char *buff; /* If tmp-table group */
- table_map used, depend_map;
+ table_map used; /* NOTE: the below is only set to 0 but is still used by eq_ref_table */
+ table_map depend_map;
} ORDER;
/**
@@ -343,7 +344,7 @@ typedef struct st_table_share
struct st_table *open_tables; /* link to open tables */
#endif
engine_option_value *option_list; /* text options for table */
- void *option_struct; /* structure with parsed options */
+ ha_table_option_struct *option_struct; /* structure with parsed options */
/* The following is copied to each TABLE on OPEN */
Field **field;
@@ -440,7 +441,6 @@ typedef struct st_table_share
bool null_field_first;
bool system; /* Set if system table (one record) */
bool crypted; /* If .frm file is crypted */
- bool db_low_byte_first; /* Portable row format */
bool crashed;
bool is_view;
bool name_lock, replace_with_name_lock;
@@ -791,7 +791,6 @@ struct st_table {
uint temp_pool_slot; /* Used by intern temp tables */
uint status; /* What's in record[0] */
uint db_stat; /* mode of file as in handler.h */
- uint max_keys; /* Size of allocated key_info array. */
/* number of select if it is derived table */
uint derived_select_number;
int current_lock; /* Type of lock on table */
@@ -827,7 +826,7 @@ struct st_table {
See TABLE_LIST::process_index_hints().
*/
bool force_index_group;
- bool distinct,const_table,no_rows;
+ bool distinct,const_table,no_rows, used_for_duplicate_elimination;
/**
If set, the optimizer has found that row retrieval should access index
@@ -867,8 +866,10 @@ struct st_table {
*/
bool auto_increment_field_not_null;
bool insert_or_update; /* Can be used by the handler */
- bool alias_name_used; /* true if table_name is alias */
+ bool alias_name_used; /* true if table_name is alias */
bool get_fields_in_item_tree; /* Signal to fix_field */
+ bool created; /* For tmp tables. TRUE <=> tmp table was actually created.*/
+
/* If MERGE children attached to parent. See top comment in ha_myisammrg.cc */
bool children_attached;
@@ -889,6 +890,7 @@ struct st_table {
bool no_partitions_used; /* If true, all partitions have been pruned away */
#endif
+ uint max_keys; /* Size of allocated key_info array. */
bool fill_item_list(List<Item> *item_list) const;
void reset_item_list(List<Item> *item_list) const;
void clear_column_bitmaps(void);
@@ -958,6 +960,12 @@ struct st_table {
bool unique);
void create_key_part_by_field(KEY *keyinfo, KEY_PART_INFO *key_part_info,
Field *field);
+ void use_index(int key_to_save);
+ void set_table_map(table_map map_arg, uint tablenr_arg)
+ {
+ map= map_arg;
+ tablenr= tablenr_arg;
+ }
bool is_children_attached(void);
inline void enable_keyread()
{
@@ -967,6 +975,12 @@ struct st_table {
file->extra(HA_EXTRA_KEYREAD);
DBUG_VOID_RETURN;
}
+ /*
+ Returns TRUE if the table is filled at execution phase (and so, the
+ optimizer must not do anything that depends on the contents of the table,
+ like range analysis or constant table detection)
+ */
+ bool is_filled_at_execution();
inline void disable_keyread()
{
DBUG_ENTER("disable_keyread");
@@ -1109,13 +1123,52 @@ typedef struct st_schema_table
} ST_SCHEMA_TABLE;
+/*
+ Types of derived tables. The ending part is a bitmap of phases that are
+ applicable to a derived table of the type.
+ * /
+#define VIEW_ALGORITHM_UNDEFINED 0
+#define VIEW_ALGORITHM_MERGE 1 + DT_COMMON + DT_MERGE
+#define DERIVED_ALGORITHM_MERGE 2 + DT_COMMON + DT_MERGE
+#define VIEW_ALGORITHM_TMPTABLE 3 + DT_COMMON + DT_MATERIALIZE
+#define DERIVED_ALGORITHM_MATERIALIZE 4 + DT_COMMON + DT_MATERIALIZE
+*/
+#define DTYPE_ALGORITHM_UNDEFINED 0
+#define DTYPE_VIEW 1
+#define DTYPE_TABLE 2
+#define DTYPE_MERGE 4
+#define DTYPE_MATERIALIZE 8
+#define DTYPE_MULTITABLE 16
+#define DTYPE_MASK 19
+
+/*
+ Phases of derived tables/views handling, see sql_derived.cc
+ Values are used as parts of a bitmap attached to derived table types.
+*/
+#define DT_INIT 1
+#define DT_PREPARE 2
+#define DT_OPTIMIZE 4
+#define DT_MERGE 8
+#define DT_MERGE_FOR_INSERT 16
+#define DT_CREATE 32
+#define DT_FILL 64
+#define DT_REINIT 128
+#define DT_PHASES 8
+/* Phases that are applicable to all derived tables. */
+#define DT_COMMON (DT_INIT + DT_PREPARE + DT_REINIT + DT_OPTIMIZE)
+/* Phases that are applicable only to materialized derived tables. */
+#define DT_MATERIALIZE (DT_CREATE + DT_FILL)
+
+#define DT_PHASES_MERGE (DT_COMMON | DT_MERGE | DT_MERGE_FOR_INSERT)
+#define DT_PHASES_MATERIALIZE (DT_COMMON | DT_MATERIALIZE)
+
+#define VIEW_ALGORITHM_UNDEFINED 0
+#define VIEW_ALGORITHM_MERGE (DTYPE_VIEW | DTYPE_MERGE)
+#define VIEW_ALGORITHM_TMPTABLE (DTYPE_VIEW + DTYPE_MATERIALIZE )
+
#define JOIN_TYPE_LEFT 1
#define JOIN_TYPE_RIGHT 2
-#define VIEW_ALGORITHM_UNDEFINED 0
-#define VIEW_ALGORITHM_TMPTABLE 1
-#define VIEW_ALGORITHM_MERGE 2
-
#define VIEW_SUID_INVOKER 0
#define VIEW_SUID_DEFINER 1
#define VIEW_SUID_DEFAULT 2
@@ -1195,7 +1248,7 @@ class Item_in_subselect;
1) table (TABLE_LIST::view == NULL)
- base table
(TABLE_LIST::derived == NULL)
- - subquery - TABLE_LIST::table is a temp table
+ - FROM-clause subquery - TABLE_LIST::table is a temp table
(TABLE_LIST::derived != NULL)
- information schema table
(TABLE_LIST::schema_table != NULL)
@@ -1205,6 +1258,7 @@ class Item_in_subselect;
also (TABLE_LIST::field_translation != NULL)
- tmptable (TABLE_LIST::effective_algorithm == VIEW_ALGORITHM_TMPTABLE)
also (TABLE_LIST::field_translation == NULL)
+ 2.5) TODO: Add derived tables description here
3) nested table reference (TABLE_LIST::nested_join != NULL)
- table sequence - e.g. (t1, t2, t3)
TODO: how to distinguish from a JOIN?
@@ -1214,9 +1268,12 @@ class Item_in_subselect;
(TABLE_LIST::natural_join != NULL)
- JOIN ... USING
(TABLE_LIST::join_using_fields != NULL)
+ - semi-join nest (sj_on_expr!= NULL && sj_subq_pred!=NULL)
+ 4) jtbm semi-join (jtbm_subselect != NULL)
*/
class Index_hint;
+struct st_lex;
struct TABLE_LIST
{
TABLE_LIST() {} /* Remove gcc warning */
@@ -1256,8 +1313,15 @@ struct TABLE_LIST
*/
table_map sj_inner_tables;
/* Number of IN-compared expressions */
- uint sj_in_exprs;
+ uint sj_in_exprs;
+
+ /* If this is a non-jtbm semi-join nest: corresponding subselect predicate */
Item_in_subselect *sj_subq_pred;
+
+ /* If this is a jtbm semi-join object: corresponding subselect predicate */
+ Item_in_subselect *jtbm_subselect;
+ uint jtbm_table_no;
+
SJ_MATERIALIZATION_INFO *sj_mat_info;
/*
@@ -1310,6 +1374,8 @@ struct TABLE_LIST
filling procedure
*/
select_union *derived_result;
+ /* Stub used for materialized derived tables. */
+ table_map map; /* ID bit of table (1,2,4,8,16...) */
/*
Reference from aux_tables to local list entry of main select of
multi-delete statement:
@@ -1354,6 +1420,7 @@ struct TABLE_LIST
Field_translator *field_translation; /* array of VIEW fields */
/* pointer to element after last one in translation table above */
Field_translator *field_translation_end;
+ bool field_translation_updated;
/*
List (based on next_local) of underlying tables of this view. I.e. it
does not include the tables of subqueries used in the view. Is set only
@@ -1368,11 +1435,18 @@ struct TABLE_LIST
List<TABLE_LIST> *view_tables;
/* most upper view this table belongs to */
TABLE_LIST *belong_to_view;
+ /* A derived table this table belongs to */
+ TABLE_LIST *belong_to_derived;
/*
The view directly referencing this table
(non-zero only for merged underlying tables of a view).
*/
TABLE_LIST *referencing_view;
+
+ table_map view_used_tables;
+ table_map map_exec;
+ uint tablenr_exec;
+
/* Ptr to parent MERGE table list item. See top comment in ha_myisammrg.cc */
TABLE_LIST *parent_l;
/*
@@ -1385,13 +1459,7 @@ struct TABLE_LIST
SQL SECURITY DEFINER)
*/
Security_context *view_sctx;
- /*
- List of all base tables local to a subquery including all view
- tables. Unlike 'next_local', this in this list views are *not*
- leaves. Created in setup_tables() -> make_leaves_list().
- */
bool allowed_show;
- TABLE_LIST *next_leaf;
Item *where; /* VIEW WHERE clause condition */
Item *check_option; /* WITH CHECK OPTION condition */
LEX_STRING select_stmt; /* text of (CREATE/SELECT) statement */
@@ -1427,7 +1495,7 @@ struct TABLE_LIST
- VIEW_ALGORITHM_MERGE
@to do Replace with an enum
*/
- uint8 effective_algorithm;
+ uint8 derived_type;
GRANT_INFO grant;
/* data need by some engines in query cache*/
ulonglong engine_data;
@@ -1454,7 +1522,6 @@ struct TABLE_LIST
bool skip_temporary; /* this table shouldn't be temporary */
/* TRUE if this merged view contain auto_increment field */
bool contain_auto_increment;
- bool multitable_view; /* TRUE iff this is multitable view */
bool compact_view_format; /* Use compact format for SHOW CREATE VIEW */
/* view where processed */
bool where_processed;
@@ -1478,6 +1545,17 @@ struct TABLE_LIST
bool internal_tmp_table;
bool deleting; /* going to delete this table */
+ /* TRUE <=> derived table should be filled right after optimization. */
+ bool fill_me;
+ /* TRUE <=> view/DT is merged. */
+ bool merged;
+ bool merged_for_insert;
+ /* TRUE <=> don't prepare this derived table/view as it should be merged.*/
+ bool skip_prepare_derived;
+
+ List<Item> used_items;
+ Item **materialized_items;
+
/* View creation context. */
View_creation_ctx *view_creation_ctx;
@@ -1515,9 +1593,10 @@ struct TABLE_LIST
bool has_table_lookup_value;
uint table_open_method;
enum enum_schema_table_state schema_table_state;
+
void calc_md5(char *buffer);
- void set_underlying_merge();
int view_check_option(THD *thd, bool ignore_failure);
+ bool create_field_translation(THD *thd);
bool setup_underlying(THD *thd);
void cleanup_items();
bool placeholder()
@@ -1547,7 +1626,7 @@ struct TABLE_LIST
inline bool prepare_where(THD *thd, Item **conds,
bool no_where_clause)
{
- if (effective_algorithm == VIEW_ALGORITHM_MERGE)
+ if (!view || is_merged_derived())
return prep_where(thd, conds, no_where_clause);
return FALSE;
}
@@ -1613,6 +1692,60 @@ struct TABLE_LIST
m_table_ref_version= s->get_table_ref_version();
}
+ /* Set of functions returning/setting state of a derived table/view. */
+ inline bool is_non_derived()
+ {
+ return (!derived_type);
+ }
+ inline bool is_view_or_derived()
+ {
+ return (derived_type);
+ }
+ inline bool is_view()
+ {
+ return (derived_type & DTYPE_VIEW);
+ }
+ inline bool is_derived()
+ {
+ return (derived_type & DTYPE_TABLE);
+ }
+ inline void set_view()
+ {
+ derived_type= DTYPE_VIEW;
+ }
+ inline void set_derived()
+ {
+ derived_type= DTYPE_TABLE;
+ }
+ inline bool is_merged_derived()
+ {
+ return (derived_type & DTYPE_MERGE);
+ }
+ inline void set_merged_derived()
+ {
+ derived_type= ((derived_type & DTYPE_MASK) |
+ DTYPE_TABLE | DTYPE_MERGE);
+ }
+ inline bool is_materialized_derived()
+ {
+ return (derived_type & DTYPE_MATERIALIZE);
+ }
+ inline void set_materialized_derived()
+ {
+ derived_type= ((derived_type & DTYPE_MASK) |
+ DTYPE_TABLE | DTYPE_MATERIALIZE);
+ }
+ inline bool is_multitable()
+ {
+ return (derived_type & DTYPE_MULTITABLE);
+ }
+ inline void set_multitable()
+ {
+ derived_type|= DTYPE_MULTITABLE;
+ }
+ void reset_const_table();
+ bool handle_derived(struct st_lex *lex, uint phases);
+
/**
@brief True if this TABLE_LIST represents an anonymous derived table,
i.e. the result of a subquery.
@@ -1632,6 +1765,12 @@ struct TABLE_LIST
respectively.
*/
char *get_table_name() { return view != NULL ? view_name.str : table_name; }
+ st_select_lex_unit *get_unit();
+ st_select_lex *get_single_select();
+ void wrap_into_nested_join(List<TABLE_LIST> &join_list);
+ bool init_derived(THD *thd, bool init_view);
+ int fetch_number_of_rows();
+ bool change_refs_to_fields();
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);
diff --git a/sql/time.cc b/sql/time.cc
index c4f6c3c9539..2845e1a6d3a 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -1,4 +1,5 @@
/* Copyright (C) 2000-2006 MySQL AB
+ Copyright (c) 2009-2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -223,56 +224,132 @@ ulong convert_month_to_period(ulong month)
timestamp_type
str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time,
- uint flags)
+ ulong flags)
{
int was_cut;
THD *thd= current_thd;
timestamp_type ts_type;
ts_type= str_to_datetime(str, length, l_time,
- (flags | (thd->variables.sql_mode &
- (MODE_INVALID_DATES |
- MODE_NO_ZERO_DATE))),
+ (flags | (sql_mode_for_dates(thd))),
&was_cut);
if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR)
- make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- str, length, ts_type, NullS);
+ make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ str, length, flags & TIME_TIME_ONLY ?
+ MYSQL_TIMESTAMP_TIME : ts_type, NullS);
return ts_type;
}
+/**
+ converts a pair of numbers (integer part, microseconds) to MYSQL_TIME
+
+ @param neg sign of the time value
+ @param nr integer part of the number to convert
+ @param sec_part microsecond part of the number
+ @param ltime converted value will be written here
+ @param fuzzydate conversion flags (TIME_FUZZY_DATE, etc)
+ @param str original number, as a Lazy_string. For the warning
+ @param field_name field name or NULL if not a field. For the warning
+
+ @returns 0 for success, 1 for a failure
+*/
+static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
+ MYSQL_TIME *ltime, ulong fuzzydate,
+ const Lazy_string *str,
+ const char *field_name)
+{
+ int was_cut;
+ longlong res;
+ enum_field_types f_type;
+
+ if (fuzzydate & TIME_TIME_ONLY)
+ {
+ f_type= MYSQL_TYPE_TIME;
+ res= number_to_time(neg, nr, sec_part, ltime, &was_cut);
+ }
+ else
+ {
+ f_type= MYSQL_TYPE_DATETIME;
+ res= neg ? -1 : number_to_datetime(nr, sec_part, ltime, fuzzydate, &was_cut);
+ }
+
+ if (res < 0 || (was_cut && !(fuzzydate & TIME_FUZZY_DATE)))
+ {
+ make_truncated_value_warning(current_thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN, str,
+ res < 0 ? MYSQL_TIMESTAMP_ERROR
+ : mysql_type_to_time_type(f_type),
+ field_name);
+ }
+ return res < 0;
+}
+
+
+bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
+ ulong fuzzydate, const char *field_name)
+{
+ const Lazy_string_double str(value);
+ bool neg= value < 0;
+
+ if (neg)
+ value= -value;
+
+ if (value > LONGLONG_MAX)
+ value= static_cast<double>(LONGLONG_MAX);
+
+ longlong nr= static_cast<ulonglong>(floor(value));
+ uint sec_part= static_cast<ulong>((value - floor(value))*TIME_SECOND_PART_FACTOR);
+ return number_to_time_with_warn(neg, nr, sec_part, ltime, fuzzydate, &str,
+ field_name);
+}
+
+
+bool decimal_to_datetime_with_warn(const my_decimal *value, MYSQL_TIME *ltime,
+ ulong fuzzydate, const char *field_name)
+{
+ const Lazy_string_decimal str(value);
+ ulonglong nr;
+ ulong sec_part;
+ bool neg= my_decimal2seconds(value, &nr, &sec_part);
+ return number_to_time_with_warn(neg, nr, sec_part, ltime, fuzzydate, &str,
+ field_name);
+}
+
+
+bool int_to_datetime_with_warn(longlong value, MYSQL_TIME *ltime,
+ ulong fuzzydate, const char *field_name)
+{
+ const Lazy_string_num str(value);
+ bool neg= value < 0;
+ return number_to_time_with_warn(neg, neg ? -value : value, 0, ltime,
+ fuzzydate, &str, field_name);
+}
+
+
/*
- Convert a datetime from broken-down MYSQL_TIME representation to corresponding
- TIMESTAMP value.
+ Convert a datetime from broken-down MYSQL_TIME representation to
+ corresponding TIMESTAMP value.
SYNOPSIS
TIME_to_timestamp()
thd - current thread
t - datetime in broken-down representation,
- in_dst_time_gap - pointer to bool which is set to true if t represents
- value which doesn't exists (falls into the spring
- time-gap) or to false otherwise.
+ error_code - 0, if the conversion was successful;
+ ER_WARN_DATA_OUT_OF_RANGE, if t contains datetime value
+ which is out of TIMESTAMP range;
+ ER_WARN_INVALID_TIMESTAMP, if t represents value which
+ doesn't exists (falls into the spring time-gap).
RETURN
Number seconds in UTC since start of Unix Epoch corresponding to t.
- 0 - t contains datetime value which is out of TIMESTAMP range.
-
+ 0 - in case of ER_WARN_DATA_OUT_OF_RANGE
*/
-my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_gap)
-{
- my_time_t timestamp;
- *in_dst_time_gap= 0;
+my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, uint *error_code)
+{
thd->time_zone_used= 1;
-
- timestamp= thd->variables.time_zone->TIME_to_gmt_sec(t, in_dst_time_gap);
- if (timestamp)
- {
- return timestamp;
- }
-
- /* If we are here we have range error. */
- return(0);
+ return thd->variables.time_zone->TIME_to_gmt_sec(t, error_code);
}
@@ -282,12 +359,19 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_
NOTE
See str_to_time() for more info.
+
+ RETURN
+ 0 ok
+ 1 wrong time value
*/
+
bool
-str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time)
+str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time,
+ ulong fuzzydate)
{
int warning;
- bool ret_val= str_to_time(str, length, l_time, &warning);
+ bool ret_val= (str_to_time(str, length, l_time, fuzzydate, &warning) ==
+ MYSQL_TIMESTAMP_ERROR);
if (ret_val || warning)
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
str, length, MYSQL_TIMESTAMP_TIME, NullS);
@@ -656,11 +740,6 @@ KNOWN_DATE_TIME_FORMAT known_date_time_formats[6]=
};
-/*
- Return format string according format name.
- If name is unknown, result is NULL
-*/
-
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
timestamp_type type)
{
@@ -677,51 +756,10 @@ const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
}
}
-/****************************************************************************
- Functions to create default time/date/datetime strings
-
- NOTE:
- For the moment the DATE_TIME_FORMAT argument is ignored becasue
- MySQL doesn't support comparing of date/time/datetime strings that
- are not in arbutary order as dates are compared as strings in some
- context)
- This functions don't check that given MYSQL_TIME structure members are
- in valid range. If they are not, return value won't reflect any
- valid date either. Additionally, make_time doesn't take into
- account time->day member: it's assumed that days have been converted
- to hours already.
-****************************************************************************/
-
-void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)),
- const MYSQL_TIME *l_time, String *str)
-{
- uint length= (uint) my_time_to_str(l_time, (char*) str->ptr());
- str->length(length);
- str->set_charset(&my_charset_bin);
-}
-
-
-void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)),
- const MYSQL_TIME *l_time, String *str)
-{
- uint length= (uint) my_date_to_str(l_time, (char*) str->ptr());
- str->length(length);
- str->set_charset(&my_charset_bin);
-}
-
-
-void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)),
- const MYSQL_TIME *l_time, String *str)
-{
- uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr());
- str->length(length);
- str->set_charset(&my_charset_bin);
-}
-
-
-void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
- const char *str_val,
- uint str_length, timestamp_type time_type,
+void make_truncated_value_warning(THD *thd,
+ MYSQL_ERROR::enum_warning_level level,
+ const Lazy_string *sval,
+ timestamp_type time_type,
const char *field_name)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
@@ -729,8 +767,7 @@ void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level leve
CHARSET_INFO *cs= &my_charset_latin1;
char buff[128];
String str(buff,(uint32) sizeof(buff), system_charset_info);
- str.copy(str_val, str_length, system_charset_info);
- str[str_length]= 0; // Ensure we have end 0 for snprintf
+ sval->copy_to(&str);
switch (time_type) {
case MYSQL_TIMESTAMP_DATE:
@@ -747,32 +784,37 @@ void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level leve
if (field_name)
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
- type_str, str.c_ptr(), field_name,
+ type_str, str.c_ptr_safe(), field_name,
(ulong) thd->row_count);
else
{
if (time_type > MYSQL_TIMESTAMP_ERROR)
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
ER(ER_TRUNCATED_WRONG_VALUE),
- type_str, str.c_ptr());
+ type_str, str.c_ptr_safe());
else
cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
- ER(ER_WRONG_VALUE), type_str, str.c_ptr());
+ ER(ER_WRONG_VALUE), type_str, str.c_ptr_safe());
}
push_warning(thd, level,
ER_TRUNCATED_WRONG_VALUE, warn_buff);
}
+
/* Daynumber from year 0 to 9999-12-31 */
#define MAX_DAY_NUMBER 3652424L
-
-bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval)
+#define COMBINE(X) \
+ (((((X)->day * 24LL + (X)->hour) * 60LL + \
+ (X)->minute) * 60LL + (X)->second)*1000000LL + \
+ (X)->second_part)
+#define GET_PART(X, N) X % N ## LL; X/= N ## LL
+
+bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
+ INTERVAL interval)
{
long period, sign;
- ltime->neg= 0;
-
- sign= (interval.neg ? -1 : 1);
+ sign= (interval.neg == ltime->neg ? 1 : -1);
switch (int_type) {
case INTERVAL_SECOND:
@@ -789,35 +831,43 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL inter
case INTERVAL_DAY_SECOND:
case INTERVAL_DAY_MINUTE:
case INTERVAL_DAY_HOUR:
+ case INTERVAL_DAY:
{
- longlong sec, days, daynr, microseconds, extra_sec;
- ltime->time_type= MYSQL_TIMESTAMP_DATETIME; // Return full date
- microseconds= ltime->second_part + sign*interval.second_part;
- extra_sec= microseconds/1000000L;
- microseconds= microseconds%1000000L;
-
- sec=((ltime->day-1)*3600*24L+ltime->hour*3600+ltime->minute*60+
- ltime->second +
- sign* (longlong) (interval.day*3600*24L +
- interval.hour*LL(3600)+interval.minute*LL(60)+
- interval.second))+ extra_sec;
- if (microseconds < 0)
+ longlong usec, daynr;
+ my_bool neg= 0;
+ enum enum_mysql_timestamp_type time_type= ltime->time_type;
+
+ if (time_type != MYSQL_TIMESTAMP_TIME)
+ ltime->day+= calc_daynr(ltime->year, ltime->month, 1) - 1;
+
+ usec= COMBINE(ltime) + sign*COMBINE(&interval);
+
+ if (usec < 0)
{
- microseconds+= LL(1000000);
- sec--;
+ neg= 1;
+ usec= -usec;
}
- days= sec/(3600*LL(24));
- sec-= days*3600*LL(24);
- if (sec < 0)
+
+ ltime->second_part= GET_PART(usec, 1000000);
+ ltime->second= GET_PART(usec, 60);
+ ltime->minute= GET_PART(usec, 60);
+ ltime->neg^= neg;
+
+ if (time_type == MYSQL_TIMESTAMP_TIME)
{
- days--;
- sec+= 3600*LL(24);
+ if (usec > TIME_MAX_HOUR)
+ goto invalid_date;
+ ltime->hour= static_cast<uint>(usec);
+ ltime->day= 0;
+ return 0;
}
- ltime->second_part= (uint) microseconds;
- ltime->second= (uint) (sec % 60);
- ltime->minute= (uint) (sec/60 % 60);
- ltime->hour= (uint) (sec/3600);
- daynr= calc_daynr(ltime->year,ltime->month,1) + days;
+
+ if (int_type != INTERVAL_DAY)
+ ltime->time_type= MYSQL_TIMESTAMP_DATETIME; // Return full date
+
+ ltime->hour= GET_PART(usec, 24);
+ daynr= usec;
+
/* Day number from year 0 to 9999-12-31 */
if ((ulonglong) daynr > MAX_DAY_NUMBER)
goto invalid_date;
@@ -825,7 +875,6 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL inter
&ltime->day);
break;
}
- case INTERVAL_DAY:
case INTERVAL_WEEK:
period= (calc_daynr(ltime->year,ltime->month,ltime->day) +
sign * (long) interval.day);
@@ -863,13 +912,15 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL inter
goto null_date;
}
- return 0; // Ok
+ if (ltime->time_type != MYSQL_TIMESTAMP_TIME)
+ return 0; // Ok
invalid_date:
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_DATETIME_FUNCTION_OVERFLOW,
ER(ER_DATETIME_FUNCTION_OVERFLOW),
- "datetime");
+ ltime->time_type == MYSQL_TIMESTAMP_TIME ?
+ "time" : "datetime");
null_date:
return 1;
}
@@ -969,19 +1020,14 @@ calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign, longlong *s
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b)
{
- ulonglong a_t= TIME_to_ulonglong_datetime(a);
- ulonglong b_t= TIME_to_ulonglong_datetime(b);
+ ulonglong a_t= pack_time(a);
+ ulonglong b_t= pack_time(b);
if (a_t < b_t)
return -1;
if (a_t > b_t)
return 1;
- if (a->second_part < b->second_part)
- return -1;
- if (a->second_part > b->second_part)
- return 1;
-
return 0;
}
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 25b3b0c8994..bb0608cc3bd 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -214,7 +214,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
ALIGN_SIZE(sp->typecnt *
sizeof(TRAN_TYPE_INFO)) +
#ifdef ABBR_ARE_USED
- ALIGN_SIZE(sp->charcnt) +
+ ALIGN_SIZE(sp->charcnt+1) +
#endif
sp->leapcnt * sizeof(LS_INFO))))
return 1;
@@ -227,7 +227,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage)
tzinfo_buf+= ALIGN_SIZE(sp->typecnt * sizeof(TRAN_TYPE_INFO));
#ifdef ABBR_ARE_USED
sp->chars= tzinfo_buf;
- tzinfo_buf+= ALIGN_SIZE(sp->charcnt);
+ tzinfo_buf+= ALIGN_SIZE(sp->charcnt+1);
#endif
sp->lsis= (LS_INFO *)tzinfo_buf;
@@ -815,9 +815,11 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec)
TIME_to_gmt_sec()
t - pointer to structure for broken down represenatation
sp - pointer to struct with time zone description
- in_dst_time_gap - pointer to bool which is set to true if datetime
- value passed doesn't really exist (i.e. falls into
- spring time-gap) and is not touched otherwise.
+ error_code - 0, if the conversion was successful;
+ ER_WARN_DATA_OUT_OF_RANGE, if t contains datetime value
+ which is out of TIMESTAMP range;
+ ER_WARN_INVALID_TIMESTAMP, if t represents value which
+ doesn't exists (falls into the spring time-gap).
DESCRIPTION
This is mktime analog for MySQL. It is essentially different
@@ -879,20 +881,23 @@ sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec)
Seconds in UTC since Epoch.
0 in case of error.
*/
+
static my_time_t
-TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
- my_bool *in_dst_time_gap)
+TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp, uint *error_code)
{
my_time_t local_t;
uint saved_seconds;
uint i;
int shift= 0;
-
DBUG_ENTER("TIME_to_gmt_sec");
if (!validate_timestamp_range(t))
+ {
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
DBUG_RETURN(0);
+ }
+ *error_code= 0;
/* We need this for correct leap seconds handling */
if (t->second < SECS_PER_MIN)
@@ -936,6 +941,7 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
This means that source time can't be represented as my_time_t due to
limited my_time_t range.
*/
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
DBUG_RETURN(0);
}
@@ -952,6 +958,7 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
if (local_t > (my_time_t) (TIMESTAMP_MAX_VALUE - shift * SECS_PER_DAY +
sp->revtis[i].rt_offset - saved_seconds))
{
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
DBUG_RETURN(0); /* my_time_t overflow */
}
local_t+= shift * SECS_PER_DAY;
@@ -965,7 +972,7 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
Now we are returning my_time_t value corresponding to the
beginning of the gap.
*/
- *in_dst_time_gap= 1;
+ *error_code= ER_WARN_INVALID_TIMESTAMP;
local_t= sp->revts[i] - sp->revtis[i].rt_offset + saved_seconds;
}
else
@@ -973,7 +980,10 @@ TIME_to_gmt_sec(const MYSQL_TIME *t, const TIME_ZONE_INFO *sp,
/* check for TIMESTAMP_MAX_VALUE was already done above */
if (local_t < TIMESTAMP_MIN_VALUE)
+ {
local_t= 0;
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
+ }
DBUG_RETURN(local_t);
}
@@ -1007,8 +1017,7 @@ class Time_zone_system : public Time_zone
{
public:
Time_zone_system() {} /* Remove gcc warning */
- virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
- my_bool *in_dst_time_gap) const;
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const;
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
};
@@ -1022,9 +1031,11 @@ public:
TIME_to_gmt_sec()
t - pointer to MYSQL_TIME structure with local time in
broken-down representation.
- in_dst_time_gap - pointer to bool which is set to true if datetime
- value passed doesn't really exist (i.e. falls into
- spring time-gap) and is not touched otherwise.
+ error_code - 0, if the conversion was successful;
+ ER_WARN_DATA_OUT_OF_RANGE, if t contains datetime value
+ which is out of TIMESTAMP range;
+ ER_WARN_INVALID_TIMESTAMP, if t represents value which
+ doesn't exists (falls into the spring time-gap).
DESCRIPTION
This method uses system function (localtime_r()) for conversion
@@ -1040,10 +1051,10 @@ public:
Corresponding my_time_t value or 0 in case of error
*/
my_time_t
-Time_zone_system::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_system::TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const
{
long not_used;
- return my_system_gmt_sec(t, &not_used, in_dst_time_gap);
+ return my_system_gmt_sec(t, &not_used, error_code);
}
@@ -1103,7 +1114,7 @@ class Time_zone_utc : public Time_zone
public:
Time_zone_utc() {} /* Remove gcc warning */
virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
- my_bool *in_dst_time_gap) const;
+ uint *error_code) const;
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
};
@@ -1112,14 +1123,6 @@ public:
/*
Convert UTC time from MYSQL_TIME representation to its my_time_t representation.
- SYNOPSIS
- TIME_to_gmt_sec()
- t - pointer to MYSQL_TIME structure with local time
- in broken-down representation.
- in_dst_time_gap - pointer to bool which is set to true if datetime
- value passed doesn't really exist (i.e. falls into
- spring time-gap) and is not touched otherwise.
-
DESCRIPTION
Since Time_zone_utc is used only internally for my_time_t -> TIME
conversions, this function of Time_zone interface is not implemented for
@@ -1129,10 +1132,11 @@ public:
0
*/
my_time_t
-Time_zone_utc::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_utc::TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const
{
/* Should be never called */
DBUG_ASSERT(0);
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
return 0;
}
@@ -1192,8 +1196,7 @@ class Time_zone_db : public Time_zone
{
public:
Time_zone_db(TIME_ZONE_INFO *tz_info_arg, const String * tz_name_arg);
- virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
- my_bool *in_dst_time_gap) const;
+ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const;
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
private:
@@ -1230,9 +1233,11 @@ Time_zone_db::Time_zone_db(TIME_ZONE_INFO *tz_info_arg,
TIME_to_gmt_sec()
t - pointer to MYSQL_TIME structure with local time
in broken-down representation.
- in_dst_time_gap - pointer to bool which is set to true if datetime
- value passed doesn't really exist (i.e. falls into
- spring time-gap) and is not touched otherwise.
+ error_code - 0, if the conversion was successful;
+ ER_WARN_DATA_OUT_OF_RANGE, if t contains datetime value
+ which is out of TIMESTAMP range;
+ ER_WARN_INVALID_TIMESTAMP, if t represents value which
+ doesn't exists (falls into the spring time-gap).
DESCRIPTION
Please see ::TIME_to_gmt_sec for function description and
@@ -1242,9 +1247,9 @@ Time_zone_db::Time_zone_db(TIME_ZONE_INFO *tz_info_arg,
Corresponding my_time_t value or 0 in case of error
*/
my_time_t
-Time_zone_db::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_db::TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const
{
- return ::TIME_to_gmt_sec(t, tz_info, in_dst_time_gap);
+ return ::TIME_to_gmt_sec(t, tz_info, error_code);
}
@@ -1290,7 +1295,7 @@ class Time_zone_offset : public Time_zone
public:
Time_zone_offset(long tz_offset_arg);
virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
- my_bool *in_dst_time_gap) const;
+ uint *error_code) const;
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const;
virtual const String * get_name() const;
/*
@@ -1332,17 +1337,19 @@ Time_zone_offset::Time_zone_offset(long tz_offset_arg):
TIME_to_gmt_sec()
t - pointer to MYSQL_TIME structure with local time
in broken-down representation.
- in_dst_time_gap - pointer to bool which should be set to true if
- datetime value passed doesn't really exist
- (i.e. falls into spring time-gap) and is not
- touched otherwise.
- It is not really used in this class.
+ error_code - 0, if the conversion was successful;
+ ER_WARN_DATA_OUT_OF_RANGE, if t contains datetime value
+ which is out of TIMESTAMP range;
+ ER_WARN_INVALID_TIMESTAMP, if t represents value which
+ doesn't exists (falls into the spring time-gap).
RETURN VALUE
- Corresponding my_time_t value or 0 in case of error
+ Corresponding my_time_t value or 0 in case of error. In case of error
+ *in_dst_time_gap is also set.
*/
+
my_time_t
-Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap) const
+Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const
{
my_time_t local_t;
int shift= 0;
@@ -1352,7 +1359,11 @@ Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap)
us to make all validation checks here.
*/
if (!validate_timestamp_range(t))
+ {
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
return 0;
+ }
+ *error_code= 0;
/*
Do a temporary shift of the boundary dates to avoid
@@ -1376,6 +1387,7 @@ Time_zone_offset::TIME_to_gmt_sec(const MYSQL_TIME *t, my_bool *in_dst_time_gap)
return local_t;
/* range error*/
+ *error_code= ER_WARN_DATA_OUT_OF_RANGE;
return 0;
}
@@ -2743,7 +2755,7 @@ main(int argc, char **argv)
for (time_tmp.second=0; time_tmp.second<60; time_tmp.second+=25)
{
long not_used;
- my_bool not_used_2;
+ uint not_used_2;
t= (time_t)my_system_gmt_sec(&time_tmp, &not_used, &not_used_2);
t1= (time_t)TIME_to_gmt_sec(&time_tmp, &tz_info, &not_used_2);
if (t != t1)
diff --git a/sql/tztime.h b/sql/tztime.h
index 9bf103519c4..306f76dfece 100644
--- a/sql/tztime.h
+++ b/sql/tztime.h
@@ -33,11 +33,11 @@ public:
/**
Converts local time in broken down MYSQL_TIME representation to
my_time_t (UTC seconds since Epoch) represenation.
- Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
- falls into spring time-gap (or lefts it untouched otherwise).
+ Returns 0 in case of error. May set error_code to ER_WARN_DATA_OUT_OF_RANGE
+ or ER_WARN_INVALID_TIMESTAMP, see TIME_to_timestamp())
*/
virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
- my_bool *in_dst_time_gap) const = 0;
+ uint *error_code) const = 0;
/**
Converts time in my_time_t representation to local time in
broken down MYSQL_TIME representation.
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 9859d27dd3b..acd3c8bdd7c 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -1043,7 +1043,6 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
}
table.in_use= thd;
- table.s->db_low_byte_first= handler->low_byte_first();
table.s->blob_ptr_size= portable_sizeof_char_ptr;
null_count=0;
diff --git a/sql/unireg.h b/sql/unireg.h
index ccdbb650485..995ccaefd64 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -72,10 +72,13 @@
#define MAX_BIT_FIELD_LENGTH 64 /* Max length in bits for bit fields */
#define MAX_DATE_WIDTH 10 /* YYYY-MM-DD */
-#define MAX_TIME_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */
+#define MIN_TIME_WIDTH 10 /* -HHH:MM:SS */
+#define MAX_TIME_WIDTH 16 /* -DDDDDD HH:MM:SS */
+#define MAX_TIME_FULL_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */
#define MAX_DATETIME_FULL_WIDTH 29 /* YYYY-MM-DD HH:MM:SS.###### AM */
#define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */
#define MAX_DATETIME_COMPRESSED_WIDTH 14 /* YYYYMMDDHHMMSS */
+#define MAX_DATETIME_PRECISION 6
#define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index a7fda9a471a..d70de0dd13c 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -357,6 +357,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
{
*rc= my_errno ? my_errno : -1;
pthread_mutex_unlock(&archive_mutex);
+ pthread_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
DBUG_RETURN(NULL);
}
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index f2aee1de70c..273b7039296 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -115,13 +115,14 @@ pthread_mutex_t example_mutex;
/**
- structure for CREATE TABLE options (table options)
+ Structure for CREATE TABLE options (table options).
+ It needs to be called ha_table_option_struct.
- These can be specified in the CREATE TABLE:
- CREATE TABLE ( ... ) {...here...}
+ The option values can be specified in the CREATE TABLE at the end:
+ CREATE TABLE ( ... ) *here*
*/
-struct example_table_options_struct
+struct ha_table_option_struct
{
const char *strparam;
ulonglong ullparam;
@@ -131,19 +132,26 @@ struct example_table_options_struct
/**
- structure for CREATE TABLE options (field options)
+ Structure for CREATE TABLE options (field options).
+ It needs to be called ha_field_option_struct.
- These can be specified in the CREATE TABLE per field:
- CREATE TABLE ( field ... {...here...}, ... )
+ The option values can be specified in the CREATE TABLE per field:
+ CREATE TABLE ( field ... *here*, ... )
*/
-struct example_field_options_struct
+struct ha_field_option_struct
{
- const char *compex_param_to_parse_it_in_engine;
+ const char *complex_param_to_parse_it_in_engine;
};
-/* HA_TOPTION_* macros expect the structure called ha_table_option_struct */
-#define ha_table_option_struct example_table_options_struct
+/*
+ no example here, but index options can be declared similarly
+ using the ha_index_option_struct structure.
+
+ Their values can be specified in the CREATE TABLE per index:
+ CREATE TABLE ( field ..., .., INDEX .... *here*, ... )
+*/
+
ha_create_table_option example_table_option_list[]=
{
/*
@@ -169,8 +177,6 @@ ha_create_table_option example_table_option_list[]=
HA_TOPTION_END
};
-/* HA_FOPTION_* macros expect the structure called ha_field_option_struct */
-#define ha_field_option_struct example_field_options_struct
ha_create_table_option example_field_option_list[]=
{
/*
@@ -178,7 +184,7 @@ ha_create_table_option example_field_option_list[]=
or boolean - for example a list - it needs to specify the option
as a string and parse it internally.
*/
- HA_FOPTION_STRING("COMPLEX", compex_param_to_parse_it_in_engine),
+ HA_FOPTION_STRING("COMPLEX", complex_param_to_parse_it_in_engine),
HA_FOPTION_END
};
@@ -368,8 +374,7 @@ int ha_example::open(const char *name, int mode, uint test_if_locked)
thr_lock_data_init(&share->lock,&lock,NULL);
#ifndef DBUG_OFF
- example_table_options_struct *options=
- (example_table_options_struct *)table->s->option_struct;
+ ha_table_option_struct *options= table->s->option_struct;
DBUG_ASSERT(options);
DBUG_PRINT("info", ("strparam: '%-.64s' ullparam: %llu enumparam: %u "\
@@ -899,8 +904,7 @@ int ha_example::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info)
{
#ifndef DBUG_OFF
- example_table_options_struct *options=
- (example_table_options_struct *)table_arg->s->option_struct;
+ ha_table_option_struct *options= table_arg->s->option_struct;
DBUG_ENTER("ha_example::create");
/*
This example shows how to support custom engine specific table and field
@@ -913,13 +917,12 @@ int ha_example::create(const char *name, TABLE *table_arg,
options->ullparam, options->enumparam, options->boolparam));
for (Field **field= table_arg->s->field; *field; field++)
{
- example_field_options_struct *field_options=
- (example_field_options_struct *)(*field)->option_struct;
+ ha_field_option_struct *field_options= (*field)->option_struct;
DBUG_ASSERT(field_options);
DBUG_PRINT("info", ("field: %s complex: '%-.64s'",
(*field)->field_name,
- (field_options->compex_param_to_parse_it_in_engine ?
- field_options->compex_param_to_parse_it_in_engine :
+ (field_options->complex_param_to_parse_it_in_engine ?
+ field_options->complex_param_to_parse_it_in_engine :
"<NULL>")));
}
#endif
@@ -941,21 +944,21 @@ int ha_example::create(const char *name, TABLE *table_arg,
bool ha_example::check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes)
{
- example_table_options_struct *param_old, *param_new;
+ ha_table_option_struct *param_old, *param_new;
uint i;
DBUG_ENTER("ha_example::check_if_incompatible_data");
/*
This example shows how custom engine specific table and field
options can be accessed from this function to be compared.
*/
- param_new= (example_table_options_struct *)info->option_struct;
+ param_new= info->option_struct;
DBUG_PRINT("info", ("new strparam: '%-.64s' ullparam: %llu enumparam: %u "
"boolparam: %u",
(param_new->strparam ? param_new->strparam : "<NULL>"),
param_new->ullparam, param_new->enumparam,
param_new->boolparam));
- param_old= (example_table_options_struct *)table->s->option_struct;
+ param_old= table->s->option_struct;
DBUG_PRINT("info", ("old strparam: '%-.64s' ullparam: %llu enumparam: %u "
"boolparam: %u",
(param_old->strparam ? param_old->strparam : "<NULL>"),
@@ -974,19 +977,19 @@ bool ha_example::check_if_incompatible_data(HA_CREATE_INFO *info,
for (i= 0; i < table->s->fields; i++)
{
- example_field_options_struct *f_old, *f_new;
- f_old= (example_field_options_struct *)table->s->field[i]->option_struct;
+ ha_field_option_struct *f_old, *f_new;
+ f_old= table->s->field[i]->option_struct;
DBUG_ASSERT(f_old);
DBUG_PRINT("info", ("old field: %u old complex: '%-.64s'", i,
- (f_old->compex_param_to_parse_it_in_engine ?
- f_old->compex_param_to_parse_it_in_engine :
+ (f_old->complex_param_to_parse_it_in_engine ?
+ f_old->complex_param_to_parse_it_in_engine :
"<NULL>")));
- if (info->fileds_option_struct[i])
+ if (info->fields_option_struct[i])
{
- f_new= (example_field_options_struct *)info->fileds_option_struct[i];
+ f_new= info->fields_option_struct[i];
DBUG_PRINT("info", ("old field: %u new complex: '%-.64s'", i,
- (f_new->compex_param_to_parse_it_in_engine ?
- f_new->compex_param_to_parse_it_in_engine :
+ (f_new->complex_param_to_parse_it_in_engine ?
+ f_new->complex_param_to_parse_it_in_engine :
"<NULL>")));
}
else
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 6bb6936de9d..0297451871f 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -142,11 +142,11 @@ int ha_heap::close(void)
DESCRIPTION
Do same as default implementation but use file->s->name instead of
table->s->path. This is needed by Windows where the clone() call sees
- '/'-delimited path in table->s->path, while ha_peap::open() was called
+ '/'-delimited path in table->s->path, while ha_heap::open() was called
with '\'-delimited path.
*/
-handler *ha_heap::clone(MEM_ROOT *mem_root)
+handler *ha_heap::clone(const char *name, MEM_ROOT *mem_root)
{
handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
if (new_handler && !new_handler->ha_open(table, file->s->name, table->db_stat,
@@ -383,6 +383,10 @@ void ha_heap::position(const uchar *record)
int ha_heap::info(uint flag)
{
HEAPINFO hp_info;
+
+ if (!table)
+ return 1;
+
(void) heap_info(file,&hp_info,flag);
errkey= hp_info.errkey;
diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h
index 49aa91a6caa..799e52d903b 100644
--- a/storage/heap/ha_heap.h
+++ b/storage/heap/ha_heap.h
@@ -34,7 +34,7 @@ class ha_heap: public handler
public:
ha_heap(handlerton *hton, TABLE_SHARE *table);
~ha_heap() {}
- handler *clone(MEM_ROOT *mem_root);
+ handler *clone(const char *name, MEM_ROOT *mem_root);
const char *table_type() const
{
return (table->in_use->variables.sql_mode & MODE_MYSQL323) ?
diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c
index bf06cf03035..ba593f31cb0 100644
--- a/storage/heap/hp_test2.c
+++ b/storage/heap/hp_test2.c
@@ -21,9 +21,6 @@
#ifdef DBUG_OFF
#undef DBUG_OFF
#endif
-#ifndef SAFEMALLOC
-#define SAFEMALLOC
-#endif
#include "heapdef.h" /* Because of hp_find_block */
#include <signal.h>
@@ -319,7 +316,8 @@ int main(int argc, char *argv[])
if (!silent)
printf("- Read last key - delete - prev - prev - opt_delete - prev -> first\n");
- if (heap_rlast(file,record3,0)) goto err;
+ if (heap_rprev(file,record))
+ goto err;
if (heap_delete(file,record3)) goto err;
key_check-=atoi((char*) record3);
key1[atoi((char*) record+keyinfo[0].seg[0].start)]--;
@@ -526,7 +524,7 @@ int main(int argc, char *argv[])
}
ant=0;
- for (error=heap_rlast(file,record,0) ;
+ for (error=heap_rprev(file,record) ;
! error ;
error=heap_rprev(file,record))
{
diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c
index a7160d74a32..6c0497cbd41 100644
--- a/storage/innobase/btr/btr0cur.c
+++ b/storage/innobase/btr/btr0cur.c
@@ -66,6 +66,13 @@ this many index pages */
/*--------------------------------------*/
#define BTR_BLOB_HDR_SIZE 8
+/* Estimated table level stats from sampled value. */
+#define BTR_TABLE_STATS_FROM_SAMPLE(value, index, ext_size, not_empty) \
+ ((value * (ib_longlong) index->stat_n_leaf_pages \
+ + BTR_KEY_VAL_ESTIMATE_N_PAGES - 1 + ext_size \
+ + not_empty) \
+ / (BTR_KEY_VAL_ESTIMATE_N_PAGES + ext_size))
+
/***********************************************************************
Marks all extern fields in a record as owned by the record. This function
should be called if the delete mark of a record is removed: a not delete
@@ -2835,9 +2842,54 @@ btr_estimate_n_rows_in_range(
}
/***********************************************************************
+Record the number of non_null key values in a given index for
+each n-column prefix of the index where n < dict_index_get_n_unique(index).
+The estimates are eventually stored in the array:
+index->stat_n_non_null_key_vals. */
+static
+void
+btr_record_not_null_field_in_rec(
+/*=============================*/
+ rec_t* rec, /* in: physical record */
+ ulint n_unique, /* in: dict_index_get_n_unique(index),
+ number of columns uniquely determine
+ an index entry */
+ const ulint* offsets, /* in: rec_get_offsets(rec, index),
+ its size could be for all fields or
+ that of "n_unique" */
+ ib_longlong* n_not_null) /* in/out: array to record number of
+ not null rows for n-column prefix */
+{
+ ulint i;
+
+ ut_ad(rec_offs_n_fields(offsets) >= n_unique);
+
+ if (n_not_null == NULL) {
+ return;
+ }
+
+ for (i = 0; i < n_unique; i++) {
+ ulint rec_len;
+ byte* field;
+
+ field = rec_get_nth_field(rec, offsets, i, &rec_len);
+
+ if (rec_len != UNIV_SQL_NULL) {
+ n_not_null[i]++;
+ } else {
+ /* Break if we hit the first NULL value */
+ break;
+ }
+ }
+}
+
+/***********************************************************************
Estimates the number of different key values in a given index, for
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
-The estimates are stored in the array index->stat_n_diff_key_vals. */
+The estimates are stored in the array index->stat_n_diff_key_vals.
+If innodb_stats_method is "nulls_ignored", we also record the number of
+non-null values for each prefix and store the estimates in
+array index->stat_n_non_null_key_vals. */
void
btr_estimate_number_of_different_key_vals(
@@ -2851,6 +2903,8 @@ btr_estimate_number_of_different_key_vals(
ulint matched_fields;
ulint matched_bytes;
ib_longlong* n_diff;
+ ib_longlong* n_not_null;
+ ibool stats_null_not_equal;
ulint not_empty_flag = 0;
ulint total_external_size = 0;
ulint i;
@@ -2858,24 +2912,47 @@ btr_estimate_number_of_different_key_vals(
ulint add_on;
mtr_t mtr;
mem_heap_t* heap = NULL;
- ulint offsets_rec_[REC_OFFS_NORMAL_SIZE];
- ulint offsets_next_rec_[REC_OFFS_NORMAL_SIZE];
- ulint* offsets_rec = offsets_rec_;
- ulint* offsets_next_rec= offsets_next_rec_;
- *offsets_rec_ = (sizeof offsets_rec_) / sizeof *offsets_rec_;
- *offsets_next_rec_
- = (sizeof offsets_next_rec_) / sizeof *offsets_next_rec_;
+ ulint* offsets_rec = NULL;
+ ulint* offsets_next_rec = NULL;
n_cols = dict_index_get_n_unique(index);
- n_diff = mem_alloc((n_cols + 1) * sizeof(ib_longlong));
+ heap = mem_heap_create((sizeof *n_diff + sizeof *n_not_null)
+ * (n_cols + 1)
+ + dict_index_get_n_fields(index)
+ * (sizeof *offsets_rec
+ + sizeof *offsets_next_rec));
+
+ n_diff = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_longlong));
+
+ n_not_null = NULL;
+
+ /* Check srv_innodb_stats_method setting, and decide whether we
+ need to record non-null value and also decide if NULL is
+ considered equal (by setting stats_null_not_equal value) */
+ switch (srv_innodb_stats_method) {
+ case SRV_STATS_NULLS_IGNORED:
+ n_not_null = mem_heap_zalloc(heap, (n_cols + 1)
+ * sizeof *n_not_null);
+ /* fall through */
+
+ case SRV_STATS_NULLS_UNEQUAL:
+ /* for both SRV_STATS_NULLS_IGNORED and SRV_STATS_NULLS_UNEQUAL
+ case, we will treat NULLs as unequal value */
+ stats_null_not_equal = TRUE;
+ break;
- memset(n_diff, 0, (n_cols + 1) * sizeof(ib_longlong));
+ case SRV_STATS_NULLS_EQUAL:
+ stats_null_not_equal = FALSE;
+ break;
+
+ default:
+ ut_error;
+ }
/* We sample some pages in the index to get an estimate */
for (i = 0; i < BTR_KEY_VAL_ESTIMATE_N_PAGES; i++) {
- rec_t* supremum;
mtr_start(&mtr);
btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr);
@@ -2888,18 +2965,25 @@ btr_estimate_number_of_different_key_vals(
page = btr_cur_get_page(&cursor);
- supremum = page_get_supremum_rec(page);
rec = page_rec_get_next(page_get_infimum_rec(page));
- if (rec != supremum) {
+ if (!page_rec_is_supremum(rec)) {
not_empty_flag = 1;
offsets_rec = rec_get_offsets(rec, index, offsets_rec,
ULINT_UNDEFINED, &heap);
+
+ if (n_not_null) {
+ btr_record_not_null_field_in_rec(
+ rec, n_cols, offsets_rec, n_not_null);
+ }
}
- while (rec != supremum) {
+ while (!page_rec_is_supremum(rec)) {
rec_t* next_rec = page_rec_get_next(rec);
- if (next_rec == supremum) {
+ if (page_rec_is_supremum(next_rec)) {
+ total_external_size +=
+ btr_rec_get_externally_stored_len(
+ rec, offsets_rec);
break;
}
@@ -2907,11 +2991,13 @@ btr_estimate_number_of_different_key_vals(
matched_bytes = 0;
offsets_next_rec = rec_get_offsets(next_rec, index,
offsets_next_rec,
- n_cols, &heap);
+ ULINT_UNDEFINED,
+ &heap);
cmp_rec_rec_with_match(rec, next_rec,
offsets_rec, offsets_next_rec,
- index, &matched_fields,
+ index, stats_null_not_equal,
+ &matched_fields,
&matched_bytes);
for (j = matched_fields + 1; j <= n_cols; j++) {
@@ -2921,6 +3007,12 @@ btr_estimate_number_of_different_key_vals(
n_diff[j]++;
}
+ if (n_not_null) {
+ btr_record_not_null_field_in_rec(
+ next_rec, n_cols, offsets_next_rec,
+ n_not_null);
+ }
+
total_external_size
+= btr_rec_get_externally_stored_len(
rec, offsets_rec);
@@ -2955,10 +3047,6 @@ btr_estimate_number_of_different_key_vals(
}
}
- offsets_rec = rec_get_offsets(rec, index, offsets_rec,
- ULINT_UNDEFINED, &heap);
- total_external_size += btr_rec_get_externally_stored_len(
- rec, offsets_rec);
mtr_commit(&mtr);
}
@@ -2971,14 +3059,8 @@ btr_estimate_number_of_different_key_vals(
included in index->stat_n_leaf_pages) */
for (j = 0; j <= n_cols; j++) {
- index->stat_n_diff_key_vals[j]
- = ((n_diff[j]
- * (ib_longlong)index->stat_n_leaf_pages
- + BTR_KEY_VAL_ESTIMATE_N_PAGES - 1
- + total_external_size
- + not_empty_flag)
- / (BTR_KEY_VAL_ESTIMATE_N_PAGES
- + total_external_size));
+ index->stat_n_diff_key_vals[j] = BTR_TABLE_STATS_FROM_SAMPLE(
+ n_diff[j], index, total_external_size, not_empty_flag);
/* If the tree is small, smaller than
10 * BTR_KEY_VAL_ESTIMATE_N_PAGES + total_external_size, then
@@ -2997,12 +3079,20 @@ btr_estimate_number_of_different_key_vals(
}
index->stat_n_diff_key_vals[j] += add_on;
- }
- mem_free(n_diff);
- if (UNIV_LIKELY_NULL(heap)) {
- mem_heap_free(heap);
+ /* Update the stat_n_non_null_key_vals[] with our
+ sampled result. stat_n_non_null_key_vals[] is created
+ and initialized to zero in dict_index_add_to_cache(),
+ along with stat_n_diff_key_vals[] array */
+ if (n_not_null != NULL && (j < n_cols)) {
+ index->stat_n_non_null_key_vals[j] =
+ BTR_TABLE_STATS_FROM_SAMPLE(
+ n_not_null[j], index,
+ total_external_size, not_empty_flag);
+ }
}
+
+ mem_heap_free(heap);
}
/*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index fda6555e082..beea0a2f411 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -1358,6 +1358,12 @@ dict_index_add_to_cache(
new_index->heap,
(1 + dict_index_get_n_unique(new_index))
* sizeof(ib_longlong));
+
+ new_index->stat_n_non_null_key_vals = mem_heap_zalloc(
+ new_index->heap,
+ (1 + dict_index_get_n_unique(new_index))
+ * sizeof(*new_index->stat_n_non_null_key_vals));
+
/* Give some sensible values to stat_n_... in case we do
not calculate statistics quickly enough */
@@ -3817,6 +3823,10 @@ dict_update_statistics_low(
for (i = dict_index_get_n_unique(index); i; ) {
index->stat_n_diff_key_vals[i--] = 1;
}
+
+ memset(index->stat_n_non_null_key_vals, 0,
+ (1 + dict_index_get_n_unique(index))
+ * sizeof(*index->stat_n_non_null_key_vals));
}
index = dict_table_get_next_index(index);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b2af257273b..ce264b1bbb4 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -130,6 +130,25 @@ static my_bool innobase_adaptive_hash_index = TRUE;
static char* internal_innobase_data_file_path = NULL;
+/* Possible values for system variable "innodb_stats_method". The values
+are defined the same as its corresponding MyISAM system variable
+"myisam_stats_method"(see "myisam_stats_method_names"), for better usability */
+static const char* innodb_stats_method_names[] = {
+ "nulls_equal",
+ "nulls_unequal",
+ "nulls_ignored",
+ NullS
+};
+
+/* Used to define an enumerate type of the system variable innodb_stats_method.
+This is the same as "myisam_stats_method_typelib" */
+static TYPELIB innodb_stats_method_typelib = {
+ array_elements(innodb_stats_method_names) - 1,
+ "innodb_stats_method_typelib",
+ innodb_stats_method_names,
+ NULL
+};
+
/* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call
srv_active_wake_master_thread after each fetch or search, we only do
@@ -3184,90 +3203,64 @@ get_innobase_type_from_mysql_type(
8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
the type */
- DBUG_ASSERT((ulint)MYSQL_TYPE_STRING < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_VAR_STRING < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_DOUBLE < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_FLOAT < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_DECIMAL < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_STRING < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_VAR_STRING < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_DOUBLE < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_FLOAT < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_DECIMAL < 256);
- if (field->flags & UNSIGNED_FLAG) {
+ *unsigned_flag = 0;
+ switch (field->key_type()) {
+ case HA_KEYTYPE_USHORT_INT:
+ case HA_KEYTYPE_ULONG_INT:
+ case HA_KEYTYPE_UINT24:
+ case HA_KEYTYPE_ULONGLONG:
*unsigned_flag = DATA_UNSIGNED;
- } else {
- *unsigned_flag = 0;
- }
-
- if (field->real_type() == MYSQL_TYPE_ENUM
- || field->real_type() == MYSQL_TYPE_SET) {
-
- /* MySQL has field->type() a string type for these, but the
- data is actually internally stored as an unsigned integer
- code! */
-
- *unsigned_flag = DATA_UNSIGNED; /* MySQL has its own unsigned
- flag set to zero, even though
- internally this is an unsigned
- integer type */
+ /* fall through */
+ case HA_KEYTYPE_SHORT_INT:
+ case HA_KEYTYPE_LONG_INT:
+ case HA_KEYTYPE_INT24:
+ case HA_KEYTYPE_INT8:
+ case HA_KEYTYPE_LONGLONG:
return(DATA_INT);
- }
-
- switch (field->type()) {
- /* NOTE that we only allow string types in DATA_MYSQL and
- DATA_VARMYSQL */
- case MYSQL_TYPE_VAR_STRING: /* old <= 4.1 VARCHAR */
- case MYSQL_TYPE_VARCHAR: /* new >= 5.0.3 true VARCHAR */
- if (field->binary()) {
- return(DATA_BINARY);
- } else if (strcmp(
- field->charset()->name,
- "latin1_swedish_ci") == 0) {
+ case HA_KEYTYPE_FLOAT:
+ return(DATA_FLOAT);
+ case HA_KEYTYPE_DOUBLE:
+ return(DATA_DOUBLE);
+ case HA_KEYTYPE_BINARY:
+ if (field->type() == MYSQL_TYPE_TINY)
+ { // compatibility workaround
+ *unsigned_flag= DATA_UNSIGNED ;
+ return DATA_INT;
+ }
+ return(DATA_FIXBINARY);
+ case HA_KEYTYPE_VARBINARY2:
+ if (field->type() != MYSQL_TYPE_VARCHAR)
+ return(DATA_BLOB);
+ /* fall through */
+ case HA_KEYTYPE_VARBINARY1:
+ return(DATA_BINARY);
+ case HA_KEYTYPE_VARTEXT2:
+ if (field->type() != MYSQL_TYPE_VARCHAR)
+ return(DATA_BLOB);
+ /* fall through */
+ case HA_KEYTYPE_VARTEXT1:
+ if (field->charset() == &my_charset_latin1) {
return(DATA_VARCHAR);
} else {
return(DATA_VARMYSQL);
}
- case MYSQL_TYPE_BIT:
- case MYSQL_TYPE_STRING: if (field->binary()) {
-
- return(DATA_FIXBINARY);
- } else if (strcmp(
- field->charset()->name,
- "latin1_swedish_ci") == 0) {
+ case HA_KEYTYPE_TEXT:
+ if (field->charset() == &my_charset_latin1) {
return(DATA_CHAR);
} else {
return(DATA_MYSQL);
}
- case MYSQL_TYPE_NEWDECIMAL:
- return(DATA_FIXBINARY);
- case MYSQL_TYPE_LONG:
- case MYSQL_TYPE_LONGLONG:
- case MYSQL_TYPE_TINY:
- case MYSQL_TYPE_SHORT:
- case MYSQL_TYPE_INT24:
- case MYSQL_TYPE_DATE:
- case MYSQL_TYPE_DATETIME:
- case MYSQL_TYPE_YEAR:
- case MYSQL_TYPE_NEWDATE:
- case MYSQL_TYPE_TIME:
- case MYSQL_TYPE_TIMESTAMP:
- return(DATA_INT);
- case MYSQL_TYPE_FLOAT:
- return(DATA_FLOAT);
- case MYSQL_TYPE_DOUBLE:
- return(DATA_DOUBLE);
- case MYSQL_TYPE_DECIMAL:
+ case HA_KEYTYPE_NUM:
return(DATA_DECIMAL);
- case MYSQL_TYPE_GEOMETRY:
- case MYSQL_TYPE_TINY_BLOB:
- case MYSQL_TYPE_MEDIUM_BLOB:
- case MYSQL_TYPE_BLOB:
- case MYSQL_TYPE_LONG_BLOB:
- return(DATA_BLOB);
- case MYSQL_TYPE_NULL:
- /* MySQL currently accepts "NULL" datatype, but will
- reject such datatype in the next release. We will cope
- with it and not trigger assertion failure in 5.1 */
- break;
- default:
+ case HA_KEYTYPE_BIT:
+ case HA_KEYTYPE_END:
assert(0);
}
@@ -6363,6 +6356,65 @@ ha_innobase::read_time(
}
/*************************************************************************
+Calculate Record Per Key value. Need to exclude the NULL value if
+innodb_stats_method is set to "nulls_ignored" */
+static
+ha_rows
+innodb_rec_per_key(
+/*===============*/
+ /* out: estimated record per key
+ value */
+ dict_index_t* index, /* in: dict_index_t structure */
+ ulint i, /* in: the column we are
+ calculating rec per key */
+ ha_rows records) /* in: estimated total records */
+{
+ ha_rows rec_per_key;
+
+ ut_ad(i < dict_index_get_n_unique(index));
+
+ /* Note the stat_n_diff_key_vals[] stores the diff value with
+ n-prefix indexing, so it is always stat_n_diff_key_vals[i + 1] */
+ if (index->stat_n_diff_key_vals[i + 1] == 0) {
+
+ rec_per_key = records;
+ } else if (srv_innodb_stats_method == SRV_STATS_NULLS_IGNORED) {
+ ib_longlong num_null;
+
+ /* Number of rows with NULL value in this
+ field */
+ num_null = records - index->stat_n_non_null_key_vals[i];
+
+ /* In theory, index->stat_n_non_null_key_vals[i]
+ should always be less than the number of records.
+ Since this is statistics value, the value could
+ have slight discrepancy. But we will make sure
+ the number of null values is not a negative number. */
+ num_null = (num_null < 0) ? 0 : num_null;
+
+ /* If the number of NULL values is the same as or
+ large than that of the distinct values, we could
+ consider that the table consists mostly of NULL value.
+ Set rec_per_key to 1. */
+ if (index->stat_n_diff_key_vals[i + 1] <= num_null) {
+ rec_per_key = 1;
+ } else {
+ /* Need to exclude rows with NULL values from
+ rec_per_key calculation */
+ rec_per_key = (ha_rows)(
+ (records - num_null)
+ / (index->stat_n_diff_key_vals[i + 1]
+ - num_null));
+ }
+ } else {
+ rec_per_key = (ha_rows)
+ (records / index->stat_n_diff_key_vals[i + 1]);
+ }
+
+ return(rec_per_key);
+}
+
+/*************************************************************************
Returns statistics information of the table to the MySQL interpreter,
in various fields of the handle object. */
@@ -6569,13 +6621,8 @@ ha_innobase::info_low(
break;
}
- if (index->stat_n_diff_key_vals[j + 1] == 0) {
-
- rec_per_key = stats.records;
- } else {
- rec_per_key = (ha_rows)(stats.records /
- index->stat_n_diff_key_vals[j + 1]);
- }
+ rec_per_key = innodb_rec_per_key(
+ index, j, stats.records);
/* Since MySQL seems to favor table scans
too much over index searches, we pretend
@@ -8991,6 +9038,13 @@ static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
AUTOINC_OLD_STYLE_LOCKING, /* Minimum value */
AUTOINC_NO_LOCKING, 0); /* Maximum value */
+static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method,
+ PLUGIN_VAR_RQCMDARG,
+ "Specifies how InnoDB index statistics collection code should "
+ "treat NULLs. Possible values are NULLS_EQUAL (default), "
+ "NULLS_UNEQUAL and NULLS_IGNORED",
+ NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib);
+
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug,
PLUGIN_VAR_RQCMDARG,
@@ -9032,6 +9086,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(stats_on_metadata),
MYSQL_SYSVAR(use_legacy_cardinality_algorithm),
MYSQL_SYSVAR(adaptive_hash_index),
+ MYSQL_SYSVAR(stats_method),
MYSQL_SYSVAR(status_file),
MYSQL_SYSVAR(support_xa),
MYSQL_SYSVAR(sync_spin_loops),
diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
index 8b91f7d4c51..06b30d4a5b0 100644
--- a/storage/innobase/handler/ha_innodb.h
+++ b/storage/innobase/handler/ha_innodb.h
@@ -98,10 +98,14 @@ class ha_innobase: public handler
Table_flags table_flags() const;
ulong index_flags(uint idx, uint part, bool all_parts) const
{
+ ulong extra_flag= 0;
+ if (table && idx == table->s->primary_key)
+ extra_flag= HA_CLUSTERED_INDEX;
return (HA_READ_NEXT |
HA_READ_PREV |
HA_READ_ORDER |
HA_READ_RANGE |
+ extra_flag |
HA_KEYREAD_ONLY);
}
uint max_supported_keys() const { return MAX_KEY; }
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index 213dcb7f568..20235c55f22 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -404,7 +404,10 @@ btr_estimate_n_rows_in_range(
/***********************************************************************
Estimates the number of different key values in a given index, for
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
-The estimates are stored in the array index->stat_n_diff_key_vals. */
+The estimates are stored in the array index->stat_n_diff_key_vals.
+If innodb_stats_method is nulls_ignored, we also record the number of
+non-null values for each prefix and stored the estimates in
+array index->stat_n_non_null_key_vals. */
void
btr_estimate_number_of_different_key_vals(
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 2f2a7441478..83dbf65ea41 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -222,6 +222,12 @@ struct dict_index_struct{
for this index, for each n-column prefix
where n <= dict_get_n_unique(index); we
periodically calculate new estimates */
+ ib_longlong* stat_n_non_null_key_vals;
+ /* approximate number of non-null key values
+ for this index, for each column where
+ n < dict_get_n_unique(index); This
+ is used when innodb_stats_method is
+ "nulls_ignored". */
ulint stat_index_size;
/* approximate index size in database pages */
ulint stat_n_leaf_pages;
diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h
index b90545f2105..6674b5ff397 100644
--- a/storage/innobase/include/dict0types.h
+++ b/storage/innobase/include/dict0types.h
@@ -16,11 +16,6 @@ typedef struct dict_index_struct dict_index_t;
typedef struct dict_table_struct dict_table_t;
typedef struct dict_foreign_struct dict_foreign_t;
-/* A cluster object is a table object with the type field set to
-DICT_CLUSTERED */
-
-typedef dict_table_t dict_cluster_t;
-
typedef struct ind_node_struct ind_node_t;
typedef struct tab_node_struct tab_node_t;
diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h
index c6a6e5de4db..22a22d13e17 100644
--- a/storage/innobase/include/rem0cmp.h
+++ b/storage/innobase/include/rem0cmp.h
@@ -141,6 +141,10 @@ cmp_rec_rec_with_match(
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
dict_index_t* index, /* in: data dictionary index */
+ ibool nulls_unequal,
+ /* in: TRUE if this is for index statistics
+ cardinality estimation, and innodb_stats_method
+ is "nulls_unequal" or "nulls_ignored" */
ulint* matched_fields, /* in/out: number of already completely
matched fields; when the function returns,
contains the value the for current
diff --git a/storage/innobase/include/rem0cmp.ic b/storage/innobase/include/rem0cmp.ic
index 52dc7ff5dc9..45e12301a3c 100644
--- a/storage/innobase/include/rem0cmp.ic
+++ b/storage/innobase/include/rem0cmp.ic
@@ -72,5 +72,5 @@ cmp_rec_rec(
ulint match_b = 0;
return(cmp_rec_rec_with_match(rec1, rec2, offsets1, offsets2, index,
- &match_f, &match_b));
+ FALSE, &match_f, &match_b));
}
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 3dd4bb961f9..811074b2be8 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -91,6 +91,11 @@ extern ulint srv_lock_table_size;
extern ulint srv_n_file_io_threads;
+/* The "innodb_stats_method" setting, decides how InnoDB is going
+to treat NULL value when collecting statistics. It is not defined
+as enum type because the configure option takes unsigned integer type. */
+extern ulong srv_innodb_stats_method;
+
#ifdef UNIV_LOG_ARCHIVE
extern ibool srv_log_archive_on;
extern ibool srv_archive_recovery;
@@ -286,6 +291,19 @@ of lower numbers are included. */
#define SRV_FORCE_NO_LOG_REDO 6 /* do not do the log roll-forward
in connection with recovery */
+/* Alternatives for srv_innodb_stats_method, which could be changed by
+setting innodb_stats_method */
+enum srv_stats_method_name_enum {
+ SRV_STATS_NULLS_EQUAL, /* All NULL values are treated as
+ equal. This is the default setting
+ for innodb_stats_method */
+ SRV_STATS_NULLS_UNEQUAL, /* All NULL values are treated as
+ NOT equal. */
+ SRV_STATS_NULLS_IGNORED /* NULL values are ignored */
+};
+
+typedef enum srv_stats_method_name_enum srv_stats_method_name_t;
+
/*************************************************************************
Boots Innobase server. */
diff --git a/storage/innobase/include/sync0arr.h b/storage/innobase/include/sync0arr.h
index fae26b7a63e..ec48059dbcb 100644
--- a/storage/innobase/include/sync0arr.h
+++ b/storage/innobase/include/sync0arr.h
@@ -93,10 +93,13 @@ sync_arr_wake_threads_if_sema_free(void);
Prints warnings of long semaphore waits to stderr. */
ibool
-sync_array_print_long_waits(void);
-/*=============================*/
- /* out: TRUE if fatal semaphore wait threshold
- was exceeded */
+sync_array_print_long_waits(
+/*========================*/
+ /* out: TRUE if fatal semaphore wait threshold
+ was exceeded */
+ os_thread_id_t* waiter, /* out: longest waiting thread */
+ const void** sema) /* out: longest-waited-for semaphore */
+ __attribute__((nonnull));
/************************************************************************
Validates the integrity of the wait array. Checks
that the number of reserved cells equals the count variable. */
diff --git a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h
index 008df80a2c7..dd898557d6e 100644
--- a/storage/innobase/include/sync0rw.h
+++ b/storage/innobase/include/sync0rw.h
@@ -1,7 +1,7 @@
/******************************************************
The read-write lock (for threads, not for database transactions)
-(c) 1995 Innobase Oy
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Created 9/11/1995 Heikki Tuuri
*******************************************************/
@@ -409,6 +409,7 @@ Prints info of a debug struct. */
void
rw_lock_debug_print(
/*================*/
+ FILE* f, /* in: output stream */
rw_lock_debug_t* info); /* in: debug struct */
#endif /* UNIV_SYNC_DEBUG */
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index 46ba010bd1d..22f8aa89181 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -121,9 +121,7 @@ struct trx_rseg_struct{
ulint id; /* rollback segment id == the index of
its slot in the trx system file copy */
mutex_t mutex; /* mutex protecting the fields in this
- struct except id; NOTE that the latching
- order must always be kernel mutex ->
- rseg mutex */
+ struct except id, which is constant */
ulint space; /* space where the rollback segment is
header is placed */
ulint page_no;/* page number of the rollback segment
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 97a47d9f46e..4652f45892e 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -198,8 +198,9 @@ which is in the prepared state */
trx_t *
trx_get_trx_by_xid(
/*===============*/
- /* out: trx or NULL */
- XID* xid); /* in: X/Open XA transaction identification */
+ /* out: trx or NULL;
+ on match, the trx->xid will be invalidated */
+ const XID* xid); /* in: X/Open XA transaction identifier */
/**************************************************************************
If required, flushes the log to disk if we called trx_commit_for_mysql()
with trx->flush_log_later == TRUE. */
diff --git a/storage/innobase/rem/rem0cmp.c b/storage/innobase/rem/rem0cmp.c
index ca0ec663548..2939c119e2e 100644
--- a/storage/innobase/rem/rem0cmp.c
+++ b/storage/innobase/rem/rem0cmp.c
@@ -720,6 +720,10 @@ cmp_rec_rec_with_match(
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
dict_index_t* index, /* in: data dictionary index */
+ ibool nulls_unequal,
+ /* in: TRUE if this is for index statistics
+ cardinality estimation, and innodb_stats_method
+ is "nulls_unequal" or "nulls_ignored" */
ulint* matched_fields, /* in/out: number of already completely
matched fields; when the function returns,
contains the value the for current
@@ -821,9 +825,13 @@ cmp_rec_rec_with_match(
|| rec2_f_len == UNIV_SQL_NULL) {
if (rec1_f_len == rec2_f_len) {
-
- goto next_field;
-
+ /* This is limited to stats collection,
+ cannot use it for regular search */
+ if (nulls_unequal) {
+ ret = -1;
+ } else {
+ goto next_field;
+ }
} else if (rec2_f_len == UNIV_SQL_NULL) {
/* We define the SQL null to be the
diff --git a/storage/innobase/row/row0vers.c b/storage/innobase/row/row0vers.c
index f4adfa855df..23aca8c3f2e 100644
--- a/storage/innobase/row/row0vers.c
+++ b/storage/innobase/row/row0vers.c
@@ -593,11 +593,15 @@ row_vers_build_for_semi_consistent_read(
mutex_enter(&kernel_mutex);
version_trx = trx_get_on_id(version_trx_id);
+ if (version_trx
+ && (version_trx->conc_state == TRX_COMMITTED_IN_MEMORY
+ || version_trx->conc_state == TRX_NOT_STARTED)) {
+
+ version_trx = NULL;
+ }
mutex_exit(&kernel_mutex);
- if (!version_trx
- || version_trx->conc_state == TRX_NOT_STARTED
- || version_trx->conc_state == TRX_COMMITTED_IN_MEMORY) {
+ if (!version_trx) {
/* We found a version that belongs to a
committed transaction: return it. */
diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
index 5b1184fb416..3f6f1982992 100644
--- a/storage/innobase/srv/srv0srv.c
+++ b/storage/innobase/srv/srv0srv.c
@@ -218,6 +218,11 @@ ulong srv_max_buf_pool_modified_pct = 90;
/* variable counts amount of data read in total (in bytes) */
ulint srv_data_read = 0;
+/* Internal setting for "innodb_stats_method". Decides how InnoDB treats
+NULL value when collecting statistics. By default, it is set to
+SRV_STATS_NULLS_EQUAL(0), ie. all NULL value are treated equal */
+ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL;
+
/* here we count the amount of data written in total (in bytes) */
ulint srv_data_written = 0;
@@ -2175,9 +2180,15 @@ srv_error_monitor_thread(
os_thread_create */
{
/* number of successive fatal timeouts observed */
- ulint fatal_cnt = 0;
- dulint old_lsn;
- dulint new_lsn;
+ ulint fatal_cnt = 0;
+ dulint old_lsn;
+ dulint new_lsn;
+ /* longest waiting thread for a semaphore */
+ os_thread_id_t waiter = os_thread_get_curr_id();
+ os_thread_id_t old_waiter = waiter;
+ /* the semaphore that is being waited for */
+ const void* sema = NULL;
+ const void* old_sema = NULL;
old_lsn = srv_start_lsn;
@@ -2219,10 +2230,11 @@ loop:
/* In case mutex_exit is not a memory barrier, it is
theoretically possible some threads are left waiting though
the semaphore is already released. Wake up those threads: */
-
+
sync_arr_wake_threads_if_sema_free();
- if (sync_array_print_long_waits()) {
+ if (sync_array_print_long_waits(&waiter, &sema)
+ && sema == old_sema && os_thread_eq(waiter, old_waiter)) {
fatal_cnt++;
if (fatal_cnt > 10) {
@@ -2237,6 +2249,8 @@ loop:
}
} else {
fatal_cnt = 0;
+ old_waiter = waiter;
+ old_sema = sema;
}
/* Flush stderr so that a database user gets the output
diff --git a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c
index 154593a9035..93a7398f252 100644
--- a/storage/innobase/sync/sync0arr.c
+++ b/storage/innobase/sync/sync0arr.c
@@ -1,7 +1,7 @@
/******************************************************
The wait array used in synchronization primitives
-(c) 1995 Innobase Oy
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Created 9/5/1995 Heikki Tuuri
*******************************************************/
@@ -709,7 +709,7 @@ print:
fprintf(stderr, "rw-lock %p ",
(void*) lock);
sync_array_cell_print(stderr, cell);
- rw_lock_debug_print(debug);
+ rw_lock_debug_print(stderr, debug);
return(TRUE);
}
}
@@ -916,10 +916,12 @@ sync_arr_wake_threads_if_sema_free(void)
Prints warnings of long semaphore waits to stderr. */
ibool
-sync_array_print_long_waits(void)
-/*=============================*/
- /* out: TRUE if fatal semaphore wait threshold
- was exceeded */
+sync_array_print_long_waits(
+/*========================*/
+ /* out: TRUE if fatal semaphore wait threshold
+ was exceeded */
+ os_thread_id_t* waiter, /* out: longest waiting thread */
+ const void** sema) /* out: longest-waited-for semaphore */
{
sync_cell_t* cell;
ibool old_val;
@@ -927,24 +929,40 @@ sync_array_print_long_waits(void)
ulint i;
ulint fatal_timeout = srv_fatal_semaphore_wait_threshold;
ibool fatal = FALSE;
+ double longest_diff = 0;
for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
+ double diff;
+ void* wait_object;
+
cell = sync_array_get_nth_cell(sync_primary_wait_array, i);
- if (cell->wait_object != NULL && cell->waiting
- && difftime(time(NULL), cell->reservation_time) > 240) {
+ wait_object = cell->wait_object;
+
+ if (wait_object == NULL || !cell->waiting) {
+
+ continue;
+ }
+
+ diff = difftime(time(NULL), cell->reservation_time);
+
+ if (diff > 240) {
fputs("InnoDB: Warning: a long semaphore wait:\n",
stderr);
sync_array_cell_print(stderr, cell);
noticed = TRUE;
}
- if (cell->wait_object != NULL && cell->waiting
- && difftime(time(NULL), cell->reservation_time)
- > fatal_timeout) {
+ if (diff > fatal_timeout) {
fatal = TRUE;
}
+
+ if (diff > longest_diff) {
+ longest_diff = diff;
+ *sema = wait_object;
+ *waiter = cell->thread;
+ }
}
if (noticed) {
diff --git a/storage/innobase/sync/sync0rw.c b/storage/innobase/sync/sync0rw.c
index 0b05fb826ac..ef4c07e8c26 100644
--- a/storage/innobase/sync/sync0rw.c
+++ b/storage/innobase/sync/sync0rw.c
@@ -1,7 +1,7 @@
/******************************************************
The read-write lock (for thread synchronization)
-(c) 1995 Innobase Oy
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Created 9/11/1995 Heikki Tuuri
*******************************************************/
@@ -830,7 +830,7 @@ rw_lock_list_print_info(
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
- rw_lock_debug_print(info);
+ rw_lock_debug_print(file, info);
info = UT_LIST_GET_NEXT(list, info);
}
}
@@ -870,7 +870,7 @@ rw_lock_print(
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
- rw_lock_debug_print(info);
+ rw_lock_debug_print(stderr, info);
info = UT_LIST_GET_NEXT(list, info);
}
}
@@ -882,28 +882,29 @@ Prints info of a debug struct. */
void
rw_lock_debug_print(
/*================*/
+ FILE* f, /* in: output stream */
rw_lock_debug_t* info) /* in: debug struct */
{
ulint rwt;
rwt = info->lock_type;
- fprintf(stderr, "Locked: thread %lu file %s line %lu ",
+ fprintf(f, "Locked: thread %lu file %s line %lu ",
(ulong) os_thread_pf(info->thread_id), info->file_name,
(ulong) info->line);
if (rwt == RW_LOCK_SHARED) {
- fputs("S-LOCK", stderr);
+ fputs("S-LOCK", f);
} else if (rwt == RW_LOCK_EX) {
- fputs("X-LOCK", stderr);
+ fputs("X-LOCK", f);
} else if (rwt == RW_LOCK_WAIT_EX) {
- fputs("WAIT X-LOCK", stderr);
+ fputs("WAIT X-LOCK", f);
} else {
ut_error;
}
if (info->pass != 0) {
- fprintf(stderr, " pass value %lu", (ulong) info->pass);
+ fprintf(f, " pass value %lu", (ulong) info->pass);
}
- putc('\n', stderr);
+ putc('\n', f);
}
/*******************************************************************
diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c
index 21f75e0818f..a82d7f452fc 100644
--- a/storage/innobase/trx/trx0trx.c
+++ b/storage/innobase/trx/trx0trx.c
@@ -2041,14 +2041,15 @@ which is in the prepared state */
trx_t*
trx_get_trx_by_xid(
/*===============*/
- /* out: trx or NULL */
- XID* xid) /* in: X/Open XA transaction identification */
+ /* out: trx or NULL;
+ on match, the trx->xid will be invalidated */
+ const XID* xid) /* in: X/Open XA transaction identifier */
{
trx_t* trx;
if (xid == NULL) {
- return (NULL);
+ return(NULL);
}
mutex_enter(&kernel_mutex);
@@ -2061,10 +2062,16 @@ trx_get_trx_by_xid(
of gtrid_lenght+bqual_length bytes should be
the same */
- if (xid->gtrid_length == trx->xid.gtrid_length
+ if (trx->conc_state == TRX_PREPARED
+ && xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
&& memcmp(xid->data, trx->xid.data,
xid->gtrid_length + xid->bqual_length) == 0) {
+
+ /* Invalidate the XID, so that subsequent calls
+ will not find it. */
+ memset(&trx->xid, 0, sizeof(trx->xid));
+ trx->xid.formatID = -1;
break;
}
@@ -2073,14 +2080,5 @@ trx_get_trx_by_xid(
mutex_exit(&kernel_mutex);
- if (trx) {
- if (trx->conc_state != TRX_PREPARED) {
-
- return(NULL);
- }
-
- return(trx);
- } else {
- return(NULL);
- }
+ return(trx);
}
diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog
index bf003b810d2..100cf3690ce 100644
--- a/storage/innodb_plugin/ChangeLog
+++ b/storage/innodb_plugin/ChangeLog
@@ -1,3 +1,89 @@
+2011-03-30 The InnoDB Team
+
+ * srv/srv0srv.c, sync/sync0arr.h, sync/sync0arr.c:
+ Fix Bug#11877216 InnoDB too eager to commit suicide on a busy server
+
+2011-03-15 The InnoDB Team
+
+ * btr/btr0cur.c, page/page0zip.c:
+ Fix Bug#11849231 inflateInit() invoked without initializing all memory
+
+2011-02-28 The InnoDB Team
+
+ * btr/btr0sea.c, buf/buf0buf.c, buf/buf0lru.c:
+ Fix Bug#58549 Race condition in buf_LRU_drop_page_hash_for_tablespace()
+ and compressed tables
+
+2011-02-15 The InnoDB Team
+
+ * sync/sync0rw.c, innodb_bug59307.test:
+ Bug#59307 Valgrind: uninitialized value in
+ rw_lock_set_writer_id_and_recursion_flag()
+
+2011-02-14 The InnoDB Team
+
+ * handler/handler0alter.cc:
+ Bug#59749 Enabling concurrent reads while creating non-primary
+ unique index gives failures
+
+2011-01-31 The InnoDB Team
+
+ * btr/btr0cur.c, include/row0upd.h,
+ row/row0purge.c, row/row0umod.c, row/row0upd.c:
+ Bug#59230 assert 0 row_upd_changes_ord_field_binary()
+ in post-crash rollback or purge
+
+2011-01-27 The InnoDB Team
+
+ * btr/btr0cur.c:
+ Bug#59465 btr_estimate_number_of_different_key_vals use
+ incorrect offset for external_size
+
+2011-01-27 The InnoDB Team
+
+ * include/trx0trx.h, trx/trx0trx.c:
+ Bug#59440 Race condition in XA ROLLBACK and XA COMMIT
+ after server restart
+
+2011-01-25 The InnoDB Team
+
+ * row/row0upd.c:
+ Bug#59585 Fix 58912 introduces compiler warning
+ due to potentially uninitialized variable
+
+2011-01-25 The InnoDB Team
+
+ * mtr/mtr0log.c:
+ Bug#59486 Incorrect usage of UNIV_UNLIKELY() in mlog_parse_string()
+
+2011-01-25 The InnoDB Team
+
+ * row/row0vers.c:
+ Fix Bug#59464 Race condition in row_vers_build_for_semi_consistent_read
+
+2011-01-25 The InnoDB Team
+
+ * btr/btr0btr.c, btr/btr0cur.c, btr/btr0sea.c,
+ buf/buf0buddy.c, buf/buf0buf.c, buf/buf0lru.c,
+ include/buf0buf.h, include/buf0buf.ic, include/buf0lru.h,
+ mem/mem0mem.c, page/page0zip.c:
+ Fix Bug#59707 Unused compression-related parameters
+ in buffer pool functions
+
+2011-01-18 The InnoDB Team
+
+ * include/sync0rw.h, sync/sync0arr.c, sync/sync0rw.c:
+ Fix Bug#59579 rw_lock_debug_print outputs to stderr, not to
+ SHOW ENGINE INNODB STATUS
+
+2011-01-14 The InnoDB Team
+ * btr/btr0cur.c, dict/dict0dict.c, handler/ha_innodb.cc,
+ include/btr0cur.h, include/dict0mem.h, include/rem0cmp.h,
+ include/rem0cmp.ic, include/srv0srv.h, rem/rem0cmp.c,
+ srv/srv0srv.c, innodb_bug30423.test:
+ Fix Bug#30423 InnoDBs treatment of NULL in index stats causes
+ bad "rows examined" estimates
+
2011-01-06 The InnoDB Team
* row/row0merge.c:
Fix Bug#59312 Examine MAX_FULL_NAME_LEN in InnoDB to address
diff --git a/storage/innodb_plugin/btr/btr0btr.c b/storage/innodb_plugin/btr/btr0btr.c
index 32e2caecdb8..46810c011c4 100644
--- a/storage/innodb_plugin/btr/btr0btr.c
+++ b/storage/innodb_plugin/btr/btr0btr.c
@@ -42,6 +42,560 @@ Created 6/2/1994 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "trx0trx.h"
+#ifdef UNIV_BLOB_DEBUG
+# include "srv0srv.h"
+# include "ut0rbt.h"
+
+/** TRUE when messages about index->blobs modification are enabled. */
+static ibool btr_blob_dbg_msg;
+
+/** Issue a message about an operation on index->blobs.
+@param op operation
+@param b the entry being subjected to the operation
+@param ctx the context of the operation */
+#define btr_blob_dbg_msg_issue(op, b, ctx) \
+ fprintf(stderr, op " %u:%u:%u->%u %s(%u,%u,%u)\n", \
+ (b)->ref_page_no, (b)->ref_heap_no, \
+ (b)->ref_field_no, (b)->blob_page_no, ctx, \
+ (b)->owner, (b)->always_owner, (b)->del)
+
+/** Insert to index->blobs a reference to an off-page column.
+@param index the index tree
+@param b the reference
+@param ctx context (for logging) */
+UNIV_INTERN
+void
+btr_blob_dbg_rbt_insert(
+/*====================*/
+ dict_index_t* index, /*!< in/out: index tree */
+ const btr_blob_dbg_t* b, /*!< in: the reference */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ if (btr_blob_dbg_msg) {
+ btr_blob_dbg_msg_issue("insert", b, ctx);
+ }
+ mutex_enter(&index->blobs_mutex);
+ rbt_insert(index->blobs, b, b);
+ mutex_exit(&index->blobs_mutex);
+}
+
+/** Remove from index->blobs a reference to an off-page column.
+@param index the index tree
+@param b the reference
+@param ctx context (for logging) */
+UNIV_INTERN
+void
+btr_blob_dbg_rbt_delete(
+/*====================*/
+ dict_index_t* index, /*!< in/out: index tree */
+ const btr_blob_dbg_t* b, /*!< in: the reference */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ if (btr_blob_dbg_msg) {
+ btr_blob_dbg_msg_issue("delete", b, ctx);
+ }
+ mutex_enter(&index->blobs_mutex);
+ ut_a(rbt_delete(index->blobs, b));
+ mutex_exit(&index->blobs_mutex);
+}
+
+/**************************************************************//**
+Comparator for items (btr_blob_dbg_t) in index->blobs.
+The key in index->blobs is (ref_page_no, ref_heap_no, ref_field_no).
+@return negative, 0 or positive if *a<*b, *a=*b, *a>*b */
+static
+int
+btr_blob_dbg_cmp(
+/*=============*/
+ const void* a, /*!< in: first btr_blob_dbg_t to compare */
+ const void* b) /*!< in: second btr_blob_dbg_t to compare */
+{
+ const btr_blob_dbg_t* aa = a;
+ const btr_blob_dbg_t* bb = b;
+
+ ut_ad(aa != NULL);
+ ut_ad(bb != NULL);
+
+ if (aa->ref_page_no != bb->ref_page_no) {
+ return(aa->ref_page_no < bb->ref_page_no ? -1 : 1);
+ }
+ if (aa->ref_heap_no != bb->ref_heap_no) {
+ return(aa->ref_heap_no < bb->ref_heap_no ? -1 : 1);
+ }
+ if (aa->ref_field_no != bb->ref_field_no) {
+ return(aa->ref_field_no < bb->ref_field_no ? -1 : 1);
+ }
+ return(0);
+}
+
+/**************************************************************//**
+Add a reference to an off-page column to the index->blobs map. */
+UNIV_INTERN
+void
+btr_blob_dbg_add_blob(
+/*==================*/
+ const rec_t* rec, /*!< in: clustered index record */
+ ulint field_no, /*!< in: off-page column number */
+ ulint page_no, /*!< in: start page of the column */
+ dict_index_t* index, /*!< in/out: index tree */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ btr_blob_dbg_t b;
+ const page_t* page = page_align(rec);
+
+ ut_a(index->blobs);
+
+ b.blob_page_no = page_no;
+ b.ref_page_no = page_get_page_no(page);
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+ b.ref_field_no = field_no;
+ ut_a(b.ref_field_no >= index->n_uniq);
+ b.always_owner = b.owner = TRUE;
+ b.del = FALSE;
+ ut_a(!rec_get_deleted_flag(rec, page_is_comp(page)));
+ btr_blob_dbg_rbt_insert(index, &b, ctx);
+}
+
+/**************************************************************//**
+Add to index->blobs any references to off-page columns from a record.
+@return number of references added */
+UNIV_INTERN
+ulint
+btr_blob_dbg_add_rec(
+/*=================*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: offsets */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ ulint count = 0;
+ ulint i;
+ btr_blob_dbg_t b;
+ ibool del;
+
+ ut_ad(rec_offs_validate(rec, index, offsets));
+
+ if (!rec_offs_any_extern(offsets)) {
+ return(0);
+ }
+
+ b.ref_page_no = page_get_page_no(page_align(rec));
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+ del = (rec_get_deleted_flag(rec, rec_offs_comp(offsets)) != 0);
+
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (rec_offs_nth_extern(offsets, i)) {
+ ulint len;
+ const byte* field_ref = rec_get_nth_field(
+ rec, offsets, i, &len);
+
+ ut_a(len != UNIV_SQL_NULL);
+ ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+ field_ref += len - BTR_EXTERN_FIELD_REF_SIZE;
+
+ if (!memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE)) {
+ /* the column has not been stored yet */
+ continue;
+ }
+
+ b.ref_field_no = i;
+ b.blob_page_no = mach_read_from_4(
+ field_ref + BTR_EXTERN_PAGE_NO);
+ ut_a(b.ref_field_no >= index->n_uniq);
+ b.always_owner = b.owner
+ = !(field_ref[BTR_EXTERN_LEN]
+ & BTR_EXTERN_OWNER_FLAG);
+ b.del = del;
+
+ btr_blob_dbg_rbt_insert(index, &b, ctx);
+ count++;
+ }
+ }
+
+ return(count);
+}
+
+/**************************************************************//**
+Display the references to off-page columns.
+This function is to be called from a debugger,
+for example when a breakpoint on ut_dbg_assertion_failed is hit. */
+UNIV_INTERN
+void
+btr_blob_dbg_print(
+/*===============*/
+ const dict_index_t* index) /*!< in: index tree */
+{
+ const ib_rbt_node_t* node;
+
+ if (!index->blobs) {
+ return;
+ }
+
+ /* We intentionally do not acquire index->blobs_mutex here.
+ This function is to be called from a debugger, and the caller
+ should make sure that the index->blobs_mutex is held. */
+
+ for (node = rbt_first(index->blobs);
+ node != NULL; node = rbt_next(index->blobs, node)) {
+ const btr_blob_dbg_t* b
+ = rbt_value(btr_blob_dbg_t, node);
+ fprintf(stderr, "%u:%u:%u->%u%s%s%s\n",
+ b->ref_page_no, b->ref_heap_no, b->ref_field_no,
+ b->blob_page_no,
+ b->owner ? "" : "(disowned)",
+ b->always_owner ? "" : "(has disowned)",
+ b->del ? "(deleted)" : "");
+ }
+}
+
+/**************************************************************//**
+Remove from index->blobs any references to off-page columns from a record.
+@return number of references removed */
+UNIV_INTERN
+ulint
+btr_blob_dbg_remove_rec(
+/*====================*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: offsets */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ ulint i;
+ ulint count = 0;
+ btr_blob_dbg_t b;
+
+ ut_ad(rec_offs_validate(rec, index, offsets));
+
+ if (!rec_offs_any_extern(offsets)) {
+ return(0);
+ }
+
+ b.ref_page_no = page_get_page_no(page_align(rec));
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (rec_offs_nth_extern(offsets, i)) {
+ ulint len;
+ const byte* field_ref = rec_get_nth_field(
+ rec, offsets, i, &len);
+
+ ut_a(len != UNIV_SQL_NULL);
+ ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+ field_ref += len - BTR_EXTERN_FIELD_REF_SIZE;
+
+ b.ref_field_no = i;
+ b.blob_page_no = mach_read_from_4(
+ field_ref + BTR_EXTERN_PAGE_NO);
+
+ switch (b.blob_page_no) {
+ case 0:
+ /* The column has not been stored yet.
+ The BLOB pointer must be all zero.
+ There cannot be a BLOB starting at
+ page 0, because page 0 is reserved for
+ the tablespace header. */
+ ut_a(!memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+ /* fall through */
+ case FIL_NULL:
+ /* the column has been freed already */
+ continue;
+ }
+
+ btr_blob_dbg_rbt_delete(index, &b, ctx);
+ count++;
+ }
+ }
+
+ return(count);
+}
+
+/**************************************************************//**
+Check that there are no references to off-page columns from or to
+the given page. Invoked when freeing or clearing a page.
+@return TRUE when no orphan references exist */
+UNIV_INTERN
+ibool
+btr_blob_dbg_is_empty(
+/*==================*/
+ dict_index_t* index, /*!< in: index */
+ ulint page_no) /*!< in: page number */
+{
+ const ib_rbt_node_t* node;
+ ibool success = TRUE;
+
+ if (!index->blobs) {
+ return(success);
+ }
+
+ mutex_enter(&index->blobs_mutex);
+
+ for (node = rbt_first(index->blobs);
+ node != NULL; node = rbt_next(index->blobs, node)) {
+ const btr_blob_dbg_t* b
+ = rbt_value(btr_blob_dbg_t, node);
+
+ if (b->ref_page_no != page_no && b->blob_page_no != page_no) {
+ continue;
+ }
+
+ fprintf(stderr,
+ "InnoDB: orphan BLOB ref%s%s%s %u:%u:%u->%u\n",
+ b->owner ? "" : "(disowned)",
+ b->always_owner ? "" : "(has disowned)",
+ b->del ? "(deleted)" : "",
+ b->ref_page_no, b->ref_heap_no, b->ref_field_no,
+ b->blob_page_no);
+
+ if (b->blob_page_no != page_no || b->owner || !b->del) {
+ success = FALSE;
+ }
+ }
+
+ mutex_exit(&index->blobs_mutex);
+ return(success);
+}
+
+/**************************************************************//**
+Count and process all references to off-page columns on a page.
+@return number of references processed */
+UNIV_INTERN
+ulint
+btr_blob_dbg_op(
+/*============*/
+ const page_t* page, /*!< in: B-tree leaf page */
+ const rec_t* rec, /*!< in: record to start from
+ (NULL to process the whole page) */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx, /*!< in: context (for logging) */
+ const btr_blob_dbg_op_f op) /*!< in: operation on records */
+{
+ ulint count = 0;
+ mem_heap_t* heap = NULL;
+ ulint offsets_[REC_OFFS_NORMAL_SIZE];
+ ulint* offsets = offsets_;
+ rec_offs_init(offsets_);
+
+ ut_a(fil_page_get_type(page) == FIL_PAGE_INDEX);
+ ut_a(!rec || page_align(rec) == page);
+
+ if (!index->blobs || !page_is_leaf(page)
+ || !dict_index_is_clust(index)) {
+ return(0);
+ }
+
+ if (rec == NULL) {
+ rec = page_get_infimum_rec(page);
+ }
+
+ do {
+ offsets = rec_get_offsets(rec, index, offsets,
+ ULINT_UNDEFINED, &heap);
+ count += op(rec, index, offsets, ctx);
+ rec = page_rec_get_next_const(rec);
+ } while (!page_rec_is_supremum(rec));
+
+ if (UNIV_LIKELY_NULL(heap)) {
+ mem_heap_free(heap);
+ }
+
+ return(count);
+}
+
+/**************************************************************//**
+Count and add to index->blobs any references to off-page columns
+from records on a page.
+@return number of references added */
+UNIV_INTERN
+ulint
+btr_blob_dbg_add(
+/*=============*/
+ const page_t* page, /*!< in: rewritten page */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ btr_blob_dbg_assert_empty(index, page_get_page_no(page));
+
+ return(btr_blob_dbg_op(page, NULL, index, ctx, btr_blob_dbg_add_rec));
+}
+
+/**************************************************************//**
+Count and remove from index->blobs any references to off-page columns
+from records on a page.
+Used when reorganizing a page, before copying the records.
+@return number of references removed */
+UNIV_INTERN
+ulint
+btr_blob_dbg_remove(
+/*================*/
+ const page_t* page, /*!< in: b-tree page */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ ulint count;
+
+ count = btr_blob_dbg_op(page, NULL, index, ctx,
+ btr_blob_dbg_remove_rec);
+
+ /* Check that no references exist. */
+ btr_blob_dbg_assert_empty(index, page_get_page_no(page));
+
+ return(count);
+}
+
+/**************************************************************//**
+Restore in index->blobs any references to off-page columns
+Used when page reorganize fails due to compressed page overflow. */
+UNIV_INTERN
+void
+btr_blob_dbg_restore(
+/*=================*/
+ const page_t* npage, /*!< in: page that failed to compress */
+ const page_t* page, /*!< in: copy of original page */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx) /*!< in: context (for logging) */
+{
+ ulint removed;
+ ulint added;
+
+ ut_a(page_get_page_no(npage) == page_get_page_no(page));
+ ut_a(page_get_space_id(npage) == page_get_space_id(page));
+
+ removed = btr_blob_dbg_remove(npage, index, ctx);
+ added = btr_blob_dbg_add(page, index, ctx);
+ ut_a(added == removed);
+}
+
+/**************************************************************//**
+Modify the 'deleted' flag of a record. */
+UNIV_INTERN
+void
+btr_blob_dbg_set_deleted_flag(
+/*==========================*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: rec_get_offs(rec, index) */
+ ibool del) /*!< in: TRUE=deleted, FALSE=exists */
+{
+ const ib_rbt_node_t* node;
+ btr_blob_dbg_t b;
+ btr_blob_dbg_t* c;
+ ulint i;
+
+ ut_ad(rec_offs_validate(rec, index, offsets));
+ ut_a(dict_index_is_clust(index));
+ ut_a(del == !!del);/* must be FALSE==0 or TRUE==1 */
+
+ if (!rec_offs_any_extern(offsets) || !index->blobs) {
+
+ return;
+ }
+
+ b.ref_page_no = page_get_page_no(page_align(rec));
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (rec_offs_nth_extern(offsets, i)) {
+ ulint len;
+ const byte* field_ref = rec_get_nth_field(
+ rec, offsets, i, &len);
+
+ ut_a(len != UNIV_SQL_NULL);
+ ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+ field_ref += len - BTR_EXTERN_FIELD_REF_SIZE;
+
+ b.ref_field_no = i;
+ b.blob_page_no = mach_read_from_4(
+ field_ref + BTR_EXTERN_PAGE_NO);
+
+ switch (b.blob_page_no) {
+ case 0:
+ ut_a(memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+ /* page number 0 is for the
+ page allocation bitmap */
+ case FIL_NULL:
+ /* the column has been freed already */
+ ut_error;
+ }
+
+ mutex_enter(&index->blobs_mutex);
+ node = rbt_lookup(index->blobs, &b);
+ ut_a(node);
+
+ c = rbt_value(btr_blob_dbg_t, node);
+ /* The flag should be modified. */
+ c->del = del;
+ if (btr_blob_dbg_msg) {
+ b = *c;
+ mutex_exit(&index->blobs_mutex);
+ btr_blob_dbg_msg_issue("del_mk", &b, "");
+ } else {
+ mutex_exit(&index->blobs_mutex);
+ }
+ }
+ }
+}
+
+/**************************************************************//**
+Change the ownership of an off-page column. */
+UNIV_INTERN
+void
+btr_blob_dbg_owner(
+/*===============*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: rec_get_offs(rec, index) */
+ ulint i, /*!< in: ith field in rec */
+ ibool own) /*!< in: TRUE=owned, FALSE=disowned */
+{
+ const ib_rbt_node_t* node;
+ btr_blob_dbg_t b;
+ const byte* field_ref;
+ ulint len;
+
+ ut_ad(rec_offs_validate(rec, index, offsets));
+ ut_a(rec_offs_nth_extern(offsets, i));
+
+ field_ref = rec_get_nth_field(rec, offsets, i, &len);
+ ut_a(len != UNIV_SQL_NULL);
+ ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+ field_ref += len - BTR_EXTERN_FIELD_REF_SIZE;
+
+ b.ref_page_no = page_get_page_no(page_align(rec));
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+ b.ref_field_no = i;
+ b.owner = !(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG);
+ b.blob_page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO);
+
+ ut_a(b.owner == own);
+
+ mutex_enter(&index->blobs_mutex);
+ node = rbt_lookup(index->blobs, &b);
+ /* row_ins_clust_index_entry_by_modify() invokes
+ btr_cur_unmark_extern_fields() also for the newly inserted
+ references, which are all zero bytes until the columns are stored.
+ The node lookup must fail if and only if that is the case. */
+ ut_a(!memcmp(field_ref, field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE)
+ == !node);
+
+ if (node) {
+ btr_blob_dbg_t* c = rbt_value(btr_blob_dbg_t, node);
+ /* Some code sets ownership from TRUE to TRUE.
+ We do not allow changing ownership from FALSE to FALSE. */
+ ut_a(own || c->owner);
+
+ c->owner = own;
+ if (!own) {
+ c->always_owner = FALSE;
+ }
+ }
+
+ mutex_exit(&index->blobs_mutex);
+}
+#endif /* UNIV_BLOB_DEBUG */
+
/*
Latching strategy of the InnoDB B-tree
--------------------------------------
@@ -296,6 +850,7 @@ btr_page_create(
page_t* page = buf_block_get_frame(block);
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
+ btr_blob_dbg_assert_empty(index, buf_block_get_page_no(block));
if (UNIV_LIKELY_NULL(page_zip)) {
page_create_zip(block, index, level, mtr);
@@ -489,6 +1044,7 @@ btr_page_free_low(
modify clock */
buf_block_modify_clock_inc(block);
+ btr_blob_dbg_assert_empty(index, buf_block_get_page_no(block));
if (dict_index_is_ibuf(index)) {
@@ -773,6 +1329,13 @@ btr_create(
block = buf_page_get(space, zip_size, page_no,
RW_X_LATCH, mtr);
} else {
+#ifdef UNIV_BLOB_DEBUG
+ if ((type & DICT_CLUSTERED) && !index->blobs) {
+ mutex_create(&index->blobs_mutex, SYNC_ANY_LATCH);
+ index->blobs = rbt_create(sizeof(btr_blob_dbg_t),
+ btr_blob_dbg_cmp);
+ }
+#endif /* UNIV_BLOB_DEBUG */
block = fseg_create(space, 0,
PAGE_HEADER + PAGE_BTR_SEG_TOP, mtr);
}
@@ -979,7 +1542,7 @@ btr_page_reorganize_low(
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
#ifndef UNIV_HOTBACKUP
- temp_block = buf_block_alloc(0);
+ temp_block = buf_block_alloc();
#else /* !UNIV_HOTBACKUP */
ut_ad(block == back_block1);
temp_block = back_block2;
@@ -996,6 +1559,7 @@ btr_page_reorganize_low(
block->check_index_page_at_flush = TRUE;
#endif /* !UNIV_HOTBACKUP */
+ btr_blob_dbg_remove(page, index, "btr_page_reorganize");
/* Recreate the page: note that global data on page (possible
segment headers, next page-field, etc.) is preserved intact */
@@ -1024,6 +1588,8 @@ btr_page_reorganize_low(
(!page_zip_compress(page_zip, page, index, NULL))) {
/* Restore the old page and exit. */
+ btr_blob_dbg_restore(page, temp_page, index,
+ "btr_page_reorganize_compress_fail");
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/* Check that the bytes that we skip are identical. */
@@ -1157,6 +1723,7 @@ btr_page_empty(
#endif /* UNIV_ZIP_DEBUG */
btr_search_drop_page_hash_index(block);
+ btr_blob_dbg_remove(page, index, "btr_page_empty");
/* Recreate the page: note that global data on page (possible
segment headers, next page-field, etc.) is preserved intact */
@@ -2497,6 +3064,7 @@ btr_lift_page_up(
index);
}
+ btr_blob_dbg_remove(page, index, "btr_lift_page_up");
lock_update_copy_and_discard(father_block, block);
/* Go upward to root page, decrementing levels by one. */
@@ -2758,6 +3326,7 @@ err_exit:
lock_update_merge_right(merge_block, orig_succ, block);
}
+ btr_blob_dbg_remove(page, index, "btr_compress");
mem_heap_free(heap);
if (!dict_index_is_clust(index) && page_is_leaf(merge_page)) {
@@ -2988,6 +3557,8 @@ btr_discard_page(
block);
}
+ btr_blob_dbg_remove(page, index, "btr_discard_page");
+
/* Free the file page */
btr_page_free(index, block, mtr);
diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c
index c57255a25ae..d7b5ed0d135 100644
--- a/storage/innodb_plugin/btr/btr0cur.c
+++ b/storage/innodb_plugin/btr/btr0cur.c
@@ -100,6 +100,18 @@ can be released by page reorganize, then it is reorganized */
/*--------------------------------------*/
#define BTR_BLOB_HDR_SIZE 8 /*!< Size of a BLOB
part header, in bytes */
+
+/** Estimated table level stats from sampled value.
+@param value sampled stats
+@param index index being sampled
+@param sample number of sampled rows
+@param ext_size external stored data size
+@param not_empty table not empty
+@return estimated table wide stats from sampled value */
+#define BTR_TABLE_STATS_FROM_SAMPLE(value, index, sample, ext_size, not_empty)\
+ (((value) * (ib_int64_t) index->stat_n_leaf_pages \
+ + (sample) - 1 + (ext_size) + (not_empty)) / ((sample) + (ext_size)))
+
/* @} */
#endif /* !UNIV_HOTBACKUP */
@@ -174,7 +186,7 @@ static
ulint
btr_rec_get_externally_stored_len(
/*==============================*/
- rec_t* rec, /*!< in: record */
+ const rec_t* rec, /*!< in: record */
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
#endif /* !UNIV_HOTBACKUP */
@@ -1756,8 +1768,8 @@ btr_cur_update_in_place(
NOT call it if index is secondary */
if (!dict_index_is_clust(index)
- || row_upd_changes_ord_field_binary(NULL, NULL,
- index, update)) {
+ || row_upd_changes_ord_field_binary(index, update, thr,
+ NULL, NULL)) {
/* Remove possible hash index pointer to this record */
btr_search_update_hash_on_delete(cursor);
@@ -2560,6 +2572,7 @@ btr_cur_del_mark_set_clust_rec(
page_zip = buf_block_get_page_zip(block);
+ btr_blob_dbg_set_deleted_flag(rec, index, offsets, val);
btr_rec_set_deleted_flag(rec, page_zip, val);
trx = thr_get_trx(thr);
@@ -3201,9 +3214,54 @@ btr_estimate_n_rows_in_range(
}
/*******************************************************************//**
+Record the number of non_null key values in a given index for
+each n-column prefix of the index where n < dict_index_get_n_unique(index).
+The estimates are eventually stored in the array:
+index->stat_n_non_null_key_vals. */
+static
+void
+btr_record_not_null_field_in_rec(
+/*=============================*/
+ rec_t* rec, /*!< in: physical record */
+ ulint n_unique, /*!< in: dict_index_get_n_unique(index),
+ number of columns uniquely determine
+ an index entry */
+ const ulint* offsets, /*!< in: rec_get_offsets(rec, index),
+ its size could be for all fields or
+ that of "n_unique" */
+ ib_int64_t* n_not_null) /*!< in/out: array to record number of
+ not null rows for n-column prefix */
+{
+ ulint i;
+
+ ut_ad(rec_offs_n_fields(offsets) >= n_unique);
+
+ if (n_not_null == NULL) {
+ return;
+ }
+
+ for (i = 0; i < n_unique; i++) {
+ ulint rec_len;
+ byte* field;
+
+ field = rec_get_nth_field(rec, offsets, i, &rec_len);
+
+ if (rec_len != UNIV_SQL_NULL) {
+ n_not_null[i]++;
+ } else {
+ /* Break if we hit the first NULL value */
+ break;
+ }
+ }
+}
+
+/*******************************************************************//**
Estimates the number of different key values in a given index, for
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
-The estimates are stored in the array index->stat_n_diff_key_vals. */
+The estimates are stored in the array index->stat_n_diff_key_vals.
+If innodb_stats_method is "nulls_ignored", we also record the number of
+non-null values for each prefix and store the estimates in
+array index->stat_n_non_null_key_vals. */
UNIV_INTERN
void
btr_estimate_number_of_different_key_vals(
@@ -3217,6 +3275,8 @@ btr_estimate_number_of_different_key_vals(
ulint matched_fields;
ulint matched_bytes;
ib_int64_t* n_diff;
+ ib_int64_t* n_not_null;
+ ibool stats_null_not_equal;
ullint n_sample_pages; /* number of pages to sample */
ulint not_empty_flag = 0;
ulint total_external_size = 0;
@@ -3225,16 +3285,43 @@ btr_estimate_number_of_different_key_vals(
ullint add_on;
mtr_t mtr;
mem_heap_t* heap = NULL;
- ulint offsets_rec_[REC_OFFS_NORMAL_SIZE];
- ulint offsets_next_rec_[REC_OFFS_NORMAL_SIZE];
- ulint* offsets_rec = offsets_rec_;
- ulint* offsets_next_rec= offsets_next_rec_;
- rec_offs_init(offsets_rec_);
- rec_offs_init(offsets_next_rec_);
+ ulint* offsets_rec = NULL;
+ ulint* offsets_next_rec = NULL;
n_cols = dict_index_get_n_unique(index);
- n_diff = mem_zalloc((n_cols + 1) * sizeof(ib_int64_t));
+ heap = mem_heap_create((sizeof *n_diff + sizeof *n_not_null)
+ * (n_cols + 1)
+ + dict_index_get_n_fields(index)
+ * (sizeof *offsets_rec
+ + sizeof *offsets_next_rec));
+
+ n_diff = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
+
+ n_not_null = NULL;
+
+ /* Check srv_innodb_stats_method setting, and decide whether we
+ need to record non-null value and also decide if NULL is
+ considered equal (by setting stats_null_not_equal value) */
+ switch (srv_innodb_stats_method) {
+ case SRV_STATS_NULLS_IGNORED:
+ n_not_null = mem_heap_zalloc(heap, (n_cols + 1)
+ * sizeof *n_not_null);
+ /* fall through */
+
+ case SRV_STATS_NULLS_UNEQUAL:
+ /* for both SRV_STATS_NULLS_IGNORED and SRV_STATS_NULLS_UNEQUAL
+ case, we will treat NULLs as unequal value */
+ stats_null_not_equal = TRUE;
+ break;
+
+ case SRV_STATS_NULLS_EQUAL:
+ stats_null_not_equal = FALSE;
+ break;
+
+ default:
+ ut_error;
+ }
/* It makes no sense to test more pages than are contained
in the index, thus we lower the number if it is too high */
@@ -3251,7 +3338,6 @@ btr_estimate_number_of_different_key_vals(
/* We sample some pages in the index to get an estimate */
for (i = 0; i < n_sample_pages; i++) {
- rec_t* supremum;
mtr_start(&mtr);
btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr);
@@ -3264,18 +3350,25 @@ btr_estimate_number_of_different_key_vals(
page = btr_cur_get_page(&cursor);
- supremum = page_get_supremum_rec(page);
rec = page_rec_get_next(page_get_infimum_rec(page));
- if (rec != supremum) {
+ if (!page_rec_is_supremum(rec)) {
not_empty_flag = 1;
offsets_rec = rec_get_offsets(rec, index, offsets_rec,
ULINT_UNDEFINED, &heap);
+
+ if (n_not_null) {
+ btr_record_not_null_field_in_rec(
+ rec, n_cols, offsets_rec, n_not_null);
+ }
}
- while (rec != supremum) {
+ while (!page_rec_is_supremum(rec)) {
rec_t* next_rec = page_rec_get_next(rec);
- if (next_rec == supremum) {
+ if (page_rec_is_supremum(next_rec)) {
+ total_external_size +=
+ btr_rec_get_externally_stored_len(
+ rec, offsets_rec);
break;
}
@@ -3283,11 +3376,13 @@ btr_estimate_number_of_different_key_vals(
matched_bytes = 0;
offsets_next_rec = rec_get_offsets(next_rec, index,
offsets_next_rec,
- n_cols, &heap);
+ ULINT_UNDEFINED,
+ &heap);
cmp_rec_rec_with_match(rec, next_rec,
offsets_rec, offsets_next_rec,
- index, &matched_fields,
+ index, stats_null_not_equal,
+ &matched_fields,
&matched_bytes);
for (j = matched_fields + 1; j <= n_cols; j++) {
@@ -3297,6 +3392,12 @@ btr_estimate_number_of_different_key_vals(
n_diff[j]++;
}
+ if (n_not_null) {
+ btr_record_not_null_field_in_rec(
+ next_rec, n_cols, offsets_next_rec,
+ n_not_null);
+ }
+
total_external_size
+= btr_rec_get_externally_stored_len(
rec, offsets_rec);
@@ -3331,10 +3432,6 @@ btr_estimate_number_of_different_key_vals(
}
}
- offsets_rec = rec_get_offsets(rec, index, offsets_rec,
- ULINT_UNDEFINED, &heap);
- total_external_size += btr_rec_get_externally_stored_len(
- rec, offsets_rec);
mtr_commit(&mtr);
}
@@ -3348,13 +3445,9 @@ btr_estimate_number_of_different_key_vals(
for (j = 0; j <= n_cols; j++) {
index->stat_n_diff_key_vals[j]
- = ((n_diff[j]
- * (ib_int64_t)index->stat_n_leaf_pages
- + n_sample_pages - 1
- + total_external_size
- + not_empty_flag)
- / (n_sample_pages
- + total_external_size));
+ = BTR_TABLE_STATS_FROM_SAMPLE(
+ n_diff[j], index, n_sample_pages,
+ total_external_size, not_empty_flag);
/* If the tree is small, smaller than
10 * n_sample_pages + total_external_size, then
@@ -3373,45 +3466,81 @@ btr_estimate_number_of_different_key_vals(
}
index->stat_n_diff_key_vals[j] += add_on;
- }
- mem_free(n_diff);
- if (UNIV_LIKELY_NULL(heap)) {
- mem_heap_free(heap);
+ /* Update the stat_n_non_null_key_vals[] with our
+ sampled result. stat_n_non_null_key_vals[] is created
+ and initialized to zero in dict_index_add_to_cache(),
+ along with stat_n_diff_key_vals[] array */
+ if (n_not_null != NULL && (j < n_cols)) {
+ index->stat_n_non_null_key_vals[j] =
+ BTR_TABLE_STATS_FROM_SAMPLE(
+ n_not_null[j], index, n_sample_pages,
+ total_external_size, not_empty_flag);
+ }
}
+
+ mem_heap_free(heap);
}
/*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
/***********************************************************//**
+Gets the offset of the pointer to the externally stored part of a field.
+@return offset of the pointer to the externally stored part */
+static
+ulint
+btr_rec_get_field_ref_offs(
+/*=======================*/
+ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ ulint n) /*!< in: index of the external field */
+{
+ ulint field_ref_offs;
+ ulint local_len;
+
+ ut_a(rec_offs_nth_extern(offsets, n));
+ field_ref_offs = rec_get_nth_field_offs(offsets, n, &local_len);
+ ut_a(local_len != UNIV_SQL_NULL);
+ ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+ return(field_ref_offs + local_len - BTR_EXTERN_FIELD_REF_SIZE);
+}
+
+/** Gets a pointer to the externally stored part of a field.
+@param rec record
+@param offsets rec_get_offsets(rec)
+@param n index of the externally stored field
+@return pointer to the externally stored part */
+#define btr_rec_get_field_ref(rec, offsets, n) \
+ ((rec) + btr_rec_get_field_ref_offs(offsets, n))
+
+/***********************************************************//**
Gets the externally stored size of a record, in units of a database page.
@return externally stored part, in units of a database page */
static
ulint
btr_rec_get_externally_stored_len(
/*==============================*/
- rec_t* rec, /*!< in: record */
+ const rec_t* rec, /*!< in: record */
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{
ulint n_fields;
- byte* data;
- ulint local_len;
- ulint extern_len;
ulint total_extern_len = 0;
ulint i;
ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
+
+ if (!rec_offs_any_extern(offsets)) {
+ return(0);
+ }
+
n_fields = rec_offs_n_fields(offsets);
for (i = 0; i < n_fields; i++) {
if (rec_offs_nth_extern(offsets, i)) {
- data = rec_get_nth_field(rec, offsets, i, &local_len);
-
- local_len -= BTR_EXTERN_FIELD_REF_SIZE;
-
- extern_len = mach_read_from_4(data + local_len
- + BTR_EXTERN_LEN + 4);
+ ulint extern_len = mach_read_from_4(
+ btr_rec_get_field_ref(rec, offsets, i)
+ + BTR_EXTERN_LEN + 4);
total_extern_len += ut_calc_align(extern_len,
UNIV_PAGE_SIZE);
@@ -3441,7 +3570,7 @@ btr_cur_set_ownership_of_extern_field(
ulint byte_val;
data = rec_get_nth_field(rec, offsets, i, &local_len);
-
+ ut_ad(rec_offs_nth_extern(offsets, i));
ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
local_len -= BTR_EXTERN_FIELD_REF_SIZE;
@@ -3451,6 +3580,9 @@ btr_cur_set_ownership_of_extern_field(
if (val) {
byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
} else {
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ ut_a(!(byte_val & BTR_EXTERN_OWNER_FLAG));
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
}
@@ -3464,6 +3596,8 @@ btr_cur_set_ownership_of_extern_field(
} else {
mach_write_to_1(data + local_len + BTR_EXTERN_LEN, byte_val);
}
+
+ btr_blob_dbg_owner(rec, index, offsets, i, val);
}
/*******************************************************************//**
@@ -3667,13 +3801,12 @@ btr_blob_free(
&& buf_block_get_space(block) == space
&& buf_block_get_page_no(block) == page_no) {
- if (buf_LRU_free_block(&block->page, all, NULL)
- != BUF_LRU_FREED
+ if (buf_LRU_free_block(&block->page, all) != BUF_LRU_FREED
&& all && block->page.zip.data) {
/* Attempt to deallocate the uncompressed page
if the whole block cannot be deallocted. */
- buf_LRU_free_block(&block->page, FALSE, NULL);
+ buf_LRU_free_block(&block->page, FALSE);
}
}
@@ -3689,8 +3822,8 @@ file segment of the index tree.
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
UNIV_INTERN
ulint
-btr_store_big_rec_extern_fields(
-/*============================*/
+btr_store_big_rec_extern_fields_func(
+/*=================================*/
dict_index_t* index, /*!< in: index of rec; the index tree
MUST be X-latched */
buf_block_t* rec_block, /*!< in/out: block containing rec */
@@ -3699,11 +3832,17 @@ btr_store_big_rec_extern_fields(
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
- big_rec_t* big_rec_vec, /*!< in: vector containing fields
+#ifdef UNIV_DEBUG
+ mtr_t* local_mtr, /*!< in: mtr containing the
+ latch to rec and to the tree */
+#endif /* UNIV_DEBUG */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ ibool update_in_place,/*! in: TRUE if the record is updated
+ in place (not delete+insert) */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+ const big_rec_t*big_rec_vec) /*!< in: vector containing fields
to be stored externally */
- mtr_t* local_mtr __attribute__((unused))) /*!< in: mtr
- containing the latch to rec and to the
- tree */
+
{
ulint rec_page_no;
byte* field_ref;
@@ -3721,6 +3860,7 @@ btr_store_big_rec_extern_fields(
z_stream c_stream;
ut_ad(rec_offs_validate(rec, index, offsets));
+ ut_ad(rec_offs_any_extern(offsets));
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
@@ -3752,21 +3892,37 @@ btr_store_big_rec_extern_fields(
ut_a(err == Z_OK);
}
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ /* All pointers to externally stored columns in the record
+ must either be zero or they must be pointers to inherited
+ columns, owned by this record or an earlier record version. */
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (!rec_offs_nth_extern(offsets, i)) {
+ continue;
+ }
+ field_ref = btr_rec_get_field_ref(rec, offsets, i);
+
+ ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
+ /* Either this must be an update in place,
+ or the BLOB must be inherited, or the BLOB pointer
+ must be zero (will be written in this function). */
+ ut_a(update_in_place
+ || (field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG)
+ || !memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+ }
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
/* We have to create a file segment to the tablespace
for each field and put the pointer to the field in rec */
for (i = 0; i < big_rec_vec->n_fields; i++) {
- ut_ad(rec_offs_nth_extern(offsets,
- big_rec_vec->fields[i].field_no));
- {
- ulint local_len;
- field_ref = rec_get_nth_field(
- rec, offsets, big_rec_vec->fields[i].field_no,
- &local_len);
- ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
- local_len -= BTR_EXTERN_FIELD_REF_SIZE;
- field_ref += local_len;
- }
+ field_ref = btr_rec_get_field_ref(
+ rec, offsets, big_rec_vec->fields[i].field_no);
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ /* A zero BLOB pointer should have been initially inserted. */
+ ut_a(!memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
extern_len = big_rec_vec->fields[i].len;
UNIV_MEM_ASSERT_RW(big_rec_vec->fields[i].data,
extern_len);
@@ -3941,6 +4097,11 @@ btr_store_big_rec_extern_fields(
}
if (prev_page_no == FIL_NULL) {
+ btr_blob_dbg_add_blob(
+ rec, big_rec_vec->fields[i]
+ .field_no, page_no, index,
+ "store");
+
mach_write_to_4(field_ref
+ BTR_EXTERN_SPACE_ID,
space_id);
@@ -4016,6 +4177,11 @@ next_zip_page:
MLOG_4BYTES, &mtr);
if (prev_page_no == FIL_NULL) {
+ btr_blob_dbg_add_blob(
+ rec, big_rec_vec->fields[i]
+ .field_no, page_no, index,
+ "store");
+
mlog_write_ulint(field_ref
+ BTR_EXTERN_SPACE_ID,
space_id,
@@ -4048,6 +4214,23 @@ next_zip_page:
mem_heap_free(heap);
}
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ /* All pointers to externally stored columns in the record
+ must be valid. */
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (!rec_offs_nth_extern(offsets, i)) {
+ continue;
+ }
+
+ field_ref = btr_rec_get_field_ref(rec, offsets, i);
+
+ /* The pointer must not be zero. */
+ ut_a(0 != memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+ /* The column must not be disowned by this record. */
+ ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
+ }
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
return(DB_SUCCESS);
}
@@ -4070,6 +4253,7 @@ btr_check_blob_fil_page_type(
if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) {
ulint flags = fil_space_get_flags(space_id);
+#ifndef UNIV_DEBUG /* Improve debug test coverage */
if (UNIV_LIKELY
((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) {
/* Old versions of InnoDB did not initialize
@@ -4078,6 +4262,7 @@ btr_check_blob_fil_page_type(
a BLOB page that is in Antelope format.*/
return;
}
+#endif /* !UNIV_DEBUG */
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -4127,23 +4312,13 @@ btr_free_externally_stored_field(
ulint page_no;
ulint next_page_no;
mtr_t mtr;
-#ifdef UNIV_DEBUG
+
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(local_mtr, field_ref,
MTR_MEMO_PAGE_X_FIX));
ut_ad(!rec || rec_offs_validate(rec, index, offsets));
-
- if (rec) {
- ulint local_len;
- const byte* f = rec_get_nth_field(rec, offsets,
- i, &local_len);
- ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
- local_len -= BTR_EXTERN_FIELD_REF_SIZE;
- f += local_len;
- ut_ad(f == field_ref);
- }
-#endif /* UNIV_DEBUG */
+ ut_ad(!rec || field_ref == btr_rec_get_field_ref(rec, offsets, i));
if (UNIV_UNLIKELY(!memcmp(field_ref, field_ref_zero,
BTR_EXTERN_FIELD_REF_SIZE))) {
@@ -4175,6 +4350,37 @@ btr_free_externally_stored_field(
rec_zip_size = 0;
}
+#ifdef UNIV_BLOB_DEBUG
+ if (!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG)
+ && !((field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG)
+ && (rb_ctx == RB_NORMAL || rb_ctx == RB_RECOVERY))) {
+ /* This off-page column will be freed.
+ Check that no references remain. */
+
+ btr_blob_dbg_t b;
+
+ b.blob_page_no = mach_read_from_4(
+ field_ref + BTR_EXTERN_PAGE_NO);
+
+ if (rec) {
+ /* Remove the reference from the record to the
+ BLOB. If the BLOB were not freed, the
+ reference would be removed when the record is
+ removed. Freeing the BLOB will overwrite the
+ BTR_EXTERN_PAGE_NO in the field_ref of the
+ record with FIL_NULL, which would make the
+ btr_blob_dbg information inconsistent with the
+ record. */
+ b.ref_page_no = page_get_page_no(page_align(rec));
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+ b.ref_field_no = i;
+ btr_blob_dbg_rbt_delete(index, &b, "free");
+ }
+
+ btr_blob_dbg_assert_empty(index, b.blob_page_no);
+ }
+#endif /* UNIV_BLOB_DEBUG */
+
for (;;) {
#ifdef UNIV_SYNC_DEBUG
buf_block_t* rec_block;
@@ -4308,13 +4514,8 @@ btr_rec_free_externally_stored_fields(
for (i = 0; i < n_fields; i++) {
if (rec_offs_nth_extern(offsets, i)) {
- ulint len;
- byte* data
- = rec_get_nth_field(rec, offsets, i, &len);
- ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
-
btr_free_externally_stored_field(
- index, data + len - BTR_EXTERN_FIELD_REF_SIZE,
+ index, btr_rec_get_field_ref(rec, offsets, i),
rec, offsets, page_zip, i, rb_ctx, mtr);
}
}
@@ -4426,27 +4627,45 @@ btr_copy_blob_prefix(
/*******************************************************************//**
Copies the prefix of a compressed BLOB. The clustered index record
-that points to this BLOB must be protected by a lock or a page latch. */
+that points to this BLOB must be protected by a lock or a page latch.
+@return number of bytes written to buf */
static
-void
+ulint
btr_copy_zblob_prefix(
/*==================*/
- z_stream* d_stream,/*!< in/out: the decompressing stream */
+ byte* buf, /*!< out: the externally stored part of
+ the field, or a prefix of it */
+ ulint len, /*!< in: length of buf, in bytes */
ulint zip_size,/*!< in: compressed BLOB page size */
ulint space_id,/*!< in: space id of the BLOB pages */
ulint page_no,/*!< in: page number of the first BLOB page */
ulint offset) /*!< in: offset on the first BLOB page */
{
- ulint page_type = FIL_PAGE_TYPE_ZBLOB;
+ ulint page_type = FIL_PAGE_TYPE_ZBLOB;
+ mem_heap_t* heap;
+ int err;
+ z_stream d_stream;
+
+ d_stream.next_out = buf;
+ d_stream.avail_out = len;
+ d_stream.next_in = Z_NULL;
+ d_stream.avail_in = 0;
+
+ /* Zlib inflate needs 32 kilobytes for the default
+ window size, plus a few kilobytes for small objects. */
+ heap = mem_heap_create(40000);
+ page_zip_set_alloc(&d_stream, heap);
ut_ad(ut_is_2pow(zip_size));
ut_ad(zip_size >= PAGE_ZIP_MIN_SIZE);
ut_ad(zip_size <= UNIV_PAGE_SIZE);
ut_ad(space_id);
+ err = inflateInit(&d_stream);
+ ut_a(err == Z_OK);
+
for (;;) {
buf_page_t* bpage;
- int err;
ulint next_page_no;
/* There is no latch on bpage directly. Instead,
@@ -4462,7 +4681,7 @@ btr_copy_zblob_prefix(
" compressed BLOB"
" page %lu space %lu\n",
(ulong) page_no, (ulong) space_id);
- return;
+ goto func_exit;
}
if (UNIV_UNLIKELY
@@ -4488,13 +4707,13 @@ btr_copy_zblob_prefix(
offset += 4;
}
- d_stream->next_in = bpage->zip.data + offset;
- d_stream->avail_in = zip_size - offset;
+ d_stream.next_in = bpage->zip.data + offset;
+ d_stream.avail_in = zip_size - offset;
- err = inflate(d_stream, Z_NO_FLUSH);
+ err = inflate(&d_stream, Z_NO_FLUSH);
switch (err) {
case Z_OK:
- if (!d_stream->avail_out) {
+ if (!d_stream.avail_out) {
goto end_of_blob;
}
break;
@@ -4511,13 +4730,13 @@ inflate_error:
" compressed BLOB"
" page %lu space %lu returned %d (%s)\n",
(ulong) page_no, (ulong) space_id,
- err, d_stream->msg);
+ err, d_stream.msg);
case Z_BUF_ERROR:
goto end_of_blob;
}
if (next_page_no == FIL_NULL) {
- if (!d_stream->avail_in) {
+ if (!d_stream.avail_in) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: unexpected end of"
@@ -4526,7 +4745,7 @@ inflate_error:
(ulong) page_no,
(ulong) space_id);
} else {
- err = inflate(d_stream, Z_FINISH);
+ err = inflate(&d_stream, Z_FINISH);
switch (err) {
case Z_STREAM_END:
case Z_BUF_ERROR:
@@ -4538,7 +4757,7 @@ inflate_error:
end_of_blob:
buf_page_release_zip(bpage);
- return;
+ goto func_exit;
}
buf_page_release_zip(bpage);
@@ -4550,6 +4769,12 @@ end_of_blob:
offset = FIL_PAGE_NEXT;
page_type = FIL_PAGE_TYPE_ZBLOB2;
}
+
+func_exit:
+ inflateEnd(&d_stream);
+ mem_heap_free(heap);
+ UNIV_MEM_ASSERT_RW(buf, d_stream.total_out);
+ return(d_stream.total_out);
}
/*******************************************************************//**
@@ -4575,28 +4800,8 @@ btr_copy_externally_stored_field_prefix_low(
}
if (UNIV_UNLIKELY(zip_size)) {
- int err;
- z_stream d_stream;
- mem_heap_t* heap;
-
- /* Zlib inflate needs 32 kilobytes for the default
- window size, plus a few kilobytes for small objects. */
- heap = mem_heap_create(40000);
- page_zip_set_alloc(&d_stream, heap);
-
- err = inflateInit(&d_stream);
- ut_a(err == Z_OK);
-
- d_stream.next_out = buf;
- d_stream.avail_out = len;
- d_stream.avail_in = 0;
-
- btr_copy_zblob_prefix(&d_stream, zip_size,
- space_id, page_no, offset);
- inflateEnd(&d_stream);
- mem_heap_free(heap);
- UNIV_MEM_ASSERT_RW(buf, d_stream.total_out);
- return(d_stream.total_out);
+ return(btr_copy_zblob_prefix(buf, len, zip_size,
+ space_id, page_no, offset));
} else {
return(btr_copy_blob_prefix(buf, len, space_id,
page_no, offset));
diff --git a/storage/innodb_plugin/btr/btr0sea.c b/storage/innodb_plugin/btr/btr0sea.c
index 035fdbb61d2..cd0eadbb1b8 100644
--- a/storage/innodb_plugin/btr/btr0sea.c
+++ b/storage/innodb_plugin/btr/btr0sea.c
@@ -141,7 +141,7 @@ btr_search_check_free_space_in_heap(void)
be enough free space in the hash table. */
if (heap->free_block == NULL) {
- buf_block_t* block = buf_block_alloc(0);
+ buf_block_t* block = buf_block_alloc();
rw_lock_x_lock(&btr_search_latch);
@@ -1201,8 +1201,8 @@ btr_search_drop_page_hash_when_freed(
having to fear a deadlock. */
block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
- BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
- &mtr);
+ BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__,
+ &mtr);
/* Because the buffer pool mutex was released by
buf_page_peek_if_search_hashed(), it is possible that the
block was removed from the buffer pool by another thread
diff --git a/storage/innodb_plugin/buf/buf0buddy.c b/storage/innodb_plugin/buf/buf0buddy.c
index ee5a569c3ff..63c99571510 100644
--- a/storage/innodb_plugin/buf/buf0buddy.c
+++ b/storage/innodb_plugin/buf/buf0buddy.c
@@ -327,7 +327,7 @@ buf_buddy_alloc_low(
/* Try replacing an uncompressed page in the buffer pool. */
buf_pool_mutex_exit();
- block = buf_LRU_get_free_block(0);
+ block = buf_LRU_get_free_block();
*lru = TRUE;
buf_pool_mutex_enter();
diff --git a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0buf.c
index dac416f9472..14ec7b75911 100644
--- a/storage/innodb_plugin/buf/buf0buf.c
+++ b/storage/innodb_plugin/buf/buf0buf.c
@@ -657,9 +657,9 @@ buf_block_init(
block->modify_clock = 0;
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
block->page.file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
block->check_index_page_at_flush = FALSE;
block->index = NULL;
@@ -1283,7 +1283,7 @@ shrink_again:
buf_LRU_make_block_old(&block->page);
dirty++;
- } else if (buf_LRU_free_block(&block->page, TRUE, NULL)
+ } else if (buf_LRU_free_block(&block->page, TRUE)
!= BUF_LRU_FREED) {
nonfree++;
}
@@ -1600,7 +1600,7 @@ buf_page_peek_if_search_hashed(
return(is_hashed);
}
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
/********************************************************************//**
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
This function should be called when we free a file page and want the
@@ -1621,6 +1621,8 @@ buf_page_set_file_page_was_freed(
bpage = buf_page_hash_get(space, offset);
if (bpage) {
+ /* bpage->file_page_was_freed can already hold
+ when this code is invoked from dict_drop_index_tree() */
bpage->file_page_was_freed = TRUE;
}
@@ -1656,7 +1658,7 @@ buf_page_reset_file_page_was_freed(
return(bpage);
}
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
/********************************************************************//**
Get read access to a compressed page (usually of type
@@ -1729,8 +1731,7 @@ err_exit:
mutex_enter(block_mutex);
/* Discard the uncompressed page frame if possible. */
- if (buf_LRU_free_block(bpage, FALSE, NULL)
- == BUF_LRU_FREED) {
+ if (buf_LRU_free_block(bpage, FALSE) == BUF_LRU_FREED) {
mutex_exit(block_mutex);
goto lookup;
@@ -1754,7 +1755,7 @@ got_block:
buf_page_set_accessed_make_young(bpage, access_time);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(!bpage->file_page_was_freed);
#endif
@@ -1892,16 +1893,19 @@ buf_block_align(
/* TODO: protect buf_pool->chunks with a mutex (it will
currently remain constant after buf_pool_init()) */
for (chunk = buf_pool->chunks, i = buf_pool->n_chunks; i--; chunk++) {
- lint offs = ptr - chunk->blocks->frame;
+ ulint offs;
- if (UNIV_UNLIKELY(offs < 0)) {
+ if (UNIV_UNLIKELY(ptr < chunk->blocks->frame)) {
continue;
}
+ /* else */
+
+ offs = ptr - chunk->blocks->frame;
offs >>= UNIV_PAGE_SIZE_SHIFT;
- if (UNIV_LIKELY((ulint) offs < chunk->size)) {
+ if (UNIV_LIKELY(offs < chunk->size)) {
buf_block_t* block = &chunk->blocks[offs];
/* The function buf_chunk_init() invokes
@@ -2027,7 +2031,7 @@ buf_page_get_gen(
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
buf_block_t* guess, /*!< in: guessed block or NULL */
ulint mode, /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
- BUF_GET_NO_LATCH */
+ BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH */
const char* file, /*!< in: file name */
ulint line, /*!< in: line where called */
mtr_t* mtr) /*!< in: mini-transaction */
@@ -2043,9 +2047,19 @@ buf_page_get_gen(
ut_ad((rw_latch == RW_S_LATCH)
|| (rw_latch == RW_X_LATCH)
|| (rw_latch == RW_NO_LATCH));
- ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH));
- ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL)
- || (mode == BUF_GET_NO_LATCH));
+#ifdef UNIV_DEBUG
+ switch (mode) {
+ case BUF_GET_NO_LATCH:
+ ut_ad(rw_latch == RW_NO_LATCH);
+ break;
+ case BUF_GET:
+ case BUF_GET_IF_IN_POOL:
+ case BUF_PEEK_IF_IN_POOL:
+ break;
+ default:
+ ut_error;
+ }
+#endif /* UNIV_DEBUG */
ut_ad(zip_size == fil_space_get_zip_size(space));
ut_ad(ut_is_2pow(zip_size));
#ifndef UNIV_LOG_DEBUG
@@ -2087,7 +2101,8 @@ loop2:
buf_pool_mutex_exit();
- if (mode == BUF_GET_IF_IN_POOL) {
+ if (mode == BUF_GET_IF_IN_POOL
+ || mode == BUF_PEEK_IF_IN_POOL) {
return(NULL);
}
@@ -2126,7 +2141,8 @@ loop2:
must_read = buf_block_get_io_fix(block) == BUF_IO_READ;
- if (must_read && mode == BUF_GET_IF_IN_POOL) {
+ if (must_read && (mode == BUF_GET_IF_IN_POOL
+ || mode == BUF_PEEK_IF_IN_POOL)) {
/* The page is only being read to buffer */
buf_pool_mutex_exit();
@@ -2165,7 +2181,7 @@ wait_until_unfixed:
buf_pool_mutex_exit();
mutex_exit(&buf_pool_zip_mutex);
- block = buf_LRU_get_free_block(0);
+ block = buf_LRU_get_free_block();
ut_a(block);
buf_pool_mutex_enter();
@@ -2244,6 +2260,7 @@ wait_until_unfixed:
mutex_exit(&buf_pool_zip_mutex);
buf_pool->n_pend_unzip++;
+ bpage->state = BUF_BLOCK_ZIP_FREE;
buf_buddy_free(bpage, sizeof *bpage);
buf_pool_mutex_exit();
@@ -2291,8 +2308,7 @@ wait_until_unfixed:
/* Try to evict the block from the buffer pool, to use the
insert buffer as much as possible. */
- if (buf_LRU_free_block(&block->page, TRUE, NULL)
- == BUF_LRU_FREED) {
+ if (buf_LRU_free_block(&block->page, TRUE) == BUF_LRU_FREED) {
buf_pool_mutex_exit();
mutex_exit(&block->mutex);
fprintf(stderr,
@@ -2321,9 +2337,11 @@ wait_until_unfixed:
buf_pool_mutex_exit();
- buf_page_set_accessed_make_young(&block->page, access_time);
+ if (UNIV_LIKELY(mode != BUF_PEEK_IF_IN_POOL)) {
+ buf_page_set_accessed_make_young(&block->page, access_time);
+ }
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(!block->page.file_page_was_freed);
#endif
@@ -2374,7 +2392,7 @@ wait_until_unfixed:
mtr_memo_push(mtr, block, fix_type);
- if (!access_time) {
+ if (UNIV_LIKELY(mode != BUF_PEEK_IF_IN_POOL) && !access_time) {
/* In the case of a first access, try to apply linear
read-ahead */
@@ -2481,7 +2499,7 @@ buf_page_optimistic_get(
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(block->page.file_page_was_freed == FALSE);
#endif
if (UNIV_UNLIKELY(!access_time)) {
@@ -2589,7 +2607,7 @@ buf_page_get_known_nowait(
ut_a(block->page.buf_fix_count > 0);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(block->page.file_page_was_freed == FALSE);
#endif
@@ -2672,9 +2690,9 @@ buf_page_try_get_func(
ut_a(block->page.buf_fix_count > 0);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(block->page.file_page_was_freed == FALSE);
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
buf_pool->stat.n_page_gets++;
@@ -2703,9 +2721,9 @@ buf_page_init_low(
bpage->newest_modification = 0;
bpage->oldest_modification = 0;
HASH_INVALIDATE(bpage, hash);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
bpage->file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
}
/********************************************************************//**
@@ -2829,7 +2847,7 @@ buf_page_init_for_read(
&& UNIV_LIKELY(!recv_recovery_is_on())) {
block = NULL;
} else {
- block = buf_LRU_get_free_block(0);
+ block = buf_LRU_get_free_block();
ut_ad(block);
}
@@ -2923,6 +2941,7 @@ err_exit:
&& UNIV_LIKELY_NULL(buf_page_hash_get(space, offset))) {
/* The block was added by some other thread. */
+ bpage->state = BUF_BLOCK_ZIP_FREE;
buf_buddy_free(bpage, sizeof *bpage);
buf_buddy_free(data, zip_size);
@@ -3001,7 +3020,7 @@ buf_page_create(
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad(space || !zip_size);
- free_block = buf_LRU_get_free_block(0);
+ free_block = buf_LRU_get_free_block();
buf_pool_mutex_enter();
@@ -3011,9 +3030,9 @@ buf_page_create(
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(space, offset) == 0);
#endif
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
block->page.file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
/* Page can be found in buf_pool */
buf_pool_mutex_exit();
diff --git a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0lru.c
index e4cf218bf2e..a69b2658c51 100644
--- a/storage/innodb_plugin/buf/buf0lru.c
+++ b/storage/innodb_plugin/buf/buf0lru.c
@@ -246,71 +246,75 @@ buf_LRU_drop_page_hash_for_tablespace(
page_arr = ut_malloc(sizeof(ulint)
* BUF_LRU_DROP_SEARCH_HASH_SIZE);
buf_pool_mutex_enter();
+ num_entries = 0;
scan_again:
- num_entries = 0;
bpage = UT_LIST_GET_LAST(buf_pool->LRU);
while (bpage != NULL) {
- mutex_t* block_mutex = buf_page_get_mutex(bpage);
buf_page_t* prev_bpage;
+ ibool is_fixed;
- mutex_enter(block_mutex);
prev_bpage = UT_LIST_GET_PREV(LRU, bpage);
ut_a(buf_page_in_file(bpage));
if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE
|| bpage->space != id
- || bpage->buf_fix_count > 0
|| bpage->io_fix != BUF_IO_NONE) {
- /* We leave the fixed pages as is in this scan.
- To be dealt with later in the final scan. */
- mutex_exit(block_mutex);
- goto next_page;
+ /* Compressed pages are never hashed.
+ Skip blocks of other tablespaces.
+ Skip I/O-fixed blocks (to be dealt with later). */
+next_page:
+ bpage = prev_bpage;
+ continue;
}
- if (((buf_block_t*) bpage)->is_hashed) {
+ mutex_enter(&((buf_block_t*) bpage)->mutex);
+ is_fixed = bpage->buf_fix_count > 0
+ || !((buf_block_t*) bpage)->is_hashed;
+ mutex_exit(&((buf_block_t*) bpage)->mutex);
- /* Store the offset(i.e.: page_no) in the array
- so that we can drop hash index in a batch
- later. */
- page_arr[num_entries] = bpage->offset;
- mutex_exit(block_mutex);
- ut_a(num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE);
- ++num_entries;
+ if (is_fixed) {
+ goto next_page;
+ }
- if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) {
- goto next_page;
- }
- /* Array full. We release the buf_pool_mutex to
- obey the latching order. */
- buf_pool_mutex_exit();
-
- buf_LRU_drop_page_hash_batch(id, zip_size, page_arr,
- num_entries);
- num_entries = 0;
- buf_pool_mutex_enter();
- } else {
- mutex_exit(block_mutex);
+ /* Store the page number so that we can drop the hash
+ index in a batch later. */
+ page_arr[num_entries] = bpage->offset;
+ ut_a(num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE);
+ ++num_entries;
+
+ if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) {
+ goto next_page;
}
-next_page:
- /* Note that we may have released the buf_pool mutex
- above after reading the prev_bpage during processing
- of a page_hash_batch (i.e.: when the array was full).
- This means that prev_bpage can change in LRU list.
- This is OK because this function is a 'best effort'
- to drop as many search hash entries as possible and
- it does not guarantee that ALL such entries will be
- dropped. */
- bpage = prev_bpage;
+ /* Array full. We release the buf_pool_mutex to
+ obey the latching order. */
+ buf_pool_mutex_exit();
+ buf_LRU_drop_page_hash_batch(id, zip_size, page_arr,
+ num_entries);
+ buf_pool_mutex_enter();
+ num_entries = 0;
+
+ /* Note that we released the buf_pool mutex above
+ after reading the prev_bpage during processing of a
+ page_hash_batch (i.e.: when the array was full).
+ Because prev_bpage could belong to a compressed-only
+ block, it may have been relocated, and thus the
+ pointer cannot be trusted. Because bpage is of type
+ buf_block_t, it is safe to dereference.
+
+ bpage can change in the LRU list. This is OK because
+ this function is a 'best effort' to drop as many
+ search hash entries as possible and it does not
+ guarantee that ALL such entries will be dropped. */
/* If, however, bpage has been removed from LRU list
to the free list then we should restart the scan.
bpage->state is protected by buf_pool mutex. */
- if (bpage && !buf_page_in_file(bpage)) {
- ut_a(num_entries == 0);
+ if (bpage
+ && buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) {
goto scan_again;
}
}
@@ -575,7 +579,7 @@ buf_LRU_free_from_unzip_LRU_list(
ut_ad(block->page.in_LRU_list);
mutex_enter(&block->mutex);
- freed = buf_LRU_free_block(&block->page, FALSE, NULL);
+ freed = buf_LRU_free_block(&block->page, FALSE);
mutex_exit(&block->mutex);
switch (freed) {
@@ -636,7 +640,7 @@ buf_LRU_free_from_common_LRU_list(
mutex_enter(block_mutex);
accessed = buf_page_is_accessed(bpage);
- freed = buf_LRU_free_block(bpage, TRUE, NULL);
+ freed = buf_LRU_free_block(bpage, TRUE);
mutex_exit(block_mutex);
switch (freed) {
@@ -798,10 +802,8 @@ LRU list to the free list.
@return the free control block, in state BUF_BLOCK_READY_FOR_USE */
UNIV_INTERN
buf_block_t*
-buf_LRU_get_free_block(
-/*===================*/
- ulint zip_size) /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_LRU_get_free_block(void)
+/*========================*/
{
buf_block_t* block = NULL;
ibool freed;
@@ -877,26 +879,10 @@ loop:
/* If there is a block in the free list, take it */
block = buf_LRU_get_free_only();
- if (block) {
-
-#ifdef UNIV_DEBUG
- block->page.zip.m_start =
-#endif /* UNIV_DEBUG */
- block->page.zip.m_end =
- block->page.zip.m_nonempty =
- block->page.zip.n_blobs = 0;
-
- if (UNIV_UNLIKELY(zip_size)) {
- ibool lru;
- page_zip_set_size(&block->page.zip, zip_size);
- block->page.zip.data = buf_buddy_alloc(zip_size, &lru);
- UNIV_MEM_DESC(block->page.zip.data, zip_size, block);
- } else {
- page_zip_set_size(&block->page.zip, 0);
- block->page.zip.data = NULL;
- }
+ buf_pool_mutex_exit();
- buf_pool_mutex_exit();
+ if (block) {
+ memset(&block->page.zip, 0, sizeof block->page.zip);
if (started_monitor) {
srv_print_innodb_monitor = mon_value_was;
@@ -908,8 +894,6 @@ loop:
/* If no block was in the free list, search from the end of the LRU
list and try to free a block there */
- buf_pool_mutex_exit();
-
freed = buf_LRU_search_and_free_block(n_iterations);
if (freed > 0) {
@@ -1378,12 +1362,8 @@ enum buf_lru_free_block_status
buf_LRU_free_block(
/*===============*/
buf_page_t* bpage, /*!< in: block to be freed */
- ibool zip, /*!< in: TRUE if should remove also the
+ ibool zip) /*!< in: TRUE if should remove also the
compressed page of an uncompressed page */
- ibool* buf_pool_mutex_released)
- /*!< in: pointer to a variable that will
- be assigned TRUE if buf_pool_mutex
- was temporarily released, or NULL */
{
buf_page_t* b = NULL;
mutex_t* block_mutex = buf_page_get_mutex(bpage);
@@ -1554,10 +1534,6 @@ alloc:
b->io_fix = BUF_IO_READ;
}
- if (buf_pool_mutex_released) {
- *buf_pool_mutex_released = TRUE;
- }
-
buf_pool_mutex_exit();
mutex_exit(block_mutex);
@@ -1827,6 +1803,7 @@ buf_LRU_block_remove_hashed_page(
buf_pool_mutex_exit_forbid();
buf_buddy_free(bpage->zip.data,
page_zip_get_size(&bpage->zip));
+ bpage->state = BUF_BLOCK_ZIP_FREE;
buf_buddy_free(bpage, sizeof(*bpage));
buf_pool_mutex_exit_allow();
UNIV_MEM_UNDESC(bpage);
diff --git a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c
index 9474ab3582a..a8787bbda61 100644
--- a/storage/innodb_plugin/dict/dict0dict.c
+++ b/storage/innodb_plugin/dict/dict0dict.c
@@ -1669,6 +1669,12 @@ undo_size_ok:
new_index->heap,
(1 + dict_index_get_n_unique(new_index))
* sizeof(ib_int64_t));
+
+ new_index->stat_n_non_null_key_vals = mem_heap_zalloc(
+ new_index->heap,
+ (1 + dict_index_get_n_unique(new_index))
+ * sizeof(*new_index->stat_n_non_null_key_vals));
+
/* Give some sensible values to stat_n_... in case we do
not calculate statistics quickly enough */
@@ -4291,6 +4297,10 @@ dict_update_statistics(
for (i = dict_index_get_n_unique(index); i; ) {
index->stat_n_diff_key_vals[i--] = 1;
}
+
+ memset(index->stat_n_non_null_key_vals, 0,
+ (1 + dict_index_get_n_unique(index))
+ * sizeof(*index->stat_n_non_null_key_vals));
}
index = dict_table_get_next_index(index);
diff --git a/storage/innodb_plugin/dict/dict0mem.c b/storage/innodb_plugin/dict/dict0mem.c
index 3287247029f..aef815dd2f6 100644
--- a/storage/innodb_plugin/dict/dict0mem.c
+++ b/storage/innodb_plugin/dict/dict0mem.c
@@ -36,6 +36,9 @@ Created 1/8/1996 Heikki Tuuri
#ifndef UNIV_HOTBACKUP
# include "lock0lock.h"
#endif /* !UNIV_HOTBACKUP */
+#ifdef UNIV_BLOB_DEBUG
+# include "ut0rbt.h"
+#endif /* UNIV_BLOB_DEBUG */
#define DICT_HEAP_SIZE 100 /*!< initial memory heap size when
creating a table or index object */
@@ -316,6 +319,12 @@ dict_mem_index_free(
{
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
+#ifdef UNIV_BLOB_DEBUG
+ if (index->blobs) {
+ mutex_free(&index->blobs_mutex);
+ rbt_free(index->blobs);
+ }
+#endif /* UNIV_BLOB_DEBUG */
mem_heap_free(index->heap);
}
diff --git a/storage/innodb_plugin/fsp/fsp0fsp.c b/storage/innodb_plugin/fsp/fsp0fsp.c
index e9d24b8fdf6..d091a14c474 100644
--- a/storage/innodb_plugin/fsp/fsp0fsp.c
+++ b/storage/innodb_plugin/fsp/fsp0fsp.c
@@ -3444,9 +3444,9 @@ fseg_free_page(
fseg_free_page_low(seg_inode, space, zip_size, page, mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_set_file_page_was_freed(space, page);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
}
/**********************************************************************//**
@@ -3513,13 +3513,13 @@ fseg_free_extent(
fsp_free_extent(space, zip_size, page, mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
buf_page_set_file_page_was_freed(space,
first_page_in_extent + i);
}
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
}
/**********************************************************************//**
diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
index 9407a0106e4..38adab109fc 100644
--- a/storage/innodb_plugin/handler/ha_innodb.cc
+++ b/storage/innodb_plugin/handler/ha_innodb.cc
@@ -173,6 +173,25 @@ static char* internal_innobase_data_file_path = NULL;
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
+/** Possible values for system variable "innodb_stats_method". The values
+are defined the same as its corresponding MyISAM system variable
+"myisam_stats_method"(see "myisam_stats_method_names"), for better usability */
+static const char* innodb_stats_method_names[] = {
+ "nulls_equal",
+ "nulls_unequal",
+ "nulls_ignored",
+ NullS
+};
+
+/** Used to define an enumerate type of the system variable innodb_stats_method.
+This is the same as "myisam_stats_method_typelib" */
+static TYPELIB innodb_stats_method_typelib = {
+ array_elements(innodb_stats_method_names) - 1,
+ "innodb_stats_method_typelib",
+ innodb_stats_method_names,
+ NULL
+};
+
/* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call
srv_active_wake_master_thread after each fetch or search, we only do
@@ -2976,12 +2995,15 @@ UNIV_INTERN
ulong
ha_innobase::index_flags(
/*=====================*/
- uint,
+ uint index,
uint,
bool)
const
{
- return(HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER
+ ulong extra_flag= 0;
+ if (table && index == table->s->primary_key)
+ extra_flag= HA_CLUSTERED_INDEX;
+ return(HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | extra_flag
| HA_READ_RANGE | HA_KEYREAD_ONLY);
}
@@ -3947,90 +3969,64 @@ get_innobase_type_from_mysql_type(
8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
the type */
- DBUG_ASSERT((ulint)MYSQL_TYPE_STRING < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_VAR_STRING < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_DOUBLE < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_FLOAT < 256);
- DBUG_ASSERT((ulint)MYSQL_TYPE_DECIMAL < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_STRING < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_VAR_STRING < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_DOUBLE < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_FLOAT < 256);
+ compile_time_assert((ulint)MYSQL_TYPE_DECIMAL < 256);
- if (field->flags & UNSIGNED_FLAG) {
+ *unsigned_flag = 0;
+ switch (field->key_type()) {
+ case HA_KEYTYPE_USHORT_INT:
+ case HA_KEYTYPE_ULONG_INT:
+ case HA_KEYTYPE_UINT24:
+ case HA_KEYTYPE_ULONGLONG:
*unsigned_flag = DATA_UNSIGNED;
- } else {
- *unsigned_flag = 0;
- }
-
- if (field->real_type() == MYSQL_TYPE_ENUM
- || field->real_type() == MYSQL_TYPE_SET) {
-
- /* MySQL has field->type() a string type for these, but the
- data is actually internally stored as an unsigned integer
- code! */
-
- *unsigned_flag = DATA_UNSIGNED; /* MySQL has its own unsigned
- flag set to zero, even though
- internally this is an unsigned
- integer type */
+ /* fall through */
+ case HA_KEYTYPE_SHORT_INT:
+ case HA_KEYTYPE_LONG_INT:
+ case HA_KEYTYPE_INT24:
+ case HA_KEYTYPE_INT8:
+ case HA_KEYTYPE_LONGLONG:
return(DATA_INT);
- }
-
- switch (field->type()) {
- /* NOTE that we only allow string types in DATA_MYSQL and
- DATA_VARMYSQL */
- case MYSQL_TYPE_VAR_STRING: /* old <= 4.1 VARCHAR */
- case MYSQL_TYPE_VARCHAR: /* new >= 5.0.3 true VARCHAR */
- if (field->binary()) {
- return(DATA_BINARY);
- } else if (strcmp(
- field->charset()->name,
- "latin1_swedish_ci") == 0) {
+ case HA_KEYTYPE_FLOAT:
+ return(DATA_FLOAT);
+ case HA_KEYTYPE_DOUBLE:
+ return(DATA_DOUBLE);
+ case HA_KEYTYPE_BINARY:
+ if (field->type() == MYSQL_TYPE_TINY)
+ { // compatibility workaround
+ *unsigned_flag= DATA_UNSIGNED;
+ return DATA_INT;
+ }
+ return(DATA_FIXBINARY);
+ case HA_KEYTYPE_VARBINARY2:
+ if (field->type() != MYSQL_TYPE_VARCHAR)
+ return(DATA_BLOB);
+ /* fall through */
+ case HA_KEYTYPE_VARBINARY1:
+ return(DATA_BINARY);
+ case HA_KEYTYPE_VARTEXT2:
+ if (field->type() != MYSQL_TYPE_VARCHAR)
+ return(DATA_BLOB);
+ /* fall through */
+ case HA_KEYTYPE_VARTEXT1:
+ if (field->charset() == &my_charset_latin1) {
return(DATA_VARCHAR);
} else {
return(DATA_VARMYSQL);
}
- case MYSQL_TYPE_BIT:
- case MYSQL_TYPE_STRING: if (field->binary()) {
-
- return(DATA_FIXBINARY);
- } else if (strcmp(
- field->charset()->name,
- "latin1_swedish_ci") == 0) {
+ case HA_KEYTYPE_TEXT:
+ if (field->charset() == &my_charset_latin1) {
return(DATA_CHAR);
} else {
return(DATA_MYSQL);
}
- case MYSQL_TYPE_NEWDECIMAL:
- return(DATA_FIXBINARY);
- case MYSQL_TYPE_LONG:
- case MYSQL_TYPE_LONGLONG:
- case MYSQL_TYPE_TINY:
- case MYSQL_TYPE_SHORT:
- case MYSQL_TYPE_INT24:
- case MYSQL_TYPE_DATE:
- case MYSQL_TYPE_DATETIME:
- case MYSQL_TYPE_YEAR:
- case MYSQL_TYPE_NEWDATE:
- case MYSQL_TYPE_TIME:
- case MYSQL_TYPE_TIMESTAMP:
- return(DATA_INT);
- case MYSQL_TYPE_FLOAT:
- return(DATA_FLOAT);
- case MYSQL_TYPE_DOUBLE:
- return(DATA_DOUBLE);
- case MYSQL_TYPE_DECIMAL:
+ case HA_KEYTYPE_NUM:
return(DATA_DECIMAL);
- case MYSQL_TYPE_GEOMETRY:
- case MYSQL_TYPE_TINY_BLOB:
- case MYSQL_TYPE_MEDIUM_BLOB:
- case MYSQL_TYPE_BLOB:
- case MYSQL_TYPE_LONG_BLOB:
- return(DATA_BLOB);
- case MYSQL_TYPE_NULL:
- /* MySQL currently accepts "NULL" datatype, but will
- reject such datatype in the next release. We will cope
- with it and not trigger assertion failure in 5.1 */
- break;
- default:
+ case HA_KEYTYPE_BIT:
+ case HA_KEYTYPE_END:
ut_error;
}
@@ -7572,6 +7568,65 @@ innobase_get_mysql_key_number_for_index(
return(0);
}
+
+/*********************************************************************//**
+Calculate Record Per Key value. Need to exclude the NULL value if
+innodb_stats_method is set to "nulls_ignored"
+@return estimated record per key value */
+static
+ha_rows
+innodb_rec_per_key(
+/*===============*/
+ dict_index_t* index, /*!< in: dict_index_t structure */
+ ulint i, /*!< in: the column we are
+ calculating rec per key */
+ ha_rows records) /*!< in: estimated total records */
+{
+ ha_rows rec_per_key;
+
+ ut_ad(i < dict_index_get_n_unique(index));
+
+ /* Note the stat_n_diff_key_vals[] stores the diff value with
+ n-prefix indexing, so it is always stat_n_diff_key_vals[i + 1] */
+ if (index->stat_n_diff_key_vals[i + 1] == 0) {
+
+ rec_per_key = records;
+ } else if (srv_innodb_stats_method == SRV_STATS_NULLS_IGNORED) {
+ ib_int64_t num_null;
+
+ /* Number of rows with NULL value in this
+ field */
+ num_null = records - index->stat_n_non_null_key_vals[i];
+
+ /* In theory, index->stat_n_non_null_key_vals[i]
+ should always be less than the number of records.
+ Since this is statistics value, the value could
+ have slight discrepancy. But we will make sure
+ the number of null values is not a negative number. */
+ num_null = (num_null < 0) ? 0 : num_null;
+
+ /* If the number of NULL values is the same as or
+ large than that of the distinct values, we could
+ consider that the table consists mostly of NULL value.
+ Set rec_per_key to 1. */
+ if (index->stat_n_diff_key_vals[i + 1] <= num_null) {
+ rec_per_key = 1;
+ } else {
+ /* Need to exclude rows with NULL values from
+ rec_per_key calculation */
+ rec_per_key = (ha_rows)(
+ (records - num_null)
+ / (index->stat_n_diff_key_vals[i + 1]
+ - num_null));
+ }
+ } else {
+ rec_per_key = (ha_rows)
+ (records / index->stat_n_diff_key_vals[i + 1]);
+ }
+
+ return(rec_per_key);
+}
+
/*********************************************************************//**
Returns statistics information of the table to the MySQL interpreter,
in various fields of the handle object. */
@@ -7804,13 +7859,8 @@ ha_innobase::info_low(
break;
}
- if (index->stat_n_diff_key_vals[j + 1] == 0) {
-
- rec_per_key = stats.records;
- } else {
- rec_per_key = (ha_rows)(stats.records /
- index->stat_n_diff_key_vals[j + 1]);
- }
+ rec_per_key = innodb_rec_per_key(
+ index, j, stats.records);
/* Since MySQL seems to favor table scans
too much over index searches, we pretend
@@ -10976,6 +11026,13 @@ static MYSQL_SYSVAR_STR(change_buffering, innobase_change_buffering,
innodb_change_buffering_validate,
innodb_change_buffering_update, "inserts");
+static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method,
+ PLUGIN_VAR_RQCMDARG,
+ "Specifies how InnoDB index statistics collection code should "
+ "treat NULLs. Possible values are NULLS_EQUAL (default), "
+ "NULLS_UNEQUAL and NULLS_IGNORED",
+ NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib);
+
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug,
PLUGIN_VAR_RQCMDARG,
@@ -11030,6 +11087,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(stats_on_metadata),
MYSQL_SYSVAR(stats_sample_pages),
MYSQL_SYSVAR(adaptive_hash_index),
+ MYSQL_SYSVAR(stats_method),
MYSQL_SYSVAR(replication_delay),
MYSQL_SYSVAR(status_file),
MYSQL_SYSVAR(strict_mode),
diff --git a/storage/innodb_plugin/handler/handler0alter.cc b/storage/innodb_plugin/handler/handler0alter.cc
index 517445f7e69..dc1317d5c5a 100644
--- a/storage/innodb_plugin/handler/handler0alter.cc
+++ b/storage/innodb_plugin/handler/handler0alter.cc
@@ -782,10 +782,6 @@ err_exit:
ut_ad(error == DB_SUCCESS);
- /* We will need to rebuild index translation table. Set
- valid index entry count in the translation table to zero */
- share->idx_trans_tbl.index_count = 0;
-
/* Commit the data dictionary transaction in order to release
the table locks on the system tables. This means that if
MySQL crashes while creating a new primary key inside
@@ -911,6 +907,14 @@ error:
}
convert_error:
+ if (error == DB_SUCCESS) {
+ /* Build index is successful. We will need to
+ rebuild index translation table. Reset the
+ index entry count in the translation table
+ to zero, so that translation table will be rebuilt */
+ share->idx_trans_tbl.index_count = 0;
+ }
+
error = convert_error_code_to_mysql(error,
innodb_table->flags,
user_thd);
diff --git a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc
index b0149967e9b..4fe8beafedc 100644
--- a/storage/innodb_plugin/handler/i_s.cc
+++ b/storage/innodb_plugin/handler/i_s.cc
@@ -161,7 +161,7 @@ field_store_time_t(
my_time.time_type = MYSQL_TIMESTAMP_DATETIME;
#endif
- return(field->store_time(&my_time, MYSQL_TIMESTAMP_DATETIME));
+ return(field->store_time(&my_time));
}
/*******************************************************************//**
diff --git a/storage/innodb_plugin/ibuf/ibuf0ibuf.c b/storage/innodb_plugin/ibuf/ibuf0ibuf.c
index 701e8f0ef04..23981ac388e 100644
--- a/storage/innodb_plugin/ibuf/ibuf0ibuf.c
+++ b/storage/innodb_plugin/ibuf/ibuf0ibuf.c
@@ -1878,9 +1878,9 @@ ibuf_remove_free_page(void)
fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
IBUF_SPACE_ID, page_no, &mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
ibuf_enter();
@@ -1922,9 +1922,9 @@ ibuf_remove_free_page(void)
ibuf_bitmap_page_set_bits(
bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, FALSE, &mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
mtr_commit(&mtr);
mutex_exit(&ibuf_mutex);
diff --git a/storage/innodb_plugin/include/btr0btr.h b/storage/innodb_plugin/include/btr0btr.h
index dde3a0bab69..5aa02694e0e 100644
--- a/storage/innodb_plugin/include/btr0btr.h
+++ b/storage/innodb_plugin/include/btr0btr.h
@@ -81,6 +81,91 @@ UNIQUE definition on secondary indexes when we decide if we can use
the insert buffer to speed up inserts */
#define BTR_IGNORE_SEC_UNIQUE 2048
+#ifdef UNIV_BLOB_DEBUG
+# include "ut0rbt.h"
+/** An index->blobs entry for keeping track of off-page column references */
+struct btr_blob_dbg_struct
+{
+ unsigned blob_page_no:32; /*!< first BLOB page number */
+ unsigned ref_page_no:32; /*!< referring page number */
+ unsigned ref_heap_no:16; /*!< referring heap number */
+ unsigned ref_field_no:10; /*!< referring field number */
+ unsigned owner:1; /*!< TRUE if BLOB owner */
+ unsigned always_owner:1; /*!< TRUE if always
+ has been the BLOB owner;
+ reset to TRUE on B-tree
+ page splits and merges */
+ unsigned del:1; /*!< TRUE if currently
+ delete-marked */
+};
+
+/**************************************************************//**
+Add a reference to an off-page column to the index->blobs map. */
+UNIV_INTERN
+void
+btr_blob_dbg_add_blob(
+/*==================*/
+ const rec_t* rec, /*!< in: clustered index record */
+ ulint field_no, /*!< in: number of off-page column */
+ ulint page_no, /*!< in: start page of the column */
+ dict_index_t* index, /*!< in/out: index tree */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+/**************************************************************//**
+Display the references to off-page columns.
+This function is to be called from a debugger,
+for example when a breakpoint on ut_dbg_assertion_failed is hit. */
+UNIV_INTERN
+void
+btr_blob_dbg_print(
+/*===============*/
+ const dict_index_t* index) /*!< in: index tree */
+ __attribute__((nonnull));
+/**************************************************************//**
+Check that there are no references to off-page columns from or to
+the given page. Invoked when freeing or clearing a page.
+@return TRUE when no orphan references exist */
+UNIV_INTERN
+ibool
+btr_blob_dbg_is_empty(
+/*==================*/
+ dict_index_t* index, /*!< in: index */
+ ulint page_no) /*!< in: page number */
+ __attribute__((nonnull, warn_unused_result));
+
+/**************************************************************//**
+Modify the 'deleted' flag of a record. */
+UNIV_INTERN
+void
+btr_blob_dbg_set_deleted_flag(
+/*==========================*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: rec_get_offs(rec, index) */
+ ibool del) /*!< in: TRUE=deleted, FALSE=exists */
+ __attribute__((nonnull));
+/**************************************************************//**
+Change the ownership of an off-page column. */
+UNIV_INTERN
+void
+btr_blob_dbg_owner(
+/*===============*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: rec_get_offs(rec, index) */
+ ulint i, /*!< in: ith field in rec */
+ ibool own) /*!< in: TRUE=owned, FALSE=disowned */
+ __attribute__((nonnull));
+/** Assert that there are no BLOB references to or from the given page. */
+# define btr_blob_dbg_assert_empty(index, page_no) \
+ ut_a(btr_blob_dbg_is_empty(index, page_no))
+#else /* UNIV_BLOB_DEBUG */
+# define btr_blob_dbg_add_blob(rec, field_no, page, index, ctx) ((void) 0)
+# define btr_blob_dbg_set_deleted_flag(rec, index, offsets, del)((void) 0)
+# define btr_blob_dbg_owner(rec, index, offsets, i, val) ((void) 0)
+# define btr_blob_dbg_assert_empty(index, page_no) ((void) 0)
+#endif /* UNIV_BLOB_DEBUG */
+
/**************************************************************//**
Gets the root node of a tree and x-latches it.
@return root page, x-latched */
diff --git a/storage/innodb_plugin/include/btr0cur.h b/storage/innodb_plugin/include/btr0cur.h
index b477ad0320a..ece3621fa97 100644
--- a/storage/innodb_plugin/include/btr0cur.h
+++ b/storage/innodb_plugin/include/btr0cur.h
@@ -478,7 +478,10 @@ btr_estimate_n_rows_in_range(
/*******************************************************************//**
Estimates the number of different key values in a given index, for
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
-The estimates are stored in the array index->stat_n_diff_key_vals. */
+The estimates are stored in the array index->stat_n_diff_key_vals.
+If innodb_stats_method is nulls_ignored, we also record the number of
+non-null values for each prefix and stored the estimates in
+array index->stat_n_non_null_key_vals. */
UNIV_INTERN
void
btr_estimate_number_of_different_key_vals(
@@ -509,8 +512,8 @@ file segment of the index tree.
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
UNIV_INTERN
ulint
-btr_store_big_rec_extern_fields(
-/*============================*/
+btr_store_big_rec_extern_fields_func(
+/*=================================*/
dict_index_t* index, /*!< in: index of rec; the index tree
MUST be X-latched */
buf_block_t* rec_block, /*!< in/out: block containing rec */
@@ -519,10 +522,42 @@ btr_store_big_rec_extern_fields(
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
- big_rec_t* big_rec_vec, /*!< in: vector containing fields
+#ifdef UNIV_DEBUG
+ mtr_t* local_mtr, /*!< in: mtr containing the
+ latch to rec and to the tree */
+#endif /* UNIV_DEBUG */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ ibool update_in_place,/*! in: TRUE if the record is updated
+ in place (not delete+insert) */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+ const big_rec_t*big_rec_vec) /*!< in: vector containing fields
to be stored externally */
- mtr_t* local_mtr); /*!< in: mtr containing the latch to
- rec and to the tree */
+ __attribute__((nonnull));
+
+/** Stores the fields in big_rec_vec to the tablespace and puts pointers to
+them in rec. The extern flags in rec will have to be set beforehand.
+The fields are stored on pages allocated from leaf node
+file segment of the index tree.
+@param index in: clustered index; MUST be X-latched by mtr
+@param b in/out: block containing rec; MUST be X-latched by mtr
+@param rec in/out: clustered index record
+@param offsets in: rec_get_offsets(rec, index);
+ the "external storage" flags in offsets will not be adjusted
+@param mtr in: mini-transaction that holds x-latch on index and b
+@param upd in: TRUE if the record is updated in place (not delete+insert)
+@param big in: vector containing fields to be stored externally
+@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
+#ifdef UNIV_DEBUG
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+ btr_store_big_rec_extern_fields_func(index,b,rec,offsets,mtr,upd,big)
+#elif defined UNIV_BLOB_LIGHT_DEBUG
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+ btr_store_big_rec_extern_fields_func(index,b,rec,offsets,upd,big)
+#else
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+ btr_store_big_rec_extern_fields_func(index,b,rec,offsets,big)
+#endif
+
/*******************************************************************//**
Frees the space in an externally stored field to the file space
management if the field in data is owned the externally stored field,
diff --git a/storage/innodb_plugin/include/btr0types.h b/storage/innodb_plugin/include/btr0types.h
index ef4a6b04b34..07c06fb18d7 100644
--- a/storage/innodb_plugin/include/btr0types.h
+++ b/storage/innodb_plugin/include/btr0types.h
@@ -38,6 +38,131 @@ typedef struct btr_cur_struct btr_cur_t;
/** B-tree search information for the adaptive hash index */
typedef struct btr_search_struct btr_search_t;
+#ifdef UNIV_BLOB_DEBUG
+# include "buf0types.h"
+/** An index->blobs entry for keeping track of off-page column references */
+typedef struct btr_blob_dbg_struct btr_blob_dbg_t;
+
+/** Insert to index->blobs a reference to an off-page column.
+@param index the index tree
+@param b the reference
+@param ctx context (for logging) */
+UNIV_INTERN
+void
+btr_blob_dbg_rbt_insert(
+/*====================*/
+ dict_index_t* index, /*!< in/out: index tree */
+ const btr_blob_dbg_t* b, /*!< in: the reference */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+
+/** Remove from index->blobs a reference to an off-page column.
+@param index the index tree
+@param b the reference
+@param ctx context (for logging) */
+UNIV_INTERN
+void
+btr_blob_dbg_rbt_delete(
+/*====================*/
+ dict_index_t* index, /*!< in/out: index tree */
+ const btr_blob_dbg_t* b, /*!< in: the reference */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+
+/**************************************************************//**
+Add to index->blobs any references to off-page columns from a record.
+@return number of references added */
+UNIV_INTERN
+ulint
+btr_blob_dbg_add_rec(
+/*=================*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: offsets */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+/**************************************************************//**
+Remove from index->blobs any references to off-page columns from a record.
+@return number of references removed */
+UNIV_INTERN
+ulint
+btr_blob_dbg_remove_rec(
+/*====================*/
+ const rec_t* rec, /*!< in: record */
+ dict_index_t* index, /*!< in/out: index */
+ const ulint* offsets,/*!< in: offsets */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+/**************************************************************//**
+Count and add to index->blobs any references to off-page columns
+from records on a page.
+@return number of references added */
+UNIV_INTERN
+ulint
+btr_blob_dbg_add(
+/*=============*/
+ const page_t* page, /*!< in: rewritten page */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+/**************************************************************//**
+Count and remove from index->blobs any references to off-page columns
+from records on a page.
+Used when reorganizing a page, before copying the records.
+@return number of references removed */
+UNIV_INTERN
+ulint
+btr_blob_dbg_remove(
+/*================*/
+ const page_t* page, /*!< in: b-tree page */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+/**************************************************************//**
+Restore in index->blobs any references to off-page columns
+Used when page reorganize fails due to compressed page overflow. */
+UNIV_INTERN
+void
+btr_blob_dbg_restore(
+/*=================*/
+ const page_t* npage, /*!< in: page that failed to compress */
+ const page_t* page, /*!< in: copy of original page */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx) /*!< in: context (for logging) */
+ __attribute__((nonnull));
+
+/** Operation that processes the BLOB references of an index record
+@param[in] rec record on index page
+@param[in/out] index the index tree of the record
+@param[in] offsets rec_get_offsets(rec,index)
+@param[in] ctx context (for logging)
+@return number of BLOB references processed */
+typedef ulint (*btr_blob_dbg_op_f)
+(const rec_t* rec,dict_index_t* index,const ulint* offsets,const char* ctx);
+
+/**************************************************************//**
+Count and process all references to off-page columns on a page.
+@return number of references processed */
+UNIV_INTERN
+ulint
+btr_blob_dbg_op(
+/*============*/
+ const page_t* page, /*!< in: B-tree leaf page */
+ const rec_t* rec, /*!< in: record to start from
+ (NULL to process the whole page) */
+ dict_index_t* index, /*!< in/out: index */
+ const char* ctx, /*!< in: context (for logging) */
+ const btr_blob_dbg_op_f op) /*!< in: operation on records */
+ __attribute__((nonnull(1,3,4,5)));
+#else /* UNIV_BLOB_DEBUG */
+# define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0)
+# define btr_blob_dbg_add(page, index, ctx) ((void) 0)
+# define btr_blob_dbg_remove_rec(rec, index, offsets, ctx) ((void) 0)
+# define btr_blob_dbg_remove(page, index, ctx) ((void) 0)
+# define btr_blob_dbg_restore(npage, page, index, ctx) ((void) 0)
+# define btr_blob_dbg_op(page, rec, index, ctx, op) ((void) 0)
+#endif /* UNIV_BLOB_DEBUG */
+
/** The size of a reference to data stored on a different page.
The reference is stored at the end of the prefix of the field
in the index record. */
diff --git a/storage/innodb_plugin/include/buf0buf.h b/storage/innodb_plugin/include/buf0buf.h
index cd4ee5906f0..05dead5ac9e 100644
--- a/storage/innodb_plugin/include/buf0buf.h
+++ b/storage/innodb_plugin/include/buf0buf.h
@@ -41,6 +41,8 @@ Created 11/5/1995 Heikki Tuuri
/* @{ */
#define BUF_GET 10 /*!< get always */
#define BUF_GET_IF_IN_POOL 11 /*!< get if in pool */
+#define BUF_PEEK_IF_IN_POOL 12 /*!< get if in pool, do not make
+ the block young in the LRU list */
#define BUF_GET_NO_LATCH 14 /*!< get and bufferfix, but
set no latch; we have
separated this case, because
@@ -165,10 +167,8 @@ Allocates a buffer block.
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
UNIV_INLINE
buf_block_t*
-buf_block_alloc(
-/*============*/
- ulint zip_size); /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_block_alloc(void);
+/*=================*/
/********************************************************************//**
Frees a buffer block which does not contain a file page. */
UNIV_INLINE
@@ -286,7 +286,7 @@ buf_page_get_gen(
ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
buf_block_t* guess, /*!< in: guessed block or NULL */
ulint mode, /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
- BUF_GET_NO_LATCH */
+ BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH */
const char* file, /*!< in: file name */
ulint line, /*!< in: line where called */
mtr_t* mtr); /*!< in: mini-transaction */
@@ -370,7 +370,7 @@ buf_reset_check_index_page_at_flush(
/*================================*/
ulint space, /*!< in: space id */
ulint offset);/*!< in: page number */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
/********************************************************************//**
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
This function should be called when we free a file page and want the
@@ -395,7 +395,7 @@ buf_page_reset_file_page_was_freed(
/*===============================*/
ulint space, /*!< in: space id */
ulint offset); /*!< in: page number */
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
/********************************************************************//**
Reads the freed_page_clock of a buffer block.
@return freed_page_clock */
@@ -1137,11 +1137,11 @@ struct buf_page_struct{
0 if the block was never accessed
in the buffer pool */
/* @} */
-# ifdef UNIV_DEBUG_FILE_ACCESSES
+# if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ibool file_page_was_freed;
/*!< this is set to TRUE when fsp
frees a page in buffer pool */
-# endif /* UNIV_DEBUG_FILE_ACCESSES */
+# endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
#endif /* !UNIV_HOTBACKUP */
};
diff --git a/storage/innodb_plugin/include/buf0buf.ic b/storage/innodb_plugin/include/buf0buf.ic
index 23db684806c..0025bef5aac 100644
--- a/storage/innodb_plugin/include/buf0buf.ic
+++ b/storage/innodb_plugin/include/buf0buf.ic
@@ -719,14 +719,12 @@ Allocates a buffer block.
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
UNIV_INLINE
buf_block_t*
-buf_block_alloc(
-/*============*/
- ulint zip_size) /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_block_alloc(void)
+/*=================*/
{
buf_block_t* block;
- block = buf_LRU_get_free_block(zip_size);
+ block = buf_LRU_get_free_block();
buf_block_set_state(block, BUF_BLOCK_MEMORY);
diff --git a/storage/innodb_plugin/include/buf0lru.h b/storage/innodb_plugin/include/buf0lru.h
index 5a9cfd059f3..d543bce53cd 100644
--- a/storage/innodb_plugin/include/buf0lru.h
+++ b/storage/innodb_plugin/include/buf0lru.h
@@ -110,12 +110,9 @@ enum buf_lru_free_block_status
buf_LRU_free_block(
/*===============*/
buf_page_t* bpage, /*!< in: block to be freed */
- ibool zip, /*!< in: TRUE if should remove also the
+ ibool zip) /*!< in: TRUE if should remove also the
compressed page of an uncompressed page */
- ibool* buf_pool_mutex_released);
- /*!< in: pointer to a variable that will
- be assigned TRUE if buf_pool_mutex
- was temporarily released, or NULL */
+ __attribute__((nonnull));
/******************************************************************//**
Try to free a replaceable block.
@return TRUE if found and freed */
@@ -146,10 +143,9 @@ LRU list to the free list.
@return the free control block, in state BUF_BLOCK_READY_FOR_USE */
UNIV_INTERN
buf_block_t*
-buf_LRU_get_free_block(
-/*===================*/
- ulint zip_size); /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_LRU_get_free_block(void)
+/*========================*/
+ __attribute__((warn_unused_result));
/******************************************************************//**
Puts a block back to the free list. */
diff --git a/storage/innodb_plugin/include/dict0mem.h b/storage/innodb_plugin/include/dict0mem.h
index 19782c2e76a..bd32a239cfd 100644
--- a/storage/innodb_plugin/include/dict0mem.h
+++ b/storage/innodb_plugin/include/dict0mem.h
@@ -321,6 +321,12 @@ struct dict_index_struct{
dict_get_n_unique(index); we
periodically calculate new
estimates */
+ ib_int64_t* stat_n_non_null_key_vals;
+ /* approximate number of non-null key values
+ for this index, for each column where
+ n < dict_get_n_unique(index); This
+ is used when innodb_stats_method is
+ "nulls_ignored". */
ulint stat_index_size;
/*!< approximate index size in
database pages */
@@ -334,6 +340,13 @@ struct dict_index_struct{
index, or 0 if the index existed
when InnoDB was started up */
#endif /* !UNIV_HOTBACKUP */
+#ifdef UNIV_BLOB_DEBUG
+ mutex_t blobs_mutex;
+ /*!< mutex protecting blobs */
+ void* blobs; /*!< map of (page_no,heap_no,field_no)
+ to first_blob_page_no; protected by
+ blobs_mutex; @see btr_blob_dbg_t */
+#endif /* UNIV_BLOB_DEBUG */
#ifdef UNIV_DEBUG
ulint magic_n;/*!< magic number */
/** Value of dict_index_struct::magic_n */
diff --git a/storage/innodb_plugin/include/dict0types.h b/storage/innodb_plugin/include/dict0types.h
index 7ad69193cc9..f14b59a19d4 100644
--- a/storage/innodb_plugin/include/dict0types.h
+++ b/storage/innodb_plugin/include/dict0types.h
@@ -33,11 +33,6 @@ typedef struct dict_index_struct dict_index_t;
typedef struct dict_table_struct dict_table_t;
typedef struct dict_foreign_struct dict_foreign_t;
-/* A cluster object is a table object with the type field set to
-DICT_CLUSTERED */
-
-typedef dict_table_t dict_cluster_t;
-
typedef struct ind_node_struct ind_node_t;
typedef struct tab_node_struct tab_node_t;
diff --git a/storage/innodb_plugin/include/page0zip.h b/storage/innodb_plugin/include/page0zip.h
index 574809e5227..00c1d0516e6 100644
--- a/storage/innodb_plugin/include/page0zip.h
+++ b/storage/innodb_plugin/include/page0zip.h
@@ -420,7 +420,7 @@ page_zip_copy_recs(
const page_t* src, /*!< in: page */
dict_index_t* index, /*!< in: index of the B-tree */
mtr_t* mtr) /*!< in: mini-transaction */
- __attribute__((nonnull(1,2,3,4)));
+ __attribute__((nonnull));
#endif /* !UNIV_HOTBACKUP */
/**********************************************************************//**
diff --git a/storage/innodb_plugin/include/rem0cmp.h b/storage/innodb_plugin/include/rem0cmp.h
index 2f751a38864..a908521c9f7 100644
--- a/storage/innodb_plugin/include/rem0cmp.h
+++ b/storage/innodb_plugin/include/rem0cmp.h
@@ -165,6 +165,10 @@ cmp_rec_rec_with_match(
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
dict_index_t* index, /*!< in: data dictionary index */
+ ibool nulls_unequal,
+ /* in: TRUE if this is for index statistics
+ cardinality estimation, and innodb_stats_method
+ is "nulls_unequal" or "nulls_ignored" */
ulint* matched_fields, /*!< in/out: number of already completely
matched fields; when the function returns,
contains the value the for current
diff --git a/storage/innodb_plugin/include/rem0cmp.ic b/storage/innodb_plugin/include/rem0cmp.ic
index 39ef5f4fba3..63415fe7837 100644
--- a/storage/innodb_plugin/include/rem0cmp.ic
+++ b/storage/innodb_plugin/include/rem0cmp.ic
@@ -87,5 +87,5 @@ cmp_rec_rec(
ulint match_b = 0;
return(cmp_rec_rec_with_match(rec1, rec2, offsets1, offsets2, index,
- &match_f, &match_b));
+ FALSE, &match_f, &match_b));
}
diff --git a/storage/innodb_plugin/include/row0upd.h b/storage/innodb_plugin/include/row0upd.h
index b61e6b6dca1..97b7ec49a17 100644
--- a/storage/innodb_plugin/include/row0upd.h
+++ b/storage/innodb_plugin/include/row0upd.h
@@ -280,19 +280,29 @@ NOTE: we compare the fields as binary strings!
@return TRUE if update vector changes an ordering field in the index record */
UNIV_INTERN
ibool
-row_upd_changes_ord_field_binary(
-/*=============================*/
+row_upd_changes_ord_field_binary_func(
+/*==================================*/
+ dict_index_t* index, /*!< in: index of the record */
+ const upd_t* update, /*!< in: update vector for the row; NOTE: the
+ field numbers in this MUST be clustered index
+ positions! */
+#ifdef UNIV_DEBUG
+ const que_thr_t*thr, /*!< in: query thread */
+#endif /* UNIV_DEBUG */
const dtuple_t* row, /*!< in: old value of row, or NULL if the
row and the data values in update are not
known when this function is called, e.g., at
compile time */
- const row_ext_t*ext, /*!< NULL, or prefixes of the externally
+ const row_ext_t*ext) /*!< NULL, or prefixes of the externally
stored columns in the old row */
- dict_index_t* index, /*!< in: index of the record */
- const upd_t* update) /*!< in: update vector for the row; NOTE: the
- field numbers in this MUST be clustered index
- positions! */
- __attribute__((nonnull(3,4), warn_unused_result));
+ __attribute__((nonnull(1,2), warn_unused_result));
+#ifdef UNIV_DEBUG
+# define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
+ row_upd_changes_ord_field_binary_func(index,update,thr,row,ext)
+#else /* UNIV_DEBUG */
+# define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
+ row_upd_changes_ord_field_binary_func(index,update,row,ext)
+#endif /* UNIV_DEBUG */
/***********************************************************//**
Checks if an update vector changes an ordering field of an index record.
This function is fast if the update vector is short or the number of ordering
diff --git a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
index 7aa2ce74720..91ae895040c 100644
--- a/storage/innodb_plugin/include/srv0srv.h
+++ b/storage/innodb_plugin/include/srv0srv.h
@@ -154,6 +154,11 @@ capacity. PCT_IO(5) -> returns the number of IO operations that
is 5% of the max where max is srv_io_capacity. */
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
+/* The "innodb_stats_method" setting, decides how InnoDB is going
+to treat NULL value when collecting statistics. It is not defined
+as enum type because the configure option takes unsigned integer type. */
+extern ulong srv_innodb_stats_method;
+
#ifdef UNIV_LOG_ARCHIVE
extern ibool srv_log_archive_on;
extern ibool srv_archive_recovery;
@@ -363,6 +368,19 @@ enum {
in connection with recovery */
};
+/* Alternatives for srv_innodb_stats_method, which could be changed by
+setting innodb_stats_method */
+enum srv_stats_method_name_enum {
+ SRV_STATS_NULLS_EQUAL, /* All NULL values are treated as
+ equal. This is the default setting
+ for innodb_stats_method */
+ SRV_STATS_NULLS_UNEQUAL, /* All NULL values are treated as
+ NOT equal. */
+ SRV_STATS_NULLS_IGNORED /* NULL values are ignored */
+};
+
+typedef enum srv_stats_method_name_enum srv_stats_method_name_t;
+
#ifndef UNIV_HOTBACKUP
/** Types of threads existing in the system. */
enum srv_thread_type {
diff --git a/storage/innodb_plugin/include/sync0arr.h b/storage/innodb_plugin/include/sync0arr.h
index 5f1280f5e28..6e931346238 100644
--- a/storage/innodb_plugin/include/sync0arr.h
+++ b/storage/innodb_plugin/include/sync0arr.h
@@ -115,8 +115,11 @@ Prints warnings of long semaphore waits to stderr.
@return TRUE if fatal semaphore wait threshold was exceeded */
UNIV_INTERN
ibool
-sync_array_print_long_waits(void);
-/*=============================*/
+sync_array_print_long_waits(
+/*========================*/
+ os_thread_id_t* waiter, /*!< out: longest waiting thread */
+ const void** sema) /*!< out: longest-waited-for semaphore */
+ __attribute__((nonnull));
/********************************************************************//**
Validates the integrity of the wait array. Checks
that the number of reserved cells equals the count variable. */
diff --git a/storage/innodb_plugin/include/sync0rw.h b/storage/innodb_plugin/include/sync0rw.h
index 175f3deb77c..47f7dbfe0eb 100644
--- a/storage/innodb_plugin/include/sync0rw.h
+++ b/storage/innodb_plugin/include/sync0rw.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -490,6 +490,7 @@ UNIV_INTERN
void
rw_lock_debug_print(
/*================*/
+ FILE* f, /*!< in: output stream */
rw_lock_debug_t* info); /*!< in: debug struct */
#endif /* UNIV_SYNC_DEBUG */
diff --git a/storage/innodb_plugin/include/trx0rseg.h b/storage/innodb_plugin/include/trx0rseg.h
index a25d84f1e84..e3674089735 100644
--- a/storage/innodb_plugin/include/trx0rseg.h
+++ b/storage/innodb_plugin/include/trx0rseg.h
@@ -135,9 +135,7 @@ struct trx_rseg_struct{
ulint id; /*!< rollback segment id == the index of
its slot in the trx system file copy */
mutex_t mutex; /*!< mutex protecting the fields in this
- struct except id; NOTE that the latching
- order must always be kernel mutex ->
- rseg mutex */
+ struct except id, which is constant */
ulint space; /*!< space where the rollback segment is
header is placed */
ulint zip_size;/* compressed page size of space
diff --git a/storage/innodb_plugin/include/trx0trx.h b/storage/innodb_plugin/include/trx0trx.h
index 5ecebdda945..53f9648d30a 100644
--- a/storage/innodb_plugin/include/trx0trx.h
+++ b/storage/innodb_plugin/include/trx0trx.h
@@ -214,12 +214,12 @@ trx_recover_for_mysql(
/*******************************************************************//**
This function is used to find one X/Open XA distributed transaction
which is in the prepared state
-@return trx or NULL */
+@return trx or NULL; on match, the trx->xid will be invalidated */
UNIV_INTERN
trx_t *
trx_get_trx_by_xid(
/*===============*/
- XID* xid); /*!< in: X/Open XA transaction identification */
+ const XID* xid); /*!< in: X/Open XA transaction identifier */
/**********************************************************************//**
If required, flushes the log to disk if we called trx_commit_for_mysql()
with trx->flush_log_later == TRUE.
diff --git a/storage/innodb_plugin/include/univ.i b/storage/innodb_plugin/include/univ.i
index b721e0406a8..319db93d137 100644
--- a/storage/innodb_plugin/include/univ.i
+++ b/storage/innodb_plugin/include/univ.i
@@ -46,7 +46,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 1
#define INNODB_VERSION_MINOR 0
-#define INNODB_VERSION_BUGFIX 15
+#define INNODB_VERSION_BUGFIX 16
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
@@ -177,14 +177,15 @@ command. Not tested on Windows. */
debugging without UNIV_DEBUG */
#define UNIV_BUF_DEBUG /* Enable buffer pool
debugging without UNIV_DEBUG */
+#define UNIV_BLOB_LIGHT_DEBUG /* Enable off-page column
+ debugging without UNIV_DEBUG */
#define UNIV_DEBUG /* Enable ut_ad() assertions
and disable UNIV_INLINE */
#define UNIV_DEBUG_LOCK_VALIDATE /* Enable
ut_ad(lock_rec_validate_page())
assertions. */
-#define UNIV_DEBUG_FILE_ACCESSES /* Debug .ibd file access
- (field file_page_was_freed
- in buf_page_t) */
+#define UNIV_DEBUG_FILE_ACCESSES /* Enable freed block access
+ debugging without UNIV_DEBUG */
#define UNIV_LRU_DEBUG /* debug the buffer pool LRU */
#define UNIV_HASH_DEBUG /* debug HASH_ macros */
#define UNIV_LIST_DEBUG /* debug UT_LIST_ macros */
@@ -193,6 +194,8 @@ this will break redo log file compatibility, but it may be useful when
debugging redo log application problems. */
#define UNIV_MEM_DEBUG /* detect memory leaks etc */
#define UNIV_IBUF_DEBUG /* debug the insert buffer */
+#define UNIV_BLOB_DEBUG /* track BLOB ownership;
+assumes that no BLOBs survive server restart */
#define UNIV_IBUF_COUNT_DEBUG /* debug the insert buffer;
this limits the database to IBUF_COUNT_N_SPACES and IBUF_COUNT_N_PAGES,
and the insert buffer must be empty when the database is started */
@@ -424,7 +427,7 @@ it is read or written. */
/* Use sun_prefetch when compile with Sun Studio */
# define UNIV_EXPECT(expr,value) (expr)
# define UNIV_LIKELY_NULL(expr) (expr)
-# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many(addr)
+# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many((void*) addr)
# define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many(addr)
#else
/* Dummy versions of the macros */
diff --git a/storage/innodb_plugin/mem/mem0mem.c b/storage/innodb_plugin/mem/mem0mem.c
index 1dd4db30841..86100b04fd6 100644
--- a/storage/innodb_plugin/mem/mem0mem.c
+++ b/storage/innodb_plugin/mem/mem0mem.c
@@ -347,7 +347,7 @@ mem_heap_create_block(
return(NULL);
}
} else {
- buf_block = buf_block_alloc(0);
+ buf_block = buf_block_alloc();
}
block = (mem_block_t*) buf_block->frame;
diff --git a/storage/innodb_plugin/mtr/mtr0log.c b/storage/innodb_plugin/mtr/mtr0log.c
index 3f3dab36b76..3349036b5b3 100644
--- a/storage/innodb_plugin/mtr/mtr0log.c
+++ b/storage/innodb_plugin/mtr/mtr0log.c
@@ -408,7 +408,7 @@ mlog_parse_string(
ptr += 2;
if (UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE)
- || UNIV_UNLIKELY(len + offset) > UNIV_PAGE_SIZE) {
+ || UNIV_UNLIKELY(len + offset > UNIV_PAGE_SIZE)) {
recv_sys->found_corrupt_log = TRUE;
return(NULL);
diff --git a/storage/innodb_plugin/page/page0cur.c b/storage/innodb_plugin/page/page0cur.c
index f10f16a7dd9..936762b986a 100644
--- a/storage/innodb_plugin/page/page0cur.c
+++ b/storage/innodb_plugin/page/page0cur.c
@@ -1149,6 +1149,8 @@ use_heap:
current_rec, index, mtr);
}
+ btr_blob_dbg_add_rec(insert_rec, index, offsets, "insert");
+
return(insert_rec);
}
@@ -1195,10 +1197,12 @@ page_cur_insert_rec_zip_reorg(
}
/* Out of space: restore the page */
+ btr_blob_dbg_remove(page, index, "insert_zip_fail");
if (!page_zip_decompress(page_zip, page, FALSE)) {
ut_error; /* Memory corrupted? */
}
ut_ad(page_validate(page, index));
+ btr_blob_dbg_add(page, index, "insert_zip_fail");
return(NULL);
}
@@ -1490,6 +1494,8 @@ use_heap:
page_zip_write_rec(page_zip, insert_rec, index, offsets, 1);
+ btr_blob_dbg_add_rec(insert_rec, index, offsets, "insert_zip_ok");
+
/* 9. Write log record of the insert */
if (UNIV_LIKELY(mtr != NULL)) {
page_cur_insert_rec_write_log(insert_rec, rec_size,
@@ -1697,6 +1703,9 @@ page_copy_rec_list_end_to_created_page(
heap_top += rec_size;
+ rec_offs_make_valid(insert_rec, index, offsets);
+ btr_blob_dbg_add_rec(insert_rec, index, offsets, "copy_end");
+
page_cur_insert_rec_write_log(insert_rec, rec_size, prev_rec,
index, mtr);
prev_rec = insert_rec;
@@ -1944,6 +1953,7 @@ page_cur_delete_rec(
page_dir_slot_set_n_owned(cur_dir_slot, page_zip, cur_n_owned - 1);
/* 6. Free the memory occupied by the record */
+ btr_blob_dbg_remove_rec(current_rec, index, offsets, "delete");
page_mem_free(page, page_zip, current_rec, index, offsets);
/* 7. Now we have decremented the number of owned records of the slot.
diff --git a/storage/innodb_plugin/page/page0page.c b/storage/innodb_plugin/page/page0page.c
index 10008f9ac25..6cae03e8829 100644
--- a/storage/innodb_plugin/page/page0page.c
+++ b/storage/innodb_plugin/page/page0page.c
@@ -685,12 +685,16 @@ page_copy_rec_list_end(
if (UNIV_UNLIKELY
(!page_zip_reorganize(new_block, index, mtr))) {
+ btr_blob_dbg_remove(new_page, index,
+ "copy_end_reorg_fail");
if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip,
new_page, FALSE))) {
ut_error;
}
ut_ad(page_validate(new_page, index));
+ btr_blob_dbg_add(new_page, index,
+ "copy_end_reorg_fail");
return(NULL);
} else {
/* The page was reorganized:
@@ -803,12 +807,16 @@ page_copy_rec_list_start(
if (UNIV_UNLIKELY
(!page_zip_reorganize(new_block, index, mtr))) {
+ btr_blob_dbg_remove(new_page, index,
+ "copy_start_reorg_fail");
if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip,
new_page, FALSE))) {
ut_error;
}
ut_ad(page_validate(new_page, index));
+ btr_blob_dbg_add(new_page, index,
+ "copy_start_reorg_fail");
return(NULL);
} else {
/* The page was reorganized:
@@ -1080,6 +1088,9 @@ page_delete_rec_list_end(
/* Remove the record chain segment from the record chain */
page_rec_set_next(prev_rec, page_get_supremum_rec(page));
+ btr_blob_dbg_op(page, rec, index, "delete_end",
+ btr_blob_dbg_remove_rec);
+
/* Catenate the deleted chain segment to the page free list */
page_rec_set_next(last_rec, page_header_get_ptr(page, PAGE_FREE));
diff --git a/storage/innodb_plugin/page/page0zip.c b/storage/innodb_plugin/page/page0zip.c
index d3b1edefc6b..6e866b3f016 100644
--- a/storage/innodb_plugin/page/page0zip.c
+++ b/storage/innodb_plugin/page/page0zip.c
@@ -653,13 +653,13 @@ page_zip_dir_encode(
Allocate memory for zlib. */
static
void*
-page_zip_malloc(
+page_zip_zalloc(
/*============*/
void* opaque, /*!< in/out: memory heap */
uInt items, /*!< in: number of items to allocate */
uInt size) /*!< in: size of an item in bytes */
{
- return(mem_heap_alloc(opaque, items * size));
+ return(mem_heap_zalloc(opaque, items * size));
}
/**********************************************************************//**
@@ -684,7 +684,7 @@ page_zip_set_alloc(
{
z_stream* strm = stream;
- strm->zalloc = page_zip_malloc;
+ strm->zalloc = page_zip_zalloc;
strm->zfree = page_zip_free;
strm->opaque = heap;
}
@@ -2912,19 +2912,18 @@ zlib_error:
page_zip_set_alloc(&d_stream, heap);
- if (UNIV_UNLIKELY(inflateInit2(&d_stream, UNIV_PAGE_SIZE_SHIFT)
- != Z_OK)) {
- ut_error;
- }
-
d_stream.next_in = page_zip->data + PAGE_DATA;
/* Subtract the space reserved for
the page header and the end marker of the modification log. */
d_stream.avail_in = page_zip_get_size(page_zip) - (PAGE_DATA + 1);
-
d_stream.next_out = page + PAGE_ZIP_START;
d_stream.avail_out = UNIV_PAGE_SIZE - PAGE_ZIP_START;
+ if (UNIV_UNLIKELY(inflateInit2(&d_stream, UNIV_PAGE_SIZE_SHIFT)
+ != Z_OK)) {
+ ut_error;
+ }
+
/* Decode the zlib header and the index information. */
if (UNIV_UNLIKELY(inflate(&d_stream, Z_BLOCK) != Z_OK)) {
@@ -4439,7 +4438,7 @@ page_zip_reorganize(
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
#ifndef UNIV_HOTBACKUP
- temp_block = buf_block_alloc(0);
+ temp_block = buf_block_alloc();
btr_search_drop_page_hash_index(block);
block->check_index_page_at_flush = TRUE;
#else /* !UNIV_HOTBACKUP */
@@ -4451,6 +4450,8 @@ page_zip_reorganize(
/* Copy the old page to temporary space */
buf_frame_copy(temp_page, page);
+ btr_blob_dbg_remove(page, index, "zip_reorg");
+
/* Recreate the page: note that global data on page (possible
segment headers, next page-field, etc.) is preserved intact */
@@ -4509,7 +4510,7 @@ page_zip_copy_recs(
mtr_t* mtr) /*!< in: mini-transaction */
{
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
- ut_ad(mtr_memo_contains_page(mtr, (page_t*) src, MTR_MEMO_PAGE_X_FIX));
+ ut_ad(mtr_memo_contains_page(mtr, src, MTR_MEMO_PAGE_X_FIX));
ut_ad(!dict_index_is_ibuf(index));
#ifdef UNIV_ZIP_DEBUG
/* The B-tree operations that call this function may set
@@ -4579,6 +4580,7 @@ page_zip_copy_recs(
#ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
+ btr_blob_dbg_add(page, index, "page_zip_copy_recs");
page_zip_compress_write_log(page_zip, page, index, mtr);
}
diff --git a/storage/innodb_plugin/rem/rem0cmp.c b/storage/innodb_plugin/rem/rem0cmp.c
index 35b67992558..04d2c15437b 100644
--- a/storage/innodb_plugin/rem/rem0cmp.c
+++ b/storage/innodb_plugin/rem/rem0cmp.c
@@ -862,6 +862,10 @@ cmp_rec_rec_with_match(
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
dict_index_t* index, /*!< in: data dictionary index */
+ ibool nulls_unequal,
+ /* in: TRUE if this is for index statistics
+ cardinality estimation, and innodb_stats_method
+ is "nulls_unequal" or "nulls_ignored" */
ulint* matched_fields, /*!< in/out: number of already completely
matched fields; when the function returns,
contains the value the for current
@@ -961,9 +965,13 @@ cmp_rec_rec_with_match(
|| rec2_f_len == UNIV_SQL_NULL) {
if (rec1_f_len == rec2_f_len) {
-
- goto next_field;
-
+ /* This is limited to stats collection,
+ cannot use it for regular search */
+ if (nulls_unequal) {
+ ret = -1;
+ } else {
+ goto next_field;
+ }
} else if (rec2_f_len == UNIV_SQL_NULL) {
/* We define the SQL null to be the
diff --git a/storage/innodb_plugin/row/row0ins.c b/storage/innodb_plugin/row/row0ins.c
index 298c601c7e3..8050c099751 100644
--- a/storage/innodb_plugin/row/row0ins.c
+++ b/storage/innodb_plugin/row/row0ins.c
@@ -2130,7 +2130,7 @@ function_exit:
err = btr_store_big_rec_extern_fields(
index, btr_cur_get_block(&cursor),
- rec, offsets, big_rec, &mtr);
+ rec, offsets, &mtr, FALSE, big_rec);
if (modify) {
dtuple_big_rec_free(big_rec);
diff --git a/storage/innodb_plugin/row/row0purge.c b/storage/innodb_plugin/row/row0purge.c
index 8bf2ae0f458..752a2ec9e83 100644
--- a/storage/innodb_plugin/row/row0purge.c
+++ b/storage/innodb_plugin/row/row0purge.c
@@ -387,8 +387,11 @@ Purges an update of an existing record. Also purges an update of a delete
marked record if that record contained an externally stored field. */
static
void
-row_purge_upd_exist_or_extern(
-/*==========================*/
+row_purge_upd_exist_or_extern_func(
+/*===============================*/
+#ifdef UNIV_DEBUG
+ const que_thr_t*thr, /*!< in: query thread */
+#endif /* UNIV_DEBUG */
purge_node_t* node) /*!< in: row purge node */
{
mem_heap_t* heap;
@@ -413,8 +416,8 @@ row_purge_upd_exist_or_extern(
while (node->index != NULL) {
index = node->index;
- if (row_upd_changes_ord_field_binary(NULL, NULL, node->index,
- node->update)) {
+ if (row_upd_changes_ord_field_binary(node->index, node->update,
+ thr, NULL, NULL)) {
/* Build the older version of the index entry */
entry = row_build_index_entry(node->row, NULL,
index, heap);
@@ -496,6 +499,14 @@ skip_secondaries:
}
}
+#ifdef UNIV_DEBUG
+# define row_purge_upd_exist_or_extern(thr,node) \
+ row_purge_upd_exist_or_extern_func(thr,node)
+#else /* UNIV_DEBUG */
+# define row_purge_upd_exist_or_extern(thr,node) \
+ row_purge_upd_exist_or_extern_func(node)
+#endif /* UNIV_DEBUG */
+
/***********************************************************//**
Parses the row reference and other info in a modify undo log record.
@return TRUE if purge operation required: NOTE that then the CALLER
@@ -602,47 +613,32 @@ err_exit:
/***********************************************************//**
Fetches an undo log record and does the purge for the recorded operation.
If none left, or the current purge completed, returns the control to the
-parent node, which is always a query thread node.
-@return DB_SUCCESS if operation successfully completed, else error code */
-static
-ulint
+parent node, which is always a query thread node. */
+static __attribute__((nonnull))
+void
row_purge(
/*======*/
purge_node_t* node, /*!< in: row purge node */
que_thr_t* thr) /*!< in: query thread */
{
- roll_ptr_t roll_ptr;
- ibool purge_needed;
ibool updated_extern;
- trx_t* trx;
- ut_ad(node && thr);
-
- trx = thr_get_trx(thr);
+ ut_ad(node);
+ ut_ad(thr);
- node->undo_rec = trx_purge_fetch_next_rec(&roll_ptr,
- &(node->reservation),
+ node->undo_rec = trx_purge_fetch_next_rec(&node->roll_ptr,
+ &node->reservation,
node->heap);
if (!node->undo_rec) {
/* Purge completed for this query thread */
thr->run_node = que_node_get_parent(node);
- return(DB_SUCCESS);
- }
-
- node->roll_ptr = roll_ptr;
-
- if (node->undo_rec == &trx_purge_dummy_rec) {
- purge_needed = FALSE;
- } else {
- purge_needed = row_purge_parse_undo_rec(node, &updated_extern,
- thr);
- /* If purge_needed == TRUE, we must also remember to unfreeze
- data dictionary! */
+ return;
}
- if (purge_needed) {
+ if (node->undo_rec != &trx_purge_dummy_rec
+ && row_purge_parse_undo_rec(node, &updated_extern, thr)) {
node->found_clust = FALSE;
node->index = dict_table_get_next_index(
@@ -654,14 +650,14 @@ row_purge(
} else if (updated_extern
|| node->rec_type == TRX_UNDO_UPD_EXIST_REC) {
- row_purge_upd_exist_or_extern(node);
+ row_purge_upd_exist_or_extern(thr, node);
}
if (node->found_clust) {
btr_pcur_close(&(node->pcur));
}
- row_mysql_unfreeze_data_dictionary(trx);
+ row_mysql_unfreeze_data_dictionary(thr_get_trx(thr));
}
/* Do some cleanup */
@@ -669,8 +665,6 @@ row_purge(
mem_heap_empty(node->heap);
thr->run_node = node;
-
- return(DB_SUCCESS);
}
/***********************************************************//**
@@ -684,9 +678,6 @@ row_purge_step(
que_thr_t* thr) /*!< in: query thread */
{
purge_node_t* node;
-#ifdef UNIV_DEBUG
- ulint err;
-#endif /* UNIV_DEBUG */
ut_ad(thr);
@@ -694,12 +685,7 @@ row_purge_step(
ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);
-#ifdef UNIV_DEBUG
- err =
-#endif /* UNIV_DEBUG */
row_purge(node, thr);
- ut_ad(err == DB_SUCCESS);
-
return(thr);
}
diff --git a/storage/innodb_plugin/row/row0umod.c b/storage/innodb_plugin/row/row0umod.c
index 562f8093c38..5202a498eed 100644
--- a/storage/innodb_plugin/row/row0umod.c
+++ b/storage/innodb_plugin/row/row0umod.c
@@ -173,40 +173,26 @@ row_undo_mod_remove_clust_low(
mtr_t* mtr, /*!< in: mtr */
ulint mode) /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */
{
- btr_pcur_t* pcur;
btr_cur_t* btr_cur;
ulint err;
- ibool success;
ut_ad(node->rec_type == TRX_UNDO_UPD_DEL_REC);
- pcur = &(node->pcur);
- btr_cur = btr_pcur_get_btr_cur(pcur);
- success = btr_pcur_restore_position(mode, pcur, mtr);
+ /* Find out if the record has been purged already
+ or if we can remove it. */
- if (!success) {
+ if (!btr_pcur_restore_position(mode, &node->pcur, mtr)
+ || row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) {
return(DB_SUCCESS);
}
- /* Find out if we can remove the whole clustered index record */
-
- if (node->rec_type == TRX_UNDO_UPD_DEL_REC
- && !row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) {
-
- /* Ok, we can remove */
- } else {
- return(DB_SUCCESS);
- }
+ btr_cur = btr_pcur_get_btr_cur(&node->pcur);
if (mode == BTR_MODIFY_LEAF) {
- success = btr_cur_optimistic_delete(btr_cur, mtr);
-
- if (success) {
- err = DB_SUCCESS;
- } else {
- err = DB_FAIL;
- }
+ err = btr_cur_optimistic_delete(btr_cur, mtr)
+ ? DB_SUCCESS
+ : DB_FAIL;
} else {
ut_ad(mode == BTR_MODIFY_TREE);
@@ -668,8 +654,9 @@ row_undo_mod_upd_exist_sec(
while (node->index != NULL) {
index = node->index;
- if (row_upd_changes_ord_field_binary(
- node->row, node->ext, node->index, node->update)) {
+ if (row_upd_changes_ord_field_binary(node->index, node->update,
+ thr,
+ node->row, node->ext)) {
/* Build the newest version of the index entry */
entry = row_build_index_entry(node->row, node->ext,
diff --git a/storage/innodb_plugin/row/row0upd.c b/storage/innodb_plugin/row/row0upd.c
index e1c78949603..13134afd1aa 100644
--- a/storage/innodb_plugin/row/row0upd.c
+++ b/storage/innodb_plugin/row/row0upd.c
@@ -498,14 +498,49 @@ row_upd_rec_in_place(
n_fields = upd_get_n_fields(update);
for (i = 0; i < n_fields; i++) {
+#ifdef UNIV_BLOB_DEBUG
+ btr_blob_dbg_t b;
+ const byte* field_ref = NULL;
+#endif /* UNIV_BLOB_DEBUG */
+
upd_field = upd_get_nth_field(update, i);
new_val = &(upd_field->new_val);
ut_ad(!dfield_is_ext(new_val) ==
!rec_offs_nth_extern(offsets, upd_field->field_no));
+#ifdef UNIV_BLOB_DEBUG
+ if (dfield_is_ext(new_val)) {
+ ulint len;
+ field_ref = rec_get_nth_field(rec, offsets, i, &len);
+ ut_a(len != UNIV_SQL_NULL);
+ ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
+ field_ref += len - BTR_EXTERN_FIELD_REF_SIZE;
+
+ b.ref_page_no = page_get_page_no(page_align(rec));
+ b.ref_heap_no = page_rec_get_heap_no(rec);
+ b.ref_field_no = i;
+ b.blob_page_no = mach_read_from_4(
+ field_ref + BTR_EXTERN_PAGE_NO);
+ ut_a(b.ref_field_no >= index->n_uniq);
+ btr_blob_dbg_rbt_delete(index, &b, "upd_in_place");
+ }
+#endif /* UNIV_BLOB_DEBUG */
rec_set_nth_field(rec, offsets, upd_field->field_no,
dfield_get_data(new_val),
dfield_get_len(new_val));
+
+#ifdef UNIV_BLOB_DEBUG
+ if (dfield_is_ext(new_val)) {
+ b.blob_page_no = mach_read_from_4(
+ field_ref + BTR_EXTERN_PAGE_NO);
+ b.always_owner = b.owner = !(field_ref[BTR_EXTERN_LEN]
+ & BTR_EXTERN_OWNER_FLAG);
+ b.del = rec_get_deleted_flag(
+ rec, rec_offs_comp(offsets));
+
+ btr_blob_dbg_rbt_insert(index, &b, "upd_in_place");
+ }
+#endif /* UNIV_BLOB_DEBUG */
}
if (UNIV_LIKELY_NULL(page_zip)) {
@@ -1192,25 +1227,31 @@ NOTE: we compare the fields as binary strings!
@return TRUE if update vector changes an ordering field in the index record */
UNIV_INTERN
ibool
-row_upd_changes_ord_field_binary(
-/*=============================*/
+row_upd_changes_ord_field_binary_func(
+/*==================================*/
+ dict_index_t* index, /*!< in: index of the record */
+ const upd_t* update, /*!< in: update vector for the row; NOTE: the
+ field numbers in this MUST be clustered index
+ positions! */
+#ifdef UNIV_DEBUG
+ const que_thr_t*thr, /*!< in: query thread */
+#endif /* UNIV_DEBUG */
const dtuple_t* row, /*!< in: old value of row, or NULL if the
row and the data values in update are not
known when this function is called, e.g., at
compile time */
- const row_ext_t*ext, /*!< NULL, or prefixes of the externally
+ const row_ext_t*ext) /*!< NULL, or prefixes of the externally
stored columns in the old row */
- dict_index_t* index, /*!< in: index of the record */
- const upd_t* update) /*!< in: update vector for the row; NOTE: the
- field numbers in this MUST be clustered index
- positions! */
{
ulint n_unique;
ulint i;
const dict_index_t* clust_index;
- ut_ad(update);
ut_ad(index);
+ ut_ad(update);
+ ut_ad(thr);
+ ut_ad(thr->graph);
+ ut_ad(thr->graph->trx);
n_unique = dict_index_get_n_unique(index);
@@ -1252,6 +1293,10 @@ row_upd_changes_ord_field_binary(
|| dfield_is_null(dfield)) {
/* do nothing special */
} else if (UNIV_LIKELY_NULL(ext)) {
+ /* Silence a compiler warning without
+ silencing a Valgrind error. */
+ dfield_len = 0;
+ UNIV_MEM_INVALID(&dfield_len, sizeof dfield_len);
/* See if the column is stored externally. */
buf = row_ext_lookup(ext, col_no, &dfield_len);
@@ -1259,9 +1304,14 @@ row_upd_changes_ord_field_binary(
if (UNIV_LIKELY_NULL(buf)) {
if (UNIV_UNLIKELY(buf == field_ref_zero)) {
- /* This should never happen, but
- we try to fail safe here. */
- ut_ad(0);
+ /* The externally stored field
+ was not written yet. This
+ record should only be seen by
+ recv_recovery_rollback_active(),
+ when the server had crashed before
+ storing the field. */
+ ut_ad(thr->graph->trx->is_recovered);
+ ut_ad(trx_is_recv(thr->graph->trx));
return(TRUE);
}
@@ -1608,8 +1658,8 @@ row_upd_sec_step(
ut_ad(!dict_index_is_clust(node->index));
if (node->state == UPD_NODE_UPDATE_ALL_SEC
- || row_upd_changes_ord_field_binary(node->row, node->ext,
- node->index, node->update)) {
+ || row_upd_changes_ord_field_binary(node->index, node->update,
+ thr, node->row, node->ext)) {
return(row_upd_sec_index_entry(node, thr));
}
@@ -1937,7 +1987,7 @@ row_upd_clust_rec(
index, btr_cur_get_block(btr_cur), rec,
rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap),
- big_rec, mtr);
+ mtr, TRUE, big_rec);
mtr_commit(mtr);
}
@@ -2136,8 +2186,8 @@ exit_func:
row_upd_store_row(node);
- if (row_upd_changes_ord_field_binary(node->row, node->ext, index,
- node->update)) {
+ if (row_upd_changes_ord_field_binary(index, node->update, thr,
+ node->row, node->ext)) {
/* Update causes an ordering field (ordering fields within
the B-tree) of the clustered index record to change: perform
diff --git a/storage/innodb_plugin/row/row0vers.c b/storage/innodb_plugin/row/row0vers.c
index b6d35363f08..d4fde0b939b 100644
--- a/storage/innodb_plugin/row/row0vers.c
+++ b/storage/innodb_plugin/row/row0vers.c
@@ -669,11 +669,15 @@ row_vers_build_for_semi_consistent_read(
mutex_enter(&kernel_mutex);
version_trx = trx_get_on_id(version_trx_id);
+ if (version_trx
+ && (version_trx->conc_state == TRX_COMMITTED_IN_MEMORY
+ || version_trx->conc_state == TRX_NOT_STARTED)) {
+
+ version_trx = NULL;
+ }
mutex_exit(&kernel_mutex);
- if (!version_trx
- || version_trx->conc_state == TRX_NOT_STARTED
- || version_trx->conc_state == TRX_COMMITTED_IN_MEMORY) {
+ if (!version_trx) {
/* We found a version that belongs to a
committed transaction: return it. */
diff --git a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
index f7e7e351bdc..b1fc1ac67fd 100644
--- a/storage/innodb_plugin/srv/srv0srv.c
+++ b/storage/innodb_plugin/srv/srv0srv.c
@@ -243,6 +243,11 @@ UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 75;
/* variable counts amount of data read in total (in bytes) */
UNIV_INTERN ulint srv_data_read = 0;
+/* Internal setting for "innodb_stats_method". Decides how InnoDB treats
+NULL value when collecting statistics. By default, it is set to
+SRV_STATS_NULLS_EQUAL(0), ie. all NULL value are treated equal */
+ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL;
+
/* here we count the amount of data written in total (in bytes) */
UNIV_INTERN ulint srv_data_written = 0;
@@ -2231,6 +2236,12 @@ srv_error_monitor_thread(
ulint fatal_cnt = 0;
ib_uint64_t old_lsn;
ib_uint64_t new_lsn;
+ /* longest waiting thread for a semaphore */
+ os_thread_id_t waiter = os_thread_get_curr_id();
+ os_thread_id_t old_waiter = waiter;
+ /* the semaphore that is being waited for */
+ const void* sema = NULL;
+ const void* old_sema = NULL;
old_lsn = srv_start_lsn;
@@ -2279,7 +2290,8 @@ loop:
sync_arr_wake_threads_if_sema_free();
- if (sync_array_print_long_waits()) {
+ if (sync_array_print_long_waits(&waiter, &sema)
+ && sema == old_sema && os_thread_eq(waiter, old_waiter)) {
fatal_cnt++;
if (fatal_cnt > 10) {
@@ -2294,6 +2306,8 @@ loop:
}
} else {
fatal_cnt = 0;
+ old_waiter = waiter;
+ old_sema = sema;
}
/* Flush stderr so that a database user gets the output
diff --git a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
index 73f8f319704..f8b5049ca65 100644
--- a/storage/innodb_plugin/srv/srv0start.c
+++ b/storage/innodb_plugin/srv/srv0start.c
@@ -1061,6 +1061,12 @@ innobase_start_or_create_for_mysql(void)
);
#endif
+#ifdef UNIV_BLOB_DEBUG
+ fprintf(stderr,
+ "InnoDB: !!!!!!!! UNIV_BLOB_DEBUG switched on !!!!!!!!!\n"
+ "InnoDB: Server restart may fail with UNIV_BLOB_DEBUG\n");
+#endif /* UNIV_BLOB_DEBUG */
+
#ifdef UNIV_SYNC_DEBUG
fprintf(stderr,
"InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n");
diff --git a/storage/innodb_plugin/sync/sync0arr.c b/storage/innodb_plugin/sync/sync0arr.c
index 3c825e2202b..13970023573 100644
--- a/storage/innodb_plugin/sync/sync0arr.c
+++ b/storage/innodb_plugin/sync/sync0arr.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -715,7 +715,7 @@ print:
fprintf(stderr, "rw-lock %p ",
(void*) lock);
sync_array_cell_print(stderr, cell);
- rw_lock_debug_print(debug);
+ rw_lock_debug_print(stderr, debug);
return(TRUE);
}
}
@@ -914,8 +914,10 @@ Prints warnings of long semaphore waits to stderr.
@return TRUE if fatal semaphore wait threshold was exceeded */
UNIV_INTERN
ibool
-sync_array_print_long_waits(void)
-/*=============================*/
+sync_array_print_long_waits(
+/*========================*/
+ os_thread_id_t* waiter, /*!< out: longest waiting thread */
+ const void** sema) /*!< out: longest-waited-for semaphore */
{
sync_cell_t* cell;
ibool old_val;
@@ -923,24 +925,40 @@ sync_array_print_long_waits(void)
ulint i;
ulint fatal_timeout = srv_fatal_semaphore_wait_threshold;
ibool fatal = FALSE;
+ double longest_diff = 0;
for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
+ double diff;
+ void* wait_object;
+
cell = sync_array_get_nth_cell(sync_primary_wait_array, i);
- if (cell->wait_object != NULL && cell->waiting
- && difftime(time(NULL), cell->reservation_time) > 240) {
+ wait_object = cell->wait_object;
+
+ if (wait_object == NULL || !cell->waiting) {
+
+ continue;
+ }
+
+ diff = difftime(time(NULL), cell->reservation_time);
+
+ if (diff > 240) {
fputs("InnoDB: Warning: a long semaphore wait:\n",
stderr);
sync_array_cell_print(stderr, cell);
noticed = TRUE;
}
- if (cell->wait_object != NULL && cell->waiting
- && difftime(time(NULL), cell->reservation_time)
- > fatal_timeout) {
+ if (diff > fatal_timeout) {
fatal = TRUE;
}
+
+ if (diff > longest_diff) {
+ longest_diff = diff;
+ *sema = wait_object;
+ *waiter = cell->thread;
+ }
}
if (noticed) {
diff --git a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sync0rw.c
index 572c3690a7f..a5da606ad80 100644
--- a/storage/innodb_plugin/sync/sync0rw.c
+++ b/storage/innodb_plugin/sync/sync0rw.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -260,6 +260,9 @@ rw_lock_create_func(
contains garbage at initialization and cannot be used for
recursive x-locking. */
lock->recursive = FALSE;
+ /* Silence Valgrind when UNIV_DEBUG_VALGRIND is not enabled. */
+ memset((void*) &lock->writer_thread, 0, sizeof lock->writer_thread);
+ UNIV_MEM_INVALID(&lock->writer_thread, sizeof lock->writer_thread);
#ifdef UNIV_SYNC_DEBUG
UT_LIST_INIT(lock->debug_list);
@@ -925,7 +928,7 @@ rw_lock_list_print_info(
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
- rw_lock_debug_print(info);
+ rw_lock_debug_print(file, info);
info = UT_LIST_GET_NEXT(list, info);
}
}
@@ -973,7 +976,7 @@ rw_lock_print(
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
- rw_lock_debug_print(info);
+ rw_lock_debug_print(stderr, info);
info = UT_LIST_GET_NEXT(list, info);
}
}
@@ -985,28 +988,29 @@ UNIV_INTERN
void
rw_lock_debug_print(
/*================*/
+ FILE* f, /*!< in: output stream */
rw_lock_debug_t* info) /*!< in: debug struct */
{
ulint rwt;
rwt = info->lock_type;
- fprintf(stderr, "Locked: thread %lu file %s line %lu ",
+ fprintf(f, "Locked: thread %lu file %s line %lu ",
(ulong) os_thread_pf(info->thread_id), info->file_name,
(ulong) info->line);
if (rwt == RW_LOCK_SHARED) {
- fputs("S-LOCK", stderr);
+ fputs("S-LOCK", f);
} else if (rwt == RW_LOCK_EX) {
- fputs("X-LOCK", stderr);
+ fputs("X-LOCK", f);
} else if (rwt == RW_LOCK_WAIT_EX) {
- fputs("WAIT X-LOCK", stderr);
+ fputs("WAIT X-LOCK", f);
} else {
ut_error;
}
if (info->pass != 0) {
- fprintf(stderr, " pass value %lu", (ulong) info->pass);
+ fprintf(f, " pass value %lu", (ulong) info->pass);
}
- putc('\n', stderr);
+ putc('\n', f);
}
/***************************************************************//**
diff --git a/storage/innodb_plugin/trx/trx0i_s.c b/storage/innodb_plugin/trx/trx0i_s.c
index e148234888b..5cc9df2d5c4 100644
--- a/storage/innodb_plugin/trx/trx0i_s.c
+++ b/storage/innodb_plugin/trx/trx0i_s.c
@@ -504,7 +504,7 @@ fill_trx_row(
query[stmt_len] = '\0';
row->trx_query = ha_storage_put_memlim(
- cache->storage, stmt, stmt_len + 1,
+ cache->storage, query, stmt_len + 1,
MAX_ALLOWED_FOR_STORAGE(cache));
row->trx_query_cs = innobase_get_charset(trx->mysql_thd);
diff --git a/storage/innodb_plugin/trx/trx0roll.c b/storage/innodb_plugin/trx/trx0roll.c
index 1a43e419214..a4bbf7fd652 100644
--- a/storage/innodb_plugin/trx/trx0roll.c
+++ b/storage/innodb_plugin/trx/trx0roll.c
@@ -48,8 +48,8 @@ Created 3/26/1996 Heikki Tuuri
rollback */
#define TRX_ROLL_TRUNC_THRESHOLD 1
-/** In crash recovery, the current trx to be rolled back */
-static trx_t* trx_roll_crash_recv_trx = NULL;
+/** In crash recovery, the current trx to be rolled back; NULL otherwise */
+static const trx_t* trx_roll_crash_recv_trx = NULL;
/** In crash recovery we set this to the undo n:o of the current trx to be
rolled back. Then we can print how many % the rollback has progressed. */
diff --git a/storage/innodb_plugin/trx/trx0trx.c b/storage/innodb_plugin/trx/trx0trx.c
index adece596e1b..1400b11035f 100644
--- a/storage/innodb_plugin/trx/trx0trx.c
+++ b/storage/innodb_plugin/trx/trx0trx.c
@@ -2010,18 +2010,18 @@ trx_recover_for_mysql(
/*******************************************************************//**
This function is used to find one X/Open XA distributed transaction
which is in the prepared state
-@return trx or NULL */
+@return trx or NULL; on match, the trx->xid will be invalidated */
UNIV_INTERN
trx_t*
trx_get_trx_by_xid(
/*===============*/
- XID* xid) /*!< in: X/Open XA transaction identification */
+ const XID* xid) /*!< in: X/Open XA transaction identifier */
{
trx_t* trx;
if (xid == NULL) {
- return (NULL);
+ return(NULL);
}
mutex_enter(&kernel_mutex);
@@ -2034,10 +2034,16 @@ trx_get_trx_by_xid(
of gtrid_lenght+bqual_length bytes should be
the same */
- if (xid->gtrid_length == trx->xid.gtrid_length
+ if (trx->conc_state == TRX_PREPARED
+ && xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
&& memcmp(xid->data, trx->xid.data,
xid->gtrid_length + xid->bqual_length) == 0) {
+
+ /* Invalidate the XID, so that subsequent calls
+ will not find it. */
+ memset(&trx->xid, 0, sizeof(trx->xid));
+ trx->xid.formatID = -1;
break;
}
@@ -2046,14 +2052,5 @@ trx_get_trx_by_xid(
mutex_exit(&kernel_mutex);
- if (trx) {
- if (trx->conc_state != TRX_PREPARED) {
-
- return(NULL);
- }
-
- return(trx);
- } else {
- return(NULL);
- }
+ return(trx);
}
diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt
index c9d3cab3359..7e32d2fe3d8 100644
--- a/storage/maria/CMakeLists.txt
+++ b/storage/maria/CMakeLists.txt
@@ -40,7 +40,7 @@ SET(ARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
ha_maria.cc trnman.c lockman.c tablockman.c
ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c
ma_sp_key.c ma_control_file.c ma_loghandler.c
- ma_pagecache.c ma_pagecaches.c compat_aliases.cc compat_aliases.h
+ ma_pagecache.c ma_pagecaches.c
ma_checkpoint.c ma_recovery.c ma_commit.c ma_pagecrc.c
ha_maria.h maria_def.h ma_recovery_util.c ma_servicethread.c
ma_norec.c
diff --git a/storage/maria/Makefile.am b/storage/maria/Makefile.am
index 3c94ffc29ec..fa01c2a602d 100644
--- a/storage/maria/Makefile.am
+++ b/storage/maria/Makefile.am
@@ -79,7 +79,7 @@ noinst_HEADERS = maria_def.h ma_rt_index.h ma_rt_key.h ma_rt_mbr.h \
ma_checkpoint.h ma_recovery.h ma_commit.h ma_state.h \
trnman_public.h ma_check_standalone.h \
ma_key_recover.h ma_recovery_util.h \
- ma_servicethread.h compat_aliases.h
+ ma_servicethread.h
ma_test1_DEPENDENCIES= $(LIBRARIES)
ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
$(top_builddir)/storage/myisam/libmyisam.a \
@@ -142,7 +142,7 @@ libaria_la_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \
ma_pagecache.c ma_pagecaches.c \
ma_checkpoint.c ma_recovery.c ma_commit.c \
ma_pagecrc.c ma_recovery_util.c \
- compat_aliases.cc ma_servicethread.c
+ ma_servicethread.c
libaria_s_la_SOURCES = ha_maria.cc
libaria_s_la_CXXFLAGS = $(AM_CXXFLAGS)
diff --git a/storage/maria/compat_aliases.cc b/storage/maria/compat_aliases.cc
deleted file mode 100644
index 2d3c67d69a7..00000000000
--- a/storage/maria/compat_aliases.cc
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Copyright (C) 2010 Monty Program Ab
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- compatibility aliases for system and static variables
-*/
-#include <my_global.h>
-#include <maria.h>
-#include <mysql/plugin.h>
-#include "ma_loghandler.h"
-#include "compat_aliases.h"
-
-ulong block_size_alias;
-static MYSQL_SYSVAR_ULONG(block_size, block_size_alias,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
- "Deprecated, use --aria-block-size instead", 0, 0,
- MARIA_KEY_BLOCK_LENGTH, MARIA_MIN_KEY_BLOCK_LENGTH,
- MARIA_MAX_KEY_BLOCK_LENGTH, MARIA_MIN_KEY_BLOCK_LENGTH);
-
-ulong checkpoint_interval_alias;
-static MYSQL_SYSVAR_ULONG(checkpoint_interval, checkpoint_interval_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-checkpoint-interval instead",
- NULL, NULL, 30, 0, UINT_MAX, 1);
-
-ulong force_start_after_recovery_failures_alias;
-static MYSQL_SYSVAR_ULONG(force_start_after_recovery_failures, force_start_after_recovery_failures_alias,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
- "Deprecated, use --aria-force-start-after-recovery-failures instead",
- NULL, NULL, 0, 0, UINT_MAX8, 1);
-
-my_bool page_checksum_alias;
-static MYSQL_SYSVAR_BOOL(page_checksum, page_checksum_alias, 0,
- "Deprecated, use --aria-page-checksum instead", 0, 0, 1);
-
-char *log_dir_path_alias;
-static MYSQL_SYSVAR_STR(log_dir_path, log_dir_path_alias,
- PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
- "Deprecated, use --aria-log-dir-path instead",
- NULL, NULL, mysql_real_data_home);
-
-ulong log_file_size_alias;
-static MYSQL_SYSVAR_ULONG(log_file_size, log_file_size_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-log-file-size instead",
- NULL, NULL, TRANSLOG_FILE_SIZE,
- TRANSLOG_MIN_FILE_SIZE, 0xffffffffL, TRANSLOG_PAGE_SIZE);
-
-ulong group_commit_alias;
-static MYSQL_SYSVAR_ENUM(group_commit, group_commit_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-group-commit instead",
- NULL, NULL,
- TRANSLOG_GCOMMIT_NONE, &maria_group_commit_typelib);
-
-ulong group_commit_interval_alias;
-static MYSQL_SYSVAR_ULONG(group_commit_interval, group_commit_interval_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-group-commit-interval instead",
- NULL, NULL, 0, 0, UINT_MAX, 1);
-
-ulong log_purge_type_alias;
-static MYSQL_SYSVAR_ENUM(log_purge_type, log_purge_type_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-log-purge-type instead",
- NULL, NULL, TRANSLOG_PURGE_IMMIDIATE,
- &maria_translog_purge_type_typelib);
-
-ulonglong max_sort_file_size_alias;
-static MYSQL_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-max-temp-length instead",
- 0, 0, MAX_FILE_SIZE, 0, MAX_FILE_SIZE, 1024*1024);
-
-ulong pagecache_age_threshold_alias;
-static MYSQL_SYSVAR_ULONG(pagecache_age_threshold, pagecache_age_threshold_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-pagecache-age-threshold instead",
- 0, 0, 300, 100, ~0L, 100);
-
-ulonglong pagecache_buffer_size_alias;
-static MYSQL_SYSVAR_ULONGLONG(pagecache_buffer_size, pagecache_buffer_size_alias,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
- "Deprecated, use --aria-pagecache-buffer-size instead",
- 0, 0, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~0UL, IO_SIZE);
-
-ulong pagecache_division_limit_alias;
-static MYSQL_SYSVAR_ULONG(pagecache_division_limit, pagecache_division_limit_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-pagecache-division-limit instead",
- 0, 0, 100, 1, 100, 1);
-
-ulong recover_alias;
-static MYSQL_SYSVAR_ENUM(recover, recover_alias, PLUGIN_VAR_OPCMDARG,
- "Deprecated, use --aria-recover instead",
- NULL, NULL, HA_RECOVER_DEFAULT, &maria_recover_typelib);
-
-ulong repair_threads_alias;
-static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-repair-threads instead",
- 0, 0, 1, 1, ~0L, 1);
-
-ulong sort_buffer_size_alias;
-static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-sort-buffer-size instead",
- 0, 0, 128L*1024L*1024L, 4, ~0L, 1);
-
-ulong stats_method_alias;
-static MYSQL_THDVAR_ENUM(stats_method, PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-stats-method instead",
- 0, 0, 0, &maria_stats_method_typelib);
-
-ulong sync_log_dir_alias;
-static MYSQL_SYSVAR_ENUM(sync_log_dir, sync_log_dir_alias,
- PLUGIN_VAR_RQCMDARG,
- "Deprecated, use --aria-sync-log-dir instead",
- NULL, NULL, TRANSLOG_SYNC_DIR_NEWFILE,
- &maria_sync_log_dir_typelib);
-
-my_bool used_for_temp_tables_alias= 1;
-static MYSQL_SYSVAR_BOOL(used_for_temp_tables,
- used_for_temp_tables_alias, PLUGIN_VAR_READONLY | PLUGIN_VAR_NOCMDOPT,
- NULL, 0, 0, 1);
-
-static struct st_mysql_show_var status_variables_aliases[]= {
- {"Maria", (char*) &status_variables, SHOW_ARRAY},
- {NullS, NullS, SHOW_LONG}
-};
-
-/*
- There is one problem with aliases for command-line options.
- Plugin initialization works like this
-
- for all plugins:
- prepare command-line options
- initialize command-line option variables to the default values
- parse command line, assign values as necessary
-
- for all plugins:
- call the plugin initialization function
-
- it means, we cannot have maria* and aria* command-line options to use
- the same underlying variables - because after assigning maria* values,
- MySQL will put there default values again preparing for parsing aria*
- values. So, maria* values will be lost.
-
- So, we create separate set of variables for maria* options,
- and take both values into account in ha_maria_init().
-
- When the command line was parsed, we patch maria* options
- to use the same variables as aria* options so that
- set @@maria_some_var would have the same value as @@aria_some_var
- without forcing us to copy the values around all the time.
-*/
-
-static struct st_mysql_sys_var* system_variables_aliases[]= {
- MYSQL_SYSVAR(block_size),
- MYSQL_SYSVAR(checkpoint_interval),
- MYSQL_SYSVAR(force_start_after_recovery_failures),
- MYSQL_SYSVAR(group_commit),
- MYSQL_SYSVAR(group_commit_interval),
- MYSQL_SYSVAR(log_dir_path),
- MYSQL_SYSVAR(log_file_size),
- MYSQL_SYSVAR(log_purge_type),
- MYSQL_SYSVAR(max_sort_file_size),
- MYSQL_SYSVAR(page_checksum),
- MYSQL_SYSVAR(pagecache_age_threshold),
- MYSQL_SYSVAR(pagecache_buffer_size),
- MYSQL_SYSVAR(pagecache_division_limit),
- MYSQL_SYSVAR(recover),
- MYSQL_SYSVAR(repair_threads),
- MYSQL_SYSVAR(sort_buffer_size),
- MYSQL_SYSVAR(stats_method),
- MYSQL_SYSVAR(sync_log_dir),
- MYSQL_SYSVAR(used_for_temp_tables),
- NULL
-};
-
-#define COPY_SYSVAR(name) \
- memcpy(&MYSQL_SYSVAR_NAME(name), system_variables[i++], \
- sizeof(MYSQL_SYSVAR_NAME(name))); \
- if (name ## _alias != MYSQL_SYSVAR_NAME(name).def_val && \
- *MYSQL_SYSVAR_NAME(name).value == MYSQL_SYSVAR_NAME(name).def_val) \
- *MYSQL_SYSVAR_NAME(name).value= name ## _alias;
-
-#define COPY_THDVAR(name) \
- name ## _alias= THDVAR(0, name); \
- memcpy(&MYSQL_SYSVAR_NAME(name), system_variables[i++], \
- sizeof(MYSQL_SYSVAR_NAME(name))); \
- if (name ## _alias != MYSQL_SYSVAR_NAME(name).def_val && \
- THDVAR(0, name) == MYSQL_SYSVAR_NAME(name).def_val) \
- THDVAR(0, name)= name ## _alias;
-
-void copy_variable_aliases()
-{
- int i= 0;
- COPY_SYSVAR(block_size);
- COPY_SYSVAR(checkpoint_interval);
- COPY_SYSVAR(force_start_after_recovery_failures);
- COPY_SYSVAR(group_commit);
- COPY_SYSVAR(group_commit_interval);
- COPY_SYSVAR(log_dir_path);
- COPY_SYSVAR(log_file_size);
- COPY_SYSVAR(log_purge_type);
- COPY_SYSVAR(max_sort_file_size);
- COPY_SYSVAR(page_checksum);
- COPY_SYSVAR(pagecache_age_threshold);
- COPY_SYSVAR(pagecache_buffer_size);
- COPY_SYSVAR(pagecache_division_limit);
- COPY_SYSVAR(recover);
- COPY_THDVAR(repair_threads);
- COPY_THDVAR(sort_buffer_size);
- COPY_THDVAR(stats_method);
- COPY_SYSVAR(sync_log_dir);
- COPY_SYSVAR(used_for_temp_tables);
-}
-
-struct st_maria_plugin compat_aliases= {
- MYSQL_DAEMON_PLUGIN,
- &maria_storage_engine,
- "Maria",
- "Monty Program Ab",
- "Compatibility aliases for the Aria engine",
- PLUGIN_LICENSE_GPL,
- NULL,
- NULL,
- 0x0105,
- status_variables_aliases,
- system_variables_aliases,
- "1.5",
- MariaDB_PLUGIN_MATURITY_GAMMA
-};
-
diff --git a/storage/maria/compat_aliases.h b/storage/maria/compat_aliases.h
deleted file mode 100644
index 46a4da74eec..00000000000
--- a/storage/maria/compat_aliases.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2010 Monty Program Ab
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-extern struct st_maria_plugin compat_aliases;
-extern char mysql_real_data_home[FN_REFLEN];
-extern TYPELIB maria_recover_typelib;
-extern TYPELIB maria_stats_method_typelib;
-extern TYPELIB maria_translog_purge_type_typelib;
-extern TYPELIB maria_sync_log_dir_typelib;
-extern TYPELIB maria_group_commit_typelib;
-extern struct st_mysql_storage_engine maria_storage_engine;
-extern my_bool use_maria_for_temp_tables;
-extern struct st_mysql_sys_var* system_variables[];
-extern st_mysql_show_var status_variables[];
-void copy_variable_aliases();
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 5d2b2ea42cb..4963e6e7a04 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -29,7 +29,6 @@
#include "ha_maria.h"
#include "trnman_public.h"
#include "trnman.h"
-#include "compat_aliases.h"
C_MODE_START
#include "maria_def.h"
@@ -213,7 +212,8 @@ static MYSQL_SYSVAR_ULONGLONG(max_sort_file_size,
maria_max_temp_length, PLUGIN_VAR_RQCMDARG,
"Don't use the fast sort index method to created index if the "
"temporary file would get bigger than this.",
- 0, 0, MAX_FILE_SIZE & ~(1*MB-1), 0, MAX_FILE_SIZE, 1*MB);
+ 0, 0, MAX_FILE_SIZE & ~((ulonglong) (1*MB-1)),
+ 0, MAX_FILE_SIZE, 1*MB);
static MYSQL_SYSVAR_ULONG(pagecache_age_threshold,
pagecache_age_threshold, PLUGIN_VAR_RQCMDARG,
@@ -500,6 +500,8 @@ static int table2maria(TABLE *table_arg, data_file_type row_type,
if (found->flags & BLOB_FLAG)
recinfo_pos->type= FIELD_BLOB;
+ else if (found->type() == MYSQL_TYPE_TIMESTAMP)
+ recinfo_pos->type= FIELD_NORMAL;
else if (found->type() == MYSQL_TYPE_VARCHAR)
recinfo_pos->type= FIELD_VARCHAR;
else if (!(options & HA_OPTION_PACK_RECORD) ||
@@ -832,9 +834,10 @@ can_enable_indexes(1), bulk_insert_single_undo(BULK_INSERT_NONE)
{}
-handler *ha_maria::clone(MEM_ROOT *mem_root)
+handler *ha_maria::clone(const char *name, MEM_ROOT *mem_root)
{
- ha_maria *new_handler= static_cast <ha_maria *>(handler::clone(mem_root));
+ ha_maria *new_handler= static_cast <ha_maria *>(handler::clone(name,
+ mem_root));
if (new_handler)
{
new_handler->file->state= file->state;
@@ -2354,7 +2357,7 @@ void ha_maria::position(const uchar *record)
int ha_maria::info(uint flag)
{
- return info(flag, table->s->tmp_table == NO_TMP_TABLE);
+ return (!table ? 1 : info(flag, table->s->tmp_table == NO_TMP_TABLE));
}
int ha_maria::info(uint flag, my_bool lock_table_share)
@@ -3366,7 +3369,6 @@ bool ha_maria::is_changed() const
static int ha_maria_init(void *p)
{
int res;
- copy_variable_aliases();
const char *log_dir= maria_data_root;
maria_hton= (handlerton *)p;
maria_hton->state= SHOW_OPTION_YES;
@@ -3714,7 +3716,6 @@ struct st_mysql_storage_engine maria_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
maria_declare_plugin(aria)
-compat_aliases,
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&maria_storage_engine,
diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h
index 58f99fe237c..0ba134a5b45 100644
--- a/storage/maria/ha_maria.h
+++ b/storage/maria/ha_maria.h
@@ -57,7 +57,7 @@ class ha_maria :public handler
public:
ha_maria(handlerton *hton, TABLE_SHARE * table_arg);
~ha_maria() {}
- handler *clone(MEM_ROOT *mem_root);
+ handler *clone(const char *name, MEM_ROOT *mem_root);
const char *table_type() const
{ return "Aria"; }
const char *index_type(uint key_number);
diff --git a/storage/maria/lockman.c b/storage/maria/lockman.c
index d6d4dcd44e6..459ee5d8ae2 100644
--- a/storage/maria/lockman.c
+++ b/storage/maria/lockman.c
@@ -690,12 +690,12 @@ enum lockman_getlock_result lockman_getlock(LOCKMAN *lm, LOCK_OWNER *lo,
}
/* yuck. waiting */
- deadline= my_getsystime() + lm->lock_timeout * 10000;
- set_timespec_nsec(timeout,lm->lock_timeout * 1000000);
+ deadline= my_hrtime().val*1000 + lm->lock_timeout * 1000000;
+ set_timespec_time_nsec(timeout, deadline);
do
{
pthread_cond_timedwait(wait_for_lo->cond, wait_for_lo->mutex, &timeout);
- } while (!DELETED(blocker->link) && my_getsystime() < deadline);
+ } while (!DELETED(blocker->link) && my_hrtime().val < deadline/1000);
pthread_mutex_unlock(wait_for_lo->mutex);
lf_rwlock_by_pins(pins);
if (!DELETED(blocker->link))
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index 62eac2d8873..63e60cc8465 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -234,14 +234,14 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
{
if (test_flag & T_VERBOSE) puts("");
_ma_check_print_error(param,"Can't read delete-link at filepos: %s",
- llstr(next_link,buff));
+ llstr(next_link,buff));
DBUG_RETURN(1);
}
if (*buff != '\0')
{
if (test_flag & T_VERBOSE) puts("");
_ma_check_print_error(param,"Record at pos: %s is not remove-marked",
- llstr(next_link,buff));
+ llstr(next_link,buff));
goto wrong;
}
if (share->options & HA_OPTION_PACK_RECORD)
@@ -250,7 +250,9 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
if (empty && prev_link != old_link)
{
if (test_flag & T_VERBOSE) puts("");
- _ma_check_print_error(param,"Deleted block at %s doesn't point back at previous delete link",llstr(next_link,buff2));
+ _ma_check_print_error(param,
+ "Deleted block at %s doesn't point back at previous delete link",
+ llstr(next_link,buff2));
goto wrong;
}
old_link=next_link;
@@ -269,23 +271,23 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
if (empty != share->state.state.empty)
{
_ma_check_print_warning(param,
- "Found %s deleted space in delete link chain. Should be %s",
- llstr(empty,buff2),
- llstr(share->state.state.empty,buff));
+ "Found %s deleted space in delete link chain. Should be %s",
+ llstr(empty,buff2),
+ llstr(share->state.state.empty,buff));
}
if (next_link != HA_OFFSET_ERROR)
{
_ma_check_print_error(param,
- "Found more than the expected %s deleted rows in delete link chain",
- llstr(share->state.state.del, buff));
+ "Found more than the expected %s deleted rows in delete link chain",
+ llstr(share->state.state.del, buff));
goto wrong;
}
if (i != 0)
{
_ma_check_print_error(param,
- "Found %s deleted rows in delete link chain. Should be %s",
- llstr(share->state.state.del - i, buff2),
- llstr(share->state.state.del, buff));
+ "Found %s deleted rows in delete link chain. Should be %s",
+ llstr(share->state.state.del - i, buff2),
+ llstr(share->state.state.del, buff));
goto wrong;
}
}
@@ -423,8 +425,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
ulonglong2double(share->state.state.key_file_length) >
ulonglong2double(share->base.margin_key_file_length)*0.9)
_ma_check_print_warning(param,"Keyfile is almost full, %10s of %10s used",
- llstr(share->state.state.key_file_length,buff),
- llstr(share->base.max_key_file_length-1,buff));
+ llstr(share->state.state.key_file_length,buff),
+ llstr(share->base.max_key_file_length-1,buff));
size= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
skr=(my_off_t) share->state.state.data_file_length;
@@ -448,8 +450,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
else
{
_ma_check_print_warning(param,
- "Size of datafile is: %-9s Should be: %s",
- llstr(size,buff), llstr(skr,buff2));
+ "Size of datafile is: %-9s Should be: %s",
+ llstr(size,buff), llstr(skr,buff2));
}
}
if (!(param->testflag & T_VERY_SILENT) &&
@@ -457,8 +459,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
ulonglong2double(share->state.state.data_file_length) >
(ulonglong2double(share->base.max_data_file_length)*0.9))
_ma_check_print_warning(param, "Datafile is almost full, %10s of %10s used",
- llstr(share->state.state.data_file_length,buff),
- llstr(share->base.max_data_file_length-1,buff2));
+ llstr(share->state.state.data_file_length,buff),
+ llstr(share->base.max_data_file_length-1,buff2));
DBUG_RETURN(error);
} /* maria_chk_size */
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index 0ed7b7d62d2..6737030cd89 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -204,7 +204,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
pack_reclength++;
not_block_record_extra_length++;
max_field_lengths++;
- packed++;
+ if (datafile_type != DYNAMIC_RECORD)
+ packed++;
column->fill_length= 1;
options|= HA_OPTION_NULL_FIELDS; /* Use ma_checksum() */
diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c
index b050d61b5a2..7aee13255de 100644
--- a/storage/maria/ma_init.c
+++ b/storage/maria/ma_init.c
@@ -21,6 +21,7 @@
#include "trnman_public.h"
#include "ma_checkpoint.h"
#include <hash.h>
+#include <my_handler.h>
void history_state_free(MARIA_STATE_HISTORY_CLOSED *closed_history)
{
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index fc8edbe36e4..d57b7e0be72 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -458,7 +458,9 @@ void translog_lock_handler_assert_owner()
@param num how many records should be filled
*/
-static void check_translog_description_table(int num)
+static uint max_allowed_translog_type= 0;
+
+void check_translog_description_table(int num)
{
int i;
DBUG_ENTER("check_translog_description_table");
@@ -467,6 +469,7 @@ static void check_translog_description_table(int num)
/* last is reserved for extending the table */
DBUG_ASSERT(num < LOGREC_NUMBER_OF_TYPES - 1);
DBUG_ASSERT(log_record_type_descriptor[0].rclass == LOGRECTYPE_NOT_ALLOWED);
+ max_allowed_translog_type= num;
for (i= 0; i <= num; i++)
{
@@ -1078,7 +1081,7 @@ static my_bool translog_write_file_header()
memcpy(page, maria_trans_file_magic, sizeof(maria_trans_file_magic));
page+= sizeof(maria_trans_file_magic);
/* timestamp */
- timestamp= my_getsystime();
+ timestamp= my_hrtime().val;
int8store(page, timestamp);
page+= 8;
/* maria version */
@@ -3583,6 +3586,7 @@ my_bool translog_init_with_table(const char *directory,
log_descriptor.flush_no= 0;
log_descriptor.next_pass_max_lsn= LSN_IMPOSSIBLE;
+ /* Normally in Aria this this calls translog_table_init() */
(*init_table_func)();
compile_time_assert(sizeof(log_descriptor.dirty_buffer_mask) * 8 >=
TRANSLOG_BUFFERS_NO);
@@ -6224,6 +6228,8 @@ my_bool translog_write_record(LSN *lsn,
(uint) short_trid, (ulong) rec_len));
DBUG_ASSERT(translog_status == TRANSLOG_OK ||
translog_status == TRANSLOG_READONLY);
+ DBUG_ASSERT(type != 0);
+ DBUG_ASSERT((uint)type <= max_allowed_translog_type);
if (unlikely(translog_status != TRANSLOG_OK))
{
DBUG_PRINT("error", ("Transaction log is write protected"));
@@ -6322,9 +6328,9 @@ my_bool translog_write_record(LSN *lsn,
/* process this parts */
if (!(rc= (log_record_type_descriptor[type].prewrite_hook &&
- (*log_record_type_descriptor[type].prewrite_hook) (type, trn,
- tbl_info,
- hook_arg))))
+ (*log_record_type_descriptor[type].prewrite_hook)(type, trn,
+ tbl_info,
+ hook_arg))))
{
switch (log_record_type_descriptor[type].rclass) {
case LOGRECTYPE_VARIABLE_LENGTH:
@@ -6337,6 +6343,7 @@ my_bool translog_write_record(LSN *lsn,
short_trid, &parts, trn, hook_arg);
break;
case LOGRECTYPE_NOT_ALLOWED:
+ DBUG_ASSERT(0);
default:
DBUG_ASSERT(0);
rc= 1;
@@ -7712,7 +7719,7 @@ static my_bool translog_sync_files(uint32 min, uint32 max,
flush_interval= group_commit_wait;
if (flush_interval)
- flush_start= my_micro_time();
+ flush_start= microsecond_interval_timer();
for (fn= min; fn <= max; fn++)
{
TRANSLOG_FILE *file= get_logfile_by_number(fn);
@@ -7979,7 +7986,8 @@ retest:
/*
We do not check time here because pthread_mutex_lock rarely takes
a lot of time so we can sacrifice a bit precision to performance
- (taking into account that my_micro_time() might be expensive call).
+ (taking into account that microsecond_interval_timer() might be
+ expensive call).
*/
if (flush_interval == 0)
break; /* flush pass is ended */
@@ -7988,7 +7996,8 @@ retest:
if (log_descriptor.next_pass_max_lsn == LSN_IMPOSSIBLE)
{
if (flush_interval == 0 ||
- (time_spent= (my_micro_time() - flush_start)) >= flush_interval)
+ (time_spent= (microsecond_interval_timer() - flush_start)) >=
+ flush_interval)
{
pthread_mutex_unlock(&log_descriptor.log_flush_lock);
break;
@@ -8779,7 +8788,7 @@ ma_soft_sync_background( void *arg __attribute__((unused)))
DBUG_ENTER("ma_soft_sync_background");
for(;;)
{
- ulonglong prev_loop= my_micro_time();
+ ulonglong prev_loop= microsecond_interval_timer();
ulonglong time, sleep;
uint32 min, max, sync_request;
min= soft_sync_min;
@@ -8791,7 +8800,7 @@ ma_soft_sync_background( void *arg __attribute__((unused)))
sleep= group_commit_wait;
if (sync_request)
translog_sync_files(min, max, FALSE);
- time= my_micro_time() - prev_loop;
+ time= microsecond_interval_timer() - prev_loop;
if (time > sleep)
sleep= 0;
else
diff --git a/storage/maria/ma_loghandler.h b/storage/maria/ma_loghandler.h
index f33e92e9771..5ac6d67413a 100644
--- a/storage/maria/ma_loghandler.h
+++ b/storage/maria/ma_loghandler.h
@@ -312,6 +312,9 @@ extern my_bool translog_init_with_table(const char *directory,
my_bool readonly,
void (*init_table_func)(),
my_bool no_error);
+#ifndef DBUG_OFF
+void check_translog_description_table(int num);
+#endif
extern my_bool
translog_write_record(LSN *lsn, enum translog_record_type type, TRN *trn,
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 5be30dee0b5..697d6ac7803 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -335,7 +335,7 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
}
}
- now= my_getsystime();
+ now= microsecond_interval_timer();
in_redo_phase= TRUE;
trnman_init(max_trid_in_control_file);
if (run_redo_phase(from_lsn, end_lsn, apply))
@@ -366,10 +366,10 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
in_redo_phase= FALSE;
old_now= now;
- now= my_getsystime();
+ now= microsecond_interval_timer();
if (recovery_message_printed == REC_MSG_REDO)
{
- double phase_took= (now - old_now)/10000000.0;
+ double phase_took= (now - old_now)/1000000.0;
/*
Detailed progress info goes to stderr, because ma_message_no_user()
cannot put several messages on one line.
@@ -435,10 +435,10 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
}
old_now= now;
- now= my_getsystime();
+ now= microsecond_interval_timer();
if (recovery_message_printed == REC_MSG_UNDO)
{
- double phase_took= (now - old_now)/10000000.0;
+ double phase_took= (now - old_now)/1000000.0;
procent_printed= 1;
fprintf(stderr, " (%.1f seconds); ", phase_took);
fflush(stderr);
@@ -455,10 +455,10 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
}
old_now= now;
- now= my_getsystime();
+ now= microsecond_interval_timer();
if (recovery_message_printed == REC_MSG_FLUSH)
{
- double phase_took= (now - old_now)/10000000.0;
+ double phase_took= (now - old_now)/1000000.0;
procent_printed= 1;
fprintf(stderr, " (%.1f seconds); ", phase_took);
fflush(stderr);
diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c
index 29cb56f426b..b687484b0eb 100644
--- a/storage/maria/maria_chk.c
+++ b/storage/maria/maria_chk.c
@@ -938,7 +938,13 @@ static void get_options(register int *argc,register char ***argv)
} /* get options */
- /* Check table */
+/**
+ Check/repair table
+
+ @return 0 table is ok
+ @return 1 Got warning during check
+ @return 2 Got error during check/repair.
+*/
static int maria_chk(HA_CHECK *param, char *filename)
{
@@ -1404,6 +1410,7 @@ end2:
if (param->error_printed)
{
+ error= 2;
if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
{
VOID(fprintf(stderr,
@@ -1422,8 +1429,12 @@ end2:
else if (param->warning_printed &&
! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_FORCE_CREATE)))
+ {
+ if (!error)
+ error= 1;
VOID(fprintf(stderr, "Aria table '%s' is usable but should be fixed\n",
filename));
+ }
VOID(fflush(stderr));
DBUG_RETURN(error);
} /* maria_chk */
@@ -1754,14 +1765,14 @@ static int maria_sort_records(HA_CHECK *param,
{
_ma_check_print_warning(param,
"Can't sort table '%s' on key %d; No such key",
- name,sort_key+1);
+ name,sort_key+1);
param->error_printed=0;
DBUG_RETURN(0); /* Nothing to do */
}
if (keyinfo->flag & HA_FULLTEXT)
{
_ma_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d",
- name,sort_key+1);
+ name,sort_key+1);
param->error_printed=0;
DBUG_RETURN(0); /* Nothing to do */
}
diff --git a/storage/maria/tablockman.c b/storage/maria/tablockman.c
index 1bb8889aaa7..eb494a8d19b 100644
--- a/storage/maria/tablockman.c
+++ b/storage/maria/tablockman.c
@@ -607,7 +607,7 @@ void tablockman_init(TABLOCKMAN *lm, loid_to_tlo_func *func, uint timeout)
lm->loid_to_tlo= func;
lm->lock_timeout= timeout;
pthread_mutex_init(& lm->pool_mutex, MY_MUTEX_INIT_FAST);
- my_getsystime(); /* ensure that my_getsystime() is initialized */
+ my_interval_timer(); /* ensure that my_interval_timer() is initialized */
}
void tablockman_destroy(TABLOCKMAN *lm)
diff --git a/storage/maria/unittest/ma_control_file-t.c b/storage/maria/unittest/ma_control_file-t.c
index 164ea284f31..ca559fe57df 100644
--- a/storage/maria/unittest/ma_control_file-t.c
+++ b/storage/maria/unittest/ma_control_file-t.c
@@ -117,6 +117,26 @@ static CONTROL_FILE_ERROR local_ma_control_file_open(void)
return error;
}
+static char *create_tmpdir(const char *progname)
+{
+ static char test_dirname[FN_REFLEN];
+ char tmp_name[FN_REFLEN];
+ uint length;
+
+ /* Create a temporary directory of name TMP-'executable', but without the -t extension */
+ fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
+ length= strlen(tmp_name);
+ if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
+ tmp_name[length-2]= 0;
+ strxmov(test_dirname, "TMP-", tmp_name, NullS);
+
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ (void) my_mkdir(test_dirname, 0777, MYF(0));
+ return test_dirname;
+}
int main(int argc,char *argv[])
@@ -124,11 +144,12 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]);
my_init();
- maria_data_root= (char *)".";
default_error_handler_hook= error_handler_hook;
plan(12);
+ maria_data_root= create_tmpdir(argv[0]);
+
diag("Unit tests for control file");
get_options(argc,argv);
@@ -155,6 +176,9 @@ int main(int argc,char *argv[])
ok(0 == test_bad_blocksize(), "test of bad blocksize");
ok(0 == test_bad_size(), "test of too small/big file");
+ delete_file(0);
+ rmdir(maria_data_root);
+
return exit_status();
}
diff --git a/storage/maria/unittest/ma_loghandler_examples.c b/storage/maria/unittest/ma_loghandler_examples.c
index 0c11a3b9a8e..cd5d927587a 100644
--- a/storage/maria/unittest/ma_loghandler_examples.c
+++ b/storage/maria/unittest/ma_loghandler_examples.c
@@ -59,6 +59,9 @@ void translog_example_table_init()
i < LOGREC_NUMBER_OF_TYPES;
i++)
log_record_type_descriptor[i].rclass= LOGRECTYPE_NOT_ALLOWED;
+#ifndef DBUG_OFF
+ check_translog_description_table(LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE);
+#endif
}
diff --git a/storage/maria/unittest/ma_maria_log_cleanup.c b/storage/maria/unittest/ma_maria_log_cleanup.c
index f85c75b1a88..5e84acf41af 100644
--- a/storage/maria/unittest/ma_maria_log_cleanup.c
+++ b/storage/maria/unittest/ma_maria_log_cleanup.c
@@ -16,7 +16,7 @@
#include "../maria_def.h"
#include <my_dir.h>
-my_bool maria_log_remove()
+my_bool maria_log_remove(const char *testdir)
{
MY_DIR *dirp;
uint i;
@@ -59,6 +59,28 @@ my_bool maria_log_remove()
}
}
my_dirend(dirp);
+ if (testdir)
+ rmdir(testdir);
return 0;
}
+char *create_tmpdir(const char *progname)
+{
+ static char test_dirname[FN_REFLEN];
+ char tmp_name[FN_REFLEN];
+ uint length;
+
+ /* Create a temporary directory of name TMP-'executable', but without the -t extension */
+ fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
+ length= strlen(tmp_name);
+ if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
+ tmp_name[length-2]= 0;
+ strxmov(test_dirname, "TMP-", tmp_name, NullS);
+
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ (void) my_mkdir(test_dirname, 0777, MYF(0));
+ return test_dirname;
+}
diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c
index 0a9e5737c7e..c060f7691a6 100644
--- a/storage/maria/unittest/ma_pagecache_consist.c
+++ b/storage/maria/unittest/ma_pagecache_consist.c
@@ -30,7 +30,8 @@
static const char* default_dbug_option;
#endif
-static char *file1_name= (char*)"page_cache_test_file_1";
+static const char *base_file1_name= "page_cache_test_file_1";
+static char file1_name[FN_REFLEN];
static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
@@ -330,6 +331,27 @@ static void *test_thread_writer(void *arg)
return 0;
}
+static char *create_tmpdir(const char *progname)
+{
+ static char test_dirname[FN_REFLEN];
+ char tmp_name[FN_REFLEN];
+ uint length;
+
+ /* Create a temporary directory of name TMP-'executable', but without the -t extension */
+ fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
+ length= strlen(tmp_name);
+ if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
+ tmp_name[length-2]= 0;
+ strxmov(test_dirname, "TMP-", tmp_name, NullS);
+
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ (void) my_mkdir(test_dirname, 0777, MYF(0));
+ return test_dirname;
+}
+
int main(int argc __attribute__((unused)),
char **argv __attribute__((unused)))
@@ -337,7 +359,6 @@ int main(int argc __attribute__((unused)),
pthread_t tid;
pthread_attr_t thr_attr;
int *param, error, pagen;
-
MY_INIT(argv[0]);
#ifndef DBUG_OFF
@@ -357,9 +378,13 @@ int main(int argc __attribute__((unused)),
DBUG_ENTER("main");
DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name()));
plan(number_of_writers + number_of_readers);
+
SKIP_BIG_TESTS(number_of_writers + number_of_readers)
{
+ char *test_dirname= create_tmpdir(argv[0]);
+ fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
+
if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{
@@ -491,6 +516,7 @@ int main(int argc __attribute__((unused)),
DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end"));
+ rmdir(test_dirname);
} /* SKIP_BIG_TESTS */
my_end(0);
diff --git a/storage/maria/unittest/ma_pagecache_rwconsist.c b/storage/maria/unittest/ma_pagecache_rwconsist.c
index ff386c48414..511a503f349 100644
--- a/storage/maria/unittest/ma_pagecache_rwconsist.c
+++ b/storage/maria/unittest/ma_pagecache_rwconsist.c
@@ -33,7 +33,8 @@ static const char* default_dbug_option;
#define SLEEP my_sleep(5)
-static char *file1_name= (char*)"page_cache_test_file_1";
+static const char *base_file1_name= "page_cache_test_file_1";
+static char file1_name[FN_REFLEN];
static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
@@ -200,6 +201,27 @@ static void *test_thread_writer(void *arg)
return 0;
}
+char *create_tmpdir(const char *progname)
+{
+ static char test_dirname[FN_REFLEN];
+ char tmp_name[FN_REFLEN];
+ uint length;
+
+ /* Create a temporary directory of name TMP-'executable', but without the -t extension */
+ fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
+ length= strlen(tmp_name);
+ if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
+ tmp_name[length-2]= 0;
+ strxmov(test_dirname, "TMP-", tmp_name, NullS);
+
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ (void) my_mkdir(test_dirname, 0777, MYF(0));
+ return test_dirname;
+}
+
int main(int argc __attribute__((unused)),
char **argv __attribute__((unused)))
@@ -230,6 +252,9 @@ int main(int argc __attribute__((unused)),
SKIP_BIG_TESTS(number_of_writers + number_of_readers)
{
+ char *test_dirname= create_tmpdir(argv[0]);
+ fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
+
if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{
@@ -355,6 +380,8 @@ int main(int argc __attribute__((unused)),
DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end"));
+
+ rmdir(test_dirname);
} /* SKIP_BIG_TESTS */
my_end(0);
diff --git a/storage/maria/unittest/ma_pagecache_rwconsist2.c b/storage/maria/unittest/ma_pagecache_rwconsist2.c
index 34183a2d0ab..97d821832fe 100644
--- a/storage/maria/unittest/ma_pagecache_rwconsist2.c
+++ b/storage/maria/unittest/ma_pagecache_rwconsist2.c
@@ -40,7 +40,8 @@ static const char* default_dbug_option;
#define SLEEP my_sleep(5)
-static char *file1_name= (char*)"page_cache_test_file_1";
+static const char *base_file1_name= "page_cache_test_file_1";
+static char file1_name[FN_REFLEN];
static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
@@ -196,6 +197,27 @@ static void *test_thread_writer(void *arg)
return 0;
}
+static char *create_tmpdir(const char *progname)
+{
+ static char test_dirname[FN_REFLEN];
+ char tmp_name[FN_REFLEN];
+ uint length;
+
+ /* Create a temporary directory of name TMP-'executable', but without the -t extension */
+ fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
+ length= strlen(tmp_name);
+ if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
+ tmp_name[length-2]= 0;
+ strxmov(test_dirname, "TMP-", tmp_name, NullS);
+
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ (void) my_mkdir(test_dirname, 0777, MYF(0));
+ return test_dirname;
+}
+
int main(int argc __attribute__((unused)),
char **argv __attribute__((unused)))
@@ -226,6 +248,9 @@ int main(int argc __attribute__((unused)),
SKIP_BIG_TESTS(number_of_writers + number_of_readers)
{
+ char *test_dirname= create_tmpdir(argv[0]);
+ fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
+
if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{
@@ -350,6 +375,8 @@ int main(int argc __attribute__((unused)),
DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end"));
+
+ rmdir(test_dirname);
} /* SKIP_BIG_TESTS */
my_end(0);
diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c
index 32e588e165a..750339f3074 100644
--- a/storage/maria/unittest/ma_pagecache_single.c
+++ b/storage/maria/unittest/ma_pagecache_single.c
@@ -35,8 +35,9 @@ static const char* default_dbug_option;
#define SKIP_BIG_TESTS(X) /* no-op */
#endif
-static char *file1_name= (char*)"page_cache_test_file_1";
-static char *file2_name= (char*)"page_cache_test_file_2";
+static const char *base_file1_name= "page_cache_test_file_1";
+static const char *base_file2_name= "page_cache_test_file_2";
+static char file1_name[FN_REFLEN], file2_name[FN_REFLEN];
static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
@@ -720,6 +721,28 @@ static void *test_thread(void *arg)
}
+static char *create_tmpdir(const char *progname)
+{
+ static char test_dirname[FN_REFLEN];
+ char tmp_name[FN_REFLEN];
+ uint length;
+
+ /* Create a temporary directory of name TMP-'executable', but without the -t extension */
+ fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
+ length= strlen(tmp_name);
+ if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
+ tmp_name[length-2]= 0;
+ strxmov(test_dirname, "TMP-", tmp_name, NullS);
+
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ (void) my_mkdir(test_dirname, 0777, MYF(0));
+ return test_dirname;
+}
+
+
int main(int argc __attribute__((unused)),
char **argv __attribute__((unused)))
{
@@ -748,6 +771,9 @@ int main(int argc __attribute__((unused)),
plan(18);
SKIP_BIG_TESTS(18)
{
+ char *test_dirname= create_tmpdir(argv[0]);
+ fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
+ fn_format(file2_name, base_file2_name, test_dirname, "", MYF(0));
if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR,
MYF(MY_WME))) < 0)
@@ -841,13 +867,13 @@ int main(int argc __attribute__((unused)),
exit(1);
my_delete(file1_name, MYF(0));
+ rmdir(test_dirname);
} /* SKIP_BIG_TESTS */
DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end"));
my_end(0);
-
}
return exit_status();
}
diff --git a/storage/maria/unittest/ma_test_all-t b/storage/maria/unittest/ma_test_all-t
index f92a25617d7..e66d269ab93 100755
--- a/storage/maria/unittest/ma_test_all-t
+++ b/storage/maria/unittest/ma_test_all-t
@@ -28,9 +28,10 @@ my $NEW_TEST= 0; # Test group separator in an array of tests
my $test_begin= 0;
my $test_end= 0;
my $test_counter= 0;
+my $using_internal_tmpdir= 0;
my $full_tmpdir;
my $tmpdir="tmp";
-
+my $exec_dir="TMP-ma_test_all"; # Run test in this directory
run_tests();
####
@@ -60,7 +61,14 @@ sub run_tests
print "$my_progname version $VER\n";
exit(0);
}
- $maria_path= dirname($0) . "/..";
+
+ if (! -d $exec_dir)
+ {
+ die if (!mkdir("$exec_dir"));
+ }
+ chdir($exec_dir);
+
+ $maria_path= "../" . dirname($0) . "/..";
my $suffix= ( $^O =~ /win/i && $^O !~ /darwin/i ) ? ".exe" : "";
$maria_exe_path= "$maria_path/release";
@@ -76,7 +84,7 @@ sub run_tests
$maria_exe_path= $maria_path;
if ( ! -f "$maria_exe_path/ma_test1$suffix" )
{
- die("Cannot find ma_test1 executable\n");
+ die("Cannot find ma_test1 executable in $maria_path\n");
}
}
}
@@ -90,7 +98,8 @@ sub run_tests
}
else
{
- $full_tmpdir= "tmp";
+ $full_tmpdir= $tmpdir;
+ $using_internal_tmpdir= 1;
if (! -d "$full_tmpdir")
{
die if (!mkdir("$full_tmpdir"));
@@ -227,6 +236,13 @@ sub run_tests
run_tests_on_clrs($suffix, $opt_verbose, 0);
unlink_all_possible_tmp_files();
+ if ($using_internal_tmpdir)
+ {
+ rmdir($tmpdir);
+ }
+ rmdir($exec_dir);
+ chdir("..");
+ rmdir($exec_dir);
exit($runtime_error);
}
@@ -430,13 +446,16 @@ sub run_pack_tests()
"cp test1.MAD test2.MAD",
"cp test1.MAI test2.MAI",
"$maria_exe_path/aria_pack$suffix --force -s --join=test3 test1 test2",
- "$maria_exe_path/aria_chk -s test3",
- "$maria_exe_path/aria_chk -s --safe-recover test3",
- "$maria_exe_path/aria_chk -s test3"
);
- return &count_tests(\@t) if ($count);
+ return (&count_tests(\@t) + 3) if ($count);
+ &run_test_bunch(\@t, $verbose, 0);
+
+ ok("$maria_exe_path/aria_chk -s test3", $verbose, 0, 1);
+ @t= ("$maria_exe_path/aria_chk -s --safe-recover test3",
+ "$maria_exe_path/aria_chk -s test3");
&run_test_bunch(\@t, $verbose, 0);
+
return 0;
}
@@ -464,7 +483,7 @@ sub run_tests_on_warnings_and_errors
# maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 will warn that
# Datafile is almost full
ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 >ma_test2_message.txt 2>&1",
- $verbose, 0);
+ $verbose, 0, 1);
ok("cat ma_test2_message.txt", $verbose, 0);
ok("grep \"warning: Datafile is almost full\" ma_test2_message.txt>/dev/null",
$verbose, 0);
@@ -551,7 +570,7 @@ sub run_tests_on_clrs
sub ok
{
my ($com, $verbose, $iteration, $expected_error)= @_;
- my ($msg, $output, $err, $len);
+ my ($msg, $output, $err, $errcode, $len);
$test_counter++;
if ($test_begin > $test_counter)
@@ -581,8 +600,9 @@ sub ok
print " " x (62 - $len);
}
$err= $?;
+ $errcode= ($? >> 8);
if ((!$err && !$expected_error) ||
- (($err >> 8) == $expected_error && $expected_error))
+ ($errcode == $expected_error && $expected_error))
{
print "[ " if ($verbose);
print "ok";
@@ -619,7 +639,7 @@ sub ok
}
$msg.= "at line ";
$msg.= (caller)[2];
- $msg.= "\n(errcode: $err, test: $test_counter)\n";
+ $msg.= "\n(errcode: $errcode, test: $test_counter)\n";
if ($expected_error)
{
$msg.= "Was expecting errcode: $expected_error\n";
@@ -682,7 +702,7 @@ sub unlink_all_possible_tmp_files()
unlink_log_files();
# Unlink tmp files that may have been created when testing the test programs
- unlink <$full_tmpdir/*.TMD aria_log_control aria_log.00000001 aria_log.00000002 aria_logtest1.MA? test2.MA? test3.MA?>;
+ unlink <$full_tmpdir/*.TMD $full_tmpdir/aria_read_log_test1.txt $full_tmpdir/test1*.MA? $full_tmpdir/ma_test_recovery.output aria_log_control aria_log.00000001 aria_log.00000002 aria_logtest1.MA? test1.MA? test2.MA? test3.MA?>;
}
####
@@ -734,6 +754,7 @@ Options
might depend on previous ones.
--start-from=... Alias for --run-tests
--silent=... Silent option passed to ma_test* tests ('$opt_silent')
+--tmpdir=... Store tests data in this directory (works for most tests)
--valgrind=... Options for valgrind.
('$opt_valgrind')
--verbose Be more verbose. Will print each unittest on a line
diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c
index ffac9b04839..4603992350f 100644
--- a/storage/maria/unittest/ma_test_loghandler-t.c
+++ b/storage/maria/unittest/ma_test_loghandler-t.c
@@ -19,7 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
extern void example_loghandler_init();
#ifndef DBUG_OFF
@@ -161,7 +162,6 @@ int main(int argc __attribute__((unused)), char *argv[])
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 3];
struct st_translog_scanner_data scanner;
int rc;
-
MY_INIT(argv[0]);
if (my_set_max_open_files(100) < 100)
@@ -170,10 +170,14 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1);
}
bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
- if (maria_log_remove())
+
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
+ /* We don't need to do physical syncs in this test */
+ my_disable_sync= 1;
+
for (i= 0; i < (LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); i+= 2)
{
int2store(long_buffer + i, (i >> 1));
@@ -205,7 +209,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -654,7 +658,7 @@ err:
end_pagecache(&pagecache, 1);
ma_control_file_end();
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
return(test(exit_status()));
diff --git a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c
index 06d9a00c04c..7e5b9543e98 100644
--- a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c
@@ -19,7 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init();
#ifndef DBUG_OFF
@@ -31,7 +32,6 @@ static const char *default_dbug_option;
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define LOG_FLAGS 0
-static char *first_translog_file= (char*)"maria_log.00000001";
int main(int argc __attribute__((unused)), char *argv[])
{
@@ -40,18 +40,18 @@ int main(int argc __attribute__((unused)), char *argv[])
PAGECACHE pagecache;
LSN lsn, first_lsn, theor_lsn;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
-
MY_INIT(argv[0]);
plan(2);
bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
- if (maria_log_remove())
+ /*
+ Don't give an error if we can't create dir, as it may already exist from a previously aborted
+ run
+ */
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
- /* be sure that we have no logs in the directory*/
- my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
- my_delete(first_translog_file, MYF(0));
bzero(long_tr_id, 6);
#ifndef DBUG_OFF
@@ -78,9 +78,8 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
- LOG_FLAGS, 0, &translog_example_table_init,
- 0))
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
+ LOG_FLAGS, 0, &translog_example_table_init, 0))
{
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
exit(1);
@@ -154,7 +153,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
exit(0);
}
diff --git a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c
index 64f486b8cf1..915bec4893d 100644
--- a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c
@@ -19,7 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init();
#ifndef DBUG_OFF
@@ -40,14 +41,14 @@ int main(int argc __attribute__((unused)), char *argv[])
PAGECACHE pagecache;
LSN lsn, max_lsn, last_lsn= LSN_IMPOSSIBLE;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
-
MY_INIT(argv[0]);
plan(2);
bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
- if (maria_log_remove())
+
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
bzero(long_tr_id, 6);
@@ -75,7 +76,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -150,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
exit(0);
}
diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
index 7ba7ce3176d..6ea9c95acfa 100644
--- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
@@ -21,7 +21,8 @@
#include "sequence_storage.h"
#include <my_getopt.h>
-extern my_bool maria_log_remove();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init();
#ifndef DBUG_OFF
@@ -238,19 +239,23 @@ int main(int argc __attribute__((unused)), char *argv[])
TRANSLOG_HEADER_BUFFER rec;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 2];
struct st_translog_scanner_data scanner;
+ const char *progname=argv[0];
int rc;
-
MY_INIT(argv[0]);
- bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
+
load_defaults("my", load_default_groups, &argc, &argv);
- default_argv= argv;
get_options(&argc, &argv);
+ default_argv= argv;
- if (maria_log_remove())
+ bzero(&pagecache, sizeof(pagecache));
+ maria_data_root= create_tmpdir(progname);
+ if (maria_log_remove(0))
exit(1);
+ /* We don't need to do physical syncs in this test */
+ my_disable_sync= 1;
+
{
uchar buff[4];
for (i= 0; i < (LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); i++)
@@ -274,7 +279,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
0, 0, &translog_example_table_init, 0))
{
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
@@ -437,7 +442,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "pass2: Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
0, READONLY, &translog_example_table_init, 0))
{
fprintf(stderr, "pass2: Can't init loghandler (%d)\n", errno);
@@ -739,7 +744,7 @@ err:
ma_control_file_end();
free_defaults(default_argv);
seq_storage_destroy(&seq);
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
return (test(exit_status()));
diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c
index dbf47ad2ee1..234b233bf52 100644
--- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c
@@ -19,8 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
-extern void translog_example_table_init();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF
static const char *default_dbug_option;
@@ -268,12 +268,18 @@ int main(int argc __attribute__((unused)),
pthread_attr_t thr_attr;
int *param, error;
int rc;
+ MY_INIT(argv[0]);
plan(WRITERS + FLUSHERS +
ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS );
+ /* We don't need to do physical syncs in this test */
+ my_disable_sync= 1;
bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
+ exit(1);
+
long_buffer= malloc(LONG_BUFFER_SIZE + 7 * 2 + 2);
if (long_buffer == 0)
{
@@ -283,11 +289,6 @@ int main(int argc __attribute__((unused)),
for (i= 0; i < (LONG_BUFFER_SIZE + 7 * 2 + 2); i++)
long_buffer[i]= (i & 0xFF);
- MY_INIT(argv[0]);
- if (maria_log_remove())
- exit(1);
-
-
#ifndef DBUG_OFF
#if defined(__WIN__)
default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
@@ -345,7 +346,7 @@ int main(int argc __attribute__((unused)),
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -544,7 +545,7 @@ err:
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
return(exit_status());
diff --git a/storage/maria/unittest/ma_test_loghandler_noflush-t.c b/storage/maria/unittest/ma_test_loghandler_noflush-t.c
index 973dfd03bcf..3e1ce202fac 100644
--- a/storage/maria/unittest/ma_test_loghandler_noflush-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_noflush-t.c
@@ -19,7 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init();
#ifndef DBUG_OFF
@@ -31,8 +32,6 @@ static const char *default_dbug_option;
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define LOG_FLAGS 0
-static char *first_translog_file= (char*)"maria_log.00000001";
-
int main(int argc __attribute__((unused)), char *argv[])
{
uint pagen;
@@ -49,12 +48,9 @@ int main(int argc __attribute__((unused)), char *argv[])
plan(1);
bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
- if (maria_log_remove())
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
- /* be sure that we have no logs in the directory*/
- my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
- my_delete(first_translog_file, MYF(0));
bzero(long_tr_id, 6);
#ifndef DBUG_OFF
@@ -81,7 +77,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -139,7 +135,7 @@ err:
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
exit(rc);
diff --git a/storage/maria/unittest/ma_test_loghandler_nologs-t.c b/storage/maria/unittest/ma_test_loghandler_nologs-t.c
index 34508d1d751..03badc9aced 100644
--- a/storage/maria/unittest/ma_test_loghandler_nologs-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_nologs-t.c
@@ -19,8 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
-extern void example_loghandler_init();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF
static const char *default_dbug_option;
@@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[])
bzero(&pagecache, sizeof(pagecache));
bzero(long_buffer, LONG_BUFFER_SIZE);
- maria_data_root= (char *)".";
- if (maria_log_remove())
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
bzero(long_tr_id, 6);
@@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -151,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
1))
{
@@ -189,7 +189,7 @@ int main(int argc __attribute__((unused)), char *argv[])
ok(1, "New log is OK");
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
exit(0);
}
diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c
index 1d21d8c6a23..4e8f7a744ee 100644
--- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c
@@ -19,8 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
-extern void translog_example_table_init();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF
static const char *default_dbug_option;
@@ -31,8 +31,10 @@ static const char *default_dbug_option;
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define LOG_FLAGS 0
-static char *first_translog_file= (char*)"aria_log.00000001";
-static char *file1_name= (char*)"page_cache_test_file_1";
+static const char *base_first_translog_file= "aria_log.00000001";
+static const char *base_file1_name= "page_cache_test_file_1";
+static char file1_name[FN_REFLEN], first_translog_file[FN_REFLEN];
+
static PAGECACHE_FILE file1;
@@ -68,18 +70,15 @@ int main(int argc __attribute__((unused)), char *argv[])
LSN lsn;
my_off_t file_size;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
-
MY_INIT(argv[0]);
plan(1);
bzero(&pagecache, sizeof(pagecache));
- maria_data_root= (char *)".";
- if (maria_log_remove())
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
- /* be sure that we have no logs in the directory*/
- my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
- my_delete(first_translog_file, MYF(0));
+ fn_format(first_translog_file, base_first_translog_file, maria_data_root, "", MYF(0));
bzero(long_tr_id, 6);
#ifndef DBUG_OFF
@@ -106,7 +105,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -145,6 +144,7 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1);
}
+ fn_format(file1_name, base_file1_name, maria_data_root, "", MYF(0));
if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{
@@ -192,9 +192,9 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
- my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
- my_delete(first_translog_file, MYF(0));
- my_delete(file1_name, MYF(0));
+ my_delete(file1_name, MYF(MY_WME));
+ if (maria_log_remove(maria_data_root))
+ exit(1);
exit(0);
}
diff --git a/storage/maria/unittest/ma_test_loghandler_purge-t.c b/storage/maria/unittest/ma_test_loghandler_purge-t.c
index d37b45bc3ca..8badfd9451e 100644
--- a/storage/maria/unittest/ma_test_loghandler_purge-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_purge-t.c
@@ -19,8 +19,8 @@
#include <tap.h>
#include "../trnman.h"
-extern my_bool maria_log_remove();
-extern void translog_example_table_init();
+extern my_bool maria_log_remove(const char *testdir);
+extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF
static const char *default_dbug_option;
@@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[])
bzero(&pagecache, sizeof(pagecache));
bzero(long_buffer, LONG_BUFFER_SIZE);
- maria_data_root= (char *)".";
- if (maria_log_remove())
+ maria_data_root= create_tmpdir(argv[0]);
+ if (maria_log_remove(0))
exit(1);
bzero(long_tr_id, 6);
@@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
- if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
+ if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init,
0))
{
@@ -186,7 +186,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
- if (maria_log_remove())
+ if (maria_log_remove(maria_data_root))
exit(1);
exit(0);
}
diff --git a/storage/maria/unittest/trnman-t.c b/storage/maria/unittest/trnman-t.c
index 43cf982a7f2..92919b37152 100644
--- a/storage/maria/unittest/trnman-t.c
+++ b/storage/maria/unittest/trnman-t.c
@@ -75,7 +75,7 @@ pthread_handler_t test_trnman(void *arg)
void run_test(const char *test, pthread_handler handler, int n, int m)
{
pthread_t *threads;
- ulonglong now= my_getsystime();
+ ulonglong now= microsecond_interval_timer();
int i;
litmus= 0;
@@ -97,8 +97,8 @@ void run_test(const char *test, pthread_handler handler, int n, int m)
}
for (i= 0 ; i < n ; i++)
pthread_join(threads[i], 0);
- now= my_getsystime()-now;
- ok(litmus == 0, "Tested %s in %g secs (%d)", test, ((double)now)/1e7, litmus);
+ now= microsecond_interval_timer() - now;
+ ok(litmus == 0, "Tested %s in %g secs (%d)", test, ((double)now)/1e6, litmus);
my_free((void*)threads, MYF(0));
}
@@ -162,10 +162,10 @@ int main(int argc __attribute__((unused)), char **argv)
diag("mallocs: %d", trnman_allocated_transactions);
{
- ulonglong now= my_getsystime();
+ ulonglong now= microsecond_interval_timer();
trnman_destroy();
- now= my_getsystime()-now;
- diag("trnman_destroy: %g", ((double)now)/1e7);
+ now= microsecond_interval_timer() - now;
+ diag("trnman_destroy: %g", ((double)now)/1e6);
}
pthread_mutex_destroy(&rt_mutex);
diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c
index 05948a936a6..5bfbf7e6c61 100644
--- a/storage/myisam/ft_stopwords.c
+++ b/storage/myisam/ft_stopwords.c
@@ -16,7 +16,7 @@
/* Written by Sergei A. Golubchik, who has a shared copyright to this code */
#include "ftdefs.h"
-#include "my_handler.h"
+#include "my_compare.h"
typedef struct st_ft_stopwords
{
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 89bdd4597f8..8f3b05a7a51 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -20,12 +20,8 @@
#define MYSQL_SERVER 1
#include "mysql_priv.h"
-#include <mysql/plugin.h>
-#include <m_ctype.h>
#include <my_bit.h>
-#include <myisampack.h>
#include "ha_myisam.h"
-#include <stdarg.h>
#include "myisamdef.h"
#include "rt_index.h"
@@ -297,6 +293,8 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
if (found->flags & BLOB_FLAG)
recinfo_pos->type= FIELD_BLOB;
+ else if (found->type() == MYSQL_TYPE_TIMESTAMP)
+ recinfo_pos->type= FIELD_NORMAL;
else if (found->type() == MYSQL_TYPE_VARCHAR)
recinfo_pos->type= FIELD_VARCHAR;
else if (!(options & HA_OPTION_PACK_RECORD))
@@ -560,9 +558,10 @@ ha_myisam::ha_myisam(handlerton *hton, TABLE_SHARE *table_arg)
can_enable_indexes(1)
{}
-handler *ha_myisam::clone(MEM_ROOT *mem_root)
+handler *ha_myisam::clone(const char *name, MEM_ROOT *mem_root)
{
- ha_myisam *new_handler= static_cast <ha_myisam *>(handler::clone(mem_root));
+ ha_myisam *new_handler= static_cast <ha_myisam *>(handler::clone(name,
+ mem_root));
if (new_handler)
new_handler->file->state= file->state;
return new_handler;
@@ -1868,6 +1867,9 @@ int ha_myisam::info(uint flag)
MI_ISAMINFO misam_info;
char name_buff[FN_REFLEN];
+ if (!table)
+ return 1;
+
(void) mi_status(file,&misam_info,flag);
if (flag & HA_STATUS_VARIABLE)
{
diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
index 9b9ca5c18d9..f895a5bf449 100644
--- a/storage/myisam/ha_myisam.h
+++ b/storage/myisam/ha_myisam.h
@@ -21,7 +21,6 @@
/* class for the the myisam handler */
#include <myisam.h>
-#include <myisamchk.h>
#include <ft_global.h>
#define HA_RECOVER_NONE 0 /* No automatic recover */
@@ -50,7 +49,7 @@ class ha_myisam: public handler
public:
ha_myisam(handlerton *hton, TABLE_SHARE *table_arg);
~ha_myisam() {}
- handler *clone(MEM_ROOT *mem_root);
+ handler *clone(const char *name, MEM_ROOT *mem_root);
const char *table_type() const { return "MyISAM"; }
const char *index_type(uint key_number);
const char **bas_ext() const;
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index d5ce941bf75..f40f1bad710 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -848,8 +848,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
err:
pthread_mutex_unlock(&THR_LOCK_myisam);
-err_no_lock:
+err_no_lock:
save_errno=my_errno;
switch (errpos) {
case 3:
diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c
index 39303fb80e5..8cde271282e 100644
--- a/storage/myisam/mi_test1.c
+++ b/storage/myisam/mi_test1.c
@@ -16,6 +16,7 @@
/* Testing of the basic functions of a MyISAM table */
#include "myisam.h"
+#include "myisamdef.h"
#include <my_getopt.h>
#include <m_string.h>
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index 86c4df77817..8229dfef9a5 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -17,6 +17,7 @@
#include "fulltext.h"
#include "rt_index.h"
+#include "my_compare.h"
#define MAX_POINTER_LENGTH 8
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 92e845bcb51..bf7e4d1ce41 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -15,8 +15,8 @@
/* This file is included by all internal myisam files */
-#include "myisam.h" /* Structs & some defines */
-#include "myisampack.h" /* packing of keys */
+#include <myisam.h> /* Structs & some defines */
+#include <myisampack.h> /* packing of keys */
#include <my_tree.h>
#ifdef THREAD
#include <my_pthread.h>
diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c
index f572c7ab19b..7a30a742fd6 100644
--- a/storage/myisam/sp_test.c
+++ b/storage/myisam/sp_test.c
@@ -17,6 +17,7 @@
/* Written by Alex Barkov, who has a shared copyright to this code */
#include "myisam.h"
+#include "myisamdef.h"
#ifdef HAVE_SPATIAL
#include "sp_defs.h"
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index ff2d01e09c0..a168decd6c8 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -459,8 +459,7 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)),
problem because all locking is handled by the original MERGE table
from which this is cloned of.
*/
- if (!(file= myrg_open(table->s->normalized_path.str, table->db_stat,
- HA_OPEN_IGNORE_IF_LOCKED)))
+ if (!(file= myrg_open(name, table->db_stat, HA_OPEN_IGNORE_IF_LOCKED)))
{
DBUG_PRINT("error", ("my_errno %d", my_errno));
DBUG_RETURN(my_errno ? my_errno : -1);
@@ -484,7 +483,7 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)),
@return A cloned handler instance.
*/
-handler *ha_myisammrg::clone(MEM_ROOT *mem_root)
+handler *ha_myisammrg::clone(const char *name, MEM_ROOT *mem_root)
{
MYRG_TABLE *u_table,*newu_table;
ha_myisammrg *new_handler=
@@ -505,8 +504,8 @@ handler *ha_myisammrg::clone(MEM_ROOT *mem_root)
return NULL;
}
- if (new_handler->ha_open(table, table->s->normalized_path.str, table->db_stat,
- HA_OPEN_IGNORE_IF_LOCKED))
+ if (new_handler->ha_open(table, name, table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED))
{
delete new_handler;
return NULL;
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 4a65a60d97b..aa8f8d3e2be 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -62,7 +62,7 @@ class ha_myisammrg: public handler
int open(const char *name, int mode, uint test_if_locked);
int attach_children(void);
int detach_children(void);
- virtual handler *clone(MEM_ROOT *mem_root);
+ virtual handler *clone(const char *name, MEM_ROOT *mem_root);
int close(void);
int write_row(uchar * buf);
int update_row(const uchar * old_data, uchar * new_data);
diff --git a/storage/mysql_storage_engine.cmake b/storage/mysql_storage_engine.cmake
index e500526350b..07b4151c50c 100644
--- a/storage/mysql_storage_engine.cmake
+++ b/storage/mysql_storage_engine.cmake
@@ -36,6 +36,7 @@ IF(NOT SOURCE_SUBLIBS)
#Create a DLL.The name of the dll is ha_<storage_engine>.dll
#The dll is linked to the mysqld executable
SET(dyn_libname ha_${libname})
+ ADD_VERSION_INFO(${dyn_libname} SHARED ${engine}_SOURCES)
ADD_LIBRARY(${dyn_libname} MODULE ${${engine}_SOURCES})
TARGET_LINK_LIBRARIES (${dyn_libname} mysqlservices mysqld)
IF(${engine}_LIBS)
diff --git a/storage/pbxt/src/cache_xt.cc b/storage/pbxt/src/cache_xt.cc
index 24e42d9e984..090250dd802 100644
--- a/storage/pbxt/src/cache_xt.cc
+++ b/storage/pbxt/src/cache_xt.cc
@@ -717,6 +717,11 @@ xtPublic void xt_ind_exit(XTThreadPtr self)
ind_handle_exit(self);
if (ind_cac_globals.cg_blocks) {
+ XTIndBlockPtr block = ind_cac_globals.cg_blocks;
+ for (u_int i=0; i<ind_cac_globals.cg_block_count; i++) {
+ XT_IPAGE_FREE_LOCK(self, &block->cb_lock);
+ block++;
+ }
xt_free(self, ind_cac_globals.cg_blocks);
ind_cac_globals.cg_blocks = NULL;
xt_free_mutex(&ind_cac_globals.cg_lock);
diff --git a/storage/pbxt/src/filesys_xt.cc b/storage/pbxt/src/filesys_xt.cc
index 31e2cf961b6..ebe0ed146b0 100644
--- a/storage/pbxt/src/filesys_xt.cc
+++ b/storage/pbxt/src/filesys_xt.cc
@@ -369,8 +369,7 @@ xtPublic xtBool xt_fs_stat(XTThreadPtr self, char *path, off_t *size, struct tim
CloseHandle(fh);
if (size)
*size = (off_t) info.nFileSizeLow | (((off_t) info.nFileSizeHigh) << 32);
- if (mod_time)
- mod_time->tv.ft = info.ftLastWriteTime;
+ memset(mod_time, 0, sizeof(*mod_time));
#else
struct stat sb;
diff --git a/storage/pbxt/src/heap_xt.cc b/storage/pbxt/src/heap_xt.cc
index a4e3fec1611..11331f6489f 100644
--- a/storage/pbxt/src/heap_xt.cc
+++ b/storage/pbxt/src/heap_xt.cc
@@ -109,6 +109,7 @@ xtPublic void xt_heap_release(XTThreadPtr self, XTHeapPtr hp)
if (hp->h_finalize)
(*hp->h_finalize)(self, hp);
xt_spinlock_unlock(&hp->h_lock);
+ xt_spinlock_free(NULL, &hp->h_lock);
xt_free(self, hp);
return;
}
diff --git a/storage/pbxt/src/lock_xt.cc b/storage/pbxt/src/lock_xt.cc
index 946adfecccc..e4a38716845 100644
--- a/storage/pbxt/src/lock_xt.cc
+++ b/storage/pbxt/src/lock_xt.cc
@@ -726,11 +726,15 @@ xtBool xt_init_row_locks(XTRowLocksPtr rl)
rl->rl_groups[i].lg_list_in_use = 0;
rl->rl_groups[i].lg_list = NULL;
}
+ rl->valid = 1;
return OK;
}
void xt_exit_row_locks(XTRowLocksPtr rl)
{
+ if (!rl->valid)
+ return;
+
for (int i=0; i<XT_ROW_LOCK_GROUP_COUNT; i++) {
xt_spinlock_free(NULL, &rl->rl_groups[i].lg_lock);
rl->rl_groups[i].lg_wait_queue = NULL;
@@ -741,6 +745,7 @@ void xt_exit_row_locks(XTRowLocksPtr rl)
rl->rl_groups[i].lg_list = NULL;
}
}
+ rl->valid = 0;
}
/*
@@ -1424,6 +1429,7 @@ xtPublic void xt_spinxslock_init(struct XTThread *XT_UNUSED(self), XTSpinXSLockP
#endif
{
sxs->sxs_xlocked = 0;
+ sxs->sxs_xwaiter = 0;
sxs->sxs_rlock_count = 0;
sxs->sxs_wait_count = 0;
#ifdef DEBUG
diff --git a/storage/pbxt/src/lock_xt.h b/storage/pbxt/src/lock_xt.h
index 4e5af648c37..28737478d48 100644
--- a/storage/pbxt/src/lock_xt.h
+++ b/storage/pbxt/src/lock_xt.h
@@ -658,6 +658,7 @@ typedef struct XTLockGroup {
struct XTLockWait;
typedef struct XTRowLocks {
+ int valid;
XTLockGroupRec rl_groups[XT_ROW_LOCK_GROUP_COUNT];
void xt_cancel_temp_lock(XTLockWaitPtr lw);
diff --git a/storage/pbxt/src/pthread_xt.cc b/storage/pbxt/src/pthread_xt.cc
index e7f0632e9ae..9f35f50b8c7 100755
--- a/storage/pbxt/src/pthread_xt.cc
+++ b/storage/pbxt/src/pthread_xt.cc
@@ -396,48 +396,7 @@ xtPublic int xt_p_cond_wait(xt_cond_type *cond, xt_mutex_type *mutex)
xtPublic int xt_p_cond_timedwait(xt_cond_type *cond, xt_mutex_type *mt, struct timespec *abstime)
{
- pthread_mutex_t *mutex = &mt->mt_cs;
- int result;
- long timeout;
- union ft64 now;
-
- if (abstime != NULL) {
- GetSystemTimeAsFileTime(&now.ft);
-
- timeout = (long)((abstime->tv.i64 - now.i64) / 10000);
- if (timeout < 0)
- timeout = 0L;
- if (timeout > abstime->max_timeout_msec)
- timeout = abstime->max_timeout_msec;
- }
- else
- timeout= INFINITE;
-
- WaitForSingleObject(cond->broadcast_block_event, INFINITE);
-
- EnterCriticalSection(&cond->lock_waiting);
- cond->waiting++;
- LeaveCriticalSection(&cond->lock_waiting);
-
- LeaveCriticalSection(mutex);
-
- result= WaitForMultipleObjects(2, cond->events, FALSE, timeout);
-
- EnterCriticalSection(&cond->lock_waiting);
- cond->waiting--;
-
- if (cond->waiting == 0) {
- /* The last waiter must reset the broadcast
- * state (whther there was a broadcast or not)!
- */
- ResetEvent(cond->events[xt_cond_type::BROADCAST]);
- SetEvent(cond->broadcast_block_event);
- }
- LeaveCriticalSection(&cond->lock_waiting);
-
- EnterCriticalSection(mutex);
-
- return result == WAIT_TIMEOUT ? ETIMEDOUT : 0;
+ return pthread_cond_timedwait(cond, &mt->mt_cs, abstime);
}
xtPublic int xt_p_join(pthread_t thread, void **value)
@@ -558,8 +517,10 @@ xtPublic int xt_p_set_low_priority(pthread_t thr)
*/
/* -20 = highest, 20 = lowest */
+#ifdef SET_GLOBAL_PRIORITY
if (setpriority(PRIO_PROCESS, getpid(), 20) == -1)
return errno;
+#endif
return 0;
}
return pth_set_priority(thr, pth_min_priority);
diff --git a/storage/pbxt/src/thread_xt.cc b/storage/pbxt/src/thread_xt.cc
index 52c2c6c29c5..eb9941f13fb 100644
--- a/storage/pbxt/src/thread_xt.cc
+++ b/storage/pbxt/src/thread_xt.cc
@@ -54,6 +54,9 @@ void xt_db_exit_thread(XTThreadPtr self);
static void thr_accumulate_statistics(XTThreadPtr self);
+#ifdef _WIN32
+#include <my_sys.h>
+#endif
/*
* -----------------------------------------------------------------------
* THREAD GLOBALS
@@ -1962,18 +1965,7 @@ xtPublic xtBool xt_timed_wait_cond(XTThreadPtr self, xt_cond_type *cond, xt_mute
XTThreadPtr me = self ? self : xt_get_self();
#ifdef XT_WIN
- union ft64 now;
-
- GetSystemTimeAsFileTime(&now.ft);
-
- /* System time is measured in 100ns units.
- * This calculation will be reversed by the Windows implementation
- * of pthread_cond_timedwait(), in order to extract the
- * milli-second timeout!
- */
- abstime.tv.i64 = now.i64 + (milli_sec * 10000);
-
- abstime.max_timeout_msec = milli_sec;
+ set_timespec_nsec(abstime, 1000000ULL* milli_sec);
#else
struct timeval now;
u_llong micro_sec;
diff --git a/storage/pbxt/src/xaction_xt.cc b/storage/pbxt/src/xaction_xt.cc
index c5f07eedabf..fd7ae88a4ae 100644
--- a/storage/pbxt/src/xaction_xt.cc
+++ b/storage/pbxt/src/xaction_xt.cc
@@ -1123,7 +1123,6 @@ xtPublic void xt_xn_init_db(XTThreadPtr self, XTDatabaseHPtr db)
*/
for (u_int i=0; i<XT_XN_NO_OF_SEGMENTS; i++) {
seg = &db->db_xn_idx[i];
- XT_XACT_INIT_LOCK(self, &seg->xs_tab_lock);
seg->xs_last_xn_id = db->db_xn_curr_id;
}
diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt
index 9782f43fb27..509f7f0fe73 100644
--- a/storage/xtradb/CMakeLists.txt
+++ b/storage/xtradb/CMakeLists.txt
@@ -48,10 +48,11 @@ IF(MSVC)
SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c
PROPERTIES COMPILE_FLAGS -Od)
ENDIF()
- # Avoid "unreferenced label" warning in generated file
- SET_SOURCE_FILES_PROPERTIES(pars/pars0grm.c
+ # Avoid "unreferenced label" warning in generated file
+ GET_FILENAME_COMPONENT(_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+ SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/pars0grm.c
PROPERTIES COMPILE_FLAGS "/wd4102")
- SET_SOURCE_FILES_PROPERTIES(pars/lexyy.c
+ SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/lexyy.c
PROPERTIES COMPILE_FLAGS "/wd4003")
ENDIF()
diff --git a/storage/xtradb/ChangeLog b/storage/xtradb/ChangeLog
index bf003b810d2..102db3d7824 100644
--- a/storage/xtradb/ChangeLog
+++ b/storage/xtradb/ChangeLog
@@ -1,3 +1,61 @@
+2011-01-31 The InnoDB Team
+
+ * btr/btr0cur.c, include/row0upd.h,
+ row/row0purge.c, row/row0umod.c, row/row0upd.c:
+ Bug#59230 assert 0 row_upd_changes_ord_field_binary()
+ in post-crash rollback or purge
+
+2011-01-27 The InnoDB Team
+
+ * btr/btr0cur.c:
+ Bug#59465 btr_estimate_number_of_different_key_vals use
+ incorrect offset for external_size
+
+2011-01-27 The InnoDB Team
+
+ * include/trx0trx.h, trx/trx0trx.c:
+ Bug#59440 Race condition in XA ROLLBACK and XA COMMIT
+ after server restart
+
+2011-01-25 The InnoDB Team
+
+ * row/row0upd.c:
+ Bug#59585 Fix 58912 introduces compiler warning
+ due to potentially uninitialized variable
+
+2011-01-25 The InnoDB Team
+
+ * mtr/mtr0log.c:
+ Bug#59486 Incorrect usage of UNIV_UNLIKELY() in mlog_parse_string()
+
+2011-01-25 The InnoDB Team
+
+ * row/row0vers.c:
+ Fix Bug#59464 Race condition in row_vers_build_for_semi_consistent_read
+
+2011-01-25 The InnoDB Team
+
+ * btr/btr0btr.c, btr/btr0cur.c, btr/btr0sea.c,
+ buf/buf0buddy.c, buf/buf0buf.c, buf/buf0lru.c,
+ include/buf0buf.h, include/buf0buf.ic, include/buf0lru.h,
+ mem/mem0mem.c, page/page0zip.c:
+ Fix Bug#59707 Unused compression-related parameters
+ in buffer pool functions
+
+2011-01-18 The InnoDB Team
+
+ * include/sync0rw.h, sync/sync0arr.c, sync/sync0rw.c:
+ Fix Bug#59579 rw_lock_debug_print outputs to stderr, not to
+ SHOW ENGINE INNODB STATUS
+
+2011-01-14 The InnoDB Team
+ * btr/btr0cur.c, dict/dict0dict.c, handler/ha_innodb.cc,
+ include/btr0cur.h, include/dict0mem.h, include/rem0cmp.h,
+ include/rem0cmp.ic, include/srv0srv.h, rem/rem0cmp.c,
+ srv/srv0srv.c, innodb_bug30423.test:
+ Fix Bug#30423 InnoDBs treatment of NULL in index stats causes
+ bad "rows examined" estimates
+
2011-01-06 The InnoDB Team
* row/row0merge.c:
Fix Bug#59312 Examine MAX_FULL_NAME_LEN in InnoDB to address
diff --git a/storage/xtradb/btr/btr0btr.c b/storage/xtradb/btr/btr0btr.c
index 55204691400..2fb14b06a7b 100644
--- a/storage/xtradb/btr/btr0btr.c
+++ b/storage/xtradb/btr/btr0btr.c
@@ -1009,7 +1009,7 @@ btr_page_reorganize_low(
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
#ifndef UNIV_HOTBACKUP
- temp_block = buf_block_alloc(0);
+ temp_block = buf_block_alloc();
#else /* !UNIV_HOTBACKUP */
ut_ad(block == back_block1);
temp_block = back_block2;
diff --git a/storage/xtradb/btr/btr0cur.c b/storage/xtradb/btr/btr0cur.c
index 321504a2b25..9b306ea2864 100644
--- a/storage/xtradb/btr/btr0cur.c
+++ b/storage/xtradb/btr/btr0cur.c
@@ -100,6 +100,18 @@ can be released by page reorganize, then it is reorganized */
/*--------------------------------------*/
#define BTR_BLOB_HDR_SIZE 8 /*!< Size of a BLOB
part header, in bytes */
+
+/** Estimated table level stats from sampled value.
+@param value sampled stats
+@param index index being sampled
+@param sample number of sampled rows
+@param ext_size external stored data size
+@param not_empty table not empty
+@return estimated table wide stats from sampled value */
+#define BTR_TABLE_STATS_FROM_SAMPLE(value, index, sample, ext_size, not_empty)\
+ (((value) * (ib_int64_t) index->stat_n_leaf_pages \
+ + (sample) - 1 + (ext_size) + (not_empty)) / ((sample) + (ext_size)))
+
/* @} */
#endif /* !UNIV_HOTBACKUP */
@@ -174,7 +186,7 @@ static
ulint
btr_rec_get_externally_stored_len(
/*==============================*/
- rec_t* rec, /*!< in: record */
+ const rec_t* rec, /*!< in: record */
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
#endif /* !UNIV_HOTBACKUP */
@@ -961,108 +973,6 @@ btr_cur_open_at_rnd_pos_func(
}
}
-/**********************************************************************//**
-Positions a cursor at a randomly chosen position within a B-tree
-after the given path
-@return TRUE if the position is at the first page, and cursor must point
- the first record for used by the caller.*/
-UNIV_INTERN
-ibool
-btr_cur_open_at_rnd_pos_after_path(
-/*====================*/
- dict_index_t* index, /*!< in: index */
- ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */
- btr_path_t* first_rec_path,
- btr_cur_t* cursor, /*!< in/out: B-tree cursor */
- mtr_t* mtr) /*!< in: mtr */
-{
- page_cur_t* page_cursor;
- btr_path_t* slot;
- ibool is_first_rec = TRUE;
- ulint page_no;
- ulint space;
- ulint zip_size;
- ulint height;
- rec_t* node_ptr;
- mem_heap_t* heap = NULL;
- ulint offsets_[REC_OFFS_NORMAL_SIZE];
- ulint* offsets = offsets_;
- rec_offs_init(offsets_);
-
- if (latch_mode == BTR_MODIFY_TREE) {
- mtr_x_lock(dict_index_get_lock(index), mtr);
- } else {
- mtr_s_lock(dict_index_get_lock(index), mtr);
- }
-
- page_cursor = btr_cur_get_page_cur(cursor);
- cursor->index = index;
-
- space = dict_index_get_space(index);
- zip_size = dict_table_zip_size(index->table);
- page_no = dict_index_get_page(index);
-
- height = ULINT_UNDEFINED;
- slot = first_rec_path;
-
- for (;;) {
- buf_block_t* block;
- page_t* page;
-
- block = buf_page_get_gen(space, zip_size, page_no,
- RW_NO_LATCH, NULL, BUF_GET,
- __FILE__, __LINE__, mtr);
- page = buf_block_get_frame(block);
- ut_ad(0 == ut_dulint_cmp(index->id,
- btr_page_get_index_id(page)));
-
- if (height == ULINT_UNDEFINED) {
- /* We are in the root node */
-
- height = btr_page_get_level(page, mtr);
- }
-
- if (height == 0) {
- btr_cur_latch_leaves(page, space, zip_size, page_no,
- latch_mode, cursor, mtr);
- }
-
- if (is_first_rec && slot->nth_rec != ULINT_UNDEFINED) {
- if (height == 0) {
- /* must open the first rec */
- page_cur_open_on_nth_user_rec(block, page_cursor, slot->nth_rec);
- } else {
- is_first_rec = page_cur_open_on_rnd_user_rec_after_nth(block,
- page_cursor, slot->nth_rec);
- }
- } else {
- is_first_rec = FALSE;
- page_cur_open_on_rnd_user_rec(block, page_cursor);
- }
-
- if (height == 0) {
- break;
- }
-
- ut_ad(height > 0);
-
- height--;
- slot++;
-
- node_ptr = page_cur_get_rec(page_cursor);
- offsets = rec_get_offsets(node_ptr, cursor->index, offsets,
- ULINT_UNDEFINED, &heap);
- /* Go to the child node */
- page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
- }
-
- if (UNIV_LIKELY_NULL(heap)) {
- mem_heap_free(heap);
- }
-
- return (is_first_rec);
-}
-
/*==================== B-TREE INSERT =========================*/
/*************************************************************//**
@@ -1933,8 +1843,8 @@ btr_cur_update_in_place(
NOT call it if index is secondary */
if (!dict_index_is_clust(index)
- || row_upd_changes_ord_field_binary(NULL, NULL,
- index, update)) {
+ || row_upd_changes_ord_field_binary(index, update, thr,
+ NULL, NULL)) {
/* Remove possible hash index pointer to this record */
btr_search_update_hash_on_delete(cursor);
@@ -3383,149 +3293,43 @@ btr_estimate_n_rows_in_range(
}
/*******************************************************************//**
-Estimates the number of pages which have not null value of the key of n_cols.
-@return estimated number of pages */
-UNIV_INTERN
-ulint
-btr_estimate_n_pages_not_null(
-/*=========================*/
- dict_index_t* index, /*!< in: index */
- ulint n_cols, /*!< in: The cols should be not null */
- btr_path_t* path1) /*!< in: path1[BTR_PATH_ARRAY_N_SLOTS] */
+Record the number of non_null key values in a given index for
+each n-column prefix of the index where n < dict_index_get_n_unique(index).
+The estimates are eventually stored in the array:
+index->stat_n_non_null_key_vals. */
+static
+void
+btr_record_not_null_field_in_rec(
+/*=============================*/
+ rec_t* rec, /*!< in: physical record */
+ ulint n_unique, /*!< in: dict_index_get_n_unique(index),
+ number of columns uniquely determine
+ an index entry */
+ const ulint* offsets, /*!< in: rec_get_offsets(rec, index),
+ its size could be for all fields or
+ that of "n_unique" */
+ ib_int64_t* n_not_null) /*!< in/out: array to record number of
+ not null rows for n-column prefix */
{
- dtuple_t* tuple1;
- btr_path_t path2[BTR_PATH_ARRAY_N_SLOTS];
- btr_cur_t cursor;
- btr_path_t* slot1;
- btr_path_t* slot2;
- ibool diverged;
- ibool diverged_lot;
- ulint divergence_level;
- ulint n_pages;
- ulint i;
- mtr_t mtr;
- mem_heap_t* heap;
-
- heap = mem_heap_create(n_cols * sizeof(dfield_t)
- + sizeof(dtuple_t));
+ ulint i;
- /* make tuple1 (NULL,NULL,,,) from n_cols */
- tuple1 = dtuple_create(heap, n_cols);
- dict_index_copy_types(tuple1, index, n_cols);
+ ut_ad(rec_offs_n_fields(offsets) >= n_unique);
- for (i = 0; i < n_cols; i++) {
- dfield_set_null(dtuple_get_nth_field(tuple1, i));
+ if (n_not_null == NULL) {
+ return;
}
- mtr_start(&mtr);
-
- cursor.path_arr = path1;
-
- btr_cur_search_to_nth_level(index, 0, tuple1, PAGE_CUR_G,
- BTR_SEARCH_LEAF | BTR_ESTIMATE,
- &cursor, 0, __FILE__, __LINE__, &mtr);
-
- mtr_commit(&mtr);
-
-
-
- mtr_start(&mtr);
-
- cursor.path_arr = path2;
-
- btr_cur_open_at_index_side(FALSE, index,
- BTR_SEARCH_LEAF | BTR_ESTIMATE,
- &cursor, &mtr);
-
- mtr_commit(&mtr);
-
- mem_heap_free(heap);
-
- /* We have the path information for the range in path1 and path2 */
-
- n_pages = 1;
- diverged = FALSE; /* This becomes true when the path is not
- the same any more */
- diverged_lot = FALSE; /* This becomes true when the paths are
- not the same or adjacent any more */
- divergence_level = 1000000; /* This is the level where paths diverged
- a lot */
- for (i = 0; ; i++) {
- ut_ad(i < BTR_PATH_ARRAY_N_SLOTS);
-
- slot1 = path1 + i;
- slot2 = path2 + i;
-
- if ((slot1 + 1)->nth_rec == ULINT_UNDEFINED
- || (slot2 + 1)->nth_rec == ULINT_UNDEFINED) {
-
- if (i > divergence_level + 1) {
- /* In trees whose height is > 1 our algorithm
- tends to underestimate: multiply the estimate
- by 2: */
-
- n_pages = n_pages * 2;
- }
-
- /* Do not estimate the number of rows in the range
- to over 1 / 2 of the estimated rows in the whole
- table */
-
- if (n_pages > index->stat_n_leaf_pages / 2) {
- n_pages = index->stat_n_leaf_pages / 2;
+ for (i = 0; i < n_unique; i++) {
+ ulint rec_len;
+ byte* field;
- /* If there are just 0 or 1 rows in the table,
- then we estimate all rows are in the range */
+ field = rec_get_nth_field(rec, offsets, i, &rec_len);
- if (n_pages == 0) {
- n_pages = index->stat_n_leaf_pages;
- }
- }
-
- return(n_pages);
- }
-
- if (!diverged && slot1->nth_rec != slot2->nth_rec) {
-
- diverged = TRUE;
-
- if (slot1->nth_rec < slot2->nth_rec) {
- n_pages = slot2->nth_rec - slot1->nth_rec;
-
- if (n_pages > 1) {
- diverged_lot = TRUE;
- divergence_level = i;
- }
- } else {
- /* Maybe the tree has changed between
- searches */
-
- return(10);
- }
-
- } else if (diverged && !diverged_lot) {
-
- if (slot1->nth_rec < slot1->n_recs
- || slot2->nth_rec > 1) {
-
- diverged_lot = TRUE;
- divergence_level = i;
-
- n_pages = 0;
-
- if (slot1->nth_rec < slot1->n_recs) {
- n_pages += slot1->n_recs
- - slot1->nth_rec;
- }
-
- if (slot2->nth_rec > 1) {
- n_pages += slot2->nth_rec - 1;
- }
- }
- } else if (diverged_lot) {
-
- n_pages = (n_pages * (slot1->n_recs + slot2->n_recs))
- / 2;
+ if (rec_len != UNIV_SQL_NULL) {
+ n_not_null[i]++;
+ } else {
+ /* Break if we hit the first NULL value */
+ break;
}
}
}
@@ -3533,7 +3337,10 @@ btr_estimate_n_pages_not_null(
/*******************************************************************//**
Estimates the number of different key values in a given index, for
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
-The estimates are stored in the array index->stat_n_diff_key_vals. */
+The estimates are stored in the array index->stat_n_diff_key_vals.
+If innodb_stats_method is "nulls_ignored", we also record the number of
+non-null values for each prefix and store the estimates in
+array index->stat_n_non_null_key_vals. */
UNIV_INTERN
void
btr_estimate_number_of_different_key_vals(
@@ -3547,6 +3354,8 @@ btr_estimate_number_of_different_key_vals(
ulint matched_fields;
ulint matched_bytes;
ib_int64_t* n_diff;
+ ib_int64_t* n_not_null;
+ ibool stats_null_not_equal;
ullint n_sample_pages; /* number of pages to sample */
ulint not_empty_flag = 0;
ulint total_external_size = 0;
@@ -3555,42 +3364,49 @@ btr_estimate_number_of_different_key_vals(
ullint add_on;
mtr_t mtr;
mem_heap_t* heap = NULL;
- ulint offsets_rec_[REC_OFFS_NORMAL_SIZE];
- ulint offsets_next_rec_[REC_OFFS_NORMAL_SIZE];
- ulint* offsets_rec = offsets_rec_;
- ulint* offsets_next_rec= offsets_next_rec_;
- ulint stats_method = srv_stats_method;
- btr_path_t first_rec_path[BTR_PATH_ARRAY_N_SLOTS];
- ulint effective_pages; /* effective leaf pages */
- rec_offs_init(offsets_rec_);
- rec_offs_init(offsets_next_rec_);
+ ulint* offsets_rec = NULL;
+ ulint* offsets_next_rec = NULL;
n_cols = dict_index_get_n_unique(index);
- if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS) {
- /* estimate effective pages and path for the first effective record */
- /* TODO: make it work also for n_cols > 1. */
- effective_pages = btr_estimate_n_pages_not_null(index, 1 /*k*/, first_rec_path);
+ heap = mem_heap_create((sizeof *n_diff + sizeof *n_not_null)
+ * (n_cols + 1)
+ + dict_index_get_n_fields(index)
+ * (sizeof *offsets_rec
+ + sizeof *offsets_next_rec));
+
+ n_diff = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
+
+ n_not_null = NULL;
+
+ /* Check srv_innodb_stats_method setting, and decide whether we
+ need to record non-null value and also decide if NULL is
+ considered equal (by setting stats_null_not_equal value) */
+ switch (srv_innodb_stats_method) {
+ case SRV_STATS_NULLS_IGNORED:
+ n_not_null = mem_heap_zalloc(heap, (n_cols + 1)
+ * sizeof *n_not_null);
+ /* fall through */
+
+ case SRV_STATS_NULLS_UNEQUAL:
+ /* for both SRV_STATS_NULLS_IGNORED and SRV_STATS_NULLS_UNEQUAL
+ case, we will treat NULLs as unequal value */
+ stats_null_not_equal = TRUE;
+ break;
- if (!effective_pages) {
- for (j = 0; j <= n_cols; j++) {
- index->stat_n_diff_key_vals[j] = (ib_int64_t)index->stat_n_leaf_pages;
- }
- return;
- } else if (effective_pages > index->stat_n_leaf_pages) {
- effective_pages = index->stat_n_leaf_pages;
- }
- } else {
- effective_pages = index->stat_n_leaf_pages;
- }
+ case SRV_STATS_NULLS_EQUAL:
+ stats_null_not_equal = FALSE;
+ break;
- n_diff = mem_zalloc((n_cols + 1) * sizeof(ib_int64_t));
+ default:
+ ut_error;
+ }
/* It makes no sense to test more pages than are contained
in the index, thus we lower the number if it is too high */
- if (srv_stats_sample_pages > effective_pages) {
- if (effective_pages > 0) {
- n_sample_pages = effective_pages;
+ if (srv_stats_sample_pages > index->stat_index_size) {
+ if (index->stat_index_size > 0) {
+ n_sample_pages = index->stat_index_size;
} else {
n_sample_pages = 1;
}
@@ -3601,16 +3417,9 @@ btr_estimate_number_of_different_key_vals(
/* We sample some pages in the index to get an estimate */
for (i = 0; i < n_sample_pages; i++) {
- rec_t* supremum;
- ibool is_first_page = TRUE;
mtr_start(&mtr);
- if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS) {
- is_first_page = btr_cur_open_at_rnd_pos_after_path(index, BTR_SEARCH_LEAF,
- first_rec_path, &cursor, &mtr);
- } else {
btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr);
- }
/* Count the number of different key values for each prefix of
the key on this index page. If the prefix does not determine
@@ -3625,25 +3434,25 @@ btr_estimate_number_of_different_key_vals(
}
ut_a(page);
- supremum = page_get_supremum_rec(page);
- if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS && is_first_page) {
- /* the cursor should be the first record of the page. */
- /* Counting should be started from here. */
- rec = btr_cur_get_rec(&cursor);
- } else {
rec = page_rec_get_next(page_get_infimum_rec(page));
- }
- if (rec != supremum) {
+ if (!page_rec_is_supremum(rec)) {
not_empty_flag = 1;
offsets_rec = rec_get_offsets(rec, index, offsets_rec,
ULINT_UNDEFINED, &heap);
+
+ if (n_not_null) {
+ btr_record_not_null_field_in_rec(
+ rec, n_cols, offsets_rec, n_not_null);
+ }
}
- while (rec != supremum) {
- rec_t* next_rec;
- next_rec = page_rec_get_next(rec);
- if (next_rec == supremum) {
+ while (!page_rec_is_supremum(rec)) {
+ rec_t* next_rec = page_rec_get_next(rec);
+ if (page_rec_is_supremum(next_rec)) {
+ total_external_size +=
+ btr_rec_get_externally_stored_len(
+ rec, offsets_rec);
break;
}
@@ -3651,15 +3460,14 @@ btr_estimate_number_of_different_key_vals(
matched_bytes = 0;
offsets_next_rec = rec_get_offsets(next_rec, index,
offsets_next_rec,
- n_cols, &heap);
+ ULINT_UNDEFINED,
+ &heap);
cmp_rec_rec_with_match(rec, next_rec,
offsets_rec, offsets_next_rec,
- index, &matched_fields,
- &matched_bytes,
- (stats_method==SRV_STATS_METHOD_NULLS_NOT_EQUAL) ?
- SRV_STATS_METHOD_NULLS_NOT_EQUAL :
- SRV_STATS_METHOD_NULLS_EQUAL);
+ index, stats_null_not_equal,
+ &matched_fields,
+ &matched_bytes);
for (j = matched_fields + 1; j <= n_cols; j++) {
/* We add one if this index record has
@@ -3668,6 +3476,12 @@ btr_estimate_number_of_different_key_vals(
n_diff[j]++;
}
+ if (n_not_null) {
+ btr_record_not_null_field_in_rec(
+ next_rec, n_cols, offsets_next_rec,
+ n_not_null);
+ }
+
total_external_size
+= btr_rec_get_externally_stored_len(
rec, offsets_rec);
@@ -3702,10 +3516,6 @@ btr_estimate_number_of_different_key_vals(
}
}
- offsets_rec = rec_get_offsets(rec, index, offsets_rec,
- ULINT_UNDEFINED, &heap);
- total_external_size += btr_rec_get_externally_stored_len(
- rec, offsets_rec);
mtr_commit(&mtr);
}
@@ -3719,13 +3529,9 @@ btr_estimate_number_of_different_key_vals(
for (j = 0; j <= n_cols; j++) {
index->stat_n_diff_key_vals[j]
- = ((n_diff[j]
- * (ib_int64_t)effective_pages
- + n_sample_pages - 1
- + total_external_size
- + not_empty_flag)
- / (n_sample_pages
- + total_external_size));
+ = BTR_TABLE_STATS_FROM_SAMPLE(
+ n_diff[j], index, n_sample_pages,
+ total_external_size, not_empty_flag);
/* If the tree is small, smaller than
10 * n_sample_pages + total_external_size, then
@@ -3735,7 +3541,7 @@ btr_estimate_number_of_different_key_vals(
different key values, or even more. Let us try to approximate
that: */
- add_on = effective_pages
+ add_on = index->stat_n_leaf_pages
/ (10 * (n_sample_pages
+ total_external_size));
@@ -3745,53 +3551,80 @@ btr_estimate_number_of_different_key_vals(
index->stat_n_diff_key_vals[j] += add_on;
- if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS) {
- /* index->stat_n_diff_key_vals[k] is used for calc rec_per_key,
- as "stats.records / index->stat_n_diff_key_vals[x]".
- So it should be adjusted to the value which is based on whole of the index. */
- index->stat_n_diff_key_vals[j] =
- index->stat_n_diff_key_vals[j] * (ib_int64_t)index->stat_n_leaf_pages
- / (ib_int64_t)effective_pages;
+ /* Update the stat_n_non_null_key_vals[] with our
+ sampled result. stat_n_non_null_key_vals[] is created
+ and initialized to zero in dict_index_add_to_cache(),
+ along with stat_n_diff_key_vals[] array */
+ if (n_not_null != NULL && (j < n_cols)) {
+ index->stat_n_non_null_key_vals[j] =
+ BTR_TABLE_STATS_FROM_SAMPLE(
+ n_not_null[j], index, n_sample_pages,
+ total_external_size, not_empty_flag);
}
}
- mem_free(n_diff);
- if (UNIV_LIKELY_NULL(heap)) {
- mem_heap_free(heap);
- }
+ mem_heap_free(heap);
}
/*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
/***********************************************************//**
+Gets the offset of the pointer to the externally stored part of a field.
+@return offset of the pointer to the externally stored part */
+static
+ulint
+btr_rec_get_field_ref_offs(
+/*=======================*/
+ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
+ ulint n) /*!< in: index of the external field */
+{
+ ulint field_ref_offs;
+ ulint local_len;
+
+ ut_a(rec_offs_nth_extern(offsets, n));
+ field_ref_offs = rec_get_nth_field_offs(offsets, n, &local_len);
+ ut_a(local_len != UNIV_SQL_NULL);
+ ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+ return(field_ref_offs + local_len - BTR_EXTERN_FIELD_REF_SIZE);
+}
+
+/** Gets a pointer to the externally stored part of a field.
+@param rec record
+@param offsets rec_get_offsets(rec)
+@param n index of the externally stored field
+@return pointer to the externally stored part */
+#define btr_rec_get_field_ref(rec, offsets, n) \
+ ((rec) + btr_rec_get_field_ref_offs(offsets, n))
+
+/***********************************************************//**
Gets the externally stored size of a record, in units of a database page.
@return externally stored part, in units of a database page */
static
ulint
btr_rec_get_externally_stored_len(
/*==============================*/
- rec_t* rec, /*!< in: record */
+ const rec_t* rec, /*!< in: record */
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{
ulint n_fields;
- byte* data;
- ulint local_len;
- ulint extern_len;
ulint total_extern_len = 0;
ulint i;
ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
+
+ if (!rec_offs_any_extern(offsets)) {
+ return(0);
+ }
+
n_fields = rec_offs_n_fields(offsets);
for (i = 0; i < n_fields; i++) {
if (rec_offs_nth_extern(offsets, i)) {
- data = rec_get_nth_field(rec, offsets, i, &local_len);
-
- local_len -= BTR_EXTERN_FIELD_REF_SIZE;
-
- extern_len = mach_read_from_4(data + local_len
- + BTR_EXTERN_LEN + 4);
+ ulint extern_len = mach_read_from_4(
+ btr_rec_get_field_ref(rec, offsets, i)
+ + BTR_EXTERN_LEN + 4);
total_extern_len += ut_calc_align(extern_len,
UNIV_PAGE_SIZE);
@@ -3821,7 +3654,7 @@ btr_cur_set_ownership_of_extern_field(
ulint byte_val;
data = rec_get_nth_field(rec, offsets, i, &local_len);
-
+ ut_ad(rec_offs_nth_extern(offsets, i));
ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
local_len -= BTR_EXTERN_FIELD_REF_SIZE;
@@ -3831,6 +3664,9 @@ btr_cur_set_ownership_of_extern_field(
if (val) {
byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
} else {
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ ut_a(!(byte_val & BTR_EXTERN_OWNER_FLAG));
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
}
@@ -4048,8 +3884,7 @@ btr_blob_free(
&& buf_block_get_space(block) == space
&& buf_block_get_page_no(block) == page_no) {
- if (buf_LRU_free_block(&block->page, all, NULL, TRUE)
- != BUF_LRU_FREED
+ if (buf_LRU_free_block(&block->page, all, TRUE) != BUF_LRU_FREED
&& all && block->page.zip.data
/* Now, buf_LRU_free_block() may release mutex temporarily */
&& buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE
@@ -4058,7 +3893,7 @@ btr_blob_free(
/* Attempt to deallocate the uncompressed page
if the whole block cannot be deallocted. */
- buf_LRU_free_block(&block->page, FALSE, NULL, TRUE);
+ buf_LRU_free_block(&block->page, FALSE, TRUE);
}
}
@@ -4075,8 +3910,8 @@ file segment of the index tree.
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
UNIV_INTERN
ulint
-btr_store_big_rec_extern_fields(
-/*============================*/
+btr_store_big_rec_extern_fields_func(
+/*=================================*/
dict_index_t* index, /*!< in: index of rec; the index tree
MUST be X-latched */
buf_block_t* rec_block, /*!< in/out: block containing rec */
@@ -4085,11 +3920,17 @@ btr_store_big_rec_extern_fields(
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
- big_rec_t* big_rec_vec, /*!< in: vector containing fields
+#ifdef UNIV_DEBUG
+ mtr_t* local_mtr, /*!< in: mtr containing the
+ latch to rec and to the tree */
+#endif /* UNIV_DEBUG */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ ibool update_in_place,/*! in: TRUE if the record is updated
+ in place (not delete+insert) */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+ const big_rec_t*big_rec_vec) /*!< in: vector containing fields
to be stored externally */
- mtr_t* local_mtr __attribute__((unused))) /*!< in: mtr
- containing the latch to rec and to the
- tree */
+
{
ulint rec_page_no;
byte* field_ref;
@@ -4107,6 +3948,7 @@ btr_store_big_rec_extern_fields(
z_stream c_stream;
ut_ad(rec_offs_validate(rec, index, offsets));
+ ut_ad(rec_offs_any_extern(offsets));
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
@@ -4138,21 +3980,37 @@ btr_store_big_rec_extern_fields(
ut_a(err == Z_OK);
}
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ /* All pointers to externally stored columns in the record
+ must either be zero or they must be pointers to inherited
+ columns, owned by this record or an earlier record version. */
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (!rec_offs_nth_extern(offsets, i)) {
+ continue;
+ }
+ field_ref = btr_rec_get_field_ref(rec, offsets, i);
+
+ ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
+ /* Either this must be an update in place,
+ or the BLOB must be inherited, or the BLOB pointer
+ must be zero (will be written in this function). */
+ ut_a(update_in_place
+ || (field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG)
+ || !memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+ }
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
/* We have to create a file segment to the tablespace
for each field and put the pointer to the field in rec */
for (i = 0; i < big_rec_vec->n_fields; i++) {
- ut_ad(rec_offs_nth_extern(offsets,
- big_rec_vec->fields[i].field_no));
- {
- ulint local_len;
- field_ref = rec_get_nth_field(
- rec, offsets, big_rec_vec->fields[i].field_no,
- &local_len);
- ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
- local_len -= BTR_EXTERN_FIELD_REF_SIZE;
- field_ref += local_len;
- }
+ field_ref = btr_rec_get_field_ref(
+ rec, offsets, big_rec_vec->fields[i].field_no);
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ /* A zero BLOB pointer should have been initially inserted. */
+ ut_a(!memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
extern_len = big_rec_vec->fields[i].len;
UNIV_MEM_ASSERT_RW(big_rec_vec->fields[i].data,
extern_len);
@@ -4434,6 +4292,23 @@ next_zip_page:
mem_heap_free(heap);
}
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ /* All pointers to externally stored columns in the record
+ must be valid. */
+ for (i = 0; i < rec_offs_n_fields(offsets); i++) {
+ if (!rec_offs_nth_extern(offsets, i)) {
+ continue;
+ }
+
+ field_ref = btr_rec_get_field_ref(rec, offsets, i);
+
+ /* The pointer must not be zero. */
+ ut_a(0 != memcmp(field_ref, field_ref_zero,
+ BTR_EXTERN_FIELD_REF_SIZE));
+ /* The column must not be disowned by this record. */
+ ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG));
+ }
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
return(DB_SUCCESS);
}
@@ -4456,6 +4331,7 @@ btr_check_blob_fil_page_type(
if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) {
ulint flags = fil_space_get_flags(space_id);
+#ifndef UNIV_DEBUG /* Improve debug test coverage */
if (UNIV_LIKELY
((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) {
/* Old versions of InnoDB did not initialize
@@ -4464,6 +4340,7 @@ btr_check_blob_fil_page_type(
a BLOB page that is in Antelope format.*/
return;
}
+#endif /* !UNIV_DEBUG */
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -4513,23 +4390,13 @@ btr_free_externally_stored_field(
ulint page_no;
ulint next_page_no;
mtr_t mtr;
-#ifdef UNIV_DEBUG
+
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(local_mtr, field_ref,
MTR_MEMO_PAGE_X_FIX));
ut_ad(!rec || rec_offs_validate(rec, index, offsets));
-
- if (rec) {
- ulint local_len;
- const byte* f = rec_get_nth_field(rec, offsets,
- i, &local_len);
- ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
- local_len -= BTR_EXTERN_FIELD_REF_SIZE;
- f += local_len;
- ut_ad(f == field_ref);
- }
-#endif /* UNIV_DEBUG */
+ ut_ad(!rec || field_ref == btr_rec_get_field_ref(rec, offsets, i));
if (UNIV_UNLIKELY(!memcmp(field_ref, field_ref_zero,
BTR_EXTERN_FIELD_REF_SIZE))) {
@@ -4694,13 +4561,8 @@ btr_rec_free_externally_stored_fields(
for (i = 0; i < n_fields; i++) {
if (rec_offs_nth_extern(offsets, i)) {
- ulint len;
- byte* data
- = rec_get_nth_field(rec, offsets, i, &len);
- ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE);
-
btr_free_externally_stored_field(
- index, data + len - BTR_EXTERN_FIELD_REF_SIZE,
+ index, btr_rec_get_field_ref(rec, offsets, i),
rec, offsets, page_zip, i, rb_ctx, mtr);
}
}
diff --git a/storage/xtradb/btr/btr0sea.c b/storage/xtradb/btr/btr0sea.c
index c78f791480c..3b38e2799c2 100644
--- a/storage/xtradb/btr/btr0sea.c
+++ b/storage/xtradb/btr/btr0sea.c
@@ -141,7 +141,7 @@ btr_search_check_free_space_in_heap(void)
be enough free space in the hash table. */
if (heap->free_block == NULL) {
- buf_block_t* block = buf_block_alloc(0);
+ buf_block_t* block = buf_block_alloc();
rw_lock_x_lock(&btr_search_latch);
@@ -1186,7 +1186,7 @@ btr_search_drop_page_hash_index_on_index(
/*=====================================*/
dict_index_t* index) /* in: record descriptor */
{
- buf_page_t* bpage;
+
hash_table_t* table;
buf_block_t* block;
ulint n_fields;
@@ -1202,96 +1202,143 @@ btr_search_drop_page_hash_index_on_index(
ulint i;
mem_heap_t* heap = NULL;
ulint* offsets;
+ ibool released_search_latch;
- rw_lock_x_lock(&btr_search_latch);
- mutex_enter(&LRU_list_mutex);
+ rw_lock_s_lock(&btr_search_latch);
table = btr_search_sys->hash_index;
- bpage = UT_LIST_GET_LAST(buf_pool->LRU);
+ do {
+ buf_chunk_t* chunks = buf_pool->chunks;
+ buf_chunk_t* chunk = chunks + buf_pool->n_chunks;
+
+ released_search_latch = FALSE;
+
+ while (--chunk >= chunks) {
+ block = chunk->blocks;
+ i = chunk->size;
+
+retry:
+ for (; i--; block++) {
+ if (buf_block_get_state(block)
+ != BUF_BLOCK_FILE_PAGE
+ || block->index != index
+ || !block->is_hashed) {
+ continue;
+ }
+
+ page = block->frame;
+
+ /* from btr_search_drop_page_hash_index() */
+ n_fields = block->curr_n_fields;
+ n_bytes = block->curr_n_bytes;
+
- while (bpage != NULL) {
- block = (buf_block_t*) bpage;
- if (block->index == index && block->is_hashed) {
- page = block->frame;
+ /* keeping latch order */
+ rw_lock_s_unlock(&btr_search_latch);
+ released_search_latch = TRUE;
+ rw_lock_x_lock(&block->lock);
- /* from btr_search_drop_page_hash_index() */
- n_fields = block->curr_n_fields;
- n_bytes = block->curr_n_bytes;
- ut_a(n_fields + n_bytes > 0);
+ ut_a(n_fields + n_bytes > 0);
- n_recs = page_get_n_recs(page);
+ n_recs = page_get_n_recs(page);
- /* Calculate and cache fold values into an array for fast deletion
- from the hash index */
+ /* Calculate and cache fold values into an array for fast deletion
+ from the hash index */
- folds = mem_alloc(n_recs * sizeof(ulint));
+ folds = mem_alloc(n_recs * sizeof(ulint));
- n_cached = 0;
+ n_cached = 0;
- rec = page_get_infimum_rec(page);
- rec = page_rec_get_next_low(rec, page_is_comp(page));
+ rec = page_get_infimum_rec(page);
+ rec = page_rec_get_next_low(rec, page_is_comp(page));
- index_id = btr_page_get_index_id(page);
+ index_id = btr_page_get_index_id(page);
- ut_a(0 == ut_dulint_cmp(index_id, index->id));
+ ut_a(0 == ut_dulint_cmp(index_id, index->id));
- prev_fold = 0;
+ prev_fold = 0;
- offsets = NULL;
+ offsets = NULL;
- while (!page_rec_is_supremum(rec)) {
- offsets = rec_get_offsets(rec, index, offsets,
- n_fields + (n_bytes > 0), &heap);
- ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
- fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
+ while (!page_rec_is_supremum(rec)) {
+ offsets = rec_get_offsets(rec, index, offsets,
+ n_fields + (n_bytes > 0), &heap);
+ ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
+ fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
- if (fold == prev_fold && prev_fold != 0) {
+ if (fold == prev_fold && prev_fold != 0) {
- goto next_rec;
- }
+ goto next_rec;
+ }
- /* Remove all hash nodes pointing to this page from the
- hash chain */
+ /* Remove all hash nodes pointing to this page from the
+ hash chain */
- folds[n_cached] = fold;
- n_cached++;
+ folds[n_cached] = fold;
+ n_cached++;
next_rec:
- rec = page_rec_get_next_low(rec, page_rec_is_comp(rec));
- prev_fold = fold;
- }
+ rec = page_rec_get_next_low(rec, page_rec_is_comp(rec));
+ prev_fold = fold;
+ }
- for (i = 0; i < n_cached; i++) {
+ if (UNIV_LIKELY_NULL(heap)) {
+ mem_heap_empty(heap);
+ }
- ha_remove_all_nodes_to_page(table, folds[i], page);
- }
+ rw_lock_x_lock(&btr_search_latch);
- ut_a(index->search_info->ref_count > 0);
- index->search_info->ref_count--;
+ if (UNIV_UNLIKELY(!block->is_hashed)) {
+ goto cleanup;
+ }
- block->is_hashed = FALSE;
- block->index = NULL;
-
+ ut_a(block->index == index);
+
+ if (UNIV_UNLIKELY(block->curr_n_fields != n_fields)
+ || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) {
+ rw_lock_x_unlock(&btr_search_latch);
+ rw_lock_x_unlock(&block->lock);
+
+ mem_free(folds);
+
+ rw_lock_s_lock(&btr_search_latch);
+ goto retry;
+ }
+
+ for (i = 0; i < n_cached; i++) {
+
+ ha_remove_all_nodes_to_page(table, folds[i], page);
+ }
+
+ ut_a(index->search_info->ref_count > 0);
+ index->search_info->ref_count--;
+
+ block->is_hashed = FALSE;
+ block->index = NULL;
+
+cleanup:
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
- if (UNIV_UNLIKELY(block->n_pointers)) {
- /* Corruption */
- ut_print_timestamp(stderr);
- fprintf(stderr,
+ if (UNIV_UNLIKELY(block->n_pointers)) {
+ /* Corruption */
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
" InnoDB: Corruption of adaptive hash index. After dropping\n"
"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n",
- index->name, (ulong) block->n_pointers);
- }
+ index->name, (ulong) block->n_pointers);
+ }
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+ rw_lock_x_unlock(&btr_search_latch);
+ rw_lock_x_unlock(&block->lock);
- mem_free(folds);
- }
+ mem_free(folds);
- bpage = UT_LIST_GET_PREV(LRU, bpage);
- }
+ rw_lock_s_lock(&btr_search_latch);
+ }
+ }
+ } while (released_search_latch);
- mutex_exit(&LRU_list_mutex);
- rw_lock_x_unlock(&btr_search_latch);
+ rw_lock_s_unlock(&btr_search_latch);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
diff --git a/storage/xtradb/buf/buf0buddy.c b/storage/xtradb/buf/buf0buddy.c
index e6b80bcda55..db94b4bed24 100644
--- a/storage/xtradb/buf/buf0buddy.c
+++ b/storage/xtradb/buf/buf0buddy.c
@@ -346,7 +346,7 @@ buf_buddy_alloc_low(
if (have_page_hash_mutex) {
rw_lock_x_unlock(&page_hash_latch);
}
- block = buf_LRU_get_free_block(0);
+ block = buf_LRU_get_free_block();
*lru = TRUE;
//buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
@@ -452,8 +452,6 @@ buf_buddy_relocate(
buf_page_t* bpage;
const ulint size = BUF_BUDDY_LOW << i;
ullint usec = ut_time_us(NULL);
- ulint space;
- ulint page_no;
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
@@ -477,6 +475,7 @@ buf_buddy_relocate(
if (size >= PAGE_ZIP_MIN_SIZE) {
/* This is a compressed page. */
mutex_t* mutex;
+ ulint space, page_no;
if (!have_page_hash_mutex) {
mutex_exit(&zip_free_mutex);
diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c
index 9dc5da2069a..5ea8056bed4 100644
--- a/storage/xtradb/buf/buf0buf.c
+++ b/storage/xtradb/buf/buf0buf.c
@@ -754,9 +754,9 @@ buf_block_init(
block->modify_clock = 0;
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
block->page.file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
block->check_index_page_at_flush = FALSE;
block->index = NULL;
@@ -839,11 +839,13 @@ buf_chunk_init(
ulint zip_hash_mem_size = 0;
hash_table_t* zip_hash_tmp = NULL;
ulint i;
+ ulint size_target;
buf_shm_info_t* shm_info = NULL;
/* Round down to a multiple of page size,
although it already should be. */
mem_size = ut_2pow_round(mem_size, UNIV_PAGE_SIZE);
+ size_target = (mem_size / UNIV_PAGE_SIZE) - 1;
srv_buffer_pool_shm_is_reused = FALSE;
@@ -1044,6 +1046,10 @@ init_again:
chunk->size = size;
}
+ if (chunk->size > size_target) {
+ chunk->size = size_target;
+ }
+
if (shm_info && !(shm_info->is_new)) {
/* convert the shared memory segment for reuse */
ptrdiff_t phys_offset;
@@ -1830,7 +1836,7 @@ shrink_again:
buf_LRU_make_block_old(&block->page);
dirty++;
- } else if (buf_LRU_free_block(&block->page, TRUE, NULL, FALSE)
+ } else if (buf_LRU_free_block(&block->page, TRUE, FALSE)
!= BUF_LRU_FREED) {
nonfree++;
}
@@ -2177,7 +2183,7 @@ buf_page_peek_if_search_hashed(
return(is_hashed);
}
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
/********************************************************************//**
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
This function should be called when we free a file page and want the
@@ -2199,6 +2205,8 @@ buf_page_set_file_page_was_freed(
bpage = buf_page_hash_get(space, offset);
if (bpage) {
+ /* bpage->file_page_was_freed can already hold
+ when this code is invoked from dict_drop_index_tree() */
bpage->file_page_was_freed = TRUE;
}
@@ -2237,7 +2245,7 @@ buf_page_reset_file_page_was_freed(
return(bpage);
}
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
/********************************************************************//**
Get read access to a compressed page (usually of type
@@ -2333,8 +2341,7 @@ err_exit:
ut_a(block_mutex == &((buf_block_t*) bpage)->mutex);
/* Discard the uncompressed page frame if possible. */
- if (buf_LRU_free_block(bpage, FALSE, NULL, FALSE)
- == BUF_LRU_FREED) {
+ if (buf_LRU_free_block(bpage, FALSE, FALSE) == BUF_LRU_FREED) {
mutex_exit(block_mutex);
goto lookup;
@@ -2358,7 +2365,7 @@ got_block:
buf_page_set_accessed_make_young(bpage, access_time);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(!bpage->file_page_was_freed);
#endif
@@ -2821,7 +2828,7 @@ wait_until_unfixed:
//mutex_exit(&buf_pool_zip_mutex);
mutex_exit(block_mutex);
- block = buf_LRU_get_free_block(0);
+ block = buf_LRU_get_free_block();
ut_a(block);
block_mutex = &block->mutex;
@@ -2974,8 +2981,7 @@ wait_until_unfixed:
/* Try to evict the block from the buffer pool, to use the
insert buffer as much as possible. */
- if (buf_LRU_free_block(&block->page, TRUE, NULL)
- == BUF_LRU_FREED) {
+ if (buf_LRU_free_block(&block->page, TRUE, FALSE) == BUF_LRU_FREED) {
buf_pool_mutex_exit();
mutex_exit(&block->mutex);
fprintf(stderr,
@@ -3007,7 +3013,7 @@ wait_until_unfixed:
buf_page_set_accessed_make_young(&block->page, access_time);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(!block->page.file_page_was_freed);
#endif
@@ -3183,7 +3189,7 @@ buf_page_optimistic_get(
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(block->page.file_page_was_freed == FALSE);
#endif
if (innobase_get_slow_log()) {
@@ -3303,7 +3309,7 @@ buf_page_get_known_nowait(
ut_a(block->page.buf_fix_count > 0);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(block->page.file_page_was_freed == FALSE);
#endif
@@ -3394,9 +3400,9 @@ buf_page_try_get_func(
ut_a(block->page.buf_fix_count > 0);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ut_a(block->page.file_page_was_freed == FALSE);
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
buf_pool->stat.n_page_gets++;
@@ -3426,9 +3432,9 @@ buf_page_init_low(
bpage->oldest_modification = 0;
HASH_INVALIDATE(bpage, hash);
bpage->is_corrupt = FALSE;
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
bpage->file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
}
/********************************************************************//**
@@ -3556,7 +3562,7 @@ buf_page_init_for_read(
&& UNIV_LIKELY(!recv_recovery_is_on())) {
block = NULL;
} else {
- block = buf_LRU_get_free_block(0);
+ block = buf_LRU_get_free_block();
ut_ad(block);
}
@@ -3682,6 +3688,7 @@ err_exit:
bpage->state = BUF_BLOCK_ZIP_PAGE;
bpage->space = space;
bpage->offset = offset;
+ bpage->space_was_being_deleted = FALSE;
#ifdef UNIV_DEBUG
bpage->in_page_hash = FALSE;
@@ -3750,7 +3757,7 @@ buf_page_create(
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad(space || !zip_size);
- free_block = buf_LRU_get_free_block(0);
+ free_block = buf_LRU_get_free_block();
//buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
@@ -3762,9 +3769,9 @@ buf_page_create(
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(space, offset) == 0);
#endif
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
block->page.file_page_was_freed = FALSE;
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
/* Page can be found in buf_pool */
//buf_pool_mutex_exit();
diff --git a/storage/xtradb/buf/buf0flu.c b/storage/xtradb/buf/buf0flu.c
index 5db6f816aab..cda8d3b170e 100644
--- a/storage/xtradb/buf/buf0flu.c
+++ b/storage/xtradb/buf/buf0flu.c
@@ -367,7 +367,7 @@ buf_flush_ready_for_replace(
if (UNIV_LIKELY(bpage->in_LRU_list && buf_page_in_file(bpage))) {
- return(bpage->oldest_modification == 0
+ return((bpage->oldest_modification == 0 || bpage->space_was_being_deleted)
&& buf_page_get_io_fix(bpage) == BUF_IO_NONE
&& bpage->buf_fix_count == 0);
}
@@ -406,6 +406,13 @@ buf_flush_ready_for_flush(
&& buf_page_get_io_fix(bpage) == BUF_IO_NONE) {
ut_ad(bpage->in_flush_list);
+ if (bpage->space_was_being_deleted) {
+ /* should be removed from flush_list here */
+ /* because buf_flush_try_neighbors() cannot flush without fil_space_get_size(space) */
+ buf_flush_remove(bpage);
+ return(FALSE);
+ }
+
if (flush_type != BUF_FLUSH_LRU) {
return(TRUE);
diff --git a/storage/xtradb/buf/buf0lru.c b/storage/xtradb/buf/buf0lru.c
index 92a645ef2f5..583eec9bd9c 100644
--- a/storage/xtradb/buf/buf0lru.c
+++ b/storage/xtradb/buf/buf0lru.c
@@ -530,6 +530,30 @@ next_page_no_mutex:
}
}
+/******************************************************************//**
+*/
+UNIV_INTERN
+void
+buf_LRU_mark_space_was_deleted(
+/*===========================*/
+ ulint id) /*!< in: space id */
+{
+ buf_page_t* bpage;
+
+ mutex_enter(&LRU_list_mutex);
+
+ bpage = UT_LIST_GET_FIRST(buf_pool->LRU);
+
+ while (bpage != NULL) {
+ if (buf_page_get_space(bpage) == id) {
+ bpage->space_was_being_deleted = TRUE;
+ }
+ bpage = UT_LIST_GET_NEXT(LRU, bpage);
+ }
+
+ mutex_exit(&LRU_list_mutex);
+}
+
/********************************************************************//**
Insert a compressed block into buf_pool->zip_clean in the LRU order. */
UNIV_INTERN
@@ -618,7 +642,7 @@ restart:
ut_ad(block->in_unzip_LRU_list);
ut_ad(block->page.in_LRU_list);
- freed = buf_LRU_free_block(&block->page, FALSE, NULL, have_LRU_mutex);
+ freed = buf_LRU_free_block(&block->page, FALSE, have_LRU_mutex);
mutex_exit(&block->mutex);
switch (freed) {
@@ -690,7 +714,7 @@ restart:
ut_ad(bpage->in_LRU_list);
accessed = buf_page_is_accessed(bpage);
- freed = buf_LRU_free_block(bpage, TRUE, NULL, have_LRU_mutex);
+ freed = buf_LRU_free_block(bpage, TRUE, have_LRU_mutex);
mutex_exit(block_mutex);
switch (freed) {
@@ -876,10 +900,8 @@ LRU list to the free list.
@return the free control block, in state BUF_BLOCK_READY_FOR_USE */
UNIV_INTERN
buf_block_t*
-buf_LRU_get_free_block(
-/*===================*/
- ulint zip_size) /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_LRU_get_free_block(void)
+/*========================*/
{
buf_block_t* block = NULL;
ibool freed;
@@ -955,28 +977,10 @@ loop:
/* If there is a block in the free list, take it */
block = buf_LRU_get_free_only();
- if (block) {
-
-#ifdef UNIV_DEBUG
- block->page.zip.m_start =
-#endif /* UNIV_DEBUG */
- block->page.zip.m_end =
- block->page.zip.m_nonempty =
- block->page.zip.n_blobs = 0;
-
- if (UNIV_UNLIKELY(zip_size)) {
- ibool lru;
- page_zip_set_size(&block->page.zip, zip_size);
- mutex_enter(&LRU_list_mutex);
- block->page.zip.data = buf_buddy_alloc(zip_size, &lru, FALSE);
- mutex_exit(&LRU_list_mutex);
- UNIV_MEM_DESC(block->page.zip.data, zip_size, block);
- } else {
- page_zip_set_size(&block->page.zip, 0);
- block->page.zip.data = NULL;
- }
+ //buf_pool_mutex_exit();
- //buf_pool_mutex_exit();
+ if (block) {
+ memset(&block->page.zip, 0, sizeof block->page.zip);
if (started_monitor) {
srv_print_innodb_monitor = mon_value_was;
@@ -988,8 +992,6 @@ loop:
/* If no block was in the free list, search from the end of the LRU
list and try to free a block there */
- //buf_pool_mutex_exit();
-
freed = buf_LRU_search_and_free_block(n_iterations);
if (freed > 0) {
@@ -1471,10 +1473,6 @@ buf_LRU_free_block(
buf_page_t* bpage, /*!< in: block to be freed */
ibool zip, /*!< in: TRUE if should remove also the
compressed page of an uncompressed page */
- ibool* buf_pool_mutex_released,
- /*!< in: pointer to a variable that will
- be assigned TRUE if buf_pool_mutex
- was temporarily released, or NULL */
ibool have_LRU_mutex)
{
buf_page_t* b = NULL;
@@ -1498,6 +1496,10 @@ buf_LRU_free_block(
return(BUF_LRU_NOT_FREED);
}
+ if (bpage->space_was_being_deleted && bpage->oldest_modification != 0) {
+ buf_flush_remove(bpage);
+ }
+
#ifdef UNIV_IBUF_COUNT_DEBUG
ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0);
#endif /* UNIV_IBUF_COUNT_DEBUG */
@@ -1685,10 +1687,6 @@ not_freed:
b->io_fix = BUF_IO_READ;
}
- if (buf_pool_mutex_released) {
- *buf_pool_mutex_released = TRUE;
- }
-
//buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
@@ -2369,8 +2367,7 @@ buf_LRU_file_restore(void)
continue;
}
- if (fil_area_is_exist(space_id, zip_size, page_no, 0,
- zip_size ? zip_size : UNIV_PAGE_SIZE)) {
+ if (fil_is_exist(space_id, page_no)) {
tablespace_version = fil_space_get_version(space_id);
diff --git a/storage/xtradb/dict/dict0boot.c b/storage/xtradb/dict/dict0boot.c
index 43cfced65a0..2b6a208321d 100644
--- a/storage/xtradb/dict/dict0boot.c
+++ b/storage/xtradb/dict/dict0boot.c
@@ -465,17 +465,21 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_STATS", DICT_HDR_SPACE, 3, 0);
+ table = dict_mem_table_create("SYS_STATS", DICT_HDR_SPACE, 4, 0);
table->n_mysql_handles_opened = 1; /* for pin */
dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "KEY_COLS", DATA_INT, 0, 4);
dict_mem_table_add_col(table, heap, "DIFF_VALS", DATA_BINARY, 0, 0);
+ dict_mem_table_add_col(table, heap, "NON_NULL_VALS", DATA_BINARY, 0, 0);
/* The '+ 2' below comes from the fields DB_TRX_ID, DB_ROLL_PTR */
#if DICT_SYS_STATS_DIFF_VALS_FIELD != 2 + 2
#error "DICT_SYS_STATS_DIFF_VALS_FIELD != 2 + 2"
#endif
+#if DICT_SYS_STATS_NON_NULL_VALS_FIELD != 3 + 2
+#error "DICT_SYS_STATS_NON_NULL_VALS_FIELD != 3 + 2"
+#endif
table->id = DICT_STATS_ID;
dict_table_add_to_cache(table, heap);
diff --git a/storage/xtradb/dict/dict0crea.c b/storage/xtradb/dict/dict0crea.c
index c63ff57be97..c6e7d588e72 100644
--- a/storage/xtradb/dict/dict0crea.c
+++ b/storage/xtradb/dict/dict0crea.c
@@ -529,7 +529,7 @@ dict_create_sys_stats_tuple(
sys_stats = dict_sys->sys_stats;
- entry = dtuple_create(heap, 3 + DATA_N_SYS_COLS);
+ entry = dtuple_create(heap, 4 + DATA_N_SYS_COLS);
dict_table_copy_types(entry, sys_stats);
@@ -548,6 +548,11 @@ dict_create_sys_stats_tuple(
ptr = mem_heap_alloc(heap, 8);
mach_write_to_8(ptr, ut_dulint_zero); /* initial value is 0 */
dfield_set_data(dfield, ptr, 8);
+ /* 5: NON_NULL_VALS ------------------*/
+ dfield = dtuple_get_nth_field(entry, 3/*NON_NULL_VALS*/);
+ ptr = mem_heap_alloc(heap, 8);
+ mach_write_to_8(ptr, ut_dulint_zero); /* initial value is 0 */
+ dfield_set_data(dfield, ptr, 8);
return(entry);
}
diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c
index 638ab55703b..18880a5c72c 100644
--- a/storage/xtradb/dict/dict0dict.c
+++ b/storage/xtradb/dict/dict0dict.c
@@ -1732,6 +1732,12 @@ undo_size_ok:
new_index->heap,
(1 + dict_index_get_n_unique(new_index))
* sizeof(ib_int64_t));
+
+ new_index->stat_n_non_null_key_vals = mem_heap_zalloc(
+ new_index->heap,
+ (1 + dict_index_get_n_unique(new_index))
+ * sizeof(*new_index->stat_n_non_null_key_vals));
+
/* Give some sensible values to stat_n_... in case we do
not calculate statistics quickly enough */
@@ -4331,15 +4337,18 @@ dict_reload_statistics(
ulint key_cols;
ulint n_cols;
const rec_t* rec;
+ ulint n_fields;
const byte* field;
ulint len;
ib_int64_t* stat_n_diff_key_vals_tmp;
+ ib_int64_t* stat_n_non_null_key_vals_tmp;
byte* buf;
ulint i;
mtr_t mtr;
n_cols = dict_index_get_n_unique(index);
stat_n_diff_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
+ stat_n_non_null_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
sys_stats = dict_sys->sys_stats;
sys_index = UT_LIST_GET_FIRST(sys_stats->indexes);
@@ -4375,9 +4384,13 @@ dict_reload_statistics(
}
if (rec_get_deleted_flag(rec, 0)) {
+ /* don't count */
+ i--;
goto next_rec;
}
+ n_fields = rec_get_n_fields_old(rec);
+
field = rec_get_nth_field_old(rec, 1, &len);
ut_a(len == 4);
@@ -4389,6 +4402,21 @@ dict_reload_statistics(
ut_a(len == 8);
stat_n_diff_key_vals_tmp[i] = ut_conv_dulint_to_longlong(mach_read_from_8(field));
+
+ if (n_fields > DICT_SYS_STATS_NON_NULL_VALS_FIELD) {
+ field = rec_get_nth_field_old(rec, DICT_SYS_STATS_NON_NULL_VALS_FIELD, &len);
+ ut_a(len == 8);
+
+ stat_n_non_null_key_vals_tmp[i] = ut_conv_dulint_to_longlong(mach_read_from_8(field));
+ } else {
+ /* not enough fields: should be older */
+ fprintf(stderr, "InnoDB: Notice: stats for %s/%s (%lu/%lu)"
+ " in SYS_STATS seems older format. "
+ "Please execute ANALYZE TABLE for it.\n",
+ index->table_name, index->name, i, n_cols);
+
+ stat_n_non_null_key_vals_tmp[i] = ((ib_int64_t)(-1));
+ }
next_rec:
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
}
@@ -4398,6 +4426,12 @@ next_rec:
for (i = 0; i <= n_cols; i++) {
index->stat_n_diff_key_vals[i] = stat_n_diff_key_vals_tmp[i];
+ if (stat_n_non_null_key_vals_tmp[i] == ((ib_int64_t)(-1))) {
+ /* approximate value */
+ index->stat_n_non_null_key_vals[i] = stat_n_diff_key_vals_tmp[n_cols];
+ } else {
+ index->stat_n_non_null_key_vals[i] = stat_n_non_null_key_vals_tmp[i];
+ }
}
}
/*===========================================*/
@@ -4442,18 +4476,22 @@ dict_store_statistics(
ulint n_cols;
ulint rests;
const rec_t* rec;
+ ulint n_fields;
const byte* field;
ulint len;
ib_int64_t* stat_n_diff_key_vals_tmp;
+ ib_int64_t* stat_n_non_null_key_vals_tmp;
byte* buf;
ulint i;
mtr_t mtr;
n_cols = dict_index_get_n_unique(index);
stat_n_diff_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
+ stat_n_non_null_key_vals_tmp = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t));
for (i = 0; i <= n_cols; i++) {
stat_n_diff_key_vals_tmp[i] = index->stat_n_diff_key_vals[i];
+ stat_n_non_null_key_vals_tmp[i] = index->stat_n_non_null_key_vals[i];
}
sys_stats = dict_sys->sys_stats;
@@ -4481,12 +4519,24 @@ dict_store_statistics(
|| ut_dulint_cmp(mach_read_from_8(rec_get_nth_field_old(rec, 0, &len)),
index->id)) {
/* not found */
- btr_pcur_close(&pcur);
- mtr_commit(&mtr);
+
+
break;
}
if (rec_get_deleted_flag(rec, 0)) {
+ /* don't count */
+ i--;
+ goto next_rec;
+ }
+
+ n_fields = rec_get_n_fields_old(rec);
+
+ if (n_fields <= DICT_SYS_STATS_NON_NULL_VALS_FIELD) {
+ /* not update for the older smaller format */
+ fprintf(stderr, "InnoDB: Notice: stats for %s/%s (%lu/%lu)"
+ " in SYS_STATS seems older format. Please ANALYZE TABLE it.\n",
+ index->table_name, index->name, i, n_cols);
goto next_rec;
}
@@ -4503,6 +4553,14 @@ dict_store_statistics(
(ulint) stat_n_diff_key_vals_tmp[key_cols] & 0xFFFFFFFF),
&mtr);
+ field = rec_get_nth_field_old(rec, DICT_SYS_STATS_NON_NULL_VALS_FIELD, &len);
+ ut_a(len == 8);
+
+ mlog_write_dulint((byte*)field,
+ ut_dulint_create((ulint) (stat_n_non_null_key_vals_tmp[key_cols] >> 32),
+ (ulint) stat_n_non_null_key_vals_tmp[key_cols] & 0xFFFFFFFF),
+ &mtr);
+
rests--;
next_rec:
@@ -4635,6 +4693,10 @@ dict_update_statistics(
for (i = dict_index_get_n_unique(index); i; ) {
index->stat_n_diff_key_vals[i--] = 1;
}
+
+ memset(index->stat_n_non_null_key_vals, 0,
+ (1 + dict_index_get_n_unique(index))
+ * sizeof(*index->stat_n_non_null_key_vals));
}
index = dict_table_get_next_index(index);
@@ -4662,6 +4724,78 @@ end:
dict_table_stats_unlock(table, RW_X_LATCH);
}
+/*********************************************************************//**
+*/
+UNIV_INTERN
+ibool
+dict_is_older_statistics(
+/*=====================*/
+ dict_index_t* index)
+{
+ mem_heap_t* heap;
+ dict_table_t* sys_stats;
+ dict_index_t* sys_index;
+ btr_pcur_t pcur;
+ dtuple_t* tuple;
+ dfield_t* dfield;
+ const rec_t* rec;
+ ulint n_fields;
+ ulint len;
+ byte* buf;
+ mtr_t mtr;
+
+ heap = mem_heap_create(100);
+
+ sys_stats = dict_sys->sys_stats;
+ sys_index = UT_LIST_GET_FIRST(sys_stats->indexes);
+ ut_a(!dict_table_is_comp(sys_stats));
+
+ tuple = dtuple_create(heap, 1);
+ dfield = dtuple_get_nth_field(tuple, 0);
+
+ buf = mem_heap_alloc(heap, 8);
+ mach_write_to_8(buf, index->id);
+
+ dfield_set_data(dfield, buf, 8);
+ dict_index_copy_types(tuple, sys_index, 1);
+
+ mtr_start(&mtr);
+
+ btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
+ BTR_SEARCH_LEAF, &pcur, &mtr);
+
+next_rec:
+ rec = btr_pcur_get_rec(&pcur);
+
+ if (!btr_pcur_is_on_user_rec(&pcur)
+ || ut_dulint_cmp(mach_read_from_8(rec_get_nth_field_old(rec, 0, &len)),
+ index->id)) {
+ /* not found */
+ btr_pcur_close(&pcur);
+ mtr_commit(&mtr);
+ mem_heap_free(heap);
+ /* no statistics == not older statistics */
+ return(FALSE);
+ }
+
+ if (rec_get_deleted_flag(rec, 0)) {
+ btr_pcur_move_to_next_user_rec(&pcur, &mtr);
+ goto next_rec;
+ }
+
+ n_fields = rec_get_n_fields_old(rec);
+
+ btr_pcur_close(&pcur);
+ mtr_commit(&mtr);
+ mem_heap_free(heap);
+
+ if (n_fields > DICT_SYS_STATS_NON_NULL_VALS_FIELD) {
+ return(FALSE);
+ } else {
+ return(TRUE);
+ }
+}
+
/**********************************************************************//**
Prints info of a foreign key constraint. */
static
diff --git a/storage/xtradb/fil/fil0fil.c b/storage/xtradb/fil/fil0fil.c
index dd15576edf7..3c535bf7331 100644
--- a/storage/xtradb/fil/fil0fil.c
+++ b/storage/xtradb/fil/fil0fil.c
@@ -242,6 +242,7 @@ the ib_logfiles form a 'space' and it is handled here */
struct fil_system_struct {
#ifndef UNIV_HOTBACKUP
mutex_t mutex; /*!< The mutex protecting the cache */
+ mutex_t file_extend_mutex;
#endif /* !UNIV_HOTBACKUP */
hash_table_t* spaces; /*!< The hash table of spaces in the
system; they are hashed on the space
@@ -690,7 +691,7 @@ fil_node_open_file(
ut_a(space->purpose != FIL_LOG);
ut_a(!trx_sys_sys_space(space->id));
- if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
+ if (size_bytes < (ib_uint64_t) (FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE)) {
fprintf(stderr,
"InnoDB: Error: the size of single-table"
" tablespace file %s\n"
@@ -816,7 +817,7 @@ fil_node_close_file(
ut_ad(node && system);
ut_ad(mutex_own(&(system->mutex)));
ut_a(node->open);
- ut_a(node->n_pending == 0);
+ ut_a(node->n_pending == 0 || srv_lazy_drop_table);
ut_a(node->n_pending_flushes == 0);
ut_a(node->modification_counter == node->flush_counter);
@@ -1028,7 +1029,7 @@ fil_node_free(
ut_ad(node && system && space);
ut_ad(mutex_own(&(system->mutex)));
ut_a(node->magic_n == FIL_NODE_MAGIC_N);
- ut_a(node->n_pending == 0);
+ ut_a(node->n_pending == 0 || srv_lazy_drop_table);
if (node->open) {
/* We fool the assertion in fil_node_close_file() to think
@@ -1549,6 +1550,7 @@ fil_init(
fil_system = mem_zalloc(sizeof(fil_system_t));
mutex_create(&fil_system->mutex, SYNC_ANY_LATCH);
+ mutex_create(&fil_system->file_extend_mutex, SYNC_OUTER_ANY_LATCH);
fil_system->spaces = hash_create(hash_size);
fil_system->name_hash = hash_create(hash_size);
@@ -2295,7 +2297,11 @@ try_again:
completely and permanently. The flag is_being_deleted also prevents
fil_flush() from being applied to this tablespace. */
+ if (srv_lazy_drop_table) {
+ buf_LRU_mark_space_was_deleted(id);
+ } else {
buf_LRU_invalidate_tablespace(id);
+ }
#endif
/* printf("Deleting tablespace %s id %lu\n", space->name, id); */
@@ -3095,8 +3101,8 @@ fil_open_single_table_tablespace(
space_id = fsp_header_get_space_id(page);
space_flags = fsp_header_get_flags(page);
- if (srv_expand_import
- && (space_id != id || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) {
+ if (srv_expand_import) {
+
ibool file_is_corrupt = FALSE;
byte* buf3;
byte* descr_page;
@@ -3167,8 +3173,10 @@ fil_open_single_table_tablespace(
if (size_bytes < free_limit_bytes) {
free_limit_bytes = size_bytes;
- fprintf(stderr, "InnoDB: free limit of %s is larger than its real size.\n", filepath);
- file_is_corrupt = TRUE;
+ if (size_bytes >= (ib_int64_t) (FSP_EXTENT_SIZE * UNIV_PAGE_SIZE)) {
+ fprintf(stderr, "InnoDB: free limit of %s is larger than its real size.\n", filepath);
+ file_is_corrupt = TRUE;
+ }
}
/* get cruster index information */
@@ -3314,7 +3322,7 @@ skip_info:
file_is_corrupt = TRUE;
descr_is_corrupt = TRUE;
} else {
- ut_a(fil_page_get_type(page) == FIL_PAGE_TYPE_XDES);
+
descr_is_corrupt = FALSE;
}
@@ -3778,7 +3786,7 @@ fil_load_single_table_tablespace(
size = (((ib_uint64_t)size_high) << 32) + (ib_uint64_t)size_low;
#ifndef UNIV_HOTBACKUP
- if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
+ if (size < (ib_uint64_t) (FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE)) {
fprintf(stderr,
"InnoDB: Error: the size of single-table tablespace"
" file %s\n"
@@ -3798,7 +3806,7 @@ fil_load_single_table_tablespace(
/* Align the memory for file i/o if we might have O_DIRECT set */
page = ut_align(buf2, UNIV_PAGE_SIZE);
- if (size >= FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
+ if (size >= (ib_uint64_t) (FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE)) {
success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
/* We have to read the tablespace id from the file */
@@ -4348,6 +4356,10 @@ fil_extend_space_to_desired_size(
ulint page_size;
ibool success = TRUE;
+ /* file_extend_mutex is for http://bugs.mysql.com/56433 */
+ /* to protect from the other fil_extend_space_to_desired_size() */
+ /* during temprary releasing &fil_system->mutex */
+ mutex_enter(&fil_system->file_extend_mutex);
fil_mutex_enter_and_prepare_for_io(space_id);
space = fil_space_get_by_id(space_id);
@@ -4359,6 +4371,7 @@ fil_extend_space_to_desired_size(
*actual_size = space->size;
mutex_exit(&fil_system->mutex);
+ mutex_exit(&fil_system->file_extend_mutex);
return(TRUE);
}
@@ -4391,6 +4404,8 @@ fil_extend_space_to_desired_size(
offset_low = ((start_page_no - file_start_page_no)
% (4096 * ((1024 * 1024) / page_size)))
* page_size;
+
+ mutex_exit(&fil_system->mutex);
#ifdef UNIV_HOTBACKUP
success = os_file_write(node->name, node->handle, buf,
offset_low, offset_high,
@@ -4400,8 +4415,10 @@ fil_extend_space_to_desired_size(
node->name, node->handle, buf,
offset_low, offset_high,
page_size * n_pages,
- NULL, NULL, NULL);
+ NULL, NULL, space_id, NULL);
#endif
+ mutex_enter(&fil_system->mutex);
+
if (success) {
node->size += n_pages;
space->size += n_pages;
@@ -4447,6 +4464,7 @@ fil_extend_space_to_desired_size(
printf("Extended %s to %lu, actual size %lu pages\n", space->name,
size_after_extend, *actual_size); */
mutex_exit(&fil_system->mutex);
+ mutex_exit(&fil_system->file_extend_mutex);
fil_flush(space_id);
@@ -4811,6 +4829,22 @@ _fil_io(
srv_data_written+= len;
}
+ /* if the table space was already deleted, space might not exist already. */
+ if (message
+ && space_id < SRV_LOG_SPACE_FIRST_ID
+ && ((buf_page_t*)message)->space_was_being_deleted) {
+
+ if (mode == OS_AIO_NORMAL) {
+ buf_page_io_complete(message, trx);
+ return(DB_SUCCESS); /*fake*/
+ }
+ if (type == OS_FILE_READ) {
+ return(DB_TABLESPACE_DELETED);
+ } else {
+ return(DB_SUCCESS); /*fake*/
+ }
+ }
+
/* Reserve the fil_system mutex and make sure that we can open at
least one file while holding it, if the file is not already open */
@@ -4940,10 +4974,24 @@ _fil_io(
#else
/* Queue the aio request */
ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
- offset_low, offset_high, len, node, message, trx);
+ offset_low, offset_high, len, node, message, space_id, trx);
#endif
} /**/
+ /* if the table space was already deleted, space might not exist already. */
+ if (message
+ && space_id < SRV_LOG_SPACE_FIRST_ID
+ && ((buf_page_t*)message)->space_was_being_deleted) {
+
+ if (mode == OS_AIO_SYNC) {
+ if (type == OS_FILE_READ) {
+ return(DB_TABLESPACE_DELETED);
+ } else {
+ return(DB_SUCCESS); /*fake*/
+ }
+ }
+ }
+
ut_a(ret);
if (mode == OS_AIO_SYNC) {
@@ -4966,21 +5014,10 @@ _fil_io(
Confirm whether the parameters are valid or not */
UNIV_INTERN
ibool
-fil_area_is_exist(
+fil_is_exist(
/*==============*/
ulint space_id, /*!< in: space id */
- ulint zip_size __attribute__((unused)),
- /*!< in: compressed page size in bytes;
- 0 for uncompressed pages */
- ulint block_offset, /*!< in: offset in number of blocks */
- ulint byte_offset __attribute__((unused)),
- /*!< in: remainder of offset in bytes; in
- aio this must be divisible by the OS block
- size */
- ulint len __attribute__((unused)))
- /*!< in: how many bytes to read or write; this
- must not cross a file boundary; in aio this
- must be a block size multiple */
+ ulint block_offset) /*!< in: offset in number of blocks */
{
fil_space_t* space;
fil_node_t* node;
@@ -5054,6 +5091,7 @@ fil_aio_wait(
fil_node_t* fil_node;
void* message;
ulint type;
+ ulint space_id = 0;
ut_ad(fil_validate());
@@ -5061,7 +5099,7 @@ fil_aio_wait(
srv_set_io_thread_op_info(segment, "native aio handle");
#ifdef WIN_ASYNC_IO
ret = os_aio_windows_handle(segment, 0, &fil_node,
- &message, &type);
+ &message, &type, &space_id);
#else
ret = 0; /* Eliminate compiler warning */
ut_error;
@@ -5070,7 +5108,22 @@ fil_aio_wait(
srv_set_io_thread_op_info(segment, "simulated aio handle");
ret = os_aio_simulated_handle(segment, &fil_node,
- &message, &type);
+ &message, &type, &space_id);
+ }
+
+ /* if the table space was already deleted, fil_node might not exist already. */
+ if (message
+ && space_id < SRV_LOG_SPACE_FIRST_ID
+ && ((buf_page_t*)message)->space_was_being_deleted) {
+
+ /* intended not to be uncompress read page */
+ ut_a(buf_page_get_io_fix(message) == BUF_IO_WRITE
+ || !buf_page_get_zip_size(message)
+ || buf_page_get_state(message) != BUF_BLOCK_FILE_PAGE);
+
+ srv_set_io_thread_op_info(segment, "complete io for buf page");
+ buf_page_io_complete(message, NULL);
+ return;
}
ut_a(ret);
diff --git a/storage/xtradb/fsp/fsp0fsp.c b/storage/xtradb/fsp/fsp0fsp.c
index 44ebe6819b7..c8e4f8e269c 100644
--- a/storage/xtradb/fsp/fsp0fsp.c
+++ b/storage/xtradb/fsp/fsp0fsp.c
@@ -657,13 +657,18 @@ xdes_calc_descriptor_page(
0 for uncompressed pages */
ulint offset) /*!< in: page offset */
{
-#ifndef DOXYGEN /* Doxygen gets confused of these */
-# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
- + (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
-# error
-# endif
-#endif /* !DOXYGEN */
+//#ifndef DOXYGEN /* Doxygen gets confused of these */
+//# if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET
+// + (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
+//# error
+//# endif
+//# if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET
+// + (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
+//# error
+//# endif
+//#endif /* !DOXYGEN */
ut_a(UNIV_PAGE_SIZE > XDES_ARR_OFFSET + (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE);
+ ut_a(PAGE_ZIP_MIN_SIZE > XDES_ARR_OFFSET + (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE);
ut_ad(ut_is_2pow(zip_size));
if (!zip_size) {
@@ -3473,9 +3478,9 @@ fseg_free_page(
fseg_free_page_low(seg_inode, space, zip_size, page, mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_set_file_page_was_freed(space, page);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
}
/**********************************************************************//**
@@ -3542,13 +3547,13 @@ fseg_free_extent(
fsp_free_extent(space, zip_size, page, mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
buf_page_set_file_page_was_freed(space,
first_page_in_extent + i);
}
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
}
/**********************************************************************//**
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 14b93704748..c4e6fa0df0d 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -206,6 +206,25 @@ static char* internal_innobase_data_file_path = NULL;
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
+/** Possible values for system variable "innodb_stats_method". The values
+are defined the same as its corresponding MyISAM system variable
+"myisam_stats_method"(see "myisam_stats_method_names"), for better usability */
+static const char* innodb_stats_method_names[] = {
+ "nulls_equal",
+ "nulls_unequal",
+ "nulls_ignored",
+ NullS
+};
+
+/** Used to define an enumerate type of the system variable innodb_stats_method.
+This is the same as "myisam_stats_method_typelib" */
+static TYPELIB innodb_stats_method_typelib = {
+ array_elements(innodb_stats_method_names) - 1,
+ "innodb_stats_method_typelib",
+ innodb_stats_method_names,
+ NULL
+};
+
/* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call
srv_active_wake_master_thread after each fetch or search, we only do
@@ -3389,12 +3408,15 @@ UNIV_INTERN
ulong
ha_innobase::index_flags(
/*=====================*/
- uint,
- uint,
- bool)
+ uint index,
+ uint part,
+ bool all_parts)
const
{
- return(HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER
+ ulong extra_flag= 0;
+ if (table && index == table->s->primary_key)
+ extra_flag= HA_CLUSTERED_INDEX;
+ return(HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | extra_flag
| HA_READ_RANGE | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN);
}
@@ -4439,12 +4461,24 @@ get_innobase_type_from_mysql_type(
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_DATE:
- case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
+ return(DATA_INT);
+
case MYSQL_TYPE_TIME:
+ case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
- return(DATA_INT);
+ /*
+ XtraDB should ideally just check field->keytype() and never
+ field->type(). The following check is here to only
+ change the new hires datetime/timestamp/time fields to
+ use DATA_FIXBINARY. We can't convert this function to
+ just test for field->keytype() as then the check if a
+ table is compatible will fail for old tables.
+ */
+ if (field->key_type() == HA_KEYTYPE_BINARY)
+ return(DATA_FIXBINARY);
+ return(DATA_INT);
case MYSQL_TYPE_FLOAT:
return(DATA_FLOAT);
case MYSQL_TYPE_DOUBLE:
@@ -4458,10 +4492,7 @@ get_innobase_type_from_mysql_type(
case MYSQL_TYPE_LONG_BLOB:
return(DATA_BLOB);
case MYSQL_TYPE_NULL:
- /* MySQL currently accepts "NULL" datatype, but will
- reject such datatype in the next release. We will cope
- with it and not trigger assertion failure in 5.1 */
- break;
+ return(DATA_FIXBINARY);
default:
ut_error;
}
@@ -6046,6 +6077,11 @@ ha_innobase::index_read(
case DB_SUCCESS:
error = 0;
table->status = 0;
+#ifdef EXTENDED_FOR_USERSTAT
+ rows_read++;
+ if (active_index < MAX_KEY)
+ index_rows_read[active_index]++;
+#endif
break;
case DB_RECORD_NOT_FOUND:
error = HA_ERR_KEY_NOT_FOUND;
@@ -6270,7 +6306,7 @@ ha_innobase::general_fetch(
table->status = 0;
#ifdef EXTENDED_FOR_USERSTAT
rows_read++;
- if (active_index >= 0 && active_index < MAX_KEY)
+ if (active_index < MAX_KEY)
index_rows_read[active_index]++;
#endif
break;
@@ -8144,6 +8180,65 @@ innobase_get_mysql_key_number_for_index(
return(0);
}
+
+/*********************************************************************//**
+Calculate Record Per Key value. Need to exclude the NULL value if
+innodb_stats_method is set to "nulls_ignored"
+@return estimated record per key value */
+static
+ha_rows
+innodb_rec_per_key(
+/*===============*/
+ dict_index_t* index, /*!< in: dict_index_t structure */
+ ulint i, /*!< in: the column we are
+ calculating rec per key */
+ ha_rows records) /*!< in: estimated total records */
+{
+ ha_rows rec_per_key;
+
+ ut_ad(i < dict_index_get_n_unique(index));
+
+ /* Note the stat_n_diff_key_vals[] stores the diff value with
+ n-prefix indexing, so it is always stat_n_diff_key_vals[i + 1] */
+ if (index->stat_n_diff_key_vals[i + 1] == 0) {
+
+ rec_per_key = records;
+ } else if (srv_innodb_stats_method == SRV_STATS_NULLS_IGNORED) {
+ ib_int64_t num_null;
+
+ /* Number of rows with NULL value in this
+ field */
+ num_null = records - index->stat_n_non_null_key_vals[i];
+
+ /* In theory, index->stat_n_non_null_key_vals[i]
+ should always be less than the number of records.
+ Since this is statistics value, the value could
+ have slight discrepancy. But we will make sure
+ the number of null values is not a negative number. */
+ num_null = (num_null < 0) ? 0 : num_null;
+
+ /* If the number of NULL values is the same as or
+ large than that of the distinct values, we could
+ consider that the table consists mostly of NULL value.
+ Set rec_per_key to 1. */
+ if (index->stat_n_diff_key_vals[i + 1] <= num_null) {
+ rec_per_key = 1;
+ } else {
+ /* Need to exclude rows with NULL values from
+ rec_per_key calculation */
+ rec_per_key = (ha_rows)(
+ (records - num_null)
+ / (index->stat_n_diff_key_vals[i + 1]
+ - num_null));
+ }
+ } else {
+ rec_per_key = (ha_rows)
+ (records / index->stat_n_diff_key_vals[i + 1]);
+ }
+
+ return(rec_per_key);
+}
+
/*********************************************************************//**
Returns statistics information of the table to the MySQL interpreter,
in various fields of the handle object. */
@@ -8202,6 +8297,10 @@ ha_innobase::info_low(
for (index = dict_table_get_first_index(ib_table);
index != NULL;
index = dict_table_get_next_index(index)) {
+ if (dict_is_older_statistics(index)) {
+ row_delete_stats_for_mysql(index, prebuilt->trx);
+ innobase_commit_low(prebuilt->trx);
+ }
row_insert_stats_for_mysql(index, prebuilt->trx);
innobase_commit_low(prebuilt->trx);
}
@@ -8395,13 +8494,8 @@ ha_innobase::info_low(
break;
}
- if (index->stat_n_diff_key_vals[j + 1] == 0) {
-
- rec_per_key = stats.records;
- } else {
- rec_per_key = (ha_rows)(stats.records /
- index->stat_n_diff_key_vals[j + 1]);
- }
+ rec_per_key = innodb_rec_per_key(
+ index, j, stats.records);
/* Since MySQL seems to favor table scans
too much over index searches, we pretend
@@ -11540,25 +11634,6 @@ static MYSQL_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
"The number of index pages to sample when calculating statistics (default 8)",
NULL, NULL, 8, 1, ~0ULL, 0);
-const char *innobase_stats_method_names[]=
-{
- "nulls_equal",
- "nulls_unequal",
- "nulls_ignored",
- NullS
-};
-TYPELIB innobase_stats_method_typelib=
-{
- array_elements(innobase_stats_method_names) - 1, "innobase_stats_method_typelib",
- innobase_stats_method_names, NULL
-};
-static MYSQL_SYSVAR_ENUM(stats_method, srv_stats_method,
- PLUGIN_VAR_RQCMDARG,
- "Specifies how InnoDB index statistics collection code should threat NULLs. "
- "Possible values of name are same to for 'myisam_stats_method'. "
- "This is startup parameter.",
- NULL, NULL, 0, &innobase_stats_method_typelib);
-
static MYSQL_SYSVAR_ULONG(stats_auto_update, srv_stats_auto_update,
PLUGIN_VAR_RQCMDARG,
"Enable/Disable InnoDB's auto update statistics of indexes. "
@@ -11747,6 +11822,13 @@ static MYSQL_SYSVAR_STR(change_buffering, innobase_change_buffering,
innodb_change_buffering_validate,
innodb_change_buffering_update, "inserts");
+static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method,
+ PLUGIN_VAR_RQCMDARG,
+ "Specifies how InnoDB index statistics collection code should "
+ "treat NULLs. Possible values are NULLS_EQUAL (default), "
+ "NULLS_UNEQUAL and NULLS_IGNORED",
+ NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib);
+
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug,
PLUGIN_VAR_RQCMDARG,
@@ -11891,6 +11973,12 @@ static MYSQL_SYSVAR_BOOL(release_locks_early, innobase_release_locks_early,
"Release row locks in the prepare stage instead of in the commit stage",
NULL, NULL, FALSE);
+static MYSQL_SYSVAR_ULINT(lazy_drop_table, srv_lazy_drop_table,
+ PLUGIN_VAR_RQCMDARG,
+ "At deleting tablespace, only miminum needed processes at the time are done. "
+ "e.g. for http://bugs.mysql.com/51325",
+ NULL, NULL, 0, 0, 1, 0);
+
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(page_size),
MYSQL_SYSVAR(log_block_size),
@@ -11940,12 +12028,12 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(overwrite_relay_log_info),
MYSQL_SYSVAR(rollback_on_timeout),
MYSQL_SYSVAR(stats_on_metadata),
- MYSQL_SYSVAR(stats_method),
MYSQL_SYSVAR(stats_auto_update),
MYSQL_SYSVAR(stats_update_need_lock),
MYSQL_SYSVAR(use_sys_stats_table),
MYSQL_SYSVAR(stats_sample_pages),
MYSQL_SYSVAR(adaptive_hash_index),
+ MYSQL_SYSVAR(stats_method),
MYSQL_SYSVAR(replication_delay),
MYSQL_SYSVAR(status_file),
MYSQL_SYSVAR(strict_mode),
@@ -11983,6 +12071,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(use_purge_thread),
MYSQL_SYSVAR(pass_corrupt_table),
MYSQL_SYSVAR(release_locks_early),
+ MYSQL_SYSVAR(lazy_drop_table),
NULL
};
diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc
index dead374e782..d989ce87aa3 100644
--- a/storage/xtradb/handler/i_s.cc
+++ b/storage/xtradb/handler/i_s.cc
@@ -168,7 +168,7 @@ field_store_time_t(
my_time.time_type = MYSQL_TIMESTAMP_DATETIME;
#endif
- return(field->store_time(&my_time, MYSQL_TIMESTAMP_DATETIME));
+ return(field->store_time(&my_time));
}
/*******************************************************************//**
@@ -3969,6 +3969,14 @@ static ST_FIELD_INFO i_s_innodb_sys_stats_info[] =
STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+ {STRUCT_FLD(field_name, "NON_NULL_VALS"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
END_OF_ST_FIELD_INFO
};
@@ -4237,6 +4245,9 @@ copy_sys_stats_rec(
{
int status;
int field;
+ ulint n_fields;
+
+ n_fields = rec_get_n_fields_old(rec);
/* INDEX_ID */
field = dict_index_get_nth_col_pos(index, 0);
@@ -4256,6 +4267,16 @@ copy_sys_stats_rec(
if (status) {
return status;
}
+ /* NON_NULL_VALS */
+ if (n_fields < 6) {
+ table->field[3]->set_null();
+ } else {
+ field = dict_index_get_nth_col_pos(index, 3);
+ status = copy_id_field(table, 3, rec, field);
+ if (status) {
+ return status;
+ }
+ }
return 0;
}
diff --git a/storage/xtradb/ibuf/ibuf0ibuf.c b/storage/xtradb/ibuf/ibuf0ibuf.c
index 12dbc29be23..3f741da60bb 100644
--- a/storage/xtradb/ibuf/ibuf0ibuf.c
+++ b/storage/xtradb/ibuf/ibuf0ibuf.c
@@ -1881,9 +1881,9 @@ ibuf_remove_free_page(void)
fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
IBUF_SPACE_ID, page_no, &mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
ibuf_enter();
@@ -1925,9 +1925,9 @@ ibuf_remove_free_page(void)
ibuf_bitmap_page_set_bits(
bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, FALSE, &mtr);
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
-#endif
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
mtr_commit(&mtr);
mutex_exit(&ibuf_mutex);
diff --git a/storage/xtradb/include/btr0cur.h b/storage/xtradb/include/btr0cur.h
index b477ad0320a..ece3621fa97 100644
--- a/storage/xtradb/include/btr0cur.h
+++ b/storage/xtradb/include/btr0cur.h
@@ -478,7 +478,10 @@ btr_estimate_n_rows_in_range(
/*******************************************************************//**
Estimates the number of different key values in a given index, for
each n-column prefix of the index where n <= dict_index_get_n_unique(index).
-The estimates are stored in the array index->stat_n_diff_key_vals. */
+The estimates are stored in the array index->stat_n_diff_key_vals.
+If innodb_stats_method is nulls_ignored, we also record the number of
+non-null values for each prefix and stored the estimates in
+array index->stat_n_non_null_key_vals. */
UNIV_INTERN
void
btr_estimate_number_of_different_key_vals(
@@ -509,8 +512,8 @@ file segment of the index tree.
@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
UNIV_INTERN
ulint
-btr_store_big_rec_extern_fields(
-/*============================*/
+btr_store_big_rec_extern_fields_func(
+/*=================================*/
dict_index_t* index, /*!< in: index of rec; the index tree
MUST be X-latched */
buf_block_t* rec_block, /*!< in/out: block containing rec */
@@ -519,10 +522,42 @@ btr_store_big_rec_extern_fields(
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
- big_rec_t* big_rec_vec, /*!< in: vector containing fields
+#ifdef UNIV_DEBUG
+ mtr_t* local_mtr, /*!< in: mtr containing the
+ latch to rec and to the tree */
+#endif /* UNIV_DEBUG */
+#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
+ ibool update_in_place,/*! in: TRUE if the record is updated
+ in place (not delete+insert) */
+#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
+ const big_rec_t*big_rec_vec) /*!< in: vector containing fields
to be stored externally */
- mtr_t* local_mtr); /*!< in: mtr containing the latch to
- rec and to the tree */
+ __attribute__((nonnull));
+
+/** Stores the fields in big_rec_vec to the tablespace and puts pointers to
+them in rec. The extern flags in rec will have to be set beforehand.
+The fields are stored on pages allocated from leaf node
+file segment of the index tree.
+@param index in: clustered index; MUST be X-latched by mtr
+@param b in/out: block containing rec; MUST be X-latched by mtr
+@param rec in/out: clustered index record
+@param offsets in: rec_get_offsets(rec, index);
+ the "external storage" flags in offsets will not be adjusted
+@param mtr in: mini-transaction that holds x-latch on index and b
+@param upd in: TRUE if the record is updated in place (not delete+insert)
+@param big in: vector containing fields to be stored externally
+@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
+#ifdef UNIV_DEBUG
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+ btr_store_big_rec_extern_fields_func(index,b,rec,offsets,mtr,upd,big)
+#elif defined UNIV_BLOB_LIGHT_DEBUG
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+ btr_store_big_rec_extern_fields_func(index,b,rec,offsets,upd,big)
+#else
+# define btr_store_big_rec_extern_fields(index,b,rec,offsets,mtr,upd,big) \
+ btr_store_big_rec_extern_fields_func(index,b,rec,offsets,big)
+#endif
+
/*******************************************************************//**
Frees the space in an externally stored field to the file space
management if the field in data is owned the externally stored field,
diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h
index e06927f42f0..bc0e9170281 100644
--- a/storage/xtradb/include/buf0buf.h
+++ b/storage/xtradb/include/buf0buf.h
@@ -166,10 +166,8 @@ Allocates a buffer block.
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
UNIV_INLINE
buf_block_t*
-buf_block_alloc(
-/*============*/
- ulint zip_size); /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_block_alloc(void);
+/*=================*/
/********************************************************************//**
Frees a buffer block which does not contain a file page. */
UNIV_INLINE
@@ -371,7 +369,7 @@ buf_reset_check_index_page_at_flush(
/*================================*/
ulint space, /*!< in: space id */
ulint offset);/*!< in: page number */
-#ifdef UNIV_DEBUG_FILE_ACCESSES
+#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
/********************************************************************//**
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
This function should be called when we free a file page and want the
@@ -396,7 +394,7 @@ buf_page_reset_file_page_was_freed(
/*===============================*/
ulint space, /*!< in: space id */
ulint offset); /*!< in: page number */
-#endif /* UNIV_DEBUG_FILE_ACCESSES */
+#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
/********************************************************************//**
Reads the freed_page_clock of a buffer block.
@return freed_page_clock */
@@ -1157,12 +1155,13 @@ struct buf_page_struct{
0 if the block was never accessed
in the buffer pool */
/* @} */
+ ibool space_was_being_deleted;
ibool is_corrupt;
-# ifdef UNIV_DEBUG_FILE_ACCESSES
+# if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
ibool file_page_was_freed;
/*!< this is set to TRUE when fsp
frees a page in buffer pool */
-# endif /* UNIV_DEBUG_FILE_ACCESSES */
+# endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
#endif /* !UNIV_HOTBACKUP */
};
diff --git a/storage/xtradb/include/buf0buf.ic b/storage/xtradb/include/buf0buf.ic
index 93cc68e7fc9..2cb0d8ef497 100644
--- a/storage/xtradb/include/buf0buf.ic
+++ b/storage/xtradb/include/buf0buf.ic
@@ -384,6 +384,7 @@ buf_block_set_file_page(
buf_block_set_state(block, BUF_BLOCK_FILE_PAGE);
block->page.space = space;
block->page.offset = page_no;
+ block->page.space_was_being_deleted = FALSE;
}
/*********************************************************************//**
@@ -757,14 +758,12 @@ Allocates a buffer block.
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
UNIV_INLINE
buf_block_t*
-buf_block_alloc(
-/*============*/
- ulint zip_size) /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_block_alloc(void)
+/*=================*/
{
buf_block_t* block;
- block = buf_LRU_get_free_block(zip_size);
+ block = buf_LRU_get_free_block();
buf_block_set_state(block, BUF_BLOCK_MEMORY);
diff --git a/storage/xtradb/include/buf0lru.h b/storage/xtradb/include/buf0lru.h
index d3b59e8b579..fe7c067dfb7 100644
--- a/storage/xtradb/include/buf0lru.h
+++ b/storage/xtradb/include/buf0lru.h
@@ -84,6 +84,13 @@ void
buf_LRU_invalidate_tablespace(
/*==========================*/
ulint id); /*!< in: space id */
+/******************************************************************//**
+*/
+UNIV_INTERN
+void
+buf_LRU_mark_space_was_deleted(
+/*===========================*/
+ ulint id); /*!< in: space id */
/********************************************************************//**
Insert a compressed block into buf_pool->zip_clean in the LRU order. */
UNIV_INTERN
@@ -112,11 +119,8 @@ buf_LRU_free_block(
buf_page_t* bpage, /*!< in: block to be freed */
ibool zip, /*!< in: TRUE if should remove also the
compressed page of an uncompressed page */
- ibool* buf_pool_mutex_released,
- /*!< in: pointer to a variable that will
- be assigned TRUE if buf_pool_mutex
- was temporarily released, or NULL */
- ibool have_LRU_mutex);
+ ibool have_LRU_mutex)
+ __attribute__((nonnull));
/******************************************************************//**
Try to free a replaceable block.
@return TRUE if found and freed */
@@ -147,10 +151,9 @@ LRU list to the free list.
@return the free control block, in state BUF_BLOCK_READY_FOR_USE */
UNIV_INTERN
buf_block_t*
-buf_LRU_get_free_block(
-/*===================*/
- ulint zip_size); /*!< in: compressed page size in bytes,
- or 0 if uncompressed tablespace */
+buf_LRU_get_free_block(void)
+/*========================*/
+ __attribute__((warn_unused_result));
/******************************************************************//**
Puts a block back to the free list. */
diff --git a/storage/xtradb/include/buf0types.h b/storage/xtradb/include/buf0types.h
index 507f1543bbb..ce3e5ecc9c5 100644
--- a/storage/xtradb/include/buf0types.h
+++ b/storage/xtradb/include/buf0types.h
@@ -76,7 +76,7 @@ enum buf_io_fix {
/** twice the maximum block size of the buddy system;
the underlying memory is aligned by this amount:
this must be equal to UNIV_PAGE_SIZE */
-#define BUF_BUDDY_HIGH (BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
+#define BUF_BUDDY_HIGH ((ulint)BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
/* @} */
#endif
diff --git a/storage/xtradb/include/dict0boot.h b/storage/xtradb/include/dict0boot.h
index 9239e031a7f..a57c5127323 100644
--- a/storage/xtradb/include/dict0boot.h
+++ b/storage/xtradb/include/dict0boot.h
@@ -146,6 +146,7 @@ clustered index */
#define DICT_SYS_INDEXES_NAME_FIELD 4
#define DICT_SYS_STATS_DIFF_VALS_FIELD 4
+#define DICT_SYS_STATS_NON_NULL_VALS_FIELD 5
/* When a row id which is zero modulo this number (which must be a power of
two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is
diff --git a/storage/xtradb/include/dict0dict.h b/storage/xtradb/include/dict0dict.h
index 7baacdd6055..2baecdc958a 100644
--- a/storage/xtradb/include/dict0dict.h
+++ b/storage/xtradb/include/dict0dict.h
@@ -1062,6 +1062,13 @@ dict_update_statistics(
not been initialized yet, otherwise
do nothing */
ibool sync);
+/*********************************************************************//**
+*/
+UNIV_INTERN
+ibool
+dict_is_older_statistics(
+/*=====================*/
+ dict_index_t* index);
/********************************************************************//**
Reserves the dictionary system mutex for MySQL. */
UNIV_INTERN
diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h
index 6736c2a3a36..f47293bedf6 100644
--- a/storage/xtradb/include/dict0mem.h
+++ b/storage/xtradb/include/dict0mem.h
@@ -321,6 +321,12 @@ struct dict_index_struct{
dict_get_n_unique(index); we
periodically calculate new
estimates */
+ ib_int64_t* stat_n_non_null_key_vals;
+ /* approximate number of non-null key values
+ for this index, for each column where
+ n < dict_get_n_unique(index); This
+ is used when innodb_stats_method is
+ "nulls_ignored". */
ulint stat_index_size;
/*!< approximate index size in
database pages */
diff --git a/storage/xtradb/include/dict0types.h b/storage/xtradb/include/dict0types.h
index 7ad69193cc9..f14b59a19d4 100644
--- a/storage/xtradb/include/dict0types.h
+++ b/storage/xtradb/include/dict0types.h
@@ -33,11 +33,6 @@ typedef struct dict_index_struct dict_index_t;
typedef struct dict_table_struct dict_table_t;
typedef struct dict_foreign_struct dict_foreign_t;
-/* A cluster object is a table object with the type field set to
-DICT_CLUSTERED */
-
-typedef dict_table_t dict_cluster_t;
-
typedef struct ind_node_struct ind_node_t;
typedef struct tab_node_struct tab_node_t;
diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h
index a262ec8f9cc..fbf8ca20db3 100644
--- a/storage/xtradb/include/fil0fil.h
+++ b/storage/xtradb/include/fil0fil.h
@@ -648,18 +648,10 @@ _fil_io(
Confirm whether the parameters are valid or not */
UNIV_INTERN
ibool
-fil_area_is_exist(
+fil_is_exist(
/*==============*/
ulint space_id, /*!< in: space id */
- ulint zip_size, /*!< in: compressed page size in bytes;
- 0 for uncompressed pages */
- ulint block_offset, /*!< in: offset in number of blocks */
- ulint byte_offset, /*!< in: remainder of offset in bytes; in
- aio this must be divisible by the OS block
- size */
- ulint len); /*!< in: how many bytes to read or write; this
- must not cross a file boundary; in aio this
- must be a block size multiple */
+ ulint block_offset); /*!< in: offset in number of blocks */
/**********************************************************************//**
Waits for an aio operation to complete. This function is used to write the
handler for completed requests. The aio array of pending requests is divided
diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h
index cbbec2cf55e..732e930517b 100644
--- a/storage/xtradb/include/os0file.h
+++ b/storage/xtradb/include/os0file.h
@@ -657,6 +657,7 @@ os_aio(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
+ ulint space_id,
trx_t* trx);
/************************************************************************//**
Wakes up all async i/o threads so that they know to exit themselves in
@@ -717,7 +718,8 @@ os_aio_windows_handle(
parameters are valid and can be used to
restart the operation, for example */
void** message2,
- ulint* type); /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* space_id);
#endif
/**********************************************************************//**
@@ -739,7 +741,8 @@ os_aio_simulated_handle(
parameters are valid and can be used to
restart the operation, for example */
void** message2,
- ulint* type); /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* space_id);
/**********************************************************************//**
Validates the consistency of the aio system.
@return TRUE if ok */
diff --git a/storage/xtradb/include/page0cur.h b/storage/xtradb/include/page0cur.h
index 6b444b3dd96..1544b0abe1c 100644
--- a/storage/xtradb/include/page0cur.h
+++ b/storage/xtradb/include/page0cur.h
@@ -293,22 +293,6 @@ page_cur_open_on_rnd_user_rec(
/*==========================*/
buf_block_t* block, /*!< in: page */
page_cur_t* cursor);/*!< out: page cursor */
-
-UNIV_INTERN
-void
-page_cur_open_on_nth_user_rec(
-/*==========================*/
- buf_block_t* block, /*!< in: page */
- page_cur_t* cursor, /*!< out: page cursor */
- ulint nth);
-
-UNIV_INTERN
-ibool
-page_cur_open_on_rnd_user_rec_after_nth(
-/*==========================*/
- buf_block_t* block, /*!< in: page */
- page_cur_t* cursor, /*!< out: page cursor */
- ulint nth);
#endif /* !UNIV_HOTBACKUP */
/***********************************************************//**
Parses a log record of a record insert on a page.
diff --git a/storage/xtradb/include/rem0cmp.h b/storage/xtradb/include/rem0cmp.h
index fcea62ad486..a908521c9f7 100644
--- a/storage/xtradb/include/rem0cmp.h
+++ b/storage/xtradb/include/rem0cmp.h
@@ -165,15 +165,18 @@ cmp_rec_rec_with_match(
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
dict_index_t* index, /*!< in: data dictionary index */
+ ibool nulls_unequal,
+ /* in: TRUE if this is for index statistics
+ cardinality estimation, and innodb_stats_method
+ is "nulls_unequal" or "nulls_ignored" */
ulint* matched_fields, /*!< in/out: number of already completely
matched fields; when the function returns,
contains the value the for current
comparison */
- ulint* matched_bytes, /*!< in/out: number of already matched
+ ulint* matched_bytes);/*!< in/out: number of already matched
bytes within the first field not completely
matched; when the function returns, contains
the value for the current comparison */
- ulint stats_method);
/*************************************************************//**
This function is used to compare two physical records. Only the common
first fields are compared.
diff --git a/storage/xtradb/include/rem0cmp.ic b/storage/xtradb/include/rem0cmp.ic
index d5185ec94af..63415fe7837 100644
--- a/storage/xtradb/include/rem0cmp.ic
+++ b/storage/xtradb/include/rem0cmp.ic
@@ -87,5 +87,5 @@ cmp_rec_rec(
ulint match_b = 0;
return(cmp_rec_rec_with_match(rec1, rec2, offsets1, offsets2, index,
- &match_f, &match_b, 0));
+ FALSE, &match_f, &match_b));
}
diff --git a/storage/xtradb/include/row0mysql.h b/storage/xtradb/include/row0mysql.h
index 88de6421cf9..cd9dec2f089 100644
--- a/storage/xtradb/include/row0mysql.h
+++ b/storage/xtradb/include/row0mysql.h
@@ -384,6 +384,14 @@ row_insert_stats_for_mysql(
dict_index_t* index,
trx_t* trx);
/*********************************************************************//**
+*/
+UNIV_INTERN
+int
+row_delete_stats_for_mysql(
+/*=======================*/
+ dict_index_t* index,
+ trx_t* trx);
+/*********************************************************************//**
Scans a table create SQL string and adds to the data dictionary
the foreign key constraints declared in the string. This function
should be called after the indexes for a table have been created.
diff --git a/storage/xtradb/include/row0upd.h b/storage/xtradb/include/row0upd.h
index b61e6b6dca1..97b7ec49a17 100644
--- a/storage/xtradb/include/row0upd.h
+++ b/storage/xtradb/include/row0upd.h
@@ -280,19 +280,29 @@ NOTE: we compare the fields as binary strings!
@return TRUE if update vector changes an ordering field in the index record */
UNIV_INTERN
ibool
-row_upd_changes_ord_field_binary(
-/*=============================*/
+row_upd_changes_ord_field_binary_func(
+/*==================================*/
+ dict_index_t* index, /*!< in: index of the record */
+ const upd_t* update, /*!< in: update vector for the row; NOTE: the
+ field numbers in this MUST be clustered index
+ positions! */
+#ifdef UNIV_DEBUG
+ const que_thr_t*thr, /*!< in: query thread */
+#endif /* UNIV_DEBUG */
const dtuple_t* row, /*!< in: old value of row, or NULL if the
row and the data values in update are not
known when this function is called, e.g., at
compile time */
- const row_ext_t*ext, /*!< NULL, or prefixes of the externally
+ const row_ext_t*ext) /*!< NULL, or prefixes of the externally
stored columns in the old row */
- dict_index_t* index, /*!< in: index of the record */
- const upd_t* update) /*!< in: update vector for the row; NOTE: the
- field numbers in this MUST be clustered index
- positions! */
- __attribute__((nonnull(3,4), warn_unused_result));
+ __attribute__((nonnull(1,2), warn_unused_result));
+#ifdef UNIV_DEBUG
+# define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
+ row_upd_changes_ord_field_binary_func(index,update,thr,row,ext)
+#else /* UNIV_DEBUG */
+# define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
+ row_upd_changes_ord_field_binary_func(index,update,row,ext)
+#endif /* UNIV_DEBUG */
/***********************************************************//**
Checks if an update vector changes an ordering field of an index record.
This function is fast if the update vector is short or the number of ordering
diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h
index 7ecf952d329..8bcf215c7ac 100644
--- a/storage/xtradb/include/srv0srv.h
+++ b/storage/xtradb/include/srv0srv.h
@@ -177,6 +177,11 @@ capacity. PCT_IO(5) -> returns the number of IO operations that
is 5% of the max where max is srv_io_capacity. */
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
+/* The "innodb_stats_method" setting, decides how InnoDB is going
+to treat NULL value when collecting statistics. It is not defined
+as enum type because the configure option takes unsigned integer type. */
+extern ulong srv_innodb_stats_method;
+
#ifdef UNIV_LOG_ARCHIVE
extern ibool srv_log_archive_on;
extern ibool srv_archive_recovery;
@@ -208,10 +213,6 @@ extern ulint srv_fast_shutdown; /* If this is 1, do not do a
extern ibool srv_innodb_status;
extern unsigned long long srv_stats_sample_pages;
-extern ulong srv_stats_method;
-#define SRV_STATS_METHOD_NULLS_EQUAL 0
-#define SRV_STATS_METHOD_NULLS_NOT_EQUAL 1
-#define SRV_STATS_METHOD_IGNORE_NULLS 2
extern ulong srv_stats_auto_update;
extern ulint srv_stats_update_need_lock;
extern ibool srv_use_sys_stats_table;
@@ -242,6 +243,8 @@ extern ulint srv_pass_corrupt_table;
extern ulong srv_extra_rsegments;
extern ulong srv_dict_size_limit;
+
+extern ulint srv_lazy_drop_table;
/*-------------------------------------------*/
extern ulint srv_n_rows_inserted;
@@ -416,6 +419,19 @@ enum {
in connection with recovery */
};
+/* Alternatives for srv_innodb_stats_method, which could be changed by
+setting innodb_stats_method */
+enum srv_stats_method_name_enum {
+ SRV_STATS_NULLS_EQUAL, /* All NULL values are treated as
+ equal. This is the default setting
+ for innodb_stats_method */
+ SRV_STATS_NULLS_UNEQUAL, /* All NULL values are treated as
+ NOT equal. */
+ SRV_STATS_NULLS_IGNORED /* NULL values are ignored */
+};
+
+typedef enum srv_stats_method_name_enum srv_stats_method_name_t;
+
#ifndef UNIV_HOTBACKUP
/** Types of threads existing in the system. */
enum srv_thread_type {
diff --git a/storage/xtradb/include/sync0rw.h b/storage/xtradb/include/sync0rw.h
index 4edf93f4042..22de1bfdd93 100644
--- a/storage/xtradb/include/sync0rw.h
+++ b/storage/xtradb/include/sync0rw.h
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -113,14 +113,14 @@ is necessary only if the memory block containing it is freed. */
#ifdef UNIV_DEBUG
# ifdef UNIV_SYNC_DEBUG
# define rw_lock_create(L, level) \
- rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
+ rw_lock_create_func((L), (level), __FILE__, __LINE__, #L)
# else /* UNIV_SYNC_DEBUG */
# define rw_lock_create(L, level) \
- rw_lock_create_func((L), #L, __FILE__, __LINE__)
+ rw_lock_create_func((L), __FILE__, __LINE__, #L)
# endif /* UNIV_SYNC_DEBUG */
#else /* UNIV_DEBUG */
# define rw_lock_create(L, level) \
- rw_lock_create_func((L), #L, NULL, 0)
+ rw_lock_create_func((L), #L)
#endif /* UNIV_DEBUG */
/******************************************************************//**
@@ -137,10 +137,10 @@ rw_lock_create_func(
# ifdef UNIV_SYNC_DEBUG
ulint level, /*!< in: level */
# endif /* UNIV_SYNC_DEBUG */
-#endif /* UNIV_DEBUG */
- const char* cmutex_name, /*!< in: mutex name */
const char* cfile_name, /*!< in: file name where created */
- ulint cline); /*!< in: file line where created */
+ ulint cline, /*!< in: file line where created */
+#endif /* UNIV_DEBUG */
+ const char* cmutex_name); /*!< in: mutex name */
/******************************************************************//**
Calling this function is obligatory only if the memory buffer containing
the rw-lock is freed. Removes an rw-lock object from the global list. The
@@ -490,6 +490,7 @@ UNIV_INTERN
void
rw_lock_debug_print(
/*================*/
+ FILE* f, /*!< in: output stream */
rw_lock_debug_t* info); /*!< in: debug struct */
#endif /* UNIV_SYNC_DEBUG */
diff --git a/storage/xtradb/include/sync0sync.h b/storage/xtradb/include/sync0sync.h
index a500cf1da45..f2ff83101ab 100644
--- a/storage/xtradb/include/sync0sync.h
+++ b/storage/xtradb/include/sync0sync.h
@@ -73,14 +73,14 @@ necessary only if the memory block containing it is freed. */
#ifdef UNIV_DEBUG
# ifdef UNIV_SYNC_DEBUG
# define mutex_create(M, level) \
- mutex_create_func((M), #M, (level), __FILE__, __LINE__)
+ mutex_create_func((M), (level), __FILE__, __LINE__, #M)
# else
# define mutex_create(M, level) \
- mutex_create_func((M), #M, __FILE__, __LINE__)
+ mutex_create_func((M), __FILE__, __LINE__, #M)
# endif
#else
# define mutex_create(M, level) \
- mutex_create_func((M), #M, NULL, 0)
+ mutex_create_func((M), #M)
#endif
/******************************************************************//**
@@ -93,14 +93,14 @@ void
mutex_create_func(
/*==============*/
mutex_t* mutex, /*!< in: pointer to memory */
- const char* cmutex_name, /*!< in: mutex name */
#ifdef UNIV_DEBUG
# ifdef UNIV_SYNC_DEBUG
ulint level, /*!< in: level */
# endif /* UNIV_SYNC_DEBUG */
-#endif /* UNIV_DEBUG */
const char* cfile_name, /*!< in: file name where created */
- ulint cline); /*!< in: file line where created */
+ ulint cline, /*!< in: file line where created */
+#endif /* UNIV_DEBUG */
+ const char* cmutex_name); /*!< in: mutex name */
#undef mutex_free /* Fix for MacOS X */
@@ -496,6 +496,7 @@ or row lock! */
#define SYNC_BUF_POOL 150
#define SYNC_BUF_FLUSH_LIST 149
#define SYNC_DOUBLEWRITE 140
+#define SYNC_OUTER_ANY_LATCH 136
#define SYNC_ANY_LATCH 135
#define SYNC_THR_LOCAL 133
#define SYNC_MEM_HASH 131
diff --git a/storage/xtradb/include/trx0rseg.h b/storage/xtradb/include/trx0rseg.h
index 303188f09f2..ea9956cd143 100644
--- a/storage/xtradb/include/trx0rseg.h
+++ b/storage/xtradb/include/trx0rseg.h
@@ -149,9 +149,7 @@ struct trx_rseg_struct{
ulint id; /*!< rollback segment id == the index of
its slot in the trx system file copy */
mutex_t mutex; /*!< mutex protecting the fields in this
- struct except id; NOTE that the latching
- order must always be kernel mutex ->
- rseg mutex */
+ struct except id, which is constant */
ulint space; /*!< space where the rollback segment is
header is placed */
ulint zip_size;/* compressed page size of space
diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h
index 47b935a7efd..8858fe2fafa 100644
--- a/storage/xtradb/include/trx0trx.h
+++ b/storage/xtradb/include/trx0trx.h
@@ -214,12 +214,12 @@ trx_recover_for_mysql(
/*******************************************************************//**
This function is used to find one X/Open XA distributed transaction
which is in the prepared state
-@return trx or NULL */
+@return trx or NULL; on match, the trx->xid will be invalidated */
UNIV_INTERN
trx_t *
trx_get_trx_by_xid(
/*===============*/
- XID* xid); /*!< in: X/Open XA transaction identification */
+ const XID* xid); /*!< in: X/Open XA transaction identifier */
/**********************************************************************//**
If required, flushes the log to disk if we called trx_commit_for_mysql()
with trx->flush_log_later == TRUE.
diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i
index 111bda1a3c5..7b11a16dae9 100644
--- a/storage/xtradb/include/univ.i
+++ b/storage/xtradb/include/univ.i
@@ -47,7 +47,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 1
#define INNODB_VERSION_MINOR 0
#define INNODB_VERSION_BUGFIX 15
-#define PERCONA_INNODB_VERSION 12.5
+#define PERCONA_INNODB_VERSION 12.7
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
@@ -180,14 +180,15 @@ command. Not tested on Windows. */
debugging without UNIV_DEBUG */
#define UNIV_BUF_DEBUG /* Enable buffer pool
debugging without UNIV_DEBUG */
+#define UNIV_BLOB_LIGHT_DEBUG /* Enable off-page column
+ debugging without UNIV_DEBUG */
#define UNIV_DEBUG /* Enable ut_ad() assertions
and disable UNIV_INLINE */
#define UNIV_DEBUG_LOCK_VALIDATE /* Enable
ut_ad(lock_rec_validate_page())
assertions. */
-#define UNIV_DEBUG_FILE_ACCESSES /* Debug .ibd file access
- (field file_page_was_freed
- in buf_page_t) */
+#define UNIV_DEBUG_FILE_ACCESSES /* Enable freed block access
+ debugging without UNIV_DEBUG */
#define UNIV_LRU_DEBUG /* debug the buffer pool LRU */
#define UNIV_HASH_DEBUG /* debug HASH_ macros */
#define UNIV_LIST_DEBUG /* debug UT_LIST_ macros */
@@ -433,7 +434,7 @@ it is read or written. */
/* Use sun_prefetch when compile with Sun Studio */
# define UNIV_EXPECT(expr,value) (expr)
# define UNIV_LIKELY_NULL(expr) (expr)
-# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many(addr)
+# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many((void*) addr)
# define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many(addr)
#else
/* Dummy versions of the macros */
diff --git a/storage/xtradb/mem/mem0mem.c b/storage/xtradb/mem/mem0mem.c
index 1dd4db30841..86100b04fd6 100644
--- a/storage/xtradb/mem/mem0mem.c
+++ b/storage/xtradb/mem/mem0mem.c
@@ -347,7 +347,7 @@ mem_heap_create_block(
return(NULL);
}
} else {
- buf_block = buf_block_alloc(0);
+ buf_block = buf_block_alloc();
}
block = (mem_block_t*) buf_block->frame;
diff --git a/storage/xtradb/mtr/mtr0log.c b/storage/xtradb/mtr/mtr0log.c
index d22015a575f..3349036b5b3 100644
--- a/storage/xtradb/mtr/mtr0log.c
+++ b/storage/xtradb/mtr/mtr0log.c
@@ -408,7 +408,7 @@ mlog_parse_string(
ptr += 2;
if (UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE)
- || UNIV_UNLIKELY(len + offset > UNIV_PAGE_SIZE)) {
+ || UNIV_UNLIKELY(len + offset > UNIV_PAGE_SIZE)) {
recv_sys->found_corrupt_log = TRUE;
return(NULL);
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c
index 7d47203e992..5b8e656d8b2 100644
--- a/storage/xtradb/os/os0file.c
+++ b/storage/xtradb/os/os0file.c
@@ -142,6 +142,7 @@ struct os_aio_slot_struct{
// made and only the slot message
// needs to be passed to the caller
// of os_aio_simulated_handle */
+ ulint space_id;
fil_node_t* message1; /*!< message which is given by the */
void* message2; /*!< the requester of an aio operation
and which can be used to identify
@@ -3390,7 +3391,8 @@ os_aio_array_reserve_slot(
offset */
ulint offset_high, /*!< in: most significant 32 bits of
offset */
- ulint len) /*!< in: length of the block to read or write */
+ ulint len, /*!< in: length of the block to read or write */
+ ulint space_id)
{
os_aio_slot_t* slot;
ulint i;
@@ -3472,6 +3474,7 @@ found:
slot->offset_high = offset_high;
// slot->io_already_done = FALSE;
slot->status = OS_AIO_NOT_ISSUED;
+ slot->space_id = space_id;
#ifdef WIN_ASYNC_IO
control = &(slot->control);
@@ -3680,6 +3683,7 @@ os_aio(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
+ ulint space_id,
trx_t* trx)
{
os_aio_array_t* array;
@@ -3762,7 +3766,7 @@ try_again:
trx->io_read += n;
}
slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
- name, buf, offset, offset_high, n);
+ name, buf, offset, offset_high, n, space_id);
if (type == OS_FILE_READ) {
if (os_aio_use_native_aio) {
#ifdef WIN_ASYNC_IO
@@ -3813,7 +3817,8 @@ try_again:
slot->pos,
&dummy_mess1,
&dummy_mess2,
- &dummy_type);
+ &dummy_type,
+ &space_id);
return(retval);
}
@@ -3872,7 +3877,8 @@ os_aio_windows_handle(
parameters are valid and can be used to
restart the operation, for example */
void** message2,
- ulint* type) /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* space_id)
{
ulint orig_seg = segment;
os_aio_array_t* array;
@@ -3926,6 +3932,7 @@ os_aio_windows_handle(
*message2 = slot->message2;
*type = slot->type;
+ *space_id = slot->space_id;
if (ret && len == slot->len) {
ret_val = TRUE;
@@ -4009,7 +4016,8 @@ os_aio_simulated_handle(
parameters are valid and can be used to
restart the operation, for example */
void** message2,
- ulint* type) /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* type, /*!< out: OS_FILE_WRITE or ..._READ */
+ ulint* space_id)
{
os_aio_array_t* array;
ulint segment;
@@ -4300,6 +4308,7 @@ slot_io_done:
*message2 = slot->message2;
*type = slot->type;
+ *space_id = slot->space_id;
os_mutex_exit(array->mutex);
diff --git a/storage/xtradb/page/page0cur.c b/storage/xtradb/page/page0cur.c
index fa3d2532deb..f10f16a7dd9 100644
--- a/storage/xtradb/page/page0cur.c
+++ b/storage/xtradb/page/page0cur.c
@@ -564,74 +564,6 @@ page_cur_open_on_rnd_user_rec(
} while (rnd--);
}
-UNIV_INTERN
-void
-page_cur_open_on_nth_user_rec(
-/*==========================*/
- buf_block_t* block, /*!< in: page */
- page_cur_t* cursor, /*!< out: page cursor */
- ulint nth)
-{
- ulint n_recs = page_get_n_recs(buf_block_get_frame(block));
-
- page_cur_set_before_first(block, cursor);
-
- if (UNIV_UNLIKELY(n_recs == 0)) {
-
- return;
- }
-
- nth--;
-
- if (nth >= n_recs) {
- nth = n_recs - 1;
- }
-
- do {
- page_cur_move_to_next(cursor);
- } while (nth--);
-}
-
-UNIV_INTERN
-ibool
-page_cur_open_on_rnd_user_rec_after_nth(
-/*==========================*/
- buf_block_t* block, /*!< in: page */
- page_cur_t* cursor, /*!< out: page cursor */
- ulint nth)
-{
- ulint rnd;
- ulint n_recs = page_get_n_recs(buf_block_get_frame(block));
- ibool ret;
-
- page_cur_set_before_first(block, cursor);
-
- if (UNIV_UNLIKELY(n_recs == 0)) {
-
- return (FALSE);
- }
-
- nth--;
-
- if (nth >= n_recs) {
- nth = n_recs - 1;
- }
-
- rnd = (ulint) (nth + page_cur_lcg_prng() % (n_recs - nth));
-
- if (rnd == nth) {
- ret = TRUE;
- } else {
- ret = FALSE;
- }
-
- do {
- page_cur_move_to_next(cursor);
- } while (rnd--);
-
- return (ret);
-}
-
/***********************************************************//**
Writes the log record of a record insert on a page. */
static
diff --git a/storage/xtradb/page/page0zip.c b/storage/xtradb/page/page0zip.c
index a94d2d54417..5b4f5d3b76a 100644
--- a/storage/xtradb/page/page0zip.c
+++ b/storage/xtradb/page/page0zip.c
@@ -4443,7 +4443,7 @@ page_zip_reorganize(
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
#ifndef UNIV_HOTBACKUP
- temp_block = buf_block_alloc(0);
+ temp_block = buf_block_alloc();
btr_search_drop_page_hash_index(block);
block->check_index_page_at_flush = TRUE;
#else /* !UNIV_HOTBACKUP */
diff --git a/storage/xtradb/rem/rem0cmp.c b/storage/xtradb/rem/rem0cmp.c
index 8ee434f85da..04d2c15437b 100644
--- a/storage/xtradb/rem/rem0cmp.c
+++ b/storage/xtradb/rem/rem0cmp.c
@@ -862,15 +862,18 @@ cmp_rec_rec_with_match(
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
dict_index_t* index, /*!< in: data dictionary index */
+ ibool nulls_unequal,
+ /* in: TRUE if this is for index statistics
+ cardinality estimation, and innodb_stats_method
+ is "nulls_unequal" or "nulls_ignored" */
ulint* matched_fields, /*!< in/out: number of already completely
matched fields; when the function returns,
contains the value the for current
comparison */
- ulint* matched_bytes, /*!< in/out: number of already matched
+ ulint* matched_bytes) /*!< in/out: number of already matched
bytes within the first field not completely
matched; when the function returns, contains
the value for the current comparison */
- ulint stats_method)
{
ulint rec1_n_fields; /* the number of fields in rec */
ulint rec1_f_len; /* length of current field in rec */
@@ -962,13 +965,13 @@ cmp_rec_rec_with_match(
|| rec2_f_len == UNIV_SQL_NULL) {
if (rec1_f_len == rec2_f_len) {
-
- if (stats_method == SRV_STATS_METHOD_NULLS_EQUAL) {
- goto next_field;
- } else {
+ /* This is limited to stats collection,
+ cannot use it for regular search */
+ if (nulls_unequal) {
ret = -1;
+ } else {
+ goto next_field;
}
-
} else if (rec2_f_len == UNIV_SQL_NULL) {
/* We define the SQL null to be the
diff --git a/storage/xtradb/row/row0ins.c b/storage/xtradb/row/row0ins.c
index 3372e1480b5..efcea62f212 100644
--- a/storage/xtradb/row/row0ins.c
+++ b/storage/xtradb/row/row0ins.c
@@ -2026,6 +2026,8 @@ row_ins_index_entry_low(
}
#ifdef UNIV_DEBUG
+ if (!srv_use_sys_stats_table
+ || index != UT_LIST_GET_FIRST(dict_sys->sys_stats->indexes))
{
page_t* page = btr_cur_get_page(&cursor);
rec_t* first_rec = page_rec_get_next(
@@ -2136,7 +2138,7 @@ function_exit:
err = btr_store_big_rec_extern_fields(
index, btr_cur_get_block(&cursor),
- rec, offsets, big_rec, &mtr);
+ rec, offsets, &mtr, FALSE, big_rec);
if (modify) {
dtuple_big_rec_free(big_rec);
diff --git a/storage/xtradb/row/row0mysql.c b/storage/xtradb/row/row0mysql.c
index 205aead8efe..1b97cbb0009 100644
--- a/storage/xtradb/row/row0mysql.c
+++ b/storage/xtradb/row/row0mysql.c
@@ -52,6 +52,7 @@ Created 9/17/2000 Heikki Tuuri
#include "btr0sea.h"
#include "fil0fil.h"
#include "ibuf0ibuf.h"
+#include "ha_prototypes.h"
/** Provide optional 4.x backwards compatibility for 5.0 and above */
UNIV_INTERN ibool row_rollback_on_timeout = FALSE;
@@ -2096,6 +2097,32 @@ row_insert_stats_for_mysql(
}
/*********************************************************************//**
+*/
+UNIV_INTERN
+int
+row_delete_stats_for_mysql(
+/*=============================*/
+ dict_index_t* index,
+ trx_t* trx)
+{
+ pars_info_t* info = pars_info_create();
+
+ trx->op_info = "delete rows from SYS_STATS";
+
+ trx_start_if_not_started(trx);
+ trx->error_state = DB_SUCCESS;
+
+ pars_info_add_dulint_literal(info, "indexid", index->id);
+
+ return((int) que_eval_sql(info,
+ "PROCEDURE DELETE_STATISTICS_PROC () IS\n"
+ "BEGIN\n"
+ "DELETE FROM SYS_STATS WHERE INDEX_ID = :indexid;\n"
+ "END;\n"
+ , TRUE, trx));
+}
+
+/*********************************************************************//**
Scans a table create SQL string and adds to the data dictionary
the foreign key constraints declared in the string. This function
should be called after the indexes for a table have been created.
diff --git a/storage/xtradb/row/row0purge.c b/storage/xtradb/row/row0purge.c
index 8bf2ae0f458..752a2ec9e83 100644
--- a/storage/xtradb/row/row0purge.c
+++ b/storage/xtradb/row/row0purge.c
@@ -387,8 +387,11 @@ Purges an update of an existing record. Also purges an update of a delete
marked record if that record contained an externally stored field. */
static
void
-row_purge_upd_exist_or_extern(
-/*==========================*/
+row_purge_upd_exist_or_extern_func(
+/*===============================*/
+#ifdef UNIV_DEBUG
+ const que_thr_t*thr, /*!< in: query thread */
+#endif /* UNIV_DEBUG */
purge_node_t* node) /*!< in: row purge node */
{
mem_heap_t* heap;
@@ -413,8 +416,8 @@ row_purge_upd_exist_or_extern(
while (node->index != NULL) {
index = node->index;
- if (row_upd_changes_ord_field_binary(NULL, NULL, node->index,
- node->update)) {
+ if (row_upd_changes_ord_field_binary(node->index, node->update,
+ thr, NULL, NULL)) {
/* Build the older version of the index entry */
entry = row_build_index_entry(node->row, NULL,
index, heap);
@@ -496,6 +499,14 @@ skip_secondaries:
}
}
+#ifdef UNIV_DEBUG
+# define row_purge_upd_exist_or_extern(thr,node) \
+ row_purge_upd_exist_or_extern_func(thr,node)
+#else /* UNIV_DEBUG */
+# define row_purge_upd_exist_or_extern(thr,node) \
+ row_purge_upd_exist_or_extern_func(node)
+#endif /* UNIV_DEBUG */
+
/***********************************************************//**
Parses the row reference and other info in a modify undo log record.
@return TRUE if purge operation required: NOTE that then the CALLER
@@ -602,47 +613,32 @@ err_exit:
/***********************************************************//**
Fetches an undo log record and does the purge for the recorded operation.
If none left, or the current purge completed, returns the control to the
-parent node, which is always a query thread node.
-@return DB_SUCCESS if operation successfully completed, else error code */
-static
-ulint
+parent node, which is always a query thread node. */
+static __attribute__((nonnull))
+void
row_purge(
/*======*/
purge_node_t* node, /*!< in: row purge node */
que_thr_t* thr) /*!< in: query thread */
{
- roll_ptr_t roll_ptr;
- ibool purge_needed;
ibool updated_extern;
- trx_t* trx;
- ut_ad(node && thr);
-
- trx = thr_get_trx(thr);
+ ut_ad(node);
+ ut_ad(thr);
- node->undo_rec = trx_purge_fetch_next_rec(&roll_ptr,
- &(node->reservation),
+ node->undo_rec = trx_purge_fetch_next_rec(&node->roll_ptr,
+ &node->reservation,
node->heap);
if (!node->undo_rec) {
/* Purge completed for this query thread */
thr->run_node = que_node_get_parent(node);
- return(DB_SUCCESS);
- }
-
- node->roll_ptr = roll_ptr;
-
- if (node->undo_rec == &trx_purge_dummy_rec) {
- purge_needed = FALSE;
- } else {
- purge_needed = row_purge_parse_undo_rec(node, &updated_extern,
- thr);
- /* If purge_needed == TRUE, we must also remember to unfreeze
- data dictionary! */
+ return;
}
- if (purge_needed) {
+ if (node->undo_rec != &trx_purge_dummy_rec
+ && row_purge_parse_undo_rec(node, &updated_extern, thr)) {
node->found_clust = FALSE;
node->index = dict_table_get_next_index(
@@ -654,14 +650,14 @@ row_purge(
} else if (updated_extern
|| node->rec_type == TRX_UNDO_UPD_EXIST_REC) {
- row_purge_upd_exist_or_extern(node);
+ row_purge_upd_exist_or_extern(thr, node);
}
if (node->found_clust) {
btr_pcur_close(&(node->pcur));
}
- row_mysql_unfreeze_data_dictionary(trx);
+ row_mysql_unfreeze_data_dictionary(thr_get_trx(thr));
}
/* Do some cleanup */
@@ -669,8 +665,6 @@ row_purge(
mem_heap_empty(node->heap);
thr->run_node = node;
-
- return(DB_SUCCESS);
}
/***********************************************************//**
@@ -684,9 +678,6 @@ row_purge_step(
que_thr_t* thr) /*!< in: query thread */
{
purge_node_t* node;
-#ifdef UNIV_DEBUG
- ulint err;
-#endif /* UNIV_DEBUG */
ut_ad(thr);
@@ -694,12 +685,7 @@ row_purge_step(
ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);
-#ifdef UNIV_DEBUG
- err =
-#endif /* UNIV_DEBUG */
row_purge(node, thr);
- ut_ad(err == DB_SUCCESS);
-
return(thr);
}
diff --git a/storage/xtradb/row/row0row.c b/storage/xtradb/row/row0row.c
index 8e806a14a98..0783d482f76 100644
--- a/storage/xtradb/row/row0row.c
+++ b/storage/xtradb/row/row0row.c
@@ -347,6 +347,14 @@ row_rec_to_index_entry_low(
rec_len = rec_offs_n_fields(offsets);
+ if (srv_use_sys_stats_table
+ && index == UT_LIST_GET_FIRST(dict_sys->sys_stats->indexes)) {
+ if (rec_len < dict_index_get_n_fields(index)) {
+ /* the new record should be extended */
+ rec_len = dict_index_get_n_fields(index);
+ }
+ }
+
entry = dtuple_create(heap, rec_len);
dtuple_set_n_fields_cmp(entry,
@@ -358,6 +366,14 @@ row_rec_to_index_entry_low(
for (i = 0; i < rec_len; i++) {
dfield = dtuple_get_nth_field(entry, i);
+
+ if (srv_use_sys_stats_table
+ && index == UT_LIST_GET_FIRST(dict_sys->sys_stats->indexes)
+ && i >= rec_offs_n_fields(offsets)) {
+ dfield_set_null(dfield);
+ continue;
+ }
+
field = rec_get_nth_field(rec, offsets, i, &len);
dfield_set_data(dfield, field, len);
diff --git a/storage/xtradb/row/row0umod.c b/storage/xtradb/row/row0umod.c
index 562f8093c38..5202a498eed 100644
--- a/storage/xtradb/row/row0umod.c
+++ b/storage/xtradb/row/row0umod.c
@@ -173,40 +173,26 @@ row_undo_mod_remove_clust_low(
mtr_t* mtr, /*!< in: mtr */
ulint mode) /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */
{
- btr_pcur_t* pcur;
btr_cur_t* btr_cur;
ulint err;
- ibool success;
ut_ad(node->rec_type == TRX_UNDO_UPD_DEL_REC);
- pcur = &(node->pcur);
- btr_cur = btr_pcur_get_btr_cur(pcur);
- success = btr_pcur_restore_position(mode, pcur, mtr);
+ /* Find out if the record has been purged already
+ or if we can remove it. */
- if (!success) {
+ if (!btr_pcur_restore_position(mode, &node->pcur, mtr)
+ || row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) {
return(DB_SUCCESS);
}
- /* Find out if we can remove the whole clustered index record */
-
- if (node->rec_type == TRX_UNDO_UPD_DEL_REC
- && !row_vers_must_preserve_del_marked(node->new_trx_id, mtr)) {
-
- /* Ok, we can remove */
- } else {
- return(DB_SUCCESS);
- }
+ btr_cur = btr_pcur_get_btr_cur(&node->pcur);
if (mode == BTR_MODIFY_LEAF) {
- success = btr_cur_optimistic_delete(btr_cur, mtr);
-
- if (success) {
- err = DB_SUCCESS;
- } else {
- err = DB_FAIL;
- }
+ err = btr_cur_optimistic_delete(btr_cur, mtr)
+ ? DB_SUCCESS
+ : DB_FAIL;
} else {
ut_ad(mode == BTR_MODIFY_TREE);
@@ -668,8 +654,9 @@ row_undo_mod_upd_exist_sec(
while (node->index != NULL) {
index = node->index;
- if (row_upd_changes_ord_field_binary(
- node->row, node->ext, node->index, node->update)) {
+ if (row_upd_changes_ord_field_binary(node->index, node->update,
+ thr,
+ node->row, node->ext)) {
/* Build the newest version of the index entry */
entry = row_build_index_entry(node->row, node->ext,
diff --git a/storage/xtradb/row/row0upd.c b/storage/xtradb/row/row0upd.c
index e1c78949603..a6fb266c4ed 100644
--- a/storage/xtradb/row/row0upd.c
+++ b/storage/xtradb/row/row0upd.c
@@ -439,6 +439,12 @@ row_upd_changes_field_size_or_external(
0);
}
+ if (srv_use_sys_stats_table
+ && index == UT_LIST_GET_FIRST(dict_sys->sys_stats->indexes)
+ && upd_field->field_no >= rec_offs_n_fields(offsets)) {
+ return(TRUE);
+ }
+
old_len = rec_offs_nth_size(offsets, upd_field->field_no);
if (rec_offs_comp(offsets)
@@ -844,6 +850,18 @@ row_upd_build_difference_binary(
for (i = 0; i < dtuple_get_n_fields(entry); i++) {
+ if (srv_use_sys_stats_table
+ && index == UT_LIST_GET_FIRST(dict_sys->sys_stats->indexes)
+ && i >= rec_offs_n_fields(offsets)) {
+ dfield = dtuple_get_nth_field(entry, i);
+
+ upd_field = upd_get_nth_field(update, n_diff);
+ dfield_copy(&(upd_field->new_val), dfield);
+ upd_field_set_field_no(upd_field, i, index, trx);
+ n_diff++;
+ goto skip_compare;
+ }
+
data = rec_get_nth_field(rec, offsets, i, &len);
dfield = dtuple_get_nth_field(entry, i);
@@ -1192,25 +1210,31 @@ NOTE: we compare the fields as binary strings!
@return TRUE if update vector changes an ordering field in the index record */
UNIV_INTERN
ibool
-row_upd_changes_ord_field_binary(
-/*=============================*/
+row_upd_changes_ord_field_binary_func(
+/*==================================*/
+ dict_index_t* index, /*!< in: index of the record */
+ const upd_t* update, /*!< in: update vector for the row; NOTE: the
+ field numbers in this MUST be clustered index
+ positions! */
+#ifdef UNIV_DEBUG
+ const que_thr_t*thr, /*!< in: query thread */
+#endif /* UNIV_DEBUG */
const dtuple_t* row, /*!< in: old value of row, or NULL if the
row and the data values in update are not
known when this function is called, e.g., at
compile time */
- const row_ext_t*ext, /*!< NULL, or prefixes of the externally
+ const row_ext_t*ext) /*!< NULL, or prefixes of the externally
stored columns in the old row */
- dict_index_t* index, /*!< in: index of the record */
- const upd_t* update) /*!< in: update vector for the row; NOTE: the
- field numbers in this MUST be clustered index
- positions! */
{
ulint n_unique;
ulint i;
const dict_index_t* clust_index;
- ut_ad(update);
ut_ad(index);
+ ut_ad(update);
+ ut_ad(thr);
+ ut_ad(thr->graph);
+ ut_ad(thr->graph->trx);
n_unique = dict_index_get_n_unique(index);
@@ -1252,6 +1276,10 @@ row_upd_changes_ord_field_binary(
|| dfield_is_null(dfield)) {
/* do nothing special */
} else if (UNIV_LIKELY_NULL(ext)) {
+ /* Silence a compiler warning without
+ silencing a Valgrind error. */
+ dfield_len = 0;
+ UNIV_MEM_INVALID(&dfield_len, sizeof dfield_len);
/* See if the column is stored externally. */
buf = row_ext_lookup(ext, col_no, &dfield_len);
@@ -1259,9 +1287,14 @@ row_upd_changes_ord_field_binary(
if (UNIV_LIKELY_NULL(buf)) {
if (UNIV_UNLIKELY(buf == field_ref_zero)) {
- /* This should never happen, but
- we try to fail safe here. */
- ut_ad(0);
+ /* The externally stored field
+ was not written yet. This
+ record should only be seen by
+ recv_recovery_rollback_active(),
+ when the server had crashed before
+ storing the field. */
+ ut_ad(thr->graph->trx->is_recovered);
+ ut_ad(trx_is_recv(thr->graph->trx));
return(TRUE);
}
@@ -1608,8 +1641,8 @@ row_upd_sec_step(
ut_ad(!dict_index_is_clust(node->index));
if (node->state == UPD_NODE_UPDATE_ALL_SEC
- || row_upd_changes_ord_field_binary(node->row, node->ext,
- node->index, node->update)) {
+ || row_upd_changes_ord_field_binary(node->index, node->update,
+ thr, node->row, node->ext)) {
return(row_upd_sec_index_entry(node, thr));
}
@@ -1937,7 +1970,7 @@ row_upd_clust_rec(
index, btr_cur_get_block(btr_cur), rec,
rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap),
- big_rec, mtr);
+ mtr, TRUE, big_rec);
mtr_commit(mtr);
}
@@ -2136,8 +2169,8 @@ exit_func:
row_upd_store_row(node);
- if (row_upd_changes_ord_field_binary(node->row, node->ext, index,
- node->update)) {
+ if (row_upd_changes_ord_field_binary(index, node->update, thr,
+ node->row, node->ext)) {
/* Update causes an ordering field (ordering fields within
the B-tree) of the clustered index record to change: perform
diff --git a/storage/xtradb/row/row0vers.c b/storage/xtradb/row/row0vers.c
index b6d35363f08..d4fde0b939b 100644
--- a/storage/xtradb/row/row0vers.c
+++ b/storage/xtradb/row/row0vers.c
@@ -669,11 +669,15 @@ row_vers_build_for_semi_consistent_read(
mutex_enter(&kernel_mutex);
version_trx = trx_get_on_id(version_trx_id);
+ if (version_trx
+ && (version_trx->conc_state == TRX_COMMITTED_IN_MEMORY
+ || version_trx->conc_state == TRX_NOT_STARTED)) {
+
+ version_trx = NULL;
+ }
mutex_exit(&kernel_mutex);
- if (!version_trx
- || version_trx->conc_state == TRX_NOT_STARTED
- || version_trx->conc_state == TRX_COMMITTED_IN_MEMORY) {
+ if (!version_trx) {
/* We found a version that belongs to a
committed transaction: return it. */
diff --git a/storage/xtradb/srv/srv0srv.c b/storage/xtradb/srv/srv0srv.c
index 1cd44b451eb..fb13ec395c2 100644
--- a/storage/xtradb/srv/srv0srv.c
+++ b/storage/xtradb/srv/srv0srv.c
@@ -269,6 +269,11 @@ UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 75;
/* variable counts amount of data read in total (in bytes) */
UNIV_INTERN ulint srv_data_read = 0;
+/* Internal setting for "innodb_stats_method". Decides how InnoDB treats
+NULL value when collecting statistics. By default, it is set to
+SRV_STATS_NULLS_EQUAL(0), ie. all NULL value are treated equal */
+ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL;
+
/* here we count the amount of data written in total (in bytes) */
UNIV_INTERN ulint srv_data_written = 0;
@@ -388,7 +393,6 @@ UNIV_INTERN ibool srv_innodb_status = FALSE;
/* When estimating number of different key values in an index, sample
this many index pages */
UNIV_INTERN unsigned long long srv_stats_sample_pages = 8;
-UNIV_INTERN ulong srv_stats_method = 0;
UNIV_INTERN ulong srv_stats_auto_update = 1;
UNIV_INTERN ulint srv_stats_update_need_lock = 1;
UNIV_INTERN ibool srv_use_sys_stats_table = FALSE;
@@ -419,6 +423,8 @@ UNIV_INTERN ulint srv_pass_corrupt_table = 0; /* 0:disable 1:enable */
UNIV_INTERN ulong srv_extra_rsegments = 0; /* extra rseg for users */
UNIV_INTERN ulong srv_dict_size_limit = 0;
+
+UNIV_INTERN ulint srv_lazy_drop_table = 0;
/*-------------------------------------------*/
UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
@@ -2712,7 +2718,8 @@ srv_master_thread(
unsigned space:32;
unsigned offset:32;
ib_uint64_t oldest_modification;
- } prev_flush_info;
+ };
+ struct t_prev_flush_info_struct prev_flush_info = {0,0,0,0};
ib_uint64_t lsn_old;
@@ -2771,6 +2778,8 @@ loop:
for (i = 0; i < 10; i++) {
ulint cur_time = ut_time_ms();
+ n_pages_flushed = 0; /* initialize */
+
n_ios_old = log_sys->n_log_ios + buf_pool->stat.n_pages_read
+ buf_pool->stat.n_pages_written;
srv_main_thread_op_info = "sleeping";
@@ -3036,7 +3045,8 @@ retry_flush_batch:
if (prev_adaptive_checkpoint == 3) {
lint n_flush;
- lint blocks_sum, new_blocks_sum, flushed_blocks_sum;
+ lint blocks_sum;
+ ulint new_blocks_sum, flushed_blocks_sum;
blocks_sum = new_blocks_sum = flushed_blocks_sum = 0;
diff --git a/storage/xtradb/sync/sync0arr.c b/storage/xtradb/sync/sync0arr.c
index 223e1715944..57a288089c7 100644
--- a/storage/xtradb/sync/sync0arr.c
+++ b/storage/xtradb/sync/sync0arr.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -714,7 +714,7 @@ print:
fprintf(stderr, "rw-lock %p ",
(void*) lock);
sync_array_cell_print(stderr, cell);
- rw_lock_debug_print(debug);
+ rw_lock_debug_print(stderr, debug);
return(TRUE);
}
}
diff --git a/storage/xtradb/sync/sync0rw.c b/storage/xtradb/sync/sync0rw.c
index 0bdffcb98b0..9431de15fda 100644
--- a/storage/xtradb/sync/sync0rw.c
+++ b/storage/xtradb/sync/sync0rw.c
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
@@ -231,10 +231,10 @@ rw_lock_create_func(
# ifdef UNIV_SYNC_DEBUG
ulint level, /*!< in: level */
# endif /* UNIV_SYNC_DEBUG */
-#endif /* UNIV_DEBUG */
- const char* cmutex_name, /*!< in: mutex name */
const char* cfile_name, /*!< in: file name where created */
- ulint cline) /*!< in: file line where created */
+ ulint cline, /*!< in: file line where created */
+#endif /* UNIV_DEBUG */
+ const char* cmutex_name) /*!< in: mutex name */
{
/* If this is the very first time a synchronization object is
created, then the following call initializes the sync system. */
@@ -247,11 +247,12 @@ rw_lock_create_func(
lock->mutex.cmutex_name = cmutex_name;
ut_d(lock->mutex.mutex_type = 1);
+#else /* INNODB_RW_LOCKS_USE_ATOMICS */
+# ifdef UNIV_DEBUG
+ UT_NOT_USED(cfile_name);
+ UT_NOT_USED(cline);
+# endif
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
-#if defined(INNODB_RW_LOCKS_USE_ATOMICS) || !defined(UNIV_DEBUG)
- (void) cfile_name;
- (void) cline;
-#endif
lock->lock_word = X_LOCK_DECR;
lock->waiters = 0;
@@ -923,7 +924,7 @@ rw_lock_list_print_info(
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
- rw_lock_debug_print(info);
+ rw_lock_debug_print(file, info);
info = UT_LIST_GET_NEXT(list, info);
}
}
@@ -971,7 +972,7 @@ rw_lock_print(
info = UT_LIST_GET_FIRST(lock->debug_list);
while (info != NULL) {
- rw_lock_debug_print(info);
+ rw_lock_debug_print(stderr, info);
info = UT_LIST_GET_NEXT(list, info);
}
}
@@ -983,28 +984,29 @@ UNIV_INTERN
void
rw_lock_debug_print(
/*================*/
+ FILE* f, /*!< in: output stream */
rw_lock_debug_t* info) /*!< in: debug struct */
{
ulint rwt;
rwt = info->lock_type;
- fprintf(stderr, "Locked: thread %lu file %s line %lu ",
+ fprintf(f, "Locked: thread %lu file %s line %lu ",
(ulong) os_thread_pf(info->thread_id), info->file_name,
(ulong) info->line);
if (rwt == RW_LOCK_SHARED) {
- fputs("S-LOCK", stderr);
+ fputs("S-LOCK", f);
} else if (rwt == RW_LOCK_EX) {
- fputs("X-LOCK", stderr);
+ fputs("X-LOCK", f);
} else if (rwt == RW_LOCK_WAIT_EX) {
- fputs("WAIT X-LOCK", stderr);
+ fputs("WAIT X-LOCK", f);
} else {
ut_error;
}
if (info->pass != 0) {
- fprintf(stderr, " pass value %lu", (ulong) info->pass);
+ fprintf(f, " pass value %lu", (ulong) info->pass);
}
- putc('\n', stderr);
+ putc('\n', f);
}
/***************************************************************//**
diff --git a/storage/xtradb/sync/sync0sync.c b/storage/xtradb/sync/sync0sync.c
index 71b444dbe54..3a80da9318b 100644
--- a/storage/xtradb/sync/sync0sync.c
+++ b/storage/xtradb/sync/sync0sync.c
@@ -238,14 +238,14 @@ void
mutex_create_func(
/*==============*/
mutex_t* mutex, /*!< in: pointer to memory */
- const char* cmutex_name, /*!< in: mutex name */
#ifdef UNIV_DEBUG
# ifdef UNIV_SYNC_DEBUG
ulint level, /*!< in: level */
# endif /* UNIV_SYNC_DEBUG */
-#endif /* UNIV_DEBUG */
const char* cfile_name, /*!< in: file name where created */
- ulint cline) /*!< in: file line where created */
+ ulint cline, /*!< in: file line where created */
+#endif /* UNIV_DEBUG */
+ const char* cmutex_name) /*!< in: mutex name */
{
#if defined(HAVE_ATOMIC_BUILTINS)
mutex_reset_lock_word(mutex);
@@ -266,9 +266,6 @@ mutex_create_func(
#ifdef UNIV_DEBUG
mutex->cfile_name = cfile_name;
mutex->cline = cline;
-#else
- (void) cfile_name;
- (void) cline;
#endif /* UNIV_DEBUG */
mutex->count_os_wait = 0;
mutex->cmutex_name= cmutex_name;
@@ -1164,6 +1161,7 @@ sync_thread_add_level(
case SYNC_LOG:
case SYNC_THR_LOCAL:
case SYNC_ANY_LATCH:
+ case SYNC_OUTER_ANY_LATCH:
case SYNC_TRX_SYS_HEADER:
case SYNC_FILE_FORMAT_TAG:
case SYNC_DOUBLEWRITE:
diff --git a/storage/xtradb/trx/trx0rec.c b/storage/xtradb/trx/trx0rec.c
index f50e10ed756..71629f01d73 100644
--- a/storage/xtradb/trx/trx0rec.c
+++ b/storage/xtradb/trx/trx0rec.c
@@ -665,14 +665,27 @@ trx_undo_page_report_modify(
/* Save to the undo log the old values of the columns to be updated. */
if (update) {
+ ulint extended = 0;
+
if (trx_undo_left(undo_page, ptr) < 5) {
return(0);
}
- ptr += mach_write_compressed(ptr, upd_get_n_fields(update));
+ if (srv_use_sys_stats_table
+ && index == UT_LIST_GET_FIRST(dict_sys->sys_stats->indexes)) {
+ for (i = 0; i < upd_get_n_fields(update); i++) {
+ ulint pos = upd_get_nth_field(update, i)->field_no;
+
+ if (pos >= rec_offs_n_fields(offsets)) {
+ extended++;
+ }
+ }
+ }
+
+ ptr += mach_write_compressed(ptr, upd_get_n_fields(update) - extended);
- for (i = 0; i < upd_get_n_fields(update); i++) {
+ for (i = 0; i < upd_get_n_fields(update) - extended; i++) {
ulint pos = upd_get_nth_field(update, i)->field_no;
diff --git a/storage/xtradb/trx/trx0roll.c b/storage/xtradb/trx/trx0roll.c
index 1a43e419214..a4bbf7fd652 100644
--- a/storage/xtradb/trx/trx0roll.c
+++ b/storage/xtradb/trx/trx0roll.c
@@ -48,8 +48,8 @@ Created 3/26/1996 Heikki Tuuri
rollback */
#define TRX_ROLL_TRUNC_THRESHOLD 1
-/** In crash recovery, the current trx to be rolled back */
-static trx_t* trx_roll_crash_recv_trx = NULL;
+/** In crash recovery, the current trx to be rolled back; NULL otherwise */
+static const trx_t* trx_roll_crash_recv_trx = NULL;
/** In crash recovery we set this to the undo n:o of the current trx to be
rolled back. Then we can print how many % the rollback has progressed. */
diff --git a/storage/xtradb/trx/trx0trx.c b/storage/xtradb/trx/trx0trx.c
index 06778bbbef7..7ea3e09036f 100644
--- a/storage/xtradb/trx/trx0trx.c
+++ b/storage/xtradb/trx/trx0trx.c
@@ -2106,18 +2106,18 @@ trx_recover_for_mysql(
/*******************************************************************//**
This function is used to find one X/Open XA distributed transaction
which is in the prepared state
-@return trx or NULL */
+@return trx or NULL; on match, the trx->xid will be invalidated */
UNIV_INTERN
trx_t*
trx_get_trx_by_xid(
/*===============*/
- XID* xid) /*!< in: X/Open XA transaction identification */
+ const XID* xid) /*!< in: X/Open XA transaction identifier */
{
trx_t* trx;
if (xid == NULL) {
- return (NULL);
+ return(NULL);
}
mutex_enter(&kernel_mutex);
@@ -2130,10 +2130,16 @@ trx_get_trx_by_xid(
of gtrid_lenght+bqual_length bytes should be
the same */
- if (xid->gtrid_length == trx->xid.gtrid_length
+ if (trx->conc_state == TRX_PREPARED
+ && xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
&& memcmp(xid->data, trx->xid.data,
xid->gtrid_length + xid->bqual_length) == 0) {
+
+ /* Invalidate the XID, so that subsequent calls
+ will not find it. */
+ memset(&trx->xid, 0, sizeof(trx->xid));
+ trx->xid.formatID = -1;
break;
}
@@ -2142,14 +2148,5 @@ trx_get_trx_by_xid(
mutex_exit(&kernel_mutex);
- if (trx) {
- if (trx->conc_state != TRX_PREPARED) {
-
- return(NULL);
- }
-
- return(trx);
- } else {
- return(NULL);
- }
+ return(trx);
}
diff --git a/strings/bchange.c b/strings/bchange.c
index 3a054efdb0a..c8e477fa186 100644
--- a/strings/bchange.c
+++ b/strings/bchange.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : bchange.c
Author : Michael widenius
diff --git a/strings/bcopy-duff.c b/strings/bcopy-duff.c
index 215857715fd..535ab4a7b9f 100644
--- a/strings/bcopy-duff.c
+++ b/strings/bcopy-duff.c
@@ -1,22 +1,34 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
#define IFACTOR 4
- void
-dcopy(char *chardest, char *charsrc, int size)
+void dcopy(char *chardest, char *charsrc, int size)
{
register int *src, *dest, intcount ;
int startcharcpy, intoffset, numints2cpy, i ;
diff --git a/strings/bfill.c b/strings/bfill.c
index 9ca9e6b551b..9f1343b05b2 100644
--- a/strings/bfill.c
+++ b/strings/bfill.c
@@ -1,19 +1,31 @@
-/* Copyright (C) 2002 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : bfill.c
Author : Richard A. O'Keefe.
diff --git a/strings/bmove.c b/strings/bmove.c
index f94f262d7b4..470fe4d27b3 100644
--- a/strings/bmove.c
+++ b/strings/bmove.c
@@ -1,19 +1,31 @@
-/* Copyright (C) 2002 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : bmove.c
Author : Richard A. O'Keefe.
diff --git a/strings/bmove512.c b/strings/bmove512.c
index 308646c0586..096dbcc0fb3 100644
--- a/strings/bmove512.c
+++ b/strings/bmove512.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : bmove512.c
Author : Michael Widenius;
diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c
index fa136751b76..6ae33f8f0ef 100644
--- a/strings/bmove_upp.c
+++ b/strings/bmove_upp.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : bmove.c
Author : Michael widenius
diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c
index 9a7887991a6..11a4042b10c 100644
--- a/strings/conf_to_src.c
+++ b/strings/conf_to_src.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -249,7 +250,9 @@ static void
fprint_copyright(FILE *file)
{
fprintf(file,
-"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems Inc., 2010-2011 Monty Program Ab\n"
+"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems Inc.\n"
+" Copyright 2010-2011 Monty Program Ab\n"
+" Copyright (c) 2003, 2011, Oracle and/or its affiliates\n"
"\n"
" This program is free software; you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n"
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 20edc2f5729..2b898fd1707 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index 2ec951aaad2..ebfdcac00d9 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 2002 MySQL AB & tommy@valley.ne.jp.
+/* Copyright tommy@valley.ne.jp.
+ Copyright (c) 2002, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c
index 9961ecacf97..c1fa3891f15 100644
--- a/strings/ctype-cp932.c
+++ b/strings/ctype-cp932.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index 6f99b33de8f..e9acdce5e79 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c
index 2c27e04ab09..058cd16d5aa 100644
--- a/strings/ctype-euc_kr.c
+++ b/strings/ctype-euc_kr.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c
index d22c9c971c9..60f43086eaf 100644
--- a/strings/ctype-eucjpms.c
+++ b/strings/ctype-eucjpms.c
@@ -1,5 +1,7 @@
-/* Copyright (C) 2002 MySQL AB & tommy@valley.ne.jp.
-
+/* Copyright tommy@valley.ne.jp.
+ Copyright (c) 2002, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c
index 99cec51bdaf..e0499c6f2e3 100644
--- a/strings/ctype-extra.c
+++ b/strings/ctype-extra.c
@@ -7,6 +7,7 @@
*/
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+ Copyright (c) 2000, 2011, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c
index 68ea0957165..dad25084d58 100644
--- a/strings/ctype-gb2312.c
+++ b/strings/ctype-gb2312.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 409ecd0c99f..7d6be3dde1e 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c
index 882e84ae6f6..e85838fdea5 100644
--- a/strings/ctype-latin1.c
+++ b/strings/ctype-latin1.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index a11476b6aa1..73001d1ad34 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 2894c1fbf95..cc142b7fbef 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002 MySQL AB
+/* Copyright (c) 2002, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1544,7 +1545,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)),
}
}
- digits= str - beg;
+ digits= (int) (str - beg);
/* Continue to accumulate into ulonglong */
for (dot= NULL, ull= ul; str < end; str++)
@@ -1581,7 +1582,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)),
}
else
{
- shift= dot - str;
+ shift= (int) (dot - str);
for ( ; str < end && (ch= (uchar) (*str - '0')) < 10; str++);
}
goto exp;
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index cb57f4aafc9..28e4950a111 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 7b5b7ff55cf..a6dee014123 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB
-
+/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
@@ -14,6 +13,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
+ Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
Copyright (C) 2003 by Sathit Jittanupat
<jsat66@hotmail.com,jsat66@yahoo.com>
* solving bug crash with long text field string
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index 0d2f1457b34..2a5e01958b4 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2004 MySQL AB
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 247ff3501d5..37ece4a9840 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index 03f0c369342..a90428a981a 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 2002 MySQL AB & tommy@valley.ne.jp.
+/* Copyright tommy@valley.ne.jp.
+ Copyright (c) 2002, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 74113a04524..a1254895fcb 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c
index 5b1924d9f4d..d42ac3a5e43 100644
--- a/strings/ctype-win1250ch.c
+++ b/strings/ctype-win1250ch.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 2003 MySQL AB
+/* Copyright (c) 2001 Jan Pazdziora.
+ Copyright (c) 2003, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/ctype.c b/strings/ctype.c
index 86b888d29a2..6b039b5336f 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/decimal.c b/strings/decimal.c
index 9450cb0d54b..a05867927ee 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,7 +31,7 @@
integer that determines the number of significant digits in a
particular radix R, where R is either 2 or 10. S is a non-negative
integer. Every value of an exact numeric type of scale S is of the
- form n*10^{-S}, where n is an integer such that �-R^P <= n <= R^P.
+ form n*10^{-S}, where n is an integer such that -R^P <= n <= R^P.
[...]
@@ -255,7 +256,7 @@ void max_decimal(int precision, int frac, decimal_t *to)
}
-static dec1 *remove_leading_zeroes(decimal_t *from, int *intg_result)
+static dec1 *remove_leading_zeroes(const decimal_t *from, int *intg_result)
{
int intg= from->intg, i;
dec1 *buf0= from->buf;
@@ -333,7 +334,7 @@ int decimal_actual_fraction(decimal_t *from)
E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW
*/
-int decimal2string(decimal_t *from, char *to, int *to_len,
+int decimal2string(const decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler)
{
@@ -949,7 +950,7 @@ fatal_error:
E_DEC_OK
*/
-int decimal2double(decimal_t *from, double *to)
+int decimal2double(const decimal_t *from, double *to)
{
double result= 0.0;
int i, exp= 0;
@@ -1041,7 +1042,7 @@ int longlong2decimal(longlong from, decimal_t *to)
return ull2dec(from, to);
}
-int decimal2ulonglong(decimal_t *from, ulonglong *to)
+int decimal2ulonglong(const decimal_t *from, ulonglong *to)
{
dec1 *buf=from->buf;
ulonglong x=0;
@@ -1070,7 +1071,7 @@ int decimal2ulonglong(decimal_t *from, ulonglong *to)
return E_DEC_OK;
}
-int decimal2longlong(decimal_t *from, longlong *to)
+int decimal2longlong(const decimal_t *from, longlong *to)
{
dec1 *buf=from->buf;
longlong x=0;
@@ -1189,7 +1190,7 @@ int decimal2longlong(decimal_t *from, longlong *to)
7E F2 04 37 2D FB 2D
*/
-int decimal2bin(decimal_t *from, uchar *to, int precision, int frac)
+int decimal2bin(const decimal_t *from, uchar *to, int precision, int frac)
{
dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1;
int error=E_DEC_OK, intg=precision-frac,
@@ -1479,7 +1480,7 @@ int decimal_bin_size(int precision, int scale)
*/
int
-decimal_round(decimal_t *from, decimal_t *to, int scale,
+decimal_round(const decimal_t *from, decimal_t *to, int scale,
decimal_round_mode mode)
{
int frac0=scale>0 ? ROUND_UP(scale) : scale/DIG_PER_DEC1,
diff --git a/strings/do_ctype.c b/strings/do_ctype.c
index 91e29c55158..8b51f7850c1 100644
--- a/strings/do_ctype.c
+++ b/strings/do_ctype.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/dump_map.c b/strings/dump_map.c
index e2b8b7db077..61e6cbb6e02 100644
--- a/strings/dump_map.c
+++ b/strings/dump_map.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2003-2004 MySQL AB
+/* Copyright (c) 2003, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/int2str.c b/strings/int2str.c
index 03e846c31dc..f2a5c15f32c 100644
--- a/strings/int2str.c
+++ b/strings/int2str.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
#include "strings_def.h"
diff --git a/strings/is_prefix.c b/strings/is_prefix.c
index f116e6bf1bf..2933577b5ab 100644
--- a/strings/is_prefix.c
+++ b/strings/is_prefix.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : is_prefix.c
Author : Michael Widenius
diff --git a/strings/llstr.c b/strings/llstr.c
index fdbe1b6f6dc..3525cab79ca 100644
--- a/strings/llstr.c
+++ b/strings/llstr.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
Defines: llstr();
diff --git a/strings/longlong2str.c b/strings/longlong2str.c
index f320baf2e34..a30eca40f2f 100644
--- a/strings/longlong2str.c
+++ b/strings/longlong2str.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
Defines: longlong2str();
diff --git a/strings/longlong2str_asm.c b/strings/longlong2str_asm.c
index dd0daf01969..237d1d15052 100644
--- a/strings/longlong2str_asm.c
+++ b/strings/longlong2str_asm.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
Wrapper for longlong2str.s
diff --git a/strings/memcmp.c b/strings/memcmp.c
index 9471353f751..ef414a9f983 100644
--- a/strings/memcmp.c
+++ b/strings/memcmp.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* memcmp(lhs, rhs, len)
compares the two memory areas lhs[0..len-1] ?? rhs[0..len-1]. It
diff --git a/strings/memcpy.c b/strings/memcpy.c
index f32d346e3ec..9ba9093e255 100644
--- a/strings/memcpy.c
+++ b/strings/memcpy.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
memcpy(dst, src, len)
diff --git a/strings/memset.c b/strings/memset.c
index e07dc4ead85..d394ff87f56 100644
--- a/strings/memset.c
+++ b/strings/memset.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : memset.c
Author : Richard A. O'Keefe.
diff --git a/strings/my_strchr.c b/strings/my_strchr.c
index 5f1d985ba1a..baf832c9a0a 100644
--- a/strings/my_strchr.c
+++ b/strings/my_strchr.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005 MySQL AB
+/* Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c
index f8e3825b441..8b8ac9e04fe 100644
--- a/strings/my_strtoll10.c
+++ b/strings/my_strtoll10.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2003 MySQL AB
+/* Copyright (c) 2003 TXT DataKonsult Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
#include "strings_def.h"
#include <my_sys.h> /* Needed for MY_ERRNO_ERANGE */
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index 0e6fd09e144..4105aaee189 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -633,4 +634,3 @@ size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
va_end(args);
return result;
}
-
diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c
index e342f72ed52..17e22496ff3 100644
--- a/strings/r_strinstr.c
+++ b/strings/r_strinstr.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 David Axmark
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
Author : David
diff --git a/strings/str2int.c b/strings/str2int.c
index 1bee56d1846..64d4e169891 100644
--- a/strings/str2int.c
+++ b/strings/str2int.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
str2int(src, radix, lower, upper, &val)
diff --git a/strings/str_alloc.c b/strings/str_alloc.c
index bb20fde0f56..5233a804153 100644
--- a/strings/str_alloc.c
+++ b/strings/str_alloc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/str_test.c b/strings/str_test.c
index 3ad1392f185..b0853cb0e98 100644
--- a/strings/str_test.c
+++ b/strings/str_test.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/strappend.c b/strings/strappend.c
index 1a95da673a7..29d38e74fb5 100644
--- a/strings/strappend.c
+++ b/strings/strappend.c
@@ -1,31 +1,33 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* File : strappend.c
- Author : Monty
- Updated: 1987.02.07
- Defines: strappend()
-
- strappend(dest, len, fill) appends fill-characters to a string so that
- the result length == len. If the string is longer than len it's
- trunked. The des+len character is allways set to NULL.
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
*/
#include "strings_def.h"
-
void strappend(register char *s, size_t len, pchar fill)
{
register char *endpos;
diff --git a/strings/strcat.c b/strings/strcat.c
index e69369c357f..76e15bdee0d 100644
--- a/strings/strcat.c
+++ b/strings/strcat.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strcat.c
Author : Richard A. O'Keefe.
@@ -32,9 +46,9 @@
char *strcat(register char *s, register const char *t)
{
- char *save;
+ char *save;
- for (save = s; *s++; ) ;
- for (--s; *s++ = *t++; ) ;
- return save;
- }
+ for (save = s; *s++; ) ;
+ for (--s; *s++ = *t++; ) ;
+ return save;
+}
diff --git a/strings/strcend.c b/strings/strcend.c
index 426995f5f31..a78bb749e0c 100644
--- a/strings/strcend.c
+++ b/strings/strcend.c
@@ -1,25 +1,29 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* File : strcend.c
- Author : Michael Widenius: ifdef MC68000
- Updated: 20 April 1984
- Defines: strcend()
-
- strcend(s, c) returns a pointer to the first place in s where c
- occurs, or a pointer to the end-null of s if c does not occur in s.
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
*/
#include "strings_def.h"
diff --git a/strings/strchr.c b/strings/strchr.c
index 5ffe386c718..e05e321681f 100644
--- a/strings/strchr.c
+++ b/strings/strchr.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strchr.c
Author : Richard A. O'Keefe.
diff --git a/strings/strcmp.c b/strings/strcmp.c
index 54bbe92279b..039d7845cbd 100644
--- a/strings/strcmp.c
+++ b/strings/strcmp.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strcmp.c
Author : Richard A. O'Keefe.
diff --git a/strings/strcont.c b/strings/strcont.c
index 9041d84b1c1..514d1a1d62f 100644
--- a/strings/strcont.c
+++ b/strings/strcont.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strcont.c
Author : Monty
diff --git a/strings/strend.c b/strings/strend.c
index 18facccdc3f..7c751120add 100644
--- a/strings/strend.c
+++ b/strings/strend.c
@@ -1,19 +1,31 @@
-/* Copyright (C) 2002 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strend.c
Author : Richard A. O'Keefe.
diff --git a/strings/strfill.c b/strings/strfill.c
index 9f30ef07548..377f9b85e36 100644
--- a/strings/strfill.c
+++ b/strings/strfill.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strfill.c
Author : Monty
diff --git a/strings/strinstr.c b/strings/strinstr.c
index 8f2e4ecd1ee..9dddfbe0d04 100644
--- a/strings/strinstr.c
+++ b/strings/strinstr.c
@@ -1,18 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strinstr.c
Author : Monty & David
Updated: 1986.12.08
diff --git a/strings/strlen.c b/strings/strlen.c
index 1469dd096ee..36c7795634b 100644
--- a/strings/strlen.c
+++ b/strings/strlen.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strlen.c
Author : Richard A. O'Keefe. / Monty
diff --git a/strings/strmake.c b/strings/strmake.c
index 761a0cdc5f7..5c26538c9bd 100644
--- a/strings/strmake.c
+++ b/strings/strmake.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/strmov.c b/strings/strmov.c
index 322c9f9ec04..1a945ad2a6f 100644
--- a/strings/strmov.c
+++ b/strings/strmov.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
strmov(dst, src) moves all the characters of src (including the
diff --git a/strings/strnlen.c b/strings/strnlen.c
index 891087a6ebe..c831d63243e 100644
--- a/strings/strnlen.c
+++ b/strings/strnlen.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strnlen.c
Author : Michael Widenius
diff --git a/strings/strnmov.c b/strings/strnmov.c
index 2087980429a..41d772c6819 100644
--- a/strings/strnmov.c
+++ b/strings/strnmov.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
strnmov(dst,src,length) moves length characters, or until end, of src to
diff --git a/strings/strrchr.c b/strings/strrchr.c
index cdb0479ef90..e447376fb2a 100644
--- a/strings/strrchr.c
+++ b/strings/strrchr.c
@@ -1,17 +1,31 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strrchr.c
Author : Richard A. O'Keefe.
diff --git a/strings/strstr.c b/strings/strstr.c
index b19fb39724c..08b5a4e457b 100644
--- a/strings/strstr.c
+++ b/strings/strstr.c
@@ -1,19 +1,30 @@
-/* Copyright (C) 2002 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strstr.c
Author : Monty
diff --git a/strings/strto.c b/strings/strto.c
index 858d10a134f..c693aa9fccb 100644
--- a/strings/strto.c
+++ b/strings/strto.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/*
strtol,strtoul,strtoll,strtoull
diff --git a/strings/strtod.c b/strings/strtod.c
index 5f2fd664da3..f0e7bd65bcd 100644
--- a/strings/strtod.c
+++ b/strings/strtod.c
@@ -1,3 +1,17 @@
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
/*
An alternative implementation of "strtod()" that is both
simplier, and thread-safe.
@@ -24,7 +38,7 @@
So do we.
- */
+*/
#include "my_base.h" /* Includes errno.h + EOVERFLOW */
#include <m_ctype.h>
diff --git a/strings/strtol.c b/strings/strtol.c
index b8269191aa7..b2bd7b2a275 100644
--- a/strings/strtol.c
+++ b/strings/strtol.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* This implements strtol() if needed */
diff --git a/strings/strtoll.c b/strings/strtoll.c
index a619ca69546..0f9251ea353 100644
--- a/strings/strtoll.c
+++ b/strings/strtoll.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* This implements strtoll() if needed */
diff --git a/strings/strtoul.c b/strings/strtoul.c
index ce3b61c9b3f..8040ac38e61 100644
--- a/strings/strtoul.c
+++ b/strings/strtoul.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* This implements strtol() if needed */
diff --git a/strings/strtoull.c b/strings/strtoull.c
index 76228ec0717..827fd4b67fe 100644
--- a/strings/strtoull.c
+++ b/strings/strtoull.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* This implements strtoull() if needed */
diff --git a/strings/strxmov.c b/strings/strxmov.c
index 1f4a44b5b88..6338832a1a0 100644
--- a/strings/strxmov.c
+++ b/strings/strxmov.c
@@ -1,19 +1,31 @@
-/* Copyright (C) 2002 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strxmov.c
Author : Richard A. O'Keefe.
diff --git a/strings/strxnmov.c b/strings/strxnmov.c
index 4685affeac9..20058b84259 100644
--- a/strings/strxnmov.c
+++ b/strings/strxnmov.c
@@ -1,19 +1,31 @@
-/* Copyright (C) 2002 MySQL AB
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; version 2
- of the License.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA */
+/* Copyright Richard A. O'Keefe.
+ Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* File : strxnmov.c
Author : Richard A. O'Keefe.
diff --git a/strings/uca-dump.c b/strings/uca-dump.c
index 774e940c7da..d281783aa2b 100644
--- a/strings/uca-dump.c
+++ b/strings/uca-dump.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2004 MySQL AB
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/uctypedump.c b/strings/uctypedump.c
index 3ae4b7935e1..117db2ba30a 100644
--- a/strings/uctypedump.c
+++ b/strings/uctypedump.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006 MySQL AB
+/* Copyright (c) 2006, 2011, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/udiv.c b/strings/udiv.c
index 7655e52e2cb..2efb9290e9c 100644
--- a/strings/udiv.c
+++ b/strings/udiv.c
@@ -1,17 +1,30 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* Copyright (c) 2000 TXT DataKonsult Ab & Monty Program Ab
+ Copyright (c) 2009-2011, Monty Program Ab
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
/* Do udiv and urem if machine dosn't have it */
diff --git a/strings/utr11-dump.c b/strings/utr11-dump.c
index a15f63025f4..41cc387b2e0 100644
--- a/strings/utr11-dump.c
+++ b/strings/utr11-dump.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2004 MySQL AB
+/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2009-2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/strings/xml.c b/strings/xml.c
index 58b20553ff7..7834f971269 100644
--- a/strings/xml.c
+++ b/strings/xml.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2011 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -105,6 +106,13 @@ static void my_xml_norm_text(MY_XML_ATTR *a)
}
+static inline my_bool
+my_xml_parser_prefix_cmp(MY_XML_PARSER *p, const char *s, size_t slen)
+{
+ return (p->cur + slen > p->end) || memcmp(p->cur, s, slen);
+}
+
+
static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
{
int lex;
@@ -122,16 +130,20 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
a->beg=p->cur;
a->end=p->cur;
- if ((p->end - p->cur > 3) && !bcmp((uchar*) p->cur, (uchar*) "<!--",4))
+ if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("<!--")))
{
- for (; (p->cur < p->end) && bcmp((uchar*) p->cur, (uchar*) "-->", 3); p->cur++)
- {}
- if (!bcmp((uchar*) p->cur, (uchar*) "-->", 3))
- p->cur+=3;
+ for (; p->cur < p->end; p->cur++)
+ {
+ if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("-->")))
+ {
+ p->cur+= 3;
+ break;
+ }
+ }
a->end=p->cur;
lex=MY_XML_COMMENT;
}
- else if (!bcmp((uchar*) p->cur, (uchar*) "<![CDATA[",9))
+ else if (!my_xml_parser_prefix_cmp(p, C_STRING_WITH_LEN("<![CDATA[")))
{
p->cur+= 9;
for (; p->cur < p->end - 2 ; p->cur++)
@@ -153,11 +165,16 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
}
else if ( (p->cur[0] == '"') || (p->cur[0] == '\'') )
{
+ /*
+ "string" or 'string' found.
+ Scan until the closing quote/doublequote, or until the END-OF-INPUT.
+ */
p->cur++;
for (; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++)
{}
a->end=p->cur;
- if (a->beg[0] == p->cur[0])p->cur++;
+ if (p->cur < p->end) /* Closing quote or doublequote has been found */
+ p->cur++;
a->beg++;
if (!(p->flags & MY_XML_FLAG_SKIP_TEXT_NORMALIZATION))
my_xml_norm_text(a);
diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp
index 3025fdf5f5d..e4c39b0c548 100644
--- a/support-files/compiler_warnings.supp
+++ b/support-files/compiler_warnings.supp
@@ -67,7 +67,6 @@ vi\.c : unused parameter
common\.c : unused parameter
term\.c : .*
-
#
# Ignore some warnings in libevent, which is not maintained by us.
#
@@ -146,6 +145,7 @@ table_xt\.cc : variable.*might be clobbered by.*longjmp
#
# Yassl
+#
include/runtime.hpp: .*pure_error.*
.*/extra/yassl/.*taocrypt/.*: comparison with string literal
.*/extra/yassl/taocrypt/src/blowfish\.cpp: array subscript is above array bounds
@@ -159,6 +159,12 @@ mySTL/algorithm\.hpp: is used uninitialized in this function
.*/dbug/.*(groff|<standard input>) : .*
#
+# Warnings on OpenSolaris
+#
+.*/my_config\.h : _FILE_OFFSET_BITS
+/usr/include/sys/feature_tests.h : this is the location of the previous definition
+
+#
# Unexplanable (?) stuff
#
listener.cc : .*conversion from 'SOCKET' to 'int'.*
@@ -183,3 +189,10 @@ ctype-simple\.c : .*unary minus operator applied to unsigned type, result still
regexec\.c : passing argument 3 of.*matcher.* discards qualifiers from pointer target type
libmysql\.c: passing argument 2 of .*memcpy.* discards qualifiers from pointer target type : 3000-4000
storage/xtradb/dict/dict0dict\.c : passing argument 1 of .*strcpy.* discards qualifiers from pointer target type : 2500-3500
+
+#
+# Strange things from autoconf that is probably safe to ignore
+#
+
+configure.in : warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
+configure.in : config/ac-macros/character_sets.m4.*prefer named diversions
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 0b826fe66a2..e98c11f258a 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -1,4 +1,4 @@
-# Copyright (c) 2000, 2010, Oracle and/or its affiliates.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates.
# Copyright (c) 2010 Monty Program Ab
#
# This program is free software; you can redistribute it and/or modify
@@ -644,7 +644,25 @@ touch $RBR%{_sysconfdir}/mysqlmanager.passwd
##############################################################################
%pre server
-mysql_datadir=%{mysqldatadir}
+# This is the code running at the beginning of a RPM upgrade action,
+# before replacing the old files with the new ones.
+
+# There are users who deviate from the default file system layout.
+# Check local settings to support them.
+if [ -x %{_bindir}/my_print_defaults ]
+then
+ mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+ PID_FILE_PATT=`%{_bindir}/my_print_defaults server mysqld | grep '^--pid-file=' | sed -n 's/--pid-file=//p'`
+fi
+if [ -z "$mysql_datadir" ]
+then
+ mysql_datadir=%{mysqldatadir}
+fi
+if [ -z "$PID_FILE_PATT" ]
+then
+ PID_FILE_PATT="$mysql_datadir/*.pid"
+fi
+
# Check if we can safely upgrade. An upgrade is only safe if it's from one
# of our RPMs in the same version family.
@@ -716,7 +734,7 @@ fi
# We assume that if there is exactly one ".pid" file,
# it contains the valid PID of a running MySQL server.
-NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l`
+NR_PID_FILES=`ls $PID_FILE_PATT 2>/dev/null | wc -l`
case $NR_PID_FILES in
0 ) SERVER_TO_START='' ;; # No "*.pid" file == no running server
1 ) SERVER_TO_START='true' ;;
@@ -738,8 +756,8 @@ if [ -f $STATUS_FILE ]; then
echo "before repeating the MySQL upgrade."
exit 1
elif [ -n "$SEVERAL_PID_FILES" ] ; then
- echo "Your MySQL directory '$mysql_datadir' has more than one PID file:"
- ls -ld $mysql_datadir/*.pid
+ echo "You have more than one PID file:"
+ ls -ld $PID_FILE_PATT
echo "Please check which one (if any) corresponds to a running server"
echo "and delete all others before repeating the MySQL upgrade."
exit 1
@@ -764,17 +782,17 @@ if [ -d $mysql_datadir ] ; then
if [ -n "$SERVER_TO_START" ] ; then
# There is only one PID file, race possibility ignored
echo "PID file:" >> $STATUS_FILE
- ls -l $mysql_datadir/*.pid >> $STATUS_FILE
- cat $mysql_datadir/*.pid >> $STATUS_FILE
+ ls -l $PID_FILE_PATT >> $STATUS_FILE
+ cat $PID_FILE_PATT >> $STATUS_FILE
echo >> $STATUS_FILE
echo "Server process:" >> $STATUS_FILE
- ps -fp `cat $mysql_datadir/*.pid` >> $STATUS_FILE
+ ps -fp `cat $PID_FILE_PATT` >> $STATUS_FILE
echo >> $STATUS_FILE
echo "SERVER_TO_START=$SERVER_TO_START" >> $STATUS_FILE
else
# Take a note we checked it ...
echo "PID file:" >> $STATUS_FILE
- ls -l $mysql_datadir/*.pid >> $STATUS_FILE 2>&1
+ ls -l $PID_FILE_PATT >> $STATUS_FILE 2>&1
fi
fi
@@ -789,7 +807,20 @@ if [ -x %{_sysconfdir}/init.d/mysql ] ; then
fi
%post server
-mysql_datadir=%{mysqldatadir}
+# This is the code running at the end of a RPM install or upgrade action,
+# after the (new) files have been written.
+
+# There are users who deviate from the default file system layout.
+# Check local settings to support them.
+if [ -x %{_bindir}/my_print_defaults ]
+then
+ mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+fi
+if [ -z "$mysql_datadir" ]
+then
+ mysql_datadir=%{mysqldatadir}
+fi
+
NEW_VERSION=%{mysql_version}-%{release}
STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER
@@ -1168,6 +1199,18 @@ fi
* Sun Feb 20 2011 Monty
Updated texts to include information about MariaDB
+ Added back EXCEPTIONS-CLIENT
+
+* Thu Feb 03 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
+
+- Fix bug#56581: If an installation deviates from the default file locations
+ ("datadir" and "pid-file"), the mechanism to detect a running server (on upgrade)
+ should still work, and use these locations.
+ The problem was that the fix for bug#27072 did not check for local settings.
+
+* Wed Nov 24 2010 Alexander Nozdrin <alexander.nozdrin@oracle.com>
+
+- EXCEPTIONS-CLIENT has been deleted, remove it from here too.
* Tue Jun 15 2010 Joerg Bruehe <joerg.bruehe@sun.com>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4095f2ec342..967ebae2e22 100755
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -20,9 +20,9 @@ ADD_DEFINITIONS("-DMYSQL_CLIENT")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_EXECUTABLE(mysql_client_test mysql_client_test.c ../mysys/my_memmem.c)
-TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient wsock32)
ADD_EXECUTABLE(bug25714 bug25714.c)
-TARGET_LINK_LIBRARIES(bug25714 mysqlclient_notls wsock32)
+TARGET_LINK_LIBRARIES(bug25714 mysqlclient wsock32)
INSTALL(TARGETS mysql_client_test DESTINATION bin COMPONENT Test)
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 759eac04fa3..2500911bd23 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1538,7 +1538,7 @@ static void test_prepare_field_result()
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prepare_field_result(int_c int, "
- "var_c varchar(50), ts_c timestamp(14), "
+ "var_c varchar(50), ts_c timestamp, "
"char_c char(4), date_c date, extra tinyint)");
myquery(rc);
@@ -4333,11 +4333,11 @@ static void test_fetch_date()
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 date, c2 time, \
- c3 timestamp(14), \
+ c3 timestamp, \
c4 year, \
c5 datetime, \
- c6 timestamp(4), \
- c7 timestamp(6))");
+ c6 timestamp, \
+ c7 timestamp)");
myquery(rc);
rc= mysql_query(mysql, "SET SQL_MODE=''");
@@ -4651,7 +4651,7 @@ static void test_prepare_ext()
" c12 numeric(8, 4),"
" c13 date,"
" c14 datetime,"
- " c15 timestamp(14),"
+ " c15 timestamp,"
" c16 time,"
" c17 year,"
" c18 bit,"
@@ -5685,7 +5685,7 @@ static void test_manual_sample()
}
if (mysql_query(mysql, "CREATE TABLE test_table(col1 int, col2 varchar(50), \
col3 smallint, \
- col4 timestamp(14))"))
+ col4 timestamp)"))
{
fprintf(stderr, "\n create table failed");
fprintf(stderr, "\n %s", mysql_error(mysql));
@@ -6595,7 +6595,7 @@ static void test_date()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date");
myquery(rc);
- rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(14), \
+ rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP, \
c2 TIME, \
c3 DATETIME, \
c4 DATE)");
@@ -6661,10 +6661,10 @@ static void test_date_ts()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date");
myquery(rc);
- rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(10), \
- c2 TIMESTAMP(14), \
+ rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP, \
+ c2 TIMESTAMP, \
c3 TIMESTAMP, \
- c4 TIMESTAMP(6))");
+ c4 TIMESTAMP)");
myquery(rc);
@@ -8353,7 +8353,7 @@ static void test_fetch_seek()
myquery(rc);
- rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))");
+ rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp)");
myquery(rc);
rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql'), ('open'), ('source')");
@@ -9123,7 +9123,7 @@ static void test_ts()
char name;
char query[MAX_TEST_QUERY_LENGTH];
const char *queries [3]= {"SELECT a, b, c FROM test_ts WHERE %c=?",
- "SELECT a, b, c FROM test_ts WHERE %c=?",
+ "SELECT a, b, c FROM test_ts WHERE %c=CAST(? AS TIME)",
"SELECT a, b, c FROM test_ts WHERE %c=CAST(? AS DATE)"};
myheader("test_ts");
@@ -12542,7 +12542,7 @@ static void test_datetime_ranges()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- DIE_UNLESS(mysql_warning_count(mysql) != 6);
+ DIE_UNLESS(mysql_warning_count(mysql) == 6);
verify_col_data("t1", "year", "0000-00-00 00:00:00");
verify_col_data("t1", "month", "0000-00-00 00:00:00");
@@ -12573,7 +12573,7 @@ static void test_datetime_ranges()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- DIE_UNLESS(mysql_warning_count(mysql) != 3);
+ DIE_UNLESS(mysql_warning_count(mysql) == 3);
verify_col_data("t1", "year", "0000-00-00 00:00:00");
verify_col_data("t1", "month", "0000-00-00 00:00:00");
@@ -18443,6 +18443,123 @@ static void test_bug47485()
/*
+ Bug#58036 client utf32, utf16, ucs2 should be disallowed, they crash server
+*/
+static void test_bug58036()
+{
+ MYSQL *conn;
+ DBUG_ENTER("test_bug47485");
+ myheader("test_bug58036");
+
+ /* Part1: try to connect with ucs2 client character set */
+ conn= mysql_client_init(NULL);
+ mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2");
+ if (mysql_real_connect(conn, opt_host, opt_user,
+ opt_password, opt_db ? opt_db : "test",
+ opt_port, opt_unix_socket, 0))
+ {
+ if (!opt_silent)
+ printf("mysql_real_connect() succeeded (failure expected)\n");
+ mysql_close(conn);
+ DIE("");
+ }
+
+ if (!opt_silent)
+ printf("Got mysql_real_connect() error (expected): %s (%d)\n",
+ mysql_error(conn), mysql_errno(conn));
+ DIE_UNLESS(mysql_errno(conn) == ER_WRONG_VALUE_FOR_VAR ||
+ mysql_errno(conn)== CR_CANT_READ_CHARSET);
+ mysql_close(conn);
+
+
+ /*
+ Part2:
+ - connect with latin1
+ - then change client character set to ucs2
+ - then try mysql_change_user()
+ */
+ conn= mysql_client_init(NULL);
+ mysql_options(conn, MYSQL_SET_CHARSET_NAME, "latin1");
+ if (!mysql_real_connect(conn, opt_host, opt_user,
+ opt_password, opt_db ? opt_db : "test",
+ opt_port, opt_unix_socket, 0))
+ {
+ if (!opt_silent)
+ printf("mysql_real_connect() failed: %s (%d)\n",
+ mysql_error(conn), mysql_errno(conn));
+ mysql_close(conn);
+ DIE("");
+ }
+
+ mysql_options(conn, MYSQL_SET_CHARSET_NAME, "ucs2");
+ if (!mysql_change_user(conn, opt_user, opt_password, NULL))
+ {
+ if (!opt_silent)
+ printf("mysql_change_user() succedded, error expected!");
+ mysql_close(conn);
+ DIE("");
+ }
+
+ if (!opt_silent)
+ printf("Got mysql_change_user() error (expected): %s (%d)\n",
+ mysql_error(conn), mysql_errno(conn));
+ mysql_close(conn);
+
+ DBUG_VOID_RETURN;
+}
+
+
+/*
+ Bug #56976: Severe Denial Of Service in prepared statements
+*/
+static void test_bug56976()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_BIND bind[1];
+ int rc;
+ const char* query = "SELECT LENGTH(?)";
+ char *long_buffer;
+ unsigned long i, packet_len = 256 * 1024L;
+ unsigned long dos_len = 2 * 1024 * 1024L;
+
+ DBUG_ENTER("test_bug56976");
+ myheader("test_bug56976");
+
+ stmt= mysql_stmt_init(mysql);
+ check_stmt(stmt);
+
+ rc= mysql_stmt_prepare(stmt, query, strlen(query));
+ check_execute(stmt, rc);
+
+ memset(bind, 0, sizeof(bind));
+ bind[0].buffer_type = MYSQL_TYPE_TINY_BLOB;
+
+ rc= mysql_stmt_bind_param(stmt, bind);
+ check_execute(stmt, rc);
+
+ long_buffer= (char*) my_malloc(packet_len, MYF(0));
+ DIE_UNLESS(long_buffer);
+
+ memset(long_buffer, 'a', packet_len);
+
+ for (i= 0; i < dos_len / packet_len; i++)
+ {
+ rc= mysql_stmt_send_long_data(stmt, 0, long_buffer, packet_len);
+ check_execute(stmt, rc);
+ }
+
+ my_free(long_buffer, MYF(0));
+ rc= mysql_stmt_execute(stmt);
+
+ DIE_UNLESS(rc && mysql_stmt_errno(stmt) == ER_UNKNOWN_ERROR);
+
+ mysql_stmt_close(stmt);
+
+ DBUG_VOID_RETURN;
+}
+
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -18767,6 +18884,8 @@ static struct my_tests_st my_tests[]= {
{ "test_bug42373", test_bug42373 },
{ "test_bug54041", test_bug54041 },
{ "test_bug47485", test_bug47485 },
+ { "test_bug58036", test_bug58036 },
+ { "test_bug56976", test_bug56976 },
{ 0, 0 }
};
diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am
index 07b9b94ab01..3a93f41afd1 100644
--- a/unittest/mysys/Makefile.am
+++ b/unittest/mysys/Makefile.am
@@ -25,4 +25,4 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
EXTRA_DIST = CMakeLists.txt
noinst_PROGRAMS = bitmap-t base64-t my_atomic-t lf-t waiting_threads-t \
- my_vsnprintf-t
+ my_vsnprintf-t ma_dyncol-t
diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c
index 0bd21b63430..2065e10b53f 100644
--- a/unittest/mysys/bitmap-t.c
+++ b/unittest/mysys/bitmap-t.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@
#include <tap.h>
#include <m_string.h>
+#define MAX_TESTED_BITMAP_SIZE 1024
+
uint get_rand_bit(uint bitsize)
{
return (rand() % bitsize);
@@ -75,11 +77,6 @@ error2:
return TRUE;
}
-my_bool test_operators(MY_BITMAP *map __attribute__((unused)),
- uint bitsize __attribute__((unused)))
-{
- return FALSE;
-}
my_bool test_get_all_bits(MY_BITMAP *map, uint bitsize)
{
@@ -129,8 +126,8 @@ my_bool test_compare_operators(MY_BITMAP *map, uint bitsize)
uint no_loops= bitsize > 128 ? 128 : bitsize;
MY_BITMAP map2_obj, map3_obj;
MY_BITMAP *map2= &map2_obj, *map3= &map3_obj;
- uint32 map2buf[1024];
- uint32 map3buf[1024];
+ my_bitmap_map map2buf[MAX_TESTED_BITMAP_SIZE];
+ my_bitmap_map map3buf[MAX_TESTED_BITMAP_SIZE];
bitmap_init(&map2_obj, map2buf, bitsize, FALSE);
bitmap_init(&map3_obj, map3buf, bitsize, FALSE);
bitmap_clear_all(map2);
@@ -257,8 +254,21 @@ error2:
my_bool test_get_first_bit(MY_BITMAP *map, uint bitsize)
{
- uint i, test_bit;
+ uint i, test_bit= 0;
uint no_loops= bitsize > 128 ? 128 : bitsize;
+
+ bitmap_set_all(map);
+ for (i=0; i < bitsize; i++)
+ bitmap_clear_bit(map, i);
+ if (bitmap_get_first_set(map) != MY_BIT_NONE)
+ goto error1;
+ bitmap_clear_all(map);
+ for (i=0; i < bitsize; i++)
+ bitmap_set_bit(map, i);
+ if (bitmap_get_first(map) != MY_BIT_NONE)
+ goto error2;
+ bitmap_clear_all(map);
+
for (i=0; i < no_loops; i++)
{
test_bit=get_rand_bit(bitsize);
@@ -321,6 +331,24 @@ my_bool test_prefix(MY_BITMAP *map, uint bitsize)
goto error3;
bitmap_clear_all(map);
}
+ for (i=0; i < bitsize; i++)
+ {
+ if (bitmap_is_prefix(map, i + 1))
+ goto error4;
+ bitmap_set_bit(map, i);
+ if (!bitmap_is_prefix(map, i + 1))
+ goto error5;
+ test_bit=get_rand_bit(bitsize);
+ bitmap_set_bit(map, test_bit);
+ if (test_bit <= i && !bitmap_is_prefix(map, i + 1))
+ goto error5;
+ else if (test_bit > i)
+ {
+ if (bitmap_is_prefix(map, i + 1))
+ goto error4;
+ bitmap_clear_bit(map, test_bit);
+ }
+ }
return FALSE;
error1:
diag("prefix1 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
@@ -331,13 +359,127 @@ error2:
error3:
diag("prefix3 error bitsize = %u, prefix_size = %u", bitsize,test_bit);
return TRUE;
+error4:
+ diag("prefix4 error bitsize = %u, i = %u", bitsize,i);
+ return TRUE;
+error5:
+ diag("prefix5 error bitsize = %u, i = %u", bitsize,i);
+ return TRUE;
}
+my_bool test_compare(MY_BITMAP *map, uint bitsize)
+{
+ MY_BITMAP map2;
+ uint32 map2buf[MAX_TESTED_BITMAP_SIZE];
+ uint i, test_bit;
+ uint no_loops= bitsize > 128 ? 128 : bitsize;
+ if (bitmap_init(&map2, map2buf, bitsize, FALSE))
+ {
+ diag("init error for bitsize %d", bitsize);
+ return TRUE;
+ }
+ /* Test all 4 possible combinations of set/unset bits. */
+ for (i=0; i < no_loops; i++)
+ {
+ test_bit=get_rand_bit(bitsize);
+ bitmap_clear_bit(map, test_bit);
+ bitmap_clear_bit(&map2, test_bit);
+ if (!bitmap_is_subset(map, &map2))
+ goto error_is_subset;
+ bitmap_set_bit(map, test_bit);
+ if (bitmap_is_subset(map, &map2))
+ goto error_is_subset;
+ bitmap_set_bit(&map2, test_bit);
+ if (!bitmap_is_subset(map, &map2))
+ goto error_is_subset;
+ bitmap_clear_bit(map, test_bit);
+ if (!bitmap_is_subset(map, &map2))
+ goto error_is_subset;
+ /* Note that test_bit is not cleared i map2. */
+ }
+ bitmap_clear_all(map);
+ bitmap_clear_all(&map2);
+ /* Test all 4 possible combinations of set/unset bits. */
+ for (i=0; i < no_loops; i++)
+ {
+ test_bit=get_rand_bit(bitsize);
+ if (bitmap_is_overlapping(map, &map2))
+ goto error_is_overlapping;
+ bitmap_set_bit(map, test_bit);
+ if (bitmap_is_overlapping(map, &map2))
+ goto error_is_overlapping;
+ bitmap_set_bit(&map2, test_bit);
+ if (!bitmap_is_overlapping(map, &map2))
+ goto error_is_overlapping;
+ bitmap_clear_bit(map, test_bit);
+ if (bitmap_is_overlapping(map, &map2))
+ goto error_is_overlapping;
+ bitmap_clear_bit(&map2, test_bit);
+ /* Note that test_bit is not cleared i map2. */
+ }
+ return FALSE;
+error_is_subset:
+ diag("is_subset error bitsize = %u", bitsize);
+ return TRUE;
+error_is_overlapping:
+ diag("is_overlapping error bitsize = %u", bitsize);
+ return TRUE;
+}
+
+my_bool test_intersect(MY_BITMAP *map, uint bitsize)
+{
+ uint bitsize2 = 1 + get_rand_bit(MAX_TESTED_BITMAP_SIZE - 1);
+ MY_BITMAP map2;
+ uint32 map2buf[MAX_TESTED_BITMAP_SIZE];
+ uint i, test_bit1, test_bit2, test_bit3;
+ if (bitmap_init(&map2, map2buf, bitsize2, FALSE))
+ {
+ diag("init error for bitsize %d", bitsize2);
+ return TRUE;
+ }
+ test_bit1= get_rand_bit(bitsize);
+ test_bit2= get_rand_bit(bitsize);
+ bitmap_set_bit(map, test_bit1);
+ bitmap_set_bit(map, test_bit2);
+ test_bit3= get_rand_bit(bitsize2);
+ bitmap_set_bit(&map2, test_bit3);
+ if (test_bit2 < bitsize2)
+ bitmap_set_bit(&map2, test_bit2);
+
+ bitmap_intersect(map, &map2);
+ if (test_bit2 < bitsize2)
+ {
+ if (!bitmap_is_set(map, test_bit2))
+ goto error;
+ bitmap_clear_bit(map, test_bit2);
+ }
+ if (test_bit1 == test_bit3)
+ {
+ if (!bitmap_is_set(map, test_bit1))
+ goto error;
+ bitmap_clear_bit(map, test_bit1);
+ }
+ if (!bitmap_is_clear_all(map))
+ goto error;
+
+ bitmap_set_all(map);
+ bitmap_set_all(&map2);
+ for (i=0; i < bitsize2; i++)
+ bitmap_clear_bit(&map2, i);
+ bitmap_intersect(map, &map2);
+ if (!bitmap_is_clear_all(map))
+ goto error;
+ return FALSE;
+error:
+ diag("intersect error bitsize = %u, bit1 = %u, bit2 = %u, bit3 = %u",
+ bitsize, test_bit1, test_bit2, test_bit3);
+ return TRUE;
+}
my_bool do_test(uint bitsize)
{
MY_BITMAP map;
- uint32 buf[1024];
+ my_bitmap_map buf[MAX_TESTED_BITMAP_SIZE];
if (bitmap_init(&map, buf, bitsize, FALSE))
{
diag("init error for bitsize %d", bitsize);
@@ -349,9 +491,6 @@ my_bool do_test(uint bitsize)
if (test_flip_bit(&map,bitsize))
goto error;
bitmap_clear_all(&map);
- if (test_operators(&map,bitsize))
- goto error;
- bitmap_clear_all(&map);
if (test_get_all_bits(&map, bitsize))
goto error;
bitmap_clear_all(&map);
@@ -366,8 +505,15 @@ my_bool do_test(uint bitsize)
bitmap_clear_all(&map);
if (test_get_next_bit(&map,bitsize))
goto error;
+ bitmap_clear_all(&map);
if (test_prefix(&map,bitsize))
goto error;
+ bitmap_clear_all(&map);
+ if (test_compare(&map,bitsize))
+ goto error;
+ bitmap_clear_all(&map);
+ if (test_intersect(&map,bitsize))
+ goto error;
return FALSE;
error:
return TRUE;
@@ -377,11 +523,17 @@ int main()
{
int i;
int const min_size = 1;
- int const max_size = 1024;
+ int const max_size = MAX_TESTED_BITMAP_SIZE;
MY_INIT("bitmap-t");
- plan(max_size - min_size);
- for (i= min_size; i < max_size; i++)
+ plan((max_size - min_size)/7+1);
+
+ /*
+ It's ok to do steps in 7, as i module 64 will go trough all values 1..63.
+ Any errors in the code should manifest as we are working with integers
+ of size 16, 32, or 64 bits...
+ */
+ for (i= min_size; i < max_size; i+=7)
ok(do_test(i) == 0, "bitmap size %d", i);
return exit_status();
}
diff --git a/unittest/mysys/ma_dyncol-t.c b/unittest/mysys/ma_dyncol-t.c
new file mode 100644
index 00000000000..0e973b20747
--- /dev/null
+++ b/unittest/mysys/ma_dyncol-t.c
@@ -0,0 +1,795 @@
+/* Copyright (c) 2011, Monty Program Ab
+ Copyright (c) 2011, Oleksandr Byelkin
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+*/
+
+#include <my_global.h>
+#include <my_sys.h>
+#include <m_string.h>
+#include <ma_dyncol.h>
+#include <tap.h>
+
+void test_value_single_null()
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_NULL;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= (res.type == DYN_COL_NULL);
+err:
+ ok(rc, "%s", "NULL");
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+void test_value_single_uint(ulonglong num, const char *name)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_UINT;
+ val.ulong_value= num;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= (res.type == DYN_COL_UINT) && (res.ulong_value == num);
+ num= res.ulong_value;
+err:
+ ok(rc, "%s - %llu", name, num);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+void test_value_single_sint(longlong num, const char *name)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_INT;
+ val.long_value= num;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= (res.type == DYN_COL_INT) && (res.long_value == num);
+ num= res.ulong_value;
+err:
+ ok(rc, "%s - %lld", name, num);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+
+void test_value_single_double(double num, const char *name)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_DOUBLE;
+ val.double_value= num;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= (res.type == DYN_COL_DOUBLE) && (res.double_value == num);
+ num= res.ulong_value;
+err:
+ ok(rc, "%s - %lf", name, num);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+void test_value_single_decimal(const char *num)
+{
+ char *end= (((char*)num) + strlen(num));
+ char buff[80];
+ int rc= FALSE;
+ int length= 80;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+
+ /* init values */
+ dynamic_column_prepare_decimal(&val); // special procedure for decimal!!!
+ if (string2decimal(num, &val.decimal_value, &end) != E_DEC_OK)
+ goto err;
+ dynamic_column_value_init(&res);
+
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= ((res.type == DYN_COL_DECIMAL) &&
+ (decimal_cmp(&res.decimal_value, &val.decimal_value) == 0));
+ decimal2string(&res.decimal_value, buff, &length, 0, 0, ' ');
+err:
+ ok(rc, "%s - %s", num, buff);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+static CHARSET_INFO *charset_list[]=
+{
+#ifdef HAVE_CHARSET_big5
+ &my_charset_big5_chinese_ci,
+ &my_charset_big5_bin,
+#endif
+#ifdef HAVE_CHARSET_euckr
+ &my_charset_euckr_korean_ci,
+ &my_charset_euckr_bin,
+#endif
+#ifdef HAVE_CHARSET_gb2312
+ &my_charset_gb2312_chinese_ci,
+ &my_charset_gb2312_bin,
+#endif
+#ifdef HAVE_CHARSET_gbk
+ &my_charset_gbk_chinese_ci,
+ &my_charset_gbk_bin,
+#endif
+#ifdef HAVE_CHARSET_latin1
+ &my_charset_latin1,
+ &my_charset_latin1_bin,
+#endif
+#ifdef HAVE_CHARSET_sjis
+ &my_charset_sjis_japanese_ci,
+ &my_charset_sjis_bin,
+#endif
+#ifdef HAVE_CHARSET_tis620
+ &my_charset_tis620_thai_ci,
+ &my_charset_tis620_bin,
+#endif
+#ifdef HAVE_CHARSET_ujis
+ &my_charset_ujis_japanese_ci,
+ &my_charset_ujis_bin,
+#endif
+#ifdef HAVE_CHARSET_utf8
+ &my_charset_utf8_general_ci,
+#ifdef HAVE_HAVE_UCA_COLLATIONS
+ &my_charset_utf8_unicode_ci,
+#endif
+ &my_charset_utf8_bin,
+#endif
+};
+
+
+void test_value_single_string(const char *string, size_t len,
+ CHARSET_INFO *cs)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+
+ /* init values */
+ val.type= DYN_COL_STRING;
+ val.string_value.str= (char*)string;
+ val.string_value.length= len;
+ val.charset= cs;
+ dynamic_column_value_init(&res);
+
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= ((res.type == DYN_COL_STRING) &&
+ (res.string_value.length == len) &&
+ (memcmp(res.string_value.str, string, len) == 0) &&
+ (res.charset->number == cs->number));
+err:
+ ok(rc, "'%s' - '%s' %u %u-%s", string,
+ res.string_value.str, (uint)res.string_value.length,
+ (uint)res.charset->number, res.charset->name);
+ /* cleanup */
+ val.string_value.str= NULL; // we did not allocated it
+ dynamic_column_column_free(&str);
+}
+
+void test_value_single_date(uint year, uint month, uint day, const char *name)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_DATE;
+ val.time_value.time_type= MYSQL_TIMESTAMP_DATE;
+ val.time_value.year= year;
+ val.time_value.month= month;
+ val.time_value.day= day;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= ((res.type == DYN_COL_DATE) &&
+ (res.time_value.time_type == MYSQL_TIMESTAMP_DATE) &&
+ (res.time_value.year == year) &&
+ (res.time_value.month == month) &&
+ (res.time_value.day == day));
+err:
+ ok(rc, "%s - %04u-%02u-%02u", name, year, month, day);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+void test_value_single_time(uint neg, uint hour, uint minute, uint second,
+ uint mic, const char *name)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_TIME;
+ val.time_value.time_type= MYSQL_TIMESTAMP_TIME;
+ val.time_value.neg= neg;
+ val.time_value.hour= hour;
+ val.time_value.minute= minute;
+ val.time_value.second= second;
+ val.time_value.second_part= mic;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= ((res.type == DYN_COL_TIME) &&
+ (res.time_value.time_type == MYSQL_TIMESTAMP_TIME) &&
+ (res.time_value.neg == (int)neg) &&
+ (res.time_value.hour == hour) &&
+ (res.time_value.minute == minute) &&
+ (res.time_value.second == second) &&
+ (res.time_value.second_part == mic));
+err:
+ ok(rc, "%s - %c%02u:%02u:%02u.%06u", name, (neg ? '-' : '+'),
+ hour, minute, second, mic);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+
+void test_value_single_datetime(uint neg, uint year, uint month, uint day,
+ uint hour, uint minute, uint second,
+ uint mic, const char *name)
+{
+ int rc= FALSE;
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val.type= DYN_COL_DATETIME;
+ val.time_value.time_type= MYSQL_TIMESTAMP_DATETIME;
+ val.time_value.neg= neg;
+ val.time_value.year= year;
+ val.time_value.month= month;
+ val.time_value.day= day;
+ val.time_value.hour= hour;
+ val.time_value.minute= minute;
+ val.time_value.second= second;
+ val.time_value.second_part= mic;
+ dynamic_column_value_init(&res);
+ /* create column */
+ if (dynamic_column_create(&str, 1, &val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ if (dynamic_column_get(&str, 1, &res))
+ goto err;
+ rc= ((res.type == DYN_COL_DATETIME) &&
+ (res.time_value.time_type == MYSQL_TIMESTAMP_DATETIME) &&
+ (res.time_value.neg == (int)neg) &&
+ (res.time_value.year == year) &&
+ (res.time_value.month == month) &&
+ (res.time_value.day == day) &&
+ (res.time_value.hour == hour) &&
+ (res.time_value.minute == minute) &&
+ (res.time_value.second == second) &&
+ (res.time_value.second_part == mic));
+err:
+ ok(rc, "%s - %c %04u-%02u-%02u %02u:%02u:%02u.%06u", name, (neg ? '-' : '+'),
+ year, month, day, hour, minute, second, mic);
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+
+void test_value_multi(ulonglong num0,
+ longlong num1,
+ double num2,
+ const char *num3,
+ const char *string4, size_t len4, CHARSET_INFO *cs4,
+ uint year5, uint month5, uint day5,
+ uint neg6, uint hour6, uint minute6,
+ uint second6, uint mic6,
+ uint neg7, uint year7, uint month7, uint day7,
+ uint hour7, uint minute7, uint second7,
+ uint mic7,
+ uint *column_numbers,
+ const char *name)
+{
+ char *end3= (((char*)num3) + strlen(num3));
+ int rc= FALSE;
+ uint i;
+ DYNAMIC_COLUMN_VALUE val[9], res[9];
+ DYNAMIC_COLUMN str;
+ /* init values */
+ val[0].type= DYN_COL_UINT;
+ val[0].ulong_value= num0;
+ val[1].type= DYN_COL_INT;
+ val[1].long_value= num1;
+ val[2].type= DYN_COL_DOUBLE;
+ val[2].double_value= num2;
+ dynamic_column_prepare_decimal(val + 3); // special procedure for decimal!!!
+ if (string2decimal(num3, &val[3].decimal_value, &end3) != E_DEC_OK)
+ goto err;
+ val[4].type= DYN_COL_STRING;
+ val[4].string_value.str= (char*)string4;
+ val[4].string_value.length= len4;
+ val[4].charset= cs4;
+ val[5].type= DYN_COL_DATE;
+ val[5].time_value.time_type= MYSQL_TIMESTAMP_DATE;
+ val[5].time_value.year= year5;
+ val[5].time_value.month= month5;
+ val[5].time_value.day= day5;
+ val[6].type= DYN_COL_TIME;
+ val[6].time_value.time_type= MYSQL_TIMESTAMP_TIME;
+ val[6].time_value.neg= neg6;
+ val[6].time_value.hour= hour6;
+ val[6].time_value.minute= minute6;
+ val[6].time_value.second= second6;
+ val[6].time_value.second_part= mic6;
+ val[7].type= DYN_COL_DATETIME;
+ val[7].time_value.time_type= MYSQL_TIMESTAMP_DATETIME;
+ val[7].time_value.neg= neg7;
+ val[7].time_value.year= year7;
+ val[7].time_value.month= month7;
+ val[7].time_value.day= day7;
+ val[7].time_value.hour= hour7;
+ val[7].time_value.minute= minute7;
+ val[7].time_value.second= second7;
+ val[7].time_value.second_part= mic7;
+ val[8].type= DYN_COL_NULL;
+ for (i= 0; i < 9; i++)
+ dynamic_column_value_init(res + i);
+ /* create column */
+ if (dynamic_column_create_many(&str, 9, column_numbers, val))
+ goto err;
+ dynstr_append(&str, "\1"); str.length--; //check for overflow
+ /* read column */
+ for (i= 0; i < 9; i++)
+ if (dynamic_column_get(&str, column_numbers[i], res + i))
+ goto err;
+ rc= ((res[0].type == DYN_COL_UINT) &&
+ (res[0].ulong_value == num0) &&
+ (res[1].type == DYN_COL_INT) &&
+ (res[1].long_value == num1) &&
+ (res[2].type == DYN_COL_DOUBLE) &&
+ (res[2].double_value == num2) &&
+ (res[3].type == DYN_COL_DECIMAL) &&
+ (decimal_cmp(&res[3].decimal_value, &val[3].decimal_value) == 0) &&
+ (res[4].type == DYN_COL_STRING) &&
+ (res[4].string_value.length == len4) &&
+ (memcmp(res[4].string_value.str, string4, len4) == 0) &&
+ (res[4].charset->number == cs4->number) &&
+ (res[5].type == DYN_COL_DATE) &&
+ (res[5].time_value.time_type == MYSQL_TIMESTAMP_DATE) &&
+ (res[5].time_value.year == year5) &&
+ (res[5].time_value.month == month5) &&
+ (res[5].time_value.day == day5) &&
+ (res[6].type == DYN_COL_TIME) &&
+ (res[6].time_value.time_type == MYSQL_TIMESTAMP_TIME) &&
+ (res[6].time_value.neg == (int)neg6) &&
+ (res[6].time_value.hour == hour6) &&
+ (res[6].time_value.minute == minute6) &&
+ (res[6].time_value.second == second6) &&
+ (res[6].time_value.second_part == mic6) &&
+ (res[7].type == DYN_COL_DATETIME) &&
+ (res[7].time_value.time_type == MYSQL_TIMESTAMP_DATETIME) &&
+ (res[7].time_value.neg == (int)neg7) &&
+ (res[7].time_value.year == year7) &&
+ (res[7].time_value.month == month7) &&
+ (res[7].time_value.day == day7) &&
+ (res[7].time_value.hour == hour7) &&
+ (res[7].time_value.minute == minute7) &&
+ (res[7].time_value.second == second7) &&
+ (res[7].time_value.second_part == mic7) &&
+ (res[8].type == DYN_COL_NULL));
+err:
+ ok(rc, "%s", name);
+ /* cleanup */
+ val[4].string_value.str= NULL; // we did not allocated it
+ dynamic_column_column_free(&str);
+}
+
+
+void test_value_multi_same_num()
+{
+ int rc= FALSE;
+ uint i;
+ DYNAMIC_COLUMN_VALUE val[5];
+ uint column_numbers[]= {3,4,5,3,6}; // same column numbers
+ DYNAMIC_COLUMN str;
+ /* init values */
+ for (i= 0; i < 5; i++)
+ val[i].type= DYN_COL_NULL;
+ /* create column */
+ if (!dynamic_column_create_many(&str, 5, column_numbers, val))
+ goto err;
+ rc= TRUE;
+err:
+ ok(rc, "%s", "same column numbers check");
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+
+void test_update_multi(uint *column_numbers, uint *column_values,
+ my_bool *null_values, int only_add, int all)
+{
+ int rc= FALSE;
+ int i, j;
+ DYNAMIC_COLUMN str;
+ DYNAMIC_COLUMN_VALUE val;
+
+ val.type= DYN_COL_UINT;
+ val.ulong_value= column_values[0];
+ if (dynamic_column_create(&str, column_numbers[0], &val))
+ goto err;
+ for (i= 1; i < all; i++)
+ {
+ val.type= (null_values[i] ? DYN_COL_NULL : DYN_COL_UINT);
+ val.ulong_value= column_values[i];
+ if (dynamic_column_update(&str, column_numbers[i], &val))
+ goto err;
+
+ /* check value(s) */
+ for (j= i; j >= (i < only_add ? 0 : i); j--)
+ {
+ if (dynamic_column_get(&str, column_numbers[j], &val))
+ goto err;
+ if (null_values[j])
+ {
+ if (val.type != DYN_COL_NULL ||
+ dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_YES)
+ goto err;
+ }
+ else
+ {
+ if (val.type != DYN_COL_UINT ||
+ val.ulong_value != column_values[j] ||
+ dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_NO)
+ goto err;
+ }
+ }
+ if (i < only_add)
+ {
+ DYNAMIC_ARRAY num;
+ if (dynamic_column_list(&str, &num))
+ goto err;
+ /* cross check arrays */
+ if ((int)num.elements != i + 1)
+ {
+ delete_dynamic(&num);
+ goto err;
+ }
+ for(j= 0; j < i + 1; j++)
+ {
+ int k;
+ for(k= 0;
+ k < i + 1 && column_numbers[j] !=
+ *dynamic_element(&num, k, uint*);
+ k++);
+ if (k >= i + 1)
+ {
+ delete_dynamic(&num);
+ goto err;
+ }
+ for(k= 0;
+ k < i + 1 && column_numbers[k] !=
+ *dynamic_element(&num, j, uint*);
+ k++);
+ if (k >= i + 1)
+ {
+ delete_dynamic(&num);
+ goto err;
+ }
+ }
+ delete_dynamic(&num);
+ }
+ }
+
+ rc= TRUE;
+err:
+ ok(rc, "%s", "add/delete/update");
+ /* cleanup */
+ dynamic_column_column_free(&str);
+}
+
+void test_empty_string()
+{
+ DYNAMIC_COLUMN_VALUE val, res;
+ DYNAMIC_COLUMN str;
+ DYNAMIC_ARRAY array_of_uint;
+ int rc;
+ /* empty string */
+ bzero(&str, sizeof(str));
+
+ rc= dynamic_column_get(&str, 1, &res);
+ ok( (rc == ER_DYNCOL_OK) && (res.type == DYN_COL_NULL), "%s", "empty get");
+
+ rc= dynamic_column_delete(&str, 1);
+ ok( (rc == ER_DYNCOL_OK), "%s", "empty delete");
+
+ rc= dynamic_column_exists(&str, 1);
+ ok( (rc == ER_DYNCOL_NO), "%s", "empty exists");
+
+ rc= dynamic_column_list(&str, &array_of_uint);
+ ok( (rc == ER_DYNCOL_OK) && (array_of_uint.elements == 0),
+ "%s", "empty list");
+
+ val.type= DYN_COL_UINT;
+ val.ulong_value= 1212;
+ rc= dynamic_column_update(&str, 1, &val);
+ if (rc == ER_DYNCOL_OK)
+ rc= dynamic_column_get(&str, 1, &res);
+ ok( (rc == ER_DYNCOL_OK) &&
+ (res.type == DYN_COL_UINT) && (res.ulong_value == val.ulong_value),
+ "%s", "empty update");
+}
+
+
+void test_update_many(uint *column_numbers, uint *column_values,
+ uint column_count,
+ uint *update_numbers, uint *update_values,
+ my_bool *update_nulls, uint update_count,
+ uint *result_numbers, uint *result_values,
+ uint result_count)
+{
+ int rc= FALSE;
+ uint i;
+ DYNAMIC_COLUMN str1;
+ DYNAMIC_COLUMN str2;
+ DYNAMIC_COLUMN_VALUE *val, *upd, *res;
+
+ val= (DYNAMIC_COLUMN_VALUE *)malloc(sizeof(DYNAMIC_COLUMN_VALUE) *
+ column_count);
+ upd= (DYNAMIC_COLUMN_VALUE *)malloc(sizeof(DYNAMIC_COLUMN_VALUE) *
+ update_count);
+ res= (DYNAMIC_COLUMN_VALUE *)malloc(sizeof(DYNAMIC_COLUMN_VALUE) *
+ result_count);
+
+
+ for (i= 0; i < column_count; i++)
+ {
+ val[i].type= DYN_COL_UINT;
+ val[i].ulong_value= column_values[i];
+ }
+ for (i= 0; i < update_count; i++)
+ {
+ if (update_nulls[i])
+ upd[i].type= DYN_COL_NULL;
+ else
+ {
+ upd[i].type= DYN_COL_UINT;
+ upd[i].ulong_value= update_values[i];
+ }
+ }
+ for (i= 0; i < result_count; i++)
+ {
+ res[i].type= DYN_COL_UINT;
+ res[i].ulong_value= result_values[i];
+ }
+ if (dynamic_column_create_many(&str1, column_count, column_numbers, val))
+ goto err;
+ if (dynamic_column_update_many(&str1, update_count, update_numbers, upd))
+ goto err;
+ if (dynamic_column_create_many(&str2, result_count, result_numbers, res))
+ goto err;
+ if (str1.length == str2.length &&
+ memcmp(str1.str, str2.str, str1.length) ==0)
+ rc= TRUE;
+
+err:
+ ok(rc, "%s", "update_many");
+ /* cleanup */
+ dynamic_column_column_free(&str1);
+ dynamic_column_column_free(&str2);
+}
+
+int main(int argc __attribute__((unused)), char **argv)
+{
+ uint i;
+ char *big_string= (char *)malloc(1024*1024);
+
+ MY_INIT(argv[0]);
+ plan(60);
+
+ if (!big_string)
+ exit(1);
+ for (i= 0; i < 1024*1024; i++)
+ big_string[i]= ('0' + (i % 10));
+ test_value_single_null();
+ test_value_single_uint(0, "0");
+ test_value_single_uint(ULL(0xffffffffffffffff), "0xffffffffffffffff");
+ test_value_single_uint(ULL(0xaaaaaaaaaaaaaaaa), "0xaaaaaaaaaaaaaaaa");
+ test_value_single_uint(ULL(0x5555555555555555), "0x5555555555555555");
+ test_value_single_uint(27652, "27652");
+ test_value_single_sint(0, "0");
+ test_value_single_sint(1, "1");
+ test_value_single_sint(-1, "-1");
+ test_value_single_sint(LL(0x7fffffffffffffff),
+ "0x7fffffffffffffff");
+ test_value_single_sint(LL(0xaaaaaaaaaaaaaaaa),
+ "0xaaaaaaaaaaaaaaaa");
+ test_value_single_sint(LL(0x5555555555555555),
+ "0x5555555555555555");
+ test_value_single_sint(LL(0x8000000000000000),
+ "0x8000000000000000");
+ test_value_single_double(0.0, "0.0");
+ test_value_single_double(1.0, "1.0");
+ test_value_single_double(-1.0, "-1.0");
+ test_value_single_double(1.0e100, "1.0e100");
+ test_value_single_double(1.0e-100, "1.0e-100");
+ test_value_single_double(9999999999999999999999999999999999999.0,
+ "9999999999999999999999999999999999999.0");
+ test_value_single_double(-9999999999999999999999999999999999999.0,
+ "-9999999999999999999999999999999999999.0");
+ test_value_single_decimal("0");
+ test_value_single_decimal("1");
+ test_value_single_decimal("-1");
+ test_value_single_decimal("9999999999999999999999999999999");
+ test_value_single_decimal("-9999999999999999999999999999999");
+ test_value_single_decimal("0.9999999999999999999999999999999");
+ test_value_single_decimal("-0.9999999999999999999999999999999");
+ test_value_single_string("", 0, charset_list[0]);
+ test_value_single_string("", 1, charset_list[0]);
+ test_value_single_string("1234567890", 11, charset_list[0]);
+ test_value_single_string("nulls\0\0\0\0\0", 10, charset_list[0]);
+ sprintf(big_string, "%x", 0x7a);
+ test_value_single_string(big_string, 0x7a, charset_list[0]);
+ sprintf(big_string, "%x", 0x80);
+ test_value_single_string(big_string, 0x80, charset_list[0]);
+ sprintf(big_string, "%x", 0x7ffa);
+ test_value_single_string(big_string, 0x7ffa, charset_list[0]);
+ sprintf(big_string, "%x", 0x8000);
+ test_value_single_string(big_string, 0x8000, charset_list[0]);
+ sprintf(big_string, "%x", 1024*1024);
+ test_value_single_string(big_string, 1024*1024, charset_list[0]);
+ test_value_single_date(0, 0, 0, "zero date");
+ test_value_single_date(9999, 12, 31, "max date");
+ test_value_single_date(2011, 3, 26, "some date");
+ test_value_single_time(0, 0, 0, 0, 0, "zero time");
+ test_value_single_time(1, 23, 59, 59, 999999, "min time");
+ test_value_single_time(0, 23, 59, 59, 999999, "max time");
+ test_value_single_time(0, 21, 36, 20, 28, "some time");
+ test_value_single_datetime(0, 0, 0, 0, 0, 0, 0, 0, "zero datetime");
+ test_value_single_datetime(1, 9999, 12, 31, 23, 59, 59, 999999,
+ "min datetime");
+ test_value_single_datetime(0, 9999, 12, 31, 23, 59, 59, 999999,
+ "max datetime");
+ test_value_single_datetime(0, 2011, 3, 26, 21, 53, 12, 3445,
+ "some datetime");
+ {
+ uint column_numbers[]= {100,1,2,3,4,5,6,7,8};
+ test_value_multi(0, 0, 0.0, "0",
+ "", 0, charset_list[0],
+ 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ column_numbers,
+ "zero data");
+ }
+ {
+ uint column_numbers[]= {10,1,12,37,4,57,6,76,87};
+ test_value_multi(ULL(0xffffffffffffffff), LL(0x7fffffffffffffff),
+ 99999999.999e120, "9999999999999999999999999999999",
+ big_string, 1024*1024, charset_list[0],
+ 9999, 12, 31,
+ 0, 23, 59, 59, 999999,
+ 0, 9999, 12, 31, 23, 59, 59, 999999,
+ column_numbers,
+ "much data");
+ }
+ free(big_string);
+ {
+ uint column_numbers[]= {101,12,122,37,24,572,16,726,77};
+ test_value_multi(37878, -3344,
+ 2873.3874, "92743.238984789898",
+ "string", 6, charset_list[0],
+ 2011, 3, 26,
+ 1, 23, 23, 20, 333,
+ 0, 2011, 3, 26, 23, 23, 53, 334,
+ column_numbers,
+ "zero data");
+ }
+ test_value_multi_same_num();
+ {
+ uint column_numbers[]= {1,2,3,4,5,6,7,2, 3, 4};
+ uint column_values[]= {1,2,3,4,5,6,7,0,30,40};
+ my_bool null_values[]= {0,0,0,0,0,0,0,1, 0, 0};
+
+ test_update_multi(column_numbers, column_values, null_values, 7, 10);
+ }
+ {
+ uint column_numbers[]= {4,3,2,1, 1,2,3,4};
+ uint column_values[]= {4,3,2,1, 0,0,0,0};
+ my_bool null_values[]= {0,0,0,0, 1,1,1,1};
+
+ test_update_multi(column_numbers, column_values, null_values, 4, 8);
+ }
+ {
+ uint column_numbers[]= {4,3,2,1, 4,3,2,1};
+ uint column_values[]= {4,3,2,1, 0,0,0,0};
+ my_bool null_values[]= {0,0,0,0, 1,1,1,1};
+
+ test_update_multi(column_numbers, column_values, null_values, 4, 8);
+ }
+ test_empty_string();
+ {
+ uint column_numbers[]= {1, 2, 3};
+ uint column_values[]= {1, 2, 3};
+ uint update_numbers[]= {4, 3, 2, 1};
+ uint update_values[]= {40,30, 0,10};
+ my_bool update_nulls[]={0, 0, 1, 0};
+ uint result_numbers[]= {1, 3, 4};
+ uint result_values[]= {10,30,40};
+ test_update_many(column_numbers, column_values, 3,
+ update_numbers, update_values, update_nulls, 4,
+ result_numbers, result_values, 3);
+ }
+ return exit_status();
+}
diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c
index 1ac03e474fd..5fc0d1497bf 100644
--- a/unittest/mysys/thr_template.c
+++ b/unittest/mysys/thr_template.c
@@ -29,7 +29,7 @@ void do_tests();
void test_concurrently(const char *test, pthread_handler handler, int n, int m)
{
pthread_t t;
- ulonglong now= my_getsystime();
+ ulonglong now= my_interval_timer();
bad= 0;
@@ -47,8 +47,8 @@ void test_concurrently(const char *test, pthread_handler handler, int n, int m)
pthread_cond_wait(&cond, &mutex);
pthread_mutex_unlock(&mutex);
- now= my_getsystime()-now;
- ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e7, bad);
+ now= my_interval_timer() - now;
+ ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad);
}
int main(int argc __attribute__((unused)), char **argv)
@@ -82,7 +82,9 @@ int main(int argc __attribute__((unused)), char **argv)
workaround until we know why it crashes randomly on some machine
(BUG#22320).
*/
- sleep(2);
+#ifdef NOT_USED
+ sleep(1);
+#endif
pthread_mutex_destroy(&mutex);
pthread_cond_destroy(&cond);
pthread_attr_destroy(&thr_attr);
diff --git a/unittest/mysys/waiting_threads-t.c b/unittest/mysys/waiting_threads-t.c
index e32a83ef172..35e86aca319 100644
--- a/unittest/mysys/waiting_threads-t.c
+++ b/unittest/mysys/waiting_threads-t.c
@@ -65,7 +65,7 @@ pthread_handler_t test_wt(void *arg)
my_rnd_init(&rand, (ulong)(intptr)&m, id);
if (kill_strategy == YOUNGEST)
- thds[id].thd.weight= (ulong)~my_getsystime();
+ thds[id].thd.weight= (ulong) ~ my_interval_timer();
if (kill_strategy == LOCKS)
thds[id].thd.weight= 0;
@@ -116,7 +116,7 @@ retry:
if (kill_strategy == LOCKS)
thds[id].thd.weight= 0;
if (kill_strategy == YOUNGEST)
- thds[id].thd.weight= (ulong)~my_getsystime();
+ thds[id].thd.weight= (ulong)~ my_interval_timer();
}
else if (kill_strategy == LOCKS)
thds[id].thd.weight++;
@@ -181,6 +181,11 @@ void do_one_test()
void do_tests()
{
DBUG_ENTER("do_tests");
+ if (skip_big_tests)
+ {
+ skip(1, "Big test skipped");
+ return;
+ }
plan(14);
compile_time_assert(THREADS >= 4);
diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c
index 1792c82519b..e0e42c6eb5e 100644
--- a/unittest/mytap/tap.c
+++ b/unittest/mytap/tap.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2011, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,6 +28,10 @@
#include <string.h>
#include <signal.h>
+static ulong start_timer(void);
+static void end_timer(ulong start_time,char *buff);
+static void nice_time(double sec,char *buff,my_bool part_second);
+
/*
Visual Studio 2003 does not know vsnprintf but knows _vsnprintf.
We don't put this #define in config-win.h because we prefer
@@ -185,6 +190,7 @@ static signal_entry install_signal[]= {
};
int skip_big_tests= 1;
+ulong start_time= 0;
void
plan(int count)
@@ -192,6 +198,8 @@ plan(int count)
char *config= getenv("MYTAP_CONFIG");
size_t i;
+ start_time= start_timer();
+
if (config)
skip_big_tests= strcmp(config, "big");
@@ -289,6 +297,7 @@ skip(int how_many, char const *fmt, ...)
}
}
+
void
todo_start(char const *message, ...)
{
@@ -304,7 +313,10 @@ todo_end()
*g_test.todo = '\0';
}
-int exit_status() {
+int exit_status()
+{
+ char buff[60];
+
/*
If there were no plan, we write one last instead.
*/
@@ -323,10 +335,81 @@ int exit_status() {
diag("Failed %d tests!", g_test.failed);
return EXIT_FAILURE;
}
+ if (start_time)
+ {
+ end_timer(start_time, buff);
+ printf("Test took %s\n", buff);
+ fflush(stdout);
+ }
return EXIT_SUCCESS;
}
+#if defined(__WIN__) || defined(__NETWARE__)
+#include <time.h>
+#else
+#include <sys/times.h>
+#ifdef _SC_CLK_TCK // For mit-pthreads
+#undef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC (sysconf(_SC_CLK_TCK))
+#endif
+#endif
+
+static ulong start_timer(void)
+{
+#if defined(__WIN__) || defined(__NETWARE__)
+ return clock();
+#else
+ struct tms tms_tmp;
+ return times(&tms_tmp);
+#endif
+}
+
+
+/**
+ Write as many as 52+1 bytes to buff, in the form of a legible
+ duration of time.
+
+ len("4294967296 days, 23 hours, 59 minutes, 60.00 seconds") -> 52
+*/
+
+static void nice_time(double sec,char *buff, my_bool part_second)
+{
+ ulong tmp;
+ if (sec >= 3600.0*24)
+ {
+ tmp=(ulong) floor(sec/(3600.0*24));
+ sec-=3600.0*24*tmp;
+ buff+= my_sprintf(buff, (buff, "%ld %s", tmp,
+ tmp > 1 ? " days " : " day "));
+ }
+ if (sec >= 3600.0)
+ {
+ tmp=(ulong) floor(sec/3600.0);
+ sec-=3600.0*tmp;
+ buff+= my_sprintf(buff, (buff, "%ld %s", tmp,
+ tmp > 1 ? " hours " : " hour "));
+ }
+ if (sec >= 60.0)
+ {
+ tmp=(ulong) floor(sec/60.0);
+ sec-=60.0*tmp;
+ buff+= my_sprintf(buff, (buff, "%ld min ", tmp));
+ }
+ if (part_second)
+ sprintf(buff,"%.2f sec",sec);
+ else
+ sprintf(buff,"%d sec",(int) sec);
+}
+
+
+static void end_timer(ulong start_time,char *buff)
+{
+ nice_time((double) (start_timer() - start_time) /
+ CLOCKS_PER_SEC,buff,1);
+}
+
+
/**
@mainpage Testing C and C++ using MyTAP
diff --git a/unittest/unit.pl b/unittest/unit.pl
index be6424ec798..4eaf4cd2f9b 100644
--- a/unittest/unit.pl
+++ b/unittest/unit.pl
@@ -103,7 +103,8 @@ sub run_cmd (@) {
# Removing the first './' from the file names
foreach (@files) { s!^\./!! }
$ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
+ $ENV{'HARNESS_OPTIONS'}="j4";
+ $Test::Harness::Timer = 1;
runtests @files;
}
}
-
diff --git a/vio/viosocket.c b/vio/viosocket.c
index f47a7a10ad2..f780764cbe4 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -193,6 +193,11 @@ int vio_fastsend(Vio * vio __attribute__((unused)))
int r=0;
DBUG_ENTER("vio_fastsend");
+ if (vio->type == VIO_TYPE_NAMEDPIPE ||vio->type == VIO_TYPE_SHARED_MEMORY)
+ {
+ DBUG_RETURN(0);
+ }
+
#if defined(IPTOS_THROUGHPUT)
{
int tos = IPTOS_THROUGHPUT;
@@ -228,7 +233,7 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
DBUG_ENTER("vio_keepalive");
DBUG_PRINT("enter", ("sd: %d set_keep_alive: %d", vio->sd, (int)
set_keep_alive));
- if (vio->type != VIO_TYPE_NAMEDPIPE)
+ if (vio->type != VIO_TYPE_NAMEDPIPE && vio->type != VIO_TYPE_SHARED_MEMORY)
{
if (set_keep_alive)
opt = 1;
diff --git a/win/Makefile.am b/win/Makefile.am
index b657acfd65c..310c54bc117 100644
--- a/win/Makefile.am
+++ b/win/Makefile.am
@@ -42,6 +42,9 @@ EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat build-vs9.bat \
packaging/ca/CustomAction.rc \
packaging/WixUIBannerBmp.jpg \
packaging/WixUIDialogBmp.jpg \
+ packaging/heidisql.cmake \
+ packaging/heidisql.wxi.in \
+ packaging/heidisql_feature.wxi.in\
upgrade_wizard/resource.h \
upgrade_wizard/stdafx.h \
upgrade_wizard/targetver.h \
diff --git a/win/cmake/create_initial_db.cmake.in b/win/cmake/create_initial_db.cmake.in
index aca8a770820..d4721b7bac4 100644
--- a/win/cmake/create_initial_db.cmake.in
+++ b/win/cmake/create_initial_db.cmake.in
@@ -57,7 +57,7 @@ SET(BOOTSTRAP_COMMAND
--language=${CMAKE_CURRENT_BINARY_DIR}/share/english
--basedir=.
--datadir=.
- --tmpdir=${CMAKE_CURRENT_BINARY_DIR}
+ --tmpdir=.
--default-storage-engine=MyISAM
--loose-skip-innodb
--loose-skip-pbxt
diff --git a/win/cmake/mysql_version.cmake b/win/cmake/mysql_version.cmake
index 79e6a18ee1d..bf623a22462 100644
--- a/win/cmake/mysql_version.cmake
+++ b/win/cmake/mysql_version.cmake
@@ -25,7 +25,7 @@ MACRO(GET_MYSQL_VERSION)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
IF(NOT VERSION_STRING)
FILE(STRINGS configure.in str REGEX "AC_INIT\\(")
- STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zA-Z0-9]+" VERSION_STRING "${str}")
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zA-Z0-9-]+" VERSION_STRING "${str}")
IF(NOT VERSION_STRING)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
ENDIF()
@@ -34,6 +34,16 @@ MACRO(GET_MYSQL_VERSION)
ENDIF()
ENDIF()
+ SET(VERSION_EXTRA) #alpha beta gamma delta epsilon, etc
+
+ FOREACH(suffix alpha beta gamma)
+ IF(VERSION_STRING MATCHES "${suffix}")
+ SET(VERSION_EXTRA "-${suffix}")
+ ENDIF()
+ ENDFOREACH()
+
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zA-Z0-9]+" VERSION_STRING "${str}")
+
IF(NOT VERSION_STRING)
MESSAGE(FATAL_ERROR
"VERSION_STRING cannot be parsed, please specify -DVERSION_STRING=major.minor.patch-extra"
@@ -91,9 +101,9 @@ IF(NOT CPACK_PACKAGE_FILE_NAME)
ENDIF()
IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
- SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION}")
+ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION_STRING}${VERSION_EXTRA}")
ENDIF()
-SET(CPACK_PACKAGE_CONTACT "MariaDB team <build@mysql.com>")
+SET(CPACK_PACKAGE_CONTACT "MariaDB team <info@montyprogram.com>")
SET(CPACK_PACKAGE_VENDOR "Monty Program AB")
SET(CPACK_SOURCE_GENERATOR "TGZ")
INCLUDE(cpack_source_ignore_files)
diff --git a/win/cmake/package_name.cmake b/win/cmake/package_name.cmake
index 1bbe68a0336..ef6f9b31328 100644
--- a/win/cmake/package_name.cmake
+++ b/win/cmake/package_name.cmake
@@ -123,7 +123,7 @@ IF(NOT VERSION)
SET(PRODUCT_TAG)
ENDIF()
- SET(package_name "mariadb${PRODUCT_TAG}-${MYSQL_NO_DASH_VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
+ SET(package_name "mariadb${PRODUCT_TAG}-${MYSQL_NO_DASH_VERSION}${VERSION_EXTRA}-${SYSTEM_NAME_AND_PROCESSOR}")
# Sometimes package suffix is added (something like "-icc-glibc23")
IF(PACKAGE_SUFFIX)
diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt
index 02fba4ae16b..795732e946b 100644
--- a/win/packaging/CMakeLists.txt
+++ b/win/packaging/CMakeLists.txt
@@ -103,6 +103,38 @@ IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_INNODB_STORAGE_ENGINE OR WITH_XTRADB_STO
SET(EXTRA_WIX_PREPROCESSOR_FLAGS ${EXTRA_WIX_PREPROCESSOR_FLAGS} "-dHaveInnodb=1")
ENDIF()
+SET(THIRD_PARTY_FEATURE_CONDITION "")
+
+IF(WITH_THIRD_PARTY)
+ SET(THIRD_PARTY_DOWNLOAD_LOCATION "$ENV{TEMP}")
+ IF(THIRD_PARTY_DOWNLOAD_LOCATION)
+ FILE(TO_CMAKE_PATH "${THIRD_PARTY_DOWNLOAD_LOCATION}" THIRD_PARTY_DOWNLOAD_LOCATION)
+ ELSE()
+ SET(THIRD_PARTY_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}")
+ ENDIF()
+ENDIF()
+
+GET_TARGET_PROPERTY(LIBMYSQL_LOCATION libmysql LOCATION)
+FOREACH(third_party ${WITH_THIRD_PARTY})
+ SET(third_party_install_plugin ${CMAKE_CURRENT_SOURCE_DIR}/${third_party}.cmake)
+ IF(NOT EXISTS ${third_party_install_plugin})
+ MESSAGE(FATAL_ERROR
+"Third party MSI installation plugin ${third_party_install_plugin} does not exist.
+It was expected due to WITH_THIRD_PARTY=${WITH_THIRD_PARTY}"
+)
+ ENDIF()
+ STRING(TOUPPER "${third_party}" upper_third_party)
+ IF(NOT THIRD_PARTY_FEATURE_CONDITION )
+ SET(THIRD_PARTY_FEATURE_CONDITION "<Condition Level='0'>${upper_third_party}INSTALLED")
+ ELSE()
+ SET(THIRD_PARTY_FEATURE_CONDITION "AND ${upper_third_party}INSTALLED")
+ ENDIF()
+ENDFOREACH()
+
+IF(THIRD_PARTY_FEATURE_CONDITION)
+ SET(THIRD_PARTY_FEATURE_CONDITION "${THIRD_PARTY_FEATURE_CONDITION}</Condition>")
+ENDIF()
+
IF(NOT CPACK_WIX_UI)
SET(CPACK_WIX_UI "MyWixUI_Mondo")
ENDIF()
@@ -125,7 +157,6 @@ ENDIF()
ADD_CUSTOM_TARGET(
MSI
- COMMAND set VS_UNICODE_OUTPUT=
COMMAND ${CMAKE_COMMAND}
${CONFIG_PARAM}
-P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
@@ -134,7 +165,6 @@ ADD_DEPENDENCIES(MSI wixca)
ADD_CUSTOM_TARGET(
MSI_ESSENTIALS
- COMMAND set VS_UNICODE_OUTPUT=
COMMAND ${CMAKE_COMMAND} -DESSENTIALS=1
${CONFIG_PARAM}
-P ${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake
diff --git a/win/packaging/create_msi.cmake.in b/win/packaging/create_msi.cmake.in
index 393e1b634b2..d291d06161c 100644
--- a/win/packaging/create_msi.cmake.in
+++ b/win/packaging/create_msi.cmake.in
@@ -23,7 +23,30 @@ SET(SIGNTOOL_PARAMETERS "@SIGNTOOL_PARAMETERS@")
SET(CMAKE_FULL_VER
"@CMAKE_MAJOR_VERSION@.@CMAKE_MINOR_VERSION@.@CMAKE_PATCH_VERSION@")
SET(EXTRA_WIX_PREPROCESSOR_FLAGS "@EXTRA_WIX_PREPROCESSOR_FLAGS@")
-
+SET(WITH_THIRD_PARTY "@WITH_THIRD_PARTY@")
+SET(THIRD_PARTY_DOWNLOAD_LOCATION "@THIRD_PARTY_DOWNLOAD_LOCATION@")
+SET(THIRD_PARTY_FEATURE_CONDITION "@THIRD_PARTY_FEATURE_CONDITION@")
+SET(LIBMYSQL_LOCATION "@LIBMYSQL_LOCATION@")
+
+SET($ENV{VS_UNICODE_OUTPUT} "")
+IF(LIBMYSQL_LOCATION AND CMAKE_CFG_INTDIR)
+ # resolve libmysql full path
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "${CMAKE_INSTALL_CONFIG_NAME}" LIBMYSQL_LOCATION "${LIBMYSQL_LOCATION}")
+ENDIF()
+
+FOREACH(third_party ${WITH_THIRD_PARTY})
+ INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/${third_party}.cmake)
+
+ # Check than above script produced ${third_party}.wxi and ${third_party}_feature.wxi
+ FOREACH(outfile ${third_party}.wxi ${third_party}_feature.wxi)
+ IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${outfile})
+ MESSAGE(FATAL_ERROR
+ "${CMAKE_CURRENT_SOURCE_DIR}/${third_party}.cmake did not produce "
+ "${CMAKE_CURRENT_BINARY_DIR}/${outfile}"
+ )
+ ENDIF()
+ ENDFOREACH()
+ENDFOREACH()
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -304,10 +327,12 @@ ENDFUNCTION()
FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)
FILE(RELATIVE_PATH rel ${topdir} ${dir})
- IF(rel AND IS_DIRECTORY "${f}")
- MAKE_WIX_IDENTIFIER("${rel}" id)
- GET_FILENAME_COMPONENT(name ${dir} NAME)
- FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n")
+ IF(rel)
+ IF (IS_DIRECTORY "${f}")
+ MAKE_WIX_IDENTIFIER("${rel}" id)
+ GET_FILENAME_COMPONENT(name ${dir} NAME)
+ FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n")
+ ENDIF()
ENDIF()
FILE(GLOB all_files ${dir}/*)
FOREACH(f ${all_files})
@@ -315,8 +340,10 @@ FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)
TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ")
ENDIF()
ENDFOREACH()
- IF(rel AND IS_DIRECTORY "${f}")
- FILE(APPEND ${file} "${prefix}</Directory>\n")
+ IF(rel)
+ IF(IS_DIRECTORY "${f}")
+ FILE(APPEND ${file} "${prefix}</Directory>\n")
+ ENDIF()
ENDIF()
ENDFUNCTION()
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
index 456b833cf4f..5aab7bc813c 100644
--- a/win/packaging/extra.wxs.in
+++ b/win/packaging/extra.wxs.in
@@ -46,6 +46,9 @@
<Property Id="CLEANUPDATA" Secure="yes" Value="1"/>
<!-- Force per machine installation -->
<Property Id="ALLUSERS" Secure="yes" Value="1"/>
+ <!-- Disable advertised shortcuts weirdness -->
+ <Property Id="DISABLEADVTSHORTCUTS" Secure="yes" Value="1"/>
+
<?if $(var.HaveInnodb) = "1" ?>
<!-- Quick configuration : set default storage engine to innodb, use strict sql_mode -->
<Property Id="STDCONFIG" Secure="yes" Value="1"/>
@@ -567,6 +570,38 @@
<?endif?>
</Feature>
+ <!-- Optional 3rd party tools -->
+ <DirectoryRef Id='TARGETDIR'>
+ <Directory Id='CommonFilesFolder'>
+ <Directory Id='MariaDBShared' Name='MariaDBShared'/>
+ </Directory>
+ <Directory Id='DesktopFolder'/>
+ </DirectoryRef>
+
+
+ <?if "@WITH_THIRD_PARTY@" != "" ?>
+
+ <!-- Include definition of 3party components -->
+ <?foreach tool in @WITH_THIRD_PARTY@ ?>
+ <?include "${CMAKE_CURRENT_BINARY_DIR}\$(var.tool).wxi" ?>
+ <?endforeach ?>
+
+ <Feature Id="ThirdPartyTools"
+ Title='Third party tools'
+ Description= 'Third party tools'
+ AllowAdvertise='no'
+ Level='1'
+ Display='expand'>
+ @THIRD_PARTY_FEATURE_CONDITION@
+ <!-- Include definition of 3rd party features -->
+ <?foreach tool in @WITH_THIRD_PARTY@ ?>
+ <?include "${CMAKE_CURRENT_BINARY_DIR}\$(var.tool)_feature.wxi" ?>
+ <?endforeach ?>
+
+ </Feature>
+
+ <?endif ?>
+
<!-- Custom action, call mysql_install_db -->
<SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="SKIPNETWORKING" Value="--skip-networking" >SKIPNETWORKING</SetProperty>
<SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="ALLOWREMOTEROOTACCESS" Value="--allow-remote-root-access">ALLOWREMOTEROOTACCESS</SetProperty>
diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake
new file mode 100644
index 00000000000..94a287cba08
--- /dev/null
+++ b/win/packaging/heidisql.cmake
@@ -0,0 +1,23 @@
+SET(HEIDISQL_BASE_NAME "HeidiSQL_6.0_Portable")
+SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip")
+SET(HEIDISQL_URL "http://heidisql.googlecode.com/files/${HEIDISQL_ZIP}")
+SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME})
+
+IF(NOT EXISTS ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP})
+ MAKE_DIRECTORY(${HEIDISQL_DOWNLOAD_DIR})
+ MESSAGE(STATUS "Downloading ${HEIDISQL_URL} to ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}")
+ FILE(DOWNLOAD ${HEIDISQL_URL} ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP} TIMEOUT 60)
+ EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E chdir ${HEIDISQL_DOWNLOAD_DIR}
+ ${CMAKE_COMMAND} -E tar xfz ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP}
+ )
+ENDIF()
+
+SET(LIBMYSQLDLL_SOURCE ${HEIDISQL_DOWNLOAD_DIR}/libmysql.dll)
+IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ # Use our libmysql if it is 32 bit.
+ IF(LIBMYSQL_LOCATION)
+ SET(LIBMYSQLDLL_SOURCE "${LIBMYSQL_LOCATION}")
+ ENDIF()
+ENDIF()
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/heidisql.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/heidisql.wxi)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/heidisql_feature.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/heidisql_feature.wxi)
diff --git a/win/packaging/heidisql.wxi.in b/win/packaging/heidisql.wxi.in
new file mode 100644
index 00000000000..2af52862e06
--- /dev/null
+++ b/win/packaging/heidisql.wxi.in
@@ -0,0 +1,46 @@
+<Include>
+<Property Id="HEIDISQLINSTALLED" Secure="yes">
+<RegistrySearch Id="HeidiSQL"
+ Root="HKLM"
+ Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\HeidiSQL_is1"
+ Name="Install"
+ Type="raw"
+ Win64="no"
+/>
+</Property>
+<DirectoryRef Id="MariaDBShared">
+ <Directory Id="D.HeidiSQL" Name="HeidiSQL">
+ <Component Id="component.HeidiSQL" Guid="96ea3879-5320-4098-8f26-2f655d2f716c" Win64="no">
+
+ <File Id="heidisql.gpl.txt" Name="gpl.txt" Source="${HEIDISQL_DOWNLOAD_DIR}\gpl.txt" />
+ <File Id="heidisql.heidisql.exe" Name="heidisql.exe" Source="${HEIDISQL_DOWNLOAD_DIR}\heidisql.exe" KeyPath="yes">
+ <Shortcut Id="desktopHeidiSQL" Directory="DesktopFolder" Name="HeidiSQL" Advertise="yes"/>
+ </File>
+ <!--
+ Forced file removal for heidisql.exe might be required.
+ HeidiSQL is self-updating, thus the version that was installed by MSI not necessarily matches
+ the version of the file on uninstall. MSI would not touch such file by default and leave it after
+ uninstallation. We use RemoveFile to force delete in any case.
+ -->
+ <RemoveFile Id="Remove_HeidiSQL_exe" Name="heidisql.exe" On="uninstall" />
+
+ <File Id="heidisql.license.txt" Name="license.txt" Source="${HEIDISQL_DOWNLOAD_DIR}\license.txt" />
+ <File Id="heidisql.readme.txt" Name="readme.txt" Source="${HEIDISQL_DOWNLOAD_DIR}\readme.txt" />
+ </Component>
+ <Component Id="component.HeidiSQL_MenuShortcut" Guid="*" Win64="no">
+ <RegistryValue Root="HKCU" Key="Software\@CPACK_WIX_PACKAGE_NAME@\Uninstall" Name="shortcuts.heidisql" Value="1" Type="string" KeyPath="yes" />
+ <Shortcut Id="startmenuHeidiSQL" Directory="ShortcutFolder" Name="HeidiSQL" Target="[D.HeidiSQL]\heidisql.exe"/>
+ <RemoveRegistryKey Id="HeidiSQL_RegistryCleanup" Root="HKCU" Key="SOFTWARE\HeidiSQL" Action="removeOnUninstall" />
+ </Component>
+ <Component Id="component.HeidiSQL_libmysql.dll" Guid="*" Win64="no">
+ <File Id="heidisql.libmysql.dll" Name="libmysql.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libmysql.dll" />
+ </Component>
+ </Directory>
+</DirectoryRef>
+
+<ComponentGroup Id="HeidiSQL">
+ <ComponentRef Id="component.HeidiSQL"/>
+ <ComponentRef Id="component.HeidiSQL_MenuShortcut"/>
+ <ComponentRef Id="component.HeidiSQL_libmysql.dll"/>
+</ComponentGroup>
+</Include>
diff --git a/win/packaging/heidisql_feature.wxi.in b/win/packaging/heidisql_feature.wxi.in
new file mode 100644
index 00000000000..9fceb4689d0
--- /dev/null
+++ b/win/packaging/heidisql_feature.wxi.in
@@ -0,0 +1,10 @@
+<Include>
+<Feature Id="HeidiSQL"
+ Title='HeidiSQL'
+ Description= 'Powerful, easy and free MySQL/MariaDB GUI client by Ansgar Becker'
+ AllowAdvertise='no'
+ Level='1'>
+ <Condition Level="0">HEIDISQLINSTALLED</Condition>
+ <ComponentGroupRef Id='HeidiSQL'/>
+</Feature>
+</Include>